@mux/mux-audio 0.10.2 → 0.10.3
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.
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +3 -3
- package/dist/mux-audio.js +29 -29
- package/dist/mux-audio.js.map +3 -3
- package/dist/mux-audio.mjs +29 -29
- package/dist/mux-audio.mjs.map +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types-ts3.4/index.d.ts +1 -0
- package/package.json +3 -3
package/dist/mux-audio.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var Vl=Object.create;var Pa=Object.defineProperty;var Yl=Object.getOwnPropertyDescriptor;var Wl=Object.getOwnPropertyNames;var zl=Object.getPrototypeOf,Xl=Object.prototype.hasOwnProperty;var Ql=(I,C,L)=>C in I?Pa(I,C,{enumerable:!0,configurable:!0,writable:!0,value:L}):I[C]=L;var Ys=(I,C)=>()=>(C||I((C={exports:{}}).exports,C),C.exports);var Jl=(I,C,L,B)=>{if(C&&typeof C=="object"||typeof C=="function")for(let j of Wl(C))!Xl.call(I,j)&&j!==L&&Pa(I,j,{get:()=>C[j],enumerable:!(B=Yl(C,j))||B.enumerable});return I};var Ws=(I,C,L)=>(L=I!=null?Vl(zl(I)):{},Jl(C||!I||!I.__esModule?Pa(L,"default",{value:I,enumerable:!0}):L,I));var Oa=(I,C,L)=>(Ql(I,typeof C!="symbol"?C+"":C,L),L),Ma=(I,C,L)=>{if(!C.has(I))throw TypeError("Cannot "+L)};var ft=(I,C,L)=>(Ma(I,C,"read from private field"),L?L.call(I):C.get(I)),vt=(I,C,L)=>{if(C.has(I))throw TypeError("Cannot add the same private member more than once");C instanceof WeakSet?C.add(I):C.set(I,L)},Rt=(I,C,L,B)=>(Ma(I,C,"write to private field"),B?B.call(I,L):C.set(I,L),L);var Ft=(I,C,L)=>(Ma(I,C,"access private method"),L);var Qs=Ys((Un,Ua)=>{(function(){var I,C;I=this,C=function(){return function(){var L={80:function(H,z,K){H.exports=K(728).default},728:function(H,z,K){"use strict";K.d(z,{default:function(){return An}});var ee=K(48),X=K.n(ee),ae=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(m){var h=16*Math.random()|0;return(m==="x"?h:3&h|8).toString(16)})},ge=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},ne=function(m){return m&&m.nodeName!==void 0?(m.muxId||(m.muxId=m.id||ge()),m.muxId):m},Ae=function(m){var h;m&&m.nodeName!==void 0?m=ne(h=m):h=document.querySelector(m);var g=h&&h.nodeName?h.nodeName.toLowerCase():"";return[h,m,g]},ke=K(640),xe=K.n(ke),je=xe().methodFactory;xe().methodFactory=function(m,h,g){var _=je(m,h,g);return function(){for(var A=["[mux]"],R=0;R<arguments.length;R++)A.push(arguments[R]);_.apply(void 0,A)}},xe().setLevel(xe().getLevel());var Re=xe();function dt(){return(X().doNotTrack||X().navigator&&X().navigator.doNotTrack)==="1"}var Ke={now:function(){var m=X().performance,h=m&&m.timing,g=h&&h.navigationStart,_=typeof g=="number"&&typeof m.now=="function"?g+m.now():Date.now();return Math.round(_)}},pe=function(m){return be(m)[0]},be=function(m){if(typeof m!="string"||m==="")return["localhost"];var h,g=(m.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return g&&(h=(g.match(/[^\.]+\.[^\.]+$/)||[])[0]),[g,h]},Z={exists:function(){var m=X().performance;return(m&&m.timing)!==void 0},domContentLoadedEventEnd:function(){var m=X().performance,h=m&&m.timing;return h&&h.domContentLoadedEventEnd},navigationStart:function(){var m=X().performance,h=m&&m.timing;return h&&h.navigationStart}};function E(m,h,g){g=g===void 0?1:g,m[h]=m[h]||0,m[h]+=g}var Q=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],F=["x-cdn","content-type"].concat(Q);function he(m){var h={};return(m=m||"").trim().split(/[\r\n]+/).forEach(function(g){if(g){var _=g.split(": "),A=_.shift();A&&(F.indexOf(A.toLowerCase())>=0||A.toLowerCase().indexOf("x-litix-")===0)&&(h[A]=_.join(": "))}}),h}function Ue(m){if(m){var h=Q.find(function(g){return m[g]!==void 0});return h?m[h]:void 0}}var Be=function(m){var h={};for(var g in m){var _=m[g];_["DATA-ID"].search("io.litix.data.")!==-1&&(h[_["DATA-ID"].replace("io.litix.data.","")]=_.VALUE)}return h};function Ut(m,h){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(m);h&&(_=_.filter(function(A){return Object.getOwnPropertyDescriptor(m,A).enumerable})),g.push.apply(g,_)}return g}function qe(m){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?Ut(Object(g),!0).forEach(function(_){x(m,_,g[_])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):Ut(Object(g)).forEach(function(_){Object.defineProperty(m,_,Object.getOwnPropertyDescriptor(g,_))})}return m}function x(m,h,g){return h in m?Object.defineProperty(m,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[h]=g,m}var nr=function(m){if(!m)return{};var h=Z.navigationStart(),g=m.loading,_=g?g.start:m.trequest,A=g?g.first:m.tfirst,R=g?g.end:m.tload;return{bytesLoaded:m.total,requestStart:Math.round(h+_),responseStart:Math.round(h+A),responseEnd:Math.round(h+R)}},Bt=function(m){if(m&&typeof m.getAllResponseHeaders=="function")return he(m.getAllResponseHeaders())};function Ve(m,h){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(m);h&&(_=_.filter(function(A){return Object.getOwnPropertyDescriptor(m,A).enumerable})),g.push.apply(g,_)}return g}function ar(m){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?Ve(Object(g),!0).forEach(function(_){Me(m,_,g[_])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):Ve(Object(g)).forEach(function(_){Object.defineProperty(m,_,Object.getOwnPropertyDescriptor(g,_))})}return m}function Me(m,h,g){return h in m?Object.defineProperty(m,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[h]=g,m}var gt=function(m,h){if(!m||typeof m.getRequests!="function")return{};var g=m.getRequests({state:"executed"});if(g.length===0)return{};var _,A=g[g.length-1],R=pe(A.url),k=A.url,P=A.bytesLoaded,U=new Date(A.requestStartDate).getTime(),M=new Date(A.firstByteDate).getTime(),Y=new Date(A.requestEndDate).getTime(),Ee=isNaN(A.duration)?0:A.duration,se=typeof h.getMetricsFor=="function"?h.getMetricsFor(A.mediaType).HttpList:h.getDashMetrics().getHttpRequests(A.mediaType);return se.length>0&&(_=he(se[se.length-1]._responseHeaders||"")),{requestStart:U,requestResponseStart:M,requestResponseEnd:Y,requestBytesLoaded:P,requestResponseHeaders:_,requestMediaDuration:Ee,requestHostname:R,requestUrl:k,requestId:_?Ue(_):void 0}},Xe=function(m,h){var g=h.getQualityFor(m),_=h.getCurrentTrackFor(m).bitrateList;return _?{currentLevel:g,renditionWidth:_[g].width||null,renditionHeight:_[g].height||null,renditionBitrate:_[g].bandwidth}:{}},mt=function(m){var h;return(h=m.match(/.*codecs\*?="(.*)"/))===null||h===void 0?void 0:h[1]};function Nr(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var ai=0,si=function(){function m(){(function(A,R){if(!(A instanceof R))throw new TypeError("Cannot call a class as a function")})(this,m)}var h,g,_;return h=m,g=[{key:"on",value:function(A,R,k){return R._eventEmitterGuid=R._eventEmitterGuid||++ai,this._listeners=this._listeners||{},this._listeners[A]=this._listeners[A]||[],k&&(R=R.bind(k)),this._listeners[A].push(R),R}},{key:"off",value:function(A,R){var k=this._listeners&&this._listeners[A];k&&k.forEach(function(P,U){P._eventEmitterGuid===R._eventEmitterGuid&&k.splice(U,1)})}},{key:"one",value:function(A,R,k){var P=this;R._eventEmitterGuid=R._eventEmitterGuid||++ai;var U=function M(){P.off(A,M),R.apply(k||this,arguments)};U._eventEmitterGuid=R._eventEmitterGuid,this.on(A,U)}},{key:"emit",value:function(A,R){var k=this;if(this._listeners){R=R||{};var P=this._listeners["before*"]||[],U=this._listeners[A]||[],M=this._listeners["after"+A]||[],Y=function(Ee,se){(Ee=Ee.slice()).forEach(function(de){de.call(k,{type:A},se)})};Y(P,R),Y(U,R),Y(M,R)}}}],g&&Nr(h.prototype,g),_&&Nr(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}(),qn=si;function ji(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var oi=function(){function m(A){var R=this;(function(k,P){if(!(k instanceof P))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,A.on("playing",function(){R._playheadShouldBeProgressing=!0}),A.on("play",this._startPlaybackHeartbeatInterval.bind(this)),A.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),A.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),A.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),A.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),A.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),A.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),A.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),A.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),A.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("seeked",function(){A.data.player_is_paused?R._stopPlaybackHeartbeatInterval():R._startPlaybackHeartbeatInterval()}),A.on("timeupdate",function(){R._playbackHeartbeatInterval!==null&&A.emit("playbackheartbeat")}),A.on("devicesleep",function(k,P){R._playbackHeartbeatInterval!==null&&(X().clearInterval(R._playbackHeartbeatInterval),A.emit("playbackheartbeatend",{viewer_time:P.viewer_time}),R._playbackHeartbeatInterval=null)})}var h,g,_;return h=m,(g=[{key:"_startPlaybackHeartbeatInterval",value:function(){var A=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=X().setInterval(function(){A.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(X().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&ji(h.prototype,g),_&&ji(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function Vi(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function Yi(m,h,g){return h&&Vi(m.prototype,h),g&&Vi(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Ye=Yi(function m(h){var g=this;(function(_,A){if(!(_ instanceof A))throw new TypeError("Cannot call a class as a function")})(this,m),h.on("viewinit",function(){g.viewErrored=!1}),h.on("error",function(_,A){try{var R=h.errorTranslator({player_error_code:A.player_error_code,player_error_message:A.player_error_message,player_error_context:A.player_error_context});R?(h.data.player_error_code=R.player_error_code||A.player_error_code,h.data.player_error_message=R.player_error_message||A.player_error_message,h.data.player_error_context=R.player_error_context||A.player_error_context,g.viewErrored=!0):(delete h.data.player_error_code,delete h.data.player_error_message,delete h.data.player_error_context)}catch(k){h.mux.log.warn("Exception in error translator callback.",k),g.viewErrored=!0}})});function Ur(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var li=function(){function m(A){(function(R,k){if(!(R instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A,this._watchTimeTrackerLastCheckedTime=null,A.on("playbackheartbeat",this._updateWatchTime.bind(this)),A.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var h,g,_;return h=m,(g=[{key:"_updateWatchTime",value:function(A,R){var k=R.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=k),E(this.pm.data,"view_watch_time",k-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=k}},{key:"_clearWatchTimeState",value:function(A,R){this._updateWatchTime(A,R),this._watchTimeTrackerLastCheckedTime=null}}])&&Ur(h.prototype,g),_&&Ur(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function gr(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var Br=function(){function m(A){(function(R,k){if(!(R instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A,this._playbackTimeTrackerLastPlayheadPosition=-1,A.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),A.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),A.on("seeking",this._clearPlaybackTimeState.bind(this))}var h,g,_;return h=m,(g=[{key:"_updatePlaybackTime",value:function(){var A=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&A>this._playbackTimeTrackerLastPlayheadPosition){var R=A-this._playbackTimeTrackerLastPlayheadPosition;R<=1e3&&E(this.pm.data,"view_content_playback_time",R)}this._playbackTimeTrackerLastPlayheadPosition=A}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&gr(h.prototype,g),_&&gr(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function ui(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var Wi=function(){function m(A){(function(k,P){if(!(k instanceof P))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A;var R=this._updatePlayheadTime.bind(this);A.on("playbackheartbeat",R),A.on("playbackheartbeatend",R),A.on("timeupdate",R),A.on("destroy",function(){A.off("timeupdate",R)})}var h,g,_;return h=m,(g=[{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(A,R){var k=this,P=function(){k.pm.currentFragmentPDT&&k.pm.currentFragmentStart&&(k.pm.data.player_program_time=k.pm.currentFragmentPDT+k.pm.data.player_playhead_time-k.pm.currentFragmentStart)};if(R&&R.player_playhead_time)this.pm.data.player_playhead_time=R.player_playhead_time,P(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var U=this.pm.getPlayheadTime();U!==void 0&&(this.pm.data.player_playhead_time=U,P(),this._updateMaxPlayheadPosition())}}}])&&ui(h.prototype,g),_&&ui(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function di(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function ci(m,h,g){return h&&di(m.prototype,h),g&&di(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var hi=3e5,Wt=ci(function m(h){if(function(R,k){if(!(R instanceof k))throw new TypeError("Cannot call a class as a function")}(this,m),!h.disableRebufferTracking){var g,_=function(R,k){A(k),g=void 0},A=function(R){if(g){var k=R.viewer_time-g;E(h.data,"view_rebuffer_duration",k),g=R.viewer_time,h.data.view_rebuffer_duration>hi&&(h.emit("viewend"),h.send("viewend"),h.mux.log.warn("Ending view after rebuffering for longer than ".concat(hi,"ms, future events will be ignored unless a programchange or videochange occurs.")))}h.data.view_watch_time>=0&&h.data.view_rebuffer_count>0&&(h.data.view_rebuffer_frequency=h.data.view_rebuffer_count/h.data.view_watch_time,h.data.view_rebuffer_percentage=h.data.view_rebuffer_duration/h.data.view_watch_time)};h.on("playbackheartbeat",function(R,k){return A(k)}),h.on("rebufferstart",function(R,k){g||(E(h.data,"view_rebuffer_count",1),g=k.viewer_time,h.one("rebufferend",_))}),h.on("viewinit",function(){g=void 0,h.off("rebufferend",_)})}});function Gr(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var fi=function(){function m(A){var R=this;(function(k,P){if(!(k instanceof P))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A,A.disableRebufferTracking||A.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,A.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),A.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),A.on("seeking",function(){R._cleanupRebufferTracker(null,{viewer_time:Ke.now()})}))}var h,g,_;return h=m,g=[{key:"_checkIfRebuffering",value:function(A,R){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(A,R);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var k=R.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&k>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=R.viewer_time}else this._cleanupRebufferTracker(A,R,!0);else this._prepareRebufferTrackerState(R.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(A){this._lastCheckedTime=A,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=A}},{key:"_cleanupRebufferTracker",value:function(A,R){var k=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:R.viewer_time});else{if(this._lastCheckedTime===null)return;var P=this.pm.data.player_playhead_time-this._lastPlayheadTime,U=R.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&P>0&&U-P>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+U-P}))}k?this._prepareRebufferTrackerState(R.viewer_time):this._clearRebufferTrackerState()}}],g&&Gr(h.prototype,g),_&&Gr(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}(),zi=fi;function mr(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var Hr=function(){function m(A){var R=this;(function(k,P){if(!(k instanceof P))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A,A.on("viewinit",function(){var k=A.data,P=k.view_id;if(!k.view_program_changed){var U=function(M,Y){var Ee=Y.viewer_time;M.type==="playing"&&A.data.view_time_to_first_frame===void 0?R.calculateTimeToFirstFrame(Ee||Ke.now(),P):M.type!=="adplaying"||A.data.view_time_to_first_frame!==void 0&&!R._inPrerollPosition()||R.calculateTimeToFirstFrame(Ee||Ke.now(),P)};A.one("playing",U),A.one("adplaying",U),A.one("viewend",function(){A.off("playing",U),A.off("adplaying",U)})}})}var h,g,_;return h=m,(g=[{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(A,R){R===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:A}),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))}}])&&mr(h.prototype,g),_&&mr(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function Xi(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function Qi(m,h,g){return h&&Xi(m.prototype,h),g&&Xi(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var jn=Qi(function m(h){var g=this;(function(_,A){if(!(_ instanceof A))throw new TypeError("Cannot call a class as a function")})(this,m),h.on("viewinit",function(){g._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(_){h.on(_,function(){if(g._lastPlayheadPosition>=0&&h.data.player_playhead_time>=0&&g._lastPlayerWidth>=0&&g._lastSourceWidth>0&&g._lastPlayerHeight>=0&&g._lastSourceHeight>0){var A=h.data.player_playhead_time-g._lastPlayheadPosition;if(A<0)return void(g._lastPlayheadPosition=-1);var R=Math.min(g._lastPlayerWidth/g._lastSourceWidth,g._lastPlayerHeight/g._lastSourceHeight),k=Math.max(0,R-1),P=Math.max(0,1-R);h.data.view_max_upscale_percentage=Math.max(h.data.view_max_upscale_percentage||0,k),h.data.view_max_downscale_percentage=Math.max(h.data.view_max_downscale_percentage||0,P),E(h.data,"view_total_content_playback_time",A),E(h.data,"view_total_upscaling",k*A),E(h.data,"view_total_downscaling",P*A)}g._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(_){h.on(_,function(){g._lastPlayheadPosition=h.data.player_playhead_time,g._lastPlayerWidth=h.data.player_width,g._lastPlayerHeight=h.data.player_height,g._lastSourceWidth=h.data.video_source_width,g._lastSourceHeight=h.data.video_source_height})})});function vi(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function Vn(m,h,g){return h&&vi(m.prototype,h),g&&vi(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Yn=Vn(function m(h){var g=this;(function(_,A){if(!(_ instanceof A))throw new TypeError("Cannot call a class as a function")})(this,m),this.isSeeking=!1,h.on("seeking",function(_,A){Object.assign(h.data,A),g._lastSeekingTime=Ke.now(),g.isSeeking===!1&&(g.isSeeking=!0,h.send("seeking"))}),h.on("seeked",function(){g.isSeeking=!1;var _=g._lastSeekingTime||Ke.now(),A=Ke.now()-_;E(h.data,"view_seek_count",1),E(h.data,"view_seek_duration",A);var R=h.data.view_max_seek_time||0;h.data.view_max_seek_time=Math.max(R,A)}),h.on("viewend",function(){g.isSeeking=!1})});function Ji(m,h){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var A=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(A!=null){var R,k,P=[],U=!0,M=!1;try{for(A=A.call(g);!(U=(R=A.next()).done)&&(P.push(R.value),!_||P.length!==_);U=!0);}catch(Y){M=!0,k=Y}finally{try{U||A.return==null||A.return()}finally{if(M)throw k}}return P}}(m,h)||function(g,_){if(g){if(typeof g=="string")return $i(g,_);var A=Object.prototype.toString.call(g).slice(8,-1);return A==="Object"&&g.constructor&&(A=g.constructor.name),A==="Map"||A==="Set"?Array.from(g):A==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(A)?$i(g,_):void 0}}(m,h)||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 $i(m,h){(h==null||h>m.length)&&(h=m.length);for(var g=0,_=new Array(h);g<h;g++)_[g]=m[g];return _}function Zi(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var St=function(m,h){m.push(h),m.sort(function(g,_){return g.viewer_time-_.viewer_time})},Wn=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Dt=function(){function m(A){var R=this;(function(P,U){if(!(P instanceof U))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A,A.on("viewinit",function(){R.isAdBreak=!1,R._currentAdRequestNumber=0,R._currentAdResponseNumber=0,R._adRequests=[],R._adResponses=[],R._adHasPlayed=!1,R._wouldBeNewAdPlay=!0,R._prerollPlayTime=void 0}),Wn.forEach(function(P){return A.on(P,R._updateAdData.bind(R))});var k=function(){R.isAdBreak=!1};A.on("adbreakstart",function(){R.isAdBreak=!0}),A.on("play",k),A.on("playing",k),A.on("viewend",k),A.on("adrequest",function(P,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+R._currentAdRequestNumber++},U),St(R._adRequests,U),E(A.data,"view_ad_request_count"),R.inPrerollPosition()&&(A.data.view_preroll_requested=!0,R._adHasPlayed||E(A.data,"view_preroll_request_count"))}),A.on("adresponse",function(P,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+R._currentAdResponseNumber++},U),St(R._adResponses,U);var M=R.findAdRequest(U.ad_request_id);M&&E(A.data,"view_ad_request_time",Math.max(0,U.viewer_time-M.viewer_time))}),A.on("adplay",function(P,U){R._adHasPlayed=!0,R._wouldBeNewAdPlay&&(R._wouldBeNewAdPlay=!1,E(A.data,"view_ad_played_count")),R.inPrerollPosition()&&!A.data.view_preroll_played&&(A.data.view_preroll_played=!0,R._adRequests.length>0&&(A.data.view_preroll_request_time=Math.max(0,U.viewer_time-R._adRequests[0].viewer_time)),A.data.view_start&&(A.data.view_startup_preroll_request_time=Math.max(0,U.viewer_time-A.data.view_start)),R._prerollPlayTime=U.viewer_time)}),A.on("adplaying",function(P,U){R.inPrerollPosition()&&A.data.view_preroll_load_time===void 0&&R._prerollPlayTime!==void 0&&(A.data.view_preroll_load_time=U.viewer_time-R._prerollPlayTime,A.data.view_startup_preroll_load_time=U.viewer_time-R._prerollPlayTime)}),A.on("adended",function(){R._wouldBeNewAdPlay=!0}),A.on("aderror",function(){R._wouldBeNewAdPlay=!0})}var h,g,_;return h=m,(g=[{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(A){for(var R=0;R<this._adRequests.length;R++)if(this._adRequests[R].ad_request_id===A)return this._adRequests[R]}},{key:"_updateAdData",value:function(A,R){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&R.ad_tag_url){var k=Ji(be(R.ad_tag_url),2),P=k[0],U=k[1];this.pm.data.view_preroll_ad_tag_domain=U,this.pm.data.view_preroll_ad_tag_hostname=P}if(!this.pm.data.view_preroll_ad_asset_hostname&&R.ad_asset_url){var M=Ji(be(R.ad_asset_url),2),Y=M[0],Ee=M[1];this.pm.data.view_preroll_ad_asset_domain=Ee,this.pm.data.view_preroll_ad_asset_hostname=Y}}this.pm.data.ad_asset_url=R==null?void 0:R.ad_asset_url,this.pm.data.ad_tag_url=R==null?void 0:R.ad_tag_url,this.pm.data.ad_creative_id=R==null?void 0:R.ad_creative_id,this.pm.data.ad_id=R==null?void 0:R.ad_id,this.pm.data.ad_universal_id=R==null?void 0:R.ad_universal_id}}])&&Zi(h.prototype,g),_&&Zi(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function pr(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function zn(m,h,g){return h&&pr(m.prototype,h),g&&pr(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var en=zn(function m(h){var g,_;(function(P,U){if(!(P instanceof U))throw new TypeError("Cannot call a class as a function")})(this,m);var A=function(){h.disableRebufferTracking||g&&(E(h.data,"view_waiting_rebuffer_duration",Ke.now()-g),g=!1,X().clearInterval(_))},R=!1,k=function(){R=!1,A()};h.on("waiting",function(){R&&(h.disableRebufferTracking||(E(h.data,"view_waiting_rebuffer_count",1),g=Ke.now(),_=X().setInterval(function(){if(g){var P=Ke.now();E(h.data,"view_waiting_rebuffer_duration",P-g),g=P}},250)))}),h.on("playing",function(){A(),R=!0}),h.on("pause",k),h.on("seeking",k)});function Qe(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function tn(m,h,g){return h&&Qe(m.prototype,h),g&&Qe(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Se=tn(function m(h){var g=this;(function(R,k){if(!(R instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m);var _=function(){g.lastWallClockTime=Ke.now(),h.on("before*",A)},A=function(R){var k=Ke.now(),P=g.lastWallClockTime;g.lastWallClockTime=k,k-P>3e4&&(h.emit("devicesleep",{viewer_time:P}),Object.assign(h.data,{viewer_time:P}),h.send("devicesleep"),h.emit("devicewake",{viewer_time:k}),Object.assign(h.data,{viewer_time:k}),h.send("devicewake"))};h.one("playbackheartbeat",_),h.on("playbackheartbeatend",function(){h.off("before*",A),h.one("playbackheartbeat",_)})}),gi=K(375),mi=K(655),Pe=K.n(mi),rn="muxData",pi=function(){var m;try{m=gi.parse(Pe().get(rn)||"")}catch{m={}}return m},yi=function(m){try{Pe().set(rn,gi.stringify(m),{expires:7300})}catch{}},Xn=function(){var m=pi();return m.mux_viewer_id=m.mux_viewer_id||ae(),m.msn=m.msn||Math.random(),yi(m),{mux_viewer_id:m.mux_viewer_id,mux_sample_number:m.msn}};function zt(m,h){var g=h.beaconCollectionDomain,_=h.beaconDomain;if(g)return"https://"+g;var A=_||"litix.io";return(m=m||"inferred").match(/^[a-z0-9]+$/)?"https://"+m+"."+A:"https://img.litix.io/a.gif"}var Ti=function(){var m;switch(nn()){case"cellular":m="cellular";break;case"ethernet":m="wired";break;case"wifi":m="wifi";break;case void 0:break;default:m="other"}return m},nn=function(){var m=X().navigator,h=m&&(m.connection||m.mozConnection||m.webkitConnection);return h&&h.type};Ti.getConnectionFromAPI=nn;var an=Ti,sn=yr({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"}),on=yr({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",cl:"canceled",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",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",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 yr(m){var h={};for(var g in m)m.hasOwnProperty(g)&&(h[m[g]]=g);return h}function Tr(m){var h={},g={};return Object.keys(m).forEach(function(_){var A=!1;if(m.hasOwnProperty(_)&&m[_]!==void 0){var R=_.split("_"),k=R[0],P=sn[k];P||(Re.info("Data key word `"+R[0]+"` not expected in "+_),P=k+"_"),R.splice(1).forEach(function(U){U==="url"&&(A=!0),on[U]?P+=on[U]:Number(U)&&Math.floor(Number(U))===Number(U)?P+=U:(Re.info("Data key word `"+U+"` not expected in "+_),P+="_"+U+"_")}),A?g[P]=m[_]:h[P]=m[_]}}),Object.assign(h,g)}var ln={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},un=["hb","requestcompleted","requestfailed","requestcanceled"],ct="https://img.litix.io",At=function(m){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=m||ct,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},ln,h)};At.prototype.queueEvent=function(m,h){var g=Object.assign({},h);return(this._eventQueue.length<=this._options.maxQueueLength||m==="eventrateexceeded")&&(this._eventQueue.push(g),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},At.prototype.flushEvents=function(){var m=arguments.length>0&&arguments[0]!==void 0&&arguments[0];m&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},At.prototype.destroy=function(){var m=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,m?this._clearBeaconQueue():this.flushEvents(),X().clearTimeout(this._sendTimeout)},At.prototype._clearBeaconQueue=function(){var m=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,h=this._eventQueue.slice(m);m>0&&Object.assign(h[h.length-1],Tr({mux_view_message:"event queue truncated"}));var g=this._createPayload(h);cn(this._beaconUrl,g,!0,function(){})},At.prototype._sendBeaconQueue=function(){var m=this;if(!this._postInFlight){var h=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var g=this._createPayload(h),_=Ke.now();cn(this._beaconUrl,g,!1,function(A,R){R?(m._eventQueue=h.concat(m._eventQueue),m._failureCount+=1,Re.info("Error sending beacon: "+R)):m._failureCount=0,m._roundTripTime=Ke.now()-_,m._postInFlight=!1})}},At.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var m=Math.pow(2,this._failureCount-1);return(1+(m*=Math.random()))*this._options.baseTimeBetweenBeacons},At.prototype._startBeaconSending=function(){var m=this;X().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=X().setTimeout(function(){m._eventQueue.length&&m._sendBeaconQueue(),m._startBeaconSending()},this._getNextBeaconTime()))},At.prototype._createPayload=function(m){var h,g,_,A=this,R={transmission_timestamp:Math.round(Ke.now())};this._roundTripTime&&(R.rtt_ms=Math.round(this._roundTripTime));var k=function(){h=JSON.stringify({metadata:R,events:g||m}),_=h.length/1024},P=function(){return _<=A._options.maxPayloadKBSize};return k(),P()||(Re.info("Payload size is too big ("+_+" kb). Removing unnecessary events."),g=m.filter(function(U){return un.indexOf(U.e)===-1}),k()),P()||(Re.info("Payload size still too big ("+_+" kb). Cropping fields.."),g.forEach(function(U){for(var M in U){var Y=U[M];typeof Y=="string"&&Y.length>51200&&(U[M]=Y.substring(0,51200))}}),k()),h};var dn=function(m){return m.length<=57344},cn=function(m,h,g,_){if(g&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(m,h))_();else if(X().fetch)X().fetch(m,{method:"POST",body:h,headers:{"Content-Type":"text/plain"},keepalive:dn(h)}).then(function(R){return _(null,R.ok?null:"Error")}).catch(function(R){return _(null,R)});else{if(X().XMLHttpRequest){var A=new(X()).XMLHttpRequest;return A.onreadystatechange=function(){if(A.readyState===4)return _(null,A.status!==200?"error":void 0)},A.open("POST",m),A.setRequestHeader("Content-Type","text/plain"),void A.send(h)}_()}},Kr=At;function Qn(m,h){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var A=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(A!=null){var R,k,P=[],U=!0,M=!1;try{for(A=A.call(g);!(U=(R=A.next()).done)&&(P.push(R.value),!_||P.length!==_);U=!0);}catch(Y){M=!0,k=Y}finally{try{U||A.return==null||A.return()}finally{if(M)throw k}}return P}}(m,h)||function(g,_){if(g){if(typeof g=="string")return Ei(g,_);var A=Object.prototype.toString.call(g).slice(8,-1);return A==="Object"&&g.constructor&&(A=g.constructor.name),A==="Map"||A==="Set"?Array.from(g):A==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(A)?Ei(g,_):void 0}}(m,h)||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 Ei(m,
|
|
4
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Ne(m,h){(h==null||h>m.length)&&(h=m.length);for(var g=0,_=new Array(h);g<h;g++)_[g]=m[g];return _}function kt(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function It(m,h){return It=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,_){return g.__proto__=_,g},It(m,h)}function mn(m){var h=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 g,_=br(m);if(h){var A=br(this).constructor;g=Reflect.construct(_,arguments,A)}else g=_.apply(this,arguments);return Ai(this,g)}}function Ai(m,h){if(h&&(yt(h)==="object"||typeof h=="function"))return h;if(h!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Je(m)}function Je(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function br(m){return br=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},br(m)}var pn=["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"],lr=function(m){(function(k,P){if(typeof P!="function"&&P!==null)throw new TypeError("Super expression must either be null or a function");k.prototype=Object.create(P&&P.prototype,{constructor:{value:k,writable:!0,configurable:!0}}),Object.defineProperty(k,"prototype",{writable:!1}),P&&It(k,P)})(R,m);var h,g,_,A=mn(R);function R(k,P,U){var M;(function(le,fe){if(!(le instanceof fe))throw new TypeError("Cannot call a class as a function")})(this,R),(M=A.call(this)).DOM_CONTENT_LOADED_EVENT_END=Z.domContentLoadedEventEnd(),M.NAVIGATION_START=Z.navigationStart(),M.mux=k,M.id=P,(U=Object.assign({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(le){return le}},U)).data=U.data||{},U.data.property_key&&(U.data.env_key=U.data.property_key,delete U.data.property_key),Re.setLevel(U.debug?"debug":"warn"),M.getPlayheadTime=U.getPlayheadTime,M.getStateData=U.getStateData||function(){return{}},M.getAdData=U.getAdData||function(){},M.minimumRebufferDuration=U.minimumRebufferDuration,M.sustainedRebufferThreshold=U.sustainedRebufferThreshold,M.playbackHeartbeatTime=U.playbackHeartbeatTime,M.disableRebufferTracking=U.disableRebufferTracking,M.disableRebufferTracking&&M.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."),M.disablePlayheadRebufferTracking=U.disablePlayheadRebufferTracking,M.errorTranslator=U.errorTranslator,M.playbackEventDispatcher=new $n(k,U.data.env_key,U),M.data={player_instance_id:ae(),mux_sample_rate:U.sampleRate,beacon_domain:U.beaconCollectionDomain?U.beaconCollectionDomain:U.beaconDomain},M.data.view_sequence_number=1,M.data.player_sequence_number=1,M.oldEmit=M.emit,M.emit=function(le,fe){fe=Object.assign({viewer_time:this.mux.utils.now()},fe),this.oldEmit(le,fe)};var Y=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Je(M));M.on("viewinit",function(le,fe){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,fe),this._initializeViewData(),this.one("play",Y),this.one("adbreakstart",Y)});var Ee=function(le){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",le)}.bind(Je(M));if(M.on("videochange",function(le,fe){Ee(fe)}),M.on("programchange",function(le,fe){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),Ee(Object.assign(fe,{view_program_changed:!0})),Y(),this.emit("play"),this.emit("playing")}),M.on("fragmentchange",function(le,fe){this.currentFragmentPDT=fe.currentFragmentPDT,this.currentFragmentStart=fe.currentFragmentStart}),M.on("destroy",M.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var se=function(){var le=M.data.view_start!==void 0;M.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",le&&M.mux.WINDOW_HIDDEN&&(M.data.player_is_paused||M.emit("hb"))};window.addEventListener("visibilitychange",se,!1);var de=function(le){le.persisted||M.destroy()};window.addEventListener("pagehide",de,!1),M.on("destroy",function(){window.removeEventListener("visibilitychange",se),window.removeEventListener("pagehide",de)})}return M.on("playerready",function(le,fe){Object.assign(this.data,fe)}),pn.forEach(function(le){M.on(le,function(fe,De){le.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,De),this._sanitizeData()}),M.on("after"+le,function(){(le!=="error"||this.errorTracker.viewErrored)&&this.send(le)})}),M.on("viewend",function(le,fe){Object.assign(M.data,fe)}),M.one("playerready",function(le){var fe=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=fe-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),M.longResumeTracker=new Qt(Je(M)),M.errorTracker=new Ye(Je(M)),new Se(Je(M)),M.seekingTracker=new Yn(Je(M)),M.playheadTime=new Wi(Je(M)),M.playbackHeartbeat=new oi(Je(M)),new jn(Je(M)),M.watchTimeTracker=new li(Je(M)),new Br(Je(M)),M.adTracker=new Dt(Je(M)),new zi(Je(M)),new Wt(Je(M)),new Hr(Je(M)),new en(Je(M)),new gn(Je(M)),U.hlsjs&&M.addHLSJS(U),U.dashjs&&M.addDashJS(U),M.emit("viewinit",U.data),M}return h=R,g=[{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(k){if(this.data.view_id){var P=Object.assign({},this.data);if(P.video_source_is_live===void 0&&(P.player_source_duration===1/0||P.video_source_duration===1/0?P.video_source_is_live=!0:(P.player_source_duration>0||P.video_source_duration>0)&&(P.video_source_is_live=!1)),P.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){P[Ee]=void 0}),P.video_source_url=P.video_source_url||P.player_source_url,P.video_source_url){var U=Gt(be(P.video_source_url),2),M=U[0],Y=U[1];P.video_source_domain=Y,P.video_source_hostname=M}delete P.ad_request_id,this.playbackEventDispatcher.send(k,P),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),k==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var k=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(P){var U=parseInt(k.data[P],10);k.data[P]=isNaN(U)?void 0:U}),["player_source_url","video_source_url"].forEach(function(P){if(k.data[P]){var U=k.data[P].toLowerCase();U.indexOf("data:")!==0&&U.indexOf("blob:")!==0||(k.data[P]="MSE style URL")}})}},{key:"_resetVideoData",value:function(k,P){var U=this;Object.keys(this.data).forEach(function(M){M.indexOf("video_")===0&&delete U.data[M]})}},{key:"_resetViewData",value:function(){var k=this;Object.keys(this.data).forEach(function(P){P.indexOf("view_")===0&&delete k.data[P]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(k,P){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var k=this,P=this.data.view_id=ae(),U=function(){P===k.data.view_id&&E(k.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",U):U()}},{key:"_restartHeartBeat",value:function(){var k=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){k.data.player_is_paused||k.emit("hb")},1e4))}},{key:"addHLSJS",value:function(k){k.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=k.hlsjs,function(P,U,M){var Y=arguments.length>4?arguments[4]:void 0,Ee=P.log,se=P.utils.secondsToMs,de=function(Fe){var $,re=parseInt(Y.version);return re===1&&Fe.programDateTime!==null&&($=Fe.programDateTime),re===0&&Fe.pdt!==null&&($=Fe.pdt),$};if(Z.exists()){var le=function(Fe,$){return P.emit(U,Fe,$)},fe=function(Fe,$){var re=$.levels,ie=$.audioTracks,_e=$.url,Ie=$.stats,We=$.networkDetails,ht=$.sessionData,Ze={},ot={};re.forEach(function(ce,Zt){Ze[Zt]={width:ce.width,height:ce.height,bitrate:ce.bitrate,attrs:ce.attrs}}),ie.forEach(function(ce,Zt){ot[Zt]={name:ce.name,language:ce.lang,bitrate:ce.bitrate}});var et=nr(Ie),tt=et.bytesLoaded,Ct=et.requestStart,Dr=et.responseStart,rt=et.responseEnd;le("requestcompleted",qe(qe({},Be(ht)),{},{request_event_type:Fe,request_bytes_loaded:tt,request_start:Ct,request_response_start:Dr,request_response_end:rt,request_type:"manifest",request_hostname:pe(_e),request_response_headers:Bt(We),request_rendition_lists:{media:Ze,audio:ot,video:{}}}))};M.on(Y.Events.MANIFEST_LOADED,fe);var De=function(Fe,$){var re=$.details,ie=$.level,_e=$.networkDetails,Ie=$.stats,We=nr(Ie),ht=We.bytesLoaded,Ze=We.requestStart,ot=We.responseStart,et=We.responseEnd,tt=re.fragments[re.fragments.length-1],Ct=de(tt)+se(tt.duration);le("requestcompleted",{request_event_type:Fe,request_bytes_loaded:ht,request_start:Ze,request_response_start:ot,request_response_end:et,request_current_level:ie,request_type:"manifest",request_hostname:pe(re.url),request_response_headers:Bt(_e),video_holdback:re.holdBack&&se(re.holdBack),video_part_holdback:re.partHoldBack&&se(re.partHoldBack),video_part_target_duration:re.partTarget&&se(re.partTarget),video_target_duration:re.targetduration&&se(re.targetduration),video_source_is_live:re.live,player_manifest_newest_program_time:isNaN(Ct)?void 0:Ct})};M.on(Y.Events.LEVEL_LOADED,De);var $e=function(Fe,$){var re=$.details,ie=$.networkDetails,_e=$.stats,Ie=nr(_e),We=Ie.bytesLoaded,ht=Ie.requestStart,Ze=Ie.responseStart,ot=Ie.responseEnd;le("requestcompleted",{request_event_type:Fe,request_bytes_loaded:We,request_start:ht,request_response_start:Ze,request_response_end:ot,request_type:"manifest",request_hostname:pe(re.url),request_response_headers:Bt(ie)})};M.on(Y.Events.AUDIO_TRACK_LOADED,$e);var it=function(Fe,$){var re=$.stats,ie=$.networkDetails,_e=$.frag;re=re||_e.stats;var Ie=nr(re),We=Ie.bytesLoaded,ht=Ie.requestStart,Ze=Ie.responseStart,ot=Ie.responseEnd,et=ie?Bt(ie):void 0,tt={request_event_type:Fe,request_bytes_loaded:We,request_start:ht,request_response_start:Ze,request_response_end:ot,request_hostname:ie?pe(ie.responseURL):void 0,request_id:et?Ue(et):void 0,request_response_headers:et,request_media_duration:_e.duration,request_url:ie==null?void 0:ie.responseURL};_e.type==="main"?(tt.request_type="media",tt.request_current_level=_e.level,tt.request_video_width=(M.levels[_e.level]||{}).width,tt.request_video_height=(M.levels[_e.level]||{}).height,tt.request_labeled_bitrate=(M.levels[_e.level]||{}).bitrate):tt.request_type=_e.type,le("requestcompleted",tt)};M.on(Y.Events.FRAG_LOADED,it);var st=function(Fe,$){var re=$.frag,ie=re.start,_e={currentFragmentPDT:de(re),currentFragmentStart:se(ie)};le("fragmentchange",_e)};M.on(Y.Events.FRAG_CHANGED,st);var pt=function(Fe,$){var re=$.type,ie=$.details,_e=$.response,Ie=$.fatal,We=$.frag,ht=$.networkDetails,Ze=(We==null?void 0:We.url)||$.url||"",ot=ht?Bt(ht):void 0;if(ie!==Y.ErrorDetails.MANIFEST_LOAD_ERROR&&ie!==Y.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.FRAG_LOAD_ERROR&&ie!==Y.ErrorDetails.FRAG_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.LEVEL_LOAD_ERROR&&ie!==Y.ErrorDetails.LEVEL_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&ie!==Y.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.SUBTITLE_LOAD_ERROR&&ie!==Y.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.KEY_LOAD_ERROR&&ie!==Y.ErrorDetails.KEY_LOAD_TIMEOUT||le("requestfailed",{request_error:ie,request_url:Ze,request_hostname:pe(Ze),request_id:ot?Ue(ot):void 0,request_type:ie===Y.ErrorDetails.FRAG_LOAD_ERROR||ie===Y.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":ie===Y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||ie===Y.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":ie===Y.ErrorDetails.SUBTITLE_LOAD_ERROR||ie===Y.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":ie===Y.ErrorDetails.KEY_LOAD_ERROR||ie===Y.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:_e==null?void 0:_e.code,request_error_text:_e==null?void 0:_e.text}),Ie){var et,tt="".concat(Ze?"url: ".concat(Ze,`
|
|
1
|
+
var Wl=Object.create;var Pa=Object.defineProperty;var zl=Object.getOwnPropertyDescriptor;var Xl=Object.getOwnPropertyNames;var Ql=Object.getPrototypeOf,Jl=Object.prototype.hasOwnProperty;var $l=(L,w,R)=>w in L?Pa(L,w,{enumerable:!0,configurable:!0,writable:!0,value:R}):L[w]=R;var Ws=(L,w)=>()=>(w||L((w={exports:{}}).exports,w),w.exports);var Zl=(L,w,R,B)=>{if(w&&typeof w=="object"||typeof w=="function")for(let j of Xl(w))!Jl.call(L,j)&&j!==R&&Pa(L,j,{get:()=>w[j],enumerable:!(B=zl(w,j))||B.enumerable});return L};var zs=(L,w,R)=>(R=L!=null?Wl(Ql(L)):{},Zl(w||!L||!L.__esModule?Pa(R,"default",{value:L,enumerable:!0}):R,L));var Oa=(L,w,R)=>($l(L,typeof w!="symbol"?w+"":w,R),R),Ma=(L,w,R)=>{if(!w.has(L))throw TypeError("Cannot "+R)};var ft=(L,w,R)=>(Ma(L,w,"read from private field"),R?R.call(L):w.get(L)),vt=(L,w,R)=>{if(w.has(L))throw TypeError("Cannot add the same private member more than once");w instanceof WeakSet?w.add(L):w.set(L,R)},Rt=(L,w,R,B)=>(Ma(L,w,"write to private field"),B?B.call(L,R):w.set(L,R),R);var Ft=(L,w,R)=>(Ma(L,w,"access private method"),R);var Js=Ws((Un,Ua)=>{(function(){var L,w;L=this,w=function(){return function(){var R={80:function(H,z,K){H.exports=K(728).default},728:function(H,z,K){"use strict";K.d(z,{default:function(){return An}});var ee=K(48),X=K.n(ee),ae=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(m){var c=16*Math.random()|0;return(m==="x"?c:3&c|8).toString(16)})},ge=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},ne=function(m){return m&&m.nodeName!==void 0?(m.muxId||(m.muxId=m.id||ge()),m.muxId):m},Ae=function(m){var c;m&&m.nodeName!==void 0?m=ne(c=m):c=document.querySelector(m);var g=c&&c.nodeName?c.nodeName.toLowerCase():"";return[c,m,g]},Le=K(640),xe=K.n(Le),je=xe().methodFactory;xe().methodFactory=function(m,c,g){var _=je(m,c,g);return function(){for(var A=["[mux]"],I=0;I<arguments.length;I++)A.push(arguments[I]);_.apply(void 0,A)}},xe().setLevel(xe().getLevel());var Re=xe();function dt(){return(X().doNotTrack||X().navigator&&X().navigator.doNotTrack)==="1"}var Ke={now:function(){var m=X().performance,c=m&&m.timing,g=c&&c.navigationStart,_=typeof g=="number"&&typeof m.now=="function"?g+m.now():Date.now();return Math.round(_)}},pe=function(m){return be(m)[0]},be=function(m){if(typeof m!="string"||m==="")return["localhost"];var c,g=(m.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return g&&(c=(g.match(/[^\.]+\.[^\.]+$/)||[])[0]),[g,c]},Z={exists:function(){var m=X().performance;return(m&&m.timing)!==void 0},domContentLoadedEventEnd:function(){var m=X().performance,c=m&&m.timing;return c&&c.domContentLoadedEventEnd},navigationStart:function(){var m=X().performance,c=m&&m.timing;return c&&c.navigationStart}};function E(m,c,g){g=g===void 0?1:g,m[c]=m[c]||0,m[c]+=g}var Q=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],F=["x-cdn","content-type"].concat(Q);function ce(m){var c={};return(m=m||"").trim().split(/[\r\n]+/).forEach(function(g){if(g){var _=g.split(": "),A=_.shift();A&&(F.indexOf(A.toLowerCase())>=0||A.toLowerCase().indexOf("x-litix-")===0)&&(c[A]=_.join(": "))}}),c}function Ue(m){if(m){var c=Q.find(function(g){return m[g]!==void 0});return c?m[c]:void 0}}var Be=function(m){var c={};for(var g in m){var _=m[g];_["DATA-ID"].search("io.litix.data.")!==-1&&(c[_["DATA-ID"].replace("io.litix.data.","")]=_.VALUE)}return c};function Ut(m,c){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(m);c&&(_=_.filter(function(A){return Object.getOwnPropertyDescriptor(m,A).enumerable})),g.push.apply(g,_)}return g}function qe(m){for(var c=1;c<arguments.length;c++){var g=arguments[c]!=null?arguments[c]:{};c%2?Ut(Object(g),!0).forEach(function(_){x(m,_,g[_])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):Ut(Object(g)).forEach(function(_){Object.defineProperty(m,_,Object.getOwnPropertyDescriptor(g,_))})}return m}function x(m,c,g){return c in m?Object.defineProperty(m,c,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[c]=g,m}var ar=function(m){if(!m)return{};var c=Z.navigationStart(),g=m.loading,_=g?g.start:m.trequest,A=g?g.first:m.tfirst,I=g?g.end:m.tload;return{bytesLoaded:m.total,requestStart:Math.round(c+_),responseStart:Math.round(c+A),responseEnd:Math.round(c+I)}},Bt=function(m){if(m&&typeof m.getAllResponseHeaders=="function")return ce(m.getAllResponseHeaders())};function Ve(m,c){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(m);c&&(_=_.filter(function(A){return Object.getOwnPropertyDescriptor(m,A).enumerable})),g.push.apply(g,_)}return g}function sr(m){for(var c=1;c<arguments.length;c++){var g=arguments[c]!=null?arguments[c]:{};c%2?Ve(Object(g),!0).forEach(function(_){Me(m,_,g[_])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):Ve(Object(g)).forEach(function(_){Object.defineProperty(m,_,Object.getOwnPropertyDescriptor(g,_))})}return m}function Me(m,c,g){return c in m?Object.defineProperty(m,c,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[c]=g,m}var gt=function(m,c){if(!m||typeof m.getRequests!="function")return{};var g=m.getRequests({state:"executed"});if(g.length===0)return{};var _,A=g[g.length-1],I=pe(A.url),k=A.url,P=A.bytesLoaded,U=new Date(A.requestStartDate).getTime(),M=new Date(A.firstByteDate).getTime(),Y=new Date(A.requestEndDate).getTime(),Ee=isNaN(A.duration)?0:A.duration,se=typeof c.getMetricsFor=="function"?c.getMetricsFor(A.mediaType).HttpList:c.getDashMetrics().getHttpRequests(A.mediaType);return se.length>0&&(_=ce(se[se.length-1]._responseHeaders||"")),{requestStart:U,requestResponseStart:M,requestResponseEnd:Y,requestBytesLoaded:P,requestResponseHeaders:_,requestMediaDuration:Ee,requestHostname:I,requestUrl:k,requestId:_?Ue(_):void 0}},Xe=function(m,c){var g=c.getQualityFor(m),_=c.getCurrentTrackFor(m).bitrateList;return _?{currentLevel:g,renditionWidth:_[g].width||null,renditionHeight:_[g].height||null,renditionBitrate:_[g].bandwidth}:{}},mt=function(m){var c;return(c=m.match(/.*codecs\*?="(.*)"/))===null||c===void 0?void 0:c[1]};function Nr(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var ai=0,si=function(){function m(){(function(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")})(this,m)}var c,g,_;return c=m,g=[{key:"on",value:function(A,I,k){return I._eventEmitterGuid=I._eventEmitterGuid||++ai,this._listeners=this._listeners||{},this._listeners[A]=this._listeners[A]||[],k&&(I=I.bind(k)),this._listeners[A].push(I),I}},{key:"off",value:function(A,I){var k=this._listeners&&this._listeners[A];k&&k.forEach(function(P,U){P._eventEmitterGuid===I._eventEmitterGuid&&k.splice(U,1)})}},{key:"one",value:function(A,I,k){var P=this;I._eventEmitterGuid=I._eventEmitterGuid||++ai;var U=function M(){P.off(A,M),I.apply(k||this,arguments)};U._eventEmitterGuid=I._eventEmitterGuid,this.on(A,U)}},{key:"emit",value:function(A,I){var k=this;if(this._listeners){I=I||{};var P=this._listeners["before*"]||[],U=this._listeners[A]||[],M=this._listeners["after"+A]||[],Y=function(Ee,se){(Ee=Ee.slice()).forEach(function(de){de.call(k,{type:A},se)})};Y(P,I),Y(U,I),Y(M,I)}}}],g&&Nr(c.prototype,g),_&&Nr(c,_),Object.defineProperty(c,"prototype",{writable:!1}),m}(),qn=si;function ji(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var oi=function(){function m(A){var I=this;(function(k,P){if(!(k instanceof P))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,A.on("playing",function(){I._playheadShouldBeProgressing=!0}),A.on("play",this._startPlaybackHeartbeatInterval.bind(this)),A.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),A.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),A.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),A.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),A.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),A.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),A.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),A.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),A.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),A.on("seeked",function(){A.data.player_is_paused?I._stopPlaybackHeartbeatInterval():I._startPlaybackHeartbeatInterval()}),A.on("timeupdate",function(){I._playbackHeartbeatInterval!==null&&A.emit("playbackheartbeat")}),A.on("devicesleep",function(k,P){I._playbackHeartbeatInterval!==null&&(X().clearInterval(I._playbackHeartbeatInterval),A.emit("playbackheartbeatend",{viewer_time:P.viewer_time}),I._playbackHeartbeatInterval=null)})}var c,g,_;return c=m,(g=[{key:"_startPlaybackHeartbeatInterval",value:function(){var A=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=X().setInterval(function(){A.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(X().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&ji(c.prototype,g),_&&ji(c,_),Object.defineProperty(c,"prototype",{writable:!1}),m}();function Vi(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function Yi(m,c,g){return c&&Vi(m.prototype,c),g&&Vi(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Ye=Yi(function m(c){var g=this;(function(_,A){if(!(_ instanceof A))throw new TypeError("Cannot call a class as a function")})(this,m),c.on("viewinit",function(){g.viewErrored=!1}),c.on("error",function(_,A){try{var I=c.errorTranslator({player_error_code:A.player_error_code,player_error_message:A.player_error_message,player_error_context:A.player_error_context});I?(c.data.player_error_code=I.player_error_code||A.player_error_code,c.data.player_error_message=I.player_error_message||A.player_error_message,c.data.player_error_context=I.player_error_context||A.player_error_context,g.viewErrored=!0):(delete c.data.player_error_code,delete c.data.player_error_message,delete c.data.player_error_context)}catch(k){c.mux.log.warn("Exception in error translator callback.",k),g.viewErrored=!0}})});function Ur(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var li=function(){function m(A){(function(I,k){if(!(I instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A,this._watchTimeTrackerLastCheckedTime=null,A.on("playbackheartbeat",this._updateWatchTime.bind(this)),A.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var c,g,_;return c=m,(g=[{key:"_updateWatchTime",value:function(A,I){var k=I.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=k),E(this.pm.data,"view_watch_time",k-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=k}},{key:"_clearWatchTimeState",value:function(A,I){this._updateWatchTime(A,I),this._watchTimeTrackerLastCheckedTime=null}}])&&Ur(c.prototype,g),_&&Ur(c,_),Object.defineProperty(c,"prototype",{writable:!1}),m}();function gr(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var Br=function(){function m(A){(function(I,k){if(!(I instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A,this._playbackTimeTrackerLastPlayheadPosition=-1,A.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),A.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),A.on("seeking",this._clearPlaybackTimeState.bind(this))}var c,g,_;return c=m,(g=[{key:"_updatePlaybackTime",value:function(){var A=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&A>this._playbackTimeTrackerLastPlayheadPosition){var I=A-this._playbackTimeTrackerLastPlayheadPosition;I<=1e3&&E(this.pm.data,"view_content_playback_time",I)}this._playbackTimeTrackerLastPlayheadPosition=A}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&gr(c.prototype,g),_&&gr(c,_),Object.defineProperty(c,"prototype",{writable:!1}),m}();function ui(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var Wi=function(){function m(A){(function(k,P){if(!(k instanceof P))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A;var I=this._updatePlayheadTime.bind(this);A.on("playbackheartbeat",I),A.on("playbackheartbeatend",I),A.on("timeupdate",I),A.on("destroy",function(){A.off("timeupdate",I)})}var c,g,_;return c=m,(g=[{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(A,I){var k=this,P=function(){k.pm.currentFragmentPDT&&k.pm.currentFragmentStart&&(k.pm.data.player_program_time=k.pm.currentFragmentPDT+k.pm.data.player_playhead_time-k.pm.currentFragmentStart)};if(I&&I.player_playhead_time)this.pm.data.player_playhead_time=I.player_playhead_time,P(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var U=this.pm.getPlayheadTime();U!==void 0&&(this.pm.data.player_playhead_time=U,P(),this._updateMaxPlayheadPosition())}}}])&&ui(c.prototype,g),_&&ui(c,_),Object.defineProperty(c,"prototype",{writable:!1}),m}();function di(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function hi(m,c,g){return c&&di(m.prototype,c),g&&di(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var ci=3e5,zt=hi(function m(c){if(function(I,k){if(!(I instanceof k))throw new TypeError("Cannot call a class as a function")}(this,m),!c.disableRebufferTracking){var g,_=function(I,k){A(k),g=void 0},A=function(I){if(g){var k=I.viewer_time-g;E(c.data,"view_rebuffer_duration",k),g=I.viewer_time,c.data.view_rebuffer_duration>ci&&(c.emit("viewend"),c.send("viewend"),c.mux.log.warn("Ending view after rebuffering for longer than ".concat(ci,"ms, future events will be ignored unless a programchange or videochange occurs.")))}c.data.view_watch_time>=0&&c.data.view_rebuffer_count>0&&(c.data.view_rebuffer_frequency=c.data.view_rebuffer_count/c.data.view_watch_time,c.data.view_rebuffer_percentage=c.data.view_rebuffer_duration/c.data.view_watch_time)};c.on("playbackheartbeat",function(I,k){return A(k)}),c.on("rebufferstart",function(I,k){g||(E(c.data,"view_rebuffer_count",1),g=k.viewer_time,c.one("rebufferend",_))}),c.on("viewinit",function(){g=void 0,c.off("rebufferend",_)})}});function Gr(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var fi=function(){function m(A){var I=this;(function(k,P){if(!(k instanceof P))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A,A.disableRebufferTracking||A.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,A.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),A.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),A.on("seeking",function(){I._cleanupRebufferTracker(null,{viewer_time:Ke.now()})}))}var c,g,_;return c=m,g=[{key:"_checkIfRebuffering",value:function(A,I){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(A,I);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var k=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&k>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=I.viewer_time}else this._cleanupRebufferTracker(A,I,!0);else this._prepareRebufferTrackerState(I.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(A){this._lastCheckedTime=A,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=A}},{key:"_cleanupRebufferTracker",value:function(A,I){var k=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:I.viewer_time});else{if(this._lastCheckedTime===null)return;var P=this.pm.data.player_playhead_time-this._lastPlayheadTime,U=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&P>0&&U-P>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+U-P}))}k?this._prepareRebufferTrackerState(I.viewer_time):this._clearRebufferTrackerState()}}],g&&Gr(c.prototype,g),_&&Gr(c,_),Object.defineProperty(c,"prototype",{writable:!1}),m}(),zi=fi;function mr(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var Hr=function(){function m(A){var I=this;(function(k,P){if(!(k instanceof P))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A,A.on("viewinit",function(){var k=A.data,P=k.view_id;if(!k.view_program_changed){var U=function(M,Y){var Ee=Y.viewer_time;M.type==="playing"&&A.data.view_time_to_first_frame===void 0?I.calculateTimeToFirstFrame(Ee||Ke.now(),P):M.type!=="adplaying"||A.data.view_time_to_first_frame!==void 0&&!I._inPrerollPosition()||I.calculateTimeToFirstFrame(Ee||Ke.now(),P)};A.one("playing",U),A.one("adplaying",U),A.one("viewend",function(){A.off("playing",U),A.off("adplaying",U)})}})}var c,g,_;return c=m,(g=[{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(A,I){I===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:A}),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))}}])&&mr(c.prototype,g),_&&mr(c,_),Object.defineProperty(c,"prototype",{writable:!1}),m}();function Xi(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function Qi(m,c,g){return c&&Xi(m.prototype,c),g&&Xi(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var jn=Qi(function m(c){var g=this;(function(_,A){if(!(_ instanceof A))throw new TypeError("Cannot call a class as a function")})(this,m),c.on("viewinit",function(){g._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(_){c.on(_,function(){if(g._lastPlayheadPosition>=0&&c.data.player_playhead_time>=0&&g._lastPlayerWidth>=0&&g._lastSourceWidth>0&&g._lastPlayerHeight>=0&&g._lastSourceHeight>0){var A=c.data.player_playhead_time-g._lastPlayheadPosition;if(A<0)return void(g._lastPlayheadPosition=-1);var I=Math.min(g._lastPlayerWidth/g._lastSourceWidth,g._lastPlayerHeight/g._lastSourceHeight),k=Math.max(0,I-1),P=Math.max(0,1-I);c.data.view_max_upscale_percentage=Math.max(c.data.view_max_upscale_percentage||0,k),c.data.view_max_downscale_percentage=Math.max(c.data.view_max_downscale_percentage||0,P),E(c.data,"view_total_content_playback_time",A),E(c.data,"view_total_upscaling",k*A),E(c.data,"view_total_downscaling",P*A)}g._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(_){c.on(_,function(){g._lastPlayheadPosition=c.data.player_playhead_time,g._lastPlayerWidth=c.data.player_width,g._lastPlayerHeight=c.data.player_height,g._lastSourceWidth=c.data.video_source_width,g._lastSourceHeight=c.data.video_source_height})})});function vi(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function Vn(m,c,g){return c&&vi(m.prototype,c),g&&vi(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Yn=Vn(function m(c){var g=this;(function(_,A){if(!(_ instanceof A))throw new TypeError("Cannot call a class as a function")})(this,m),this.isSeeking=!1,c.on("seeking",function(_,A){Object.assign(c.data,A),g._lastSeekingTime=Ke.now(),g.isSeeking===!1&&(g.isSeeking=!0,c.send("seeking"))}),c.on("seeked",function(){g.isSeeking=!1;var _=g._lastSeekingTime||Ke.now(),A=Ke.now()-_;E(c.data,"view_seek_count",1),E(c.data,"view_seek_duration",A);var I=c.data.view_max_seek_time||0;c.data.view_max_seek_time=Math.max(I,A)}),c.on("viewend",function(){g.isSeeking=!1})});function Ji(m,c){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var A=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(A!=null){var I,k,P=[],U=!0,M=!1;try{for(A=A.call(g);!(U=(I=A.next()).done)&&(P.push(I.value),!_||P.length!==_);U=!0);}catch(Y){M=!0,k=Y}finally{try{U||A.return==null||A.return()}finally{if(M)throw k}}return P}}(m,c)||function(g,_){if(g){if(typeof g=="string")return $i(g,_);var A=Object.prototype.toString.call(g).slice(8,-1);return A==="Object"&&g.constructor&&(A=g.constructor.name),A==="Map"||A==="Set"?Array.from(g):A==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(A)?$i(g,_):void 0}}(m,c)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function $i(m,c){(c==null||c>m.length)&&(c=m.length);for(var g=0,_=new Array(c);g<c;g++)_[g]=m[g];return _}function Zi(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var At=function(m,c){m.push(c),m.sort(function(g,_){return g.viewer_time-_.viewer_time})},Wn=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Dt=function(){function m(A){var I=this;(function(P,U){if(!(P instanceof U))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=A,A.on("viewinit",function(){I.isAdBreak=!1,I._currentAdRequestNumber=0,I._currentAdResponseNumber=0,I._adRequests=[],I._adResponses=[],I._adHasPlayed=!1,I._wouldBeNewAdPlay=!0,I._prerollPlayTime=void 0}),Wn.forEach(function(P){return A.on(P,I._updateAdData.bind(I))});var k=function(){I.isAdBreak=!1};A.on("adbreakstart",function(){I.isAdBreak=!0}),A.on("play",k),A.on("playing",k),A.on("viewend",k),A.on("adrequest",function(P,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdRequestNumber++},U),At(I._adRequests,U),E(A.data,"view_ad_request_count"),I.inPrerollPosition()&&(A.data.view_preroll_requested=!0,I._adHasPlayed||E(A.data,"view_preroll_request_count"))}),A.on("adresponse",function(P,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdResponseNumber++},U),At(I._adResponses,U);var M=I.findAdRequest(U.ad_request_id);M&&E(A.data,"view_ad_request_time",Math.max(0,U.viewer_time-M.viewer_time))}),A.on("adplay",function(P,U){I._adHasPlayed=!0,I._wouldBeNewAdPlay&&(I._wouldBeNewAdPlay=!1,E(A.data,"view_ad_played_count")),I.inPrerollPosition()&&!A.data.view_preroll_played&&(A.data.view_preroll_played=!0,I._adRequests.length>0&&(A.data.view_preroll_request_time=Math.max(0,U.viewer_time-I._adRequests[0].viewer_time)),A.data.view_start&&(A.data.view_startup_preroll_request_time=Math.max(0,U.viewer_time-A.data.view_start)),I._prerollPlayTime=U.viewer_time)}),A.on("adplaying",function(P,U){I.inPrerollPosition()&&A.data.view_preroll_load_time===void 0&&I._prerollPlayTime!==void 0&&(A.data.view_preroll_load_time=U.viewer_time-I._prerollPlayTime,A.data.view_startup_preroll_load_time=U.viewer_time-I._prerollPlayTime)}),A.on("adended",function(){I._wouldBeNewAdPlay=!0}),A.on("aderror",function(){I._wouldBeNewAdPlay=!0})}var c,g,_;return c=m,(g=[{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(A){for(var I=0;I<this._adRequests.length;I++)if(this._adRequests[I].ad_request_id===A)return this._adRequests[I]}},{key:"_updateAdData",value:function(A,I){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&I.ad_tag_url){var k=Ji(be(I.ad_tag_url),2),P=k[0],U=k[1];this.pm.data.view_preroll_ad_tag_domain=U,this.pm.data.view_preroll_ad_tag_hostname=P}if(!this.pm.data.view_preroll_ad_asset_hostname&&I.ad_asset_url){var M=Ji(be(I.ad_asset_url),2),Y=M[0],Ee=M[1];this.pm.data.view_preroll_ad_asset_domain=Ee,this.pm.data.view_preroll_ad_asset_hostname=Y}}this.pm.data.ad_asset_url=I==null?void 0:I.ad_asset_url,this.pm.data.ad_tag_url=I==null?void 0:I.ad_tag_url,this.pm.data.ad_creative_id=I==null?void 0:I.ad_creative_id,this.pm.data.ad_id=I==null?void 0:I.ad_id,this.pm.data.ad_universal_id=I==null?void 0:I.ad_universal_id}}])&&Zi(c.prototype,g),_&&Zi(c,_),Object.defineProperty(c,"prototype",{writable:!1}),m}();function pr(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function zn(m,c,g){return c&&pr(m.prototype,c),g&&pr(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var en=zn(function m(c){var g,_;(function(P,U){if(!(P instanceof U))throw new TypeError("Cannot call a class as a function")})(this,m);var A=function(){c.disableRebufferTracking||g&&(E(c.data,"view_waiting_rebuffer_duration",Ke.now()-g),g=!1,X().clearInterval(_))},I=!1,k=function(){I=!1,A()};c.on("waiting",function(){I&&(c.disableRebufferTracking||(E(c.data,"view_waiting_rebuffer_count",1),g=Ke.now(),_=X().setInterval(function(){if(g){var P=Ke.now();E(c.data,"view_waiting_rebuffer_duration",P-g),g=P}},250)))}),c.on("playing",function(){A(),I=!0}),c.on("pause",k),c.on("seeking",k)});function Qe(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function tn(m,c,g){return c&&Qe(m.prototype,c),g&&Qe(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Se=tn(function m(c){var g=this;(function(I,k){if(!(I instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m);var _=function(){g.lastWallClockTime=Ke.now(),c.on("before*",A)},A=function(I){var k=Ke.now(),P=g.lastWallClockTime;g.lastWallClockTime=k,k-P>3e4&&(c.emit("devicesleep",{viewer_time:P}),Object.assign(c.data,{viewer_time:P}),c.send("devicesleep"),c.emit("devicewake",{viewer_time:k}),Object.assign(c.data,{viewer_time:k}),c.send("devicewake"))};c.one("playbackheartbeat",_),c.on("playbackheartbeatend",function(){c.off("before*",A),c.one("playbackheartbeat",_)})}),gi=K(375),mi=K(655),Pe=K.n(mi),rn="muxData",pi=function(){var m;try{m=gi.parse(Pe().get(rn)||"")}catch{m={}}return m},yi=function(m){try{Pe().set(rn,gi.stringify(m),{expires:7300})}catch{}},Xn=function(){var m=pi();return m.mux_viewer_id=m.mux_viewer_id||ae(),m.msn=m.msn||Math.random(),yi(m),{mux_viewer_id:m.mux_viewer_id,mux_sample_number:m.msn}};function Xt(m,c){var g=c.beaconCollectionDomain,_=c.beaconDomain;if(g)return"https://"+g;var A=_||"litix.io";return(m=m||"inferred").match(/^[a-z0-9]+$/)?"https://"+m+"."+A:"https://img.litix.io/a.gif"}var Ti=function(){var m;switch(nn()){case"cellular":m="cellular";break;case"ethernet":m="wired";break;case"wifi":m="wifi";break;case void 0:break;default:m="other"}return m},nn=function(){var m=X().navigator,c=m&&(m.connection||m.mozConnection||m.webkitConnection);return c&&c.type};Ti.getConnectionFromAPI=nn;var an=Ti,sn=yr({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"}),on=yr({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",cl:"canceled",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",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",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 yr(m){var c={};for(var g in m)m.hasOwnProperty(g)&&(c[m[g]]=g);return c}function Tr(m){var c={},g={};return Object.keys(m).forEach(function(_){var A=!1;if(m.hasOwnProperty(_)&&m[_]!==void 0){var I=_.split("_"),k=I[0],P=sn[k];P||(Re.info("Data key word `"+I[0]+"` not expected in "+_),P=k+"_"),I.splice(1).forEach(function(U){U==="url"&&(A=!0),on[U]?P+=on[U]:Number(U)&&Math.floor(Number(U))===Number(U)?P+=U:(Re.info("Data key word `"+U+"` not expected in "+_),P+="_"+U+"_")}),A?g[P]=m[_]:c[P]=m[_]}}),Object.assign(c,g)}var ln={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},un=["hb","requestcompleted","requestfailed","requestcanceled"],ht="https://img.litix.io",Lt=function(m){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=m||ht,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},ln,c)};Lt.prototype.queueEvent=function(m,c){var g=Object.assign({},c);return(this._eventQueue.length<=this._options.maxQueueLength||m==="eventrateexceeded")&&(this._eventQueue.push(g),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},Lt.prototype.flushEvents=function(){var m=arguments.length>0&&arguments[0]!==void 0&&arguments[0];m&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},Lt.prototype.destroy=function(){var m=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,m?this._clearBeaconQueue():this.flushEvents(),X().clearTimeout(this._sendTimeout)},Lt.prototype._clearBeaconQueue=function(){var m=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,c=this._eventQueue.slice(m);m>0&&Object.assign(c[c.length-1],Tr({mux_view_message:"event queue truncated"}));var g=this._createPayload(c);hn(this._beaconUrl,g,!0,function(){})},Lt.prototype._sendBeaconQueue=function(){var m=this;if(!this._postInFlight){var c=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var g=this._createPayload(c),_=Ke.now();hn(this._beaconUrl,g,!1,function(A,I){I?(m._eventQueue=c.concat(m._eventQueue),m._failureCount+=1,Re.info("Error sending beacon: "+I)):m._failureCount=0,m._roundTripTime=Ke.now()-_,m._postInFlight=!1})}},Lt.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var m=Math.pow(2,this._failureCount-1);return(1+(m*=Math.random()))*this._options.baseTimeBetweenBeacons},Lt.prototype._startBeaconSending=function(){var m=this;X().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=X().setTimeout(function(){m._eventQueue.length&&m._sendBeaconQueue(),m._startBeaconSending()},this._getNextBeaconTime()))},Lt.prototype._createPayload=function(m){var c,g,_,A=this,I={transmission_timestamp:Math.round(Ke.now())};this._roundTripTime&&(I.rtt_ms=Math.round(this._roundTripTime));var k=function(){c=JSON.stringify({metadata:I,events:g||m}),_=c.length/1024},P=function(){return _<=A._options.maxPayloadKBSize};return k(),P()||(Re.info("Payload size is too big ("+_+" kb). Removing unnecessary events."),g=m.filter(function(U){return un.indexOf(U.e)===-1}),k()),P()||(Re.info("Payload size still too big ("+_+" kb). Cropping fields.."),g.forEach(function(U){for(var M in U){var Y=U[M];typeof Y=="string"&&Y.length>51200&&(U[M]=Y.substring(0,51200))}}),k()),c};var dn=function(m){return m.length<=57344},hn=function(m,c,g,_){if(g&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(m,c))_();else if(X().fetch)X().fetch(m,{method:"POST",body:c,headers:{"Content-Type":"text/plain"},keepalive:dn(c)}).then(function(I){return _(null,I.ok?null:"Error")}).catch(function(I){return _(null,I)});else{if(X().XMLHttpRequest){var A=new(X()).XMLHttpRequest;return A.onreadystatechange=function(){if(A.readyState===4)return _(null,A.status!==200?"error":void 0)},A.open("POST",m),A.setRequestHeader("Content-Type","text/plain"),void A.send(c)}_()}},Kr=Lt;function Qn(m,c){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var A=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(A!=null){var I,k,P=[],U=!0,M=!1;try{for(A=A.call(g);!(U=(I=A.next()).done)&&(P.push(I.value),!_||P.length!==_);U=!0);}catch(Y){M=!0,k=Y}finally{try{U||A.return==null||A.return()}finally{if(M)throw k}}return P}}(m,c)||function(g,_){if(g){if(typeof g=="string")return Ei(g,_);var A=Object.prototype.toString.call(g).slice(8,-1);return A==="Object"&&g.constructor&&(A=g.constructor.name),A==="Map"||A==="Set"?Array.from(g):A==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(A)?Ei(g,_):void 0}}(m,c)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Ei(m,c){(c==null||c>m.length)&&(c=m.length);for(var g=0,_=new Array(c);g<c;g++)_[g]=m[g];return _}function qr(m,c){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(m);c&&(_=_.filter(function(A){return Object.getOwnPropertyDescriptor(m,A).enumerable})),g.push.apply(g,_)}return g}function Qt(m){for(var c=1;c<arguments.length;c++){var g=arguments[c]!=null?arguments[c]:{};c%2?qr(Object(g),!0).forEach(function(_){jr(m,_,g[_])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):qr(Object(g)).forEach(function(_){Object.defineProperty(m,_,Object.getOwnPropertyDescriptor(g,_))})}return m}function or(m){return or=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},or(m)}function Jn(m,c){if(!(m instanceof c))throw new TypeError("Cannot call a class as a function")}function bi(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function jr(m,c,g){return c in m?Object.defineProperty(m,c,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[c]=g,m}var Er=["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"],cn=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse"],fn=["viewstart","error","ended","viewend"],$n=function(){function m(A,I){var k,P,U,M,Y,Ee,se,de,le,fe,De,$e,it,st,pt,ke=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Jn(this,m),jr(this,"previousBeaconData",null),jr(this,"lastEventTime",0),jr(this,"rateLimited",!1),this.mux=A,this.envKey=I,this.options=ke,this.eventQueue=new Kr(Xt(this.envKey,this.options)),this.sampleRate=(k=this.options.sampleRate)!==null&&k!==void 0?k:1,this.disableCookies=(P=this.options.disableCookies)!==null&&P!==void 0&&P,this.respectDoNotTrack=(U=this.options.respectDoNotTrack)!==null&&U!==void 0&&U,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:(M=this.options.platform)===null||M===void 0?void 0:M.name,viewer_application_version:(Y=this.options.platform)===null||Y===void 0?void 0:Y.version,viewer_application_engine:(Ee=this.options.platform)===null||Ee===void 0?void 0:Ee.layout,viewer_device_name:(se=this.options.platform)===null||se===void 0?void 0:se.product,viewer_device_category:"",viewer_device_manufacturer:(de=this.options.platform)===null||de===void 0?void 0:de.manufacturer,viewer_os_family:(le=this.options.platform)===null||le===void 0||(fe=le.os)===null||fe===void 0?void 0:fe.family,viewer_os_architecture:(De=this.options.platform)===null||De===void 0||($e=De.os)===null||$e===void 0?void 0:$e.architecture,viewer_os_version:(it=this.options.platform)===null||it===void 0||(st=it.os)===null||st===void 0?void 0:st.version,viewer_connection_type:an(),page_url:X()===null||X()===void 0||(pt=X().location)===null||pt===void 0?void 0:pt.href},this.viewerData=this.disableCookies?{}:Xn()}var c,g,_;return c=m,(g=[{key:"send",value:function(A,I){var k;if(A&&I!=null&&I.view_id){if(this.respectDoNotTrack&&dt())return Re.info("Not sending `"+A+"` because Do Not Track is enabled");if(!I||or(I)!=="object")return Re.error("A data object was expected in send() but was not provided");var P,U,M=this.disableCookies?{}:(P=pi(),U=Ke.now(),P.session_start&&(P.sst=P.session_start,delete P.session_start),P.session_id&&(P.sid=P.session_id,delete P.session_id),P.session_expires&&(P.sex=P.session_expires,delete P.session_expires),(!P.sex||P.sex<U)&&(P.sid=ae(),P.sst=U),P.sex=U+15e5,yi(P),{session_id:P.sid,session_start:P.sst,session_expires:P.sex}),Y=Qt(Qt(Qt(Qt(Qt({},this.pageLevelData),I),M),this.viewerData),{},{event:A,env_key:this.envKey});Y.user_id&&(Y.viewer_user_id=Y.user_id,delete Y.user_id);var Ee=((k=Y.mux_sample_number)!==null&&k!==void 0?k:0)>=this.sampleRate,se=Tr(this._deduplicateBeaconData(A,Y));if(this.lastEventTime=this.mux.utils.now(),Ee)return Re.info("Not sending event due to sample rate restriction",A,Y,se);if(this.envKey||Re.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",A,Y,se),!this.rateLimited){if(Re.info("Sending event",A,Y,se),this.rateLimited=!this.eventQueue.queueEvent(A,se),this.mux.WINDOW_UNLOADING&&A==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&A==="hb"?this.eventQueue.flushEvents(!0):fn.indexOf(A)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return Y.event="eventrateexceeded",se=Tr(Y),this.eventQueue.queueEvent(Y.event,se),Re.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(A,I){var k=this,P={},U=I.view_id;if(U==="-1"||A==="viewstart"||A==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)P=Qt({},I),U&&(this.previousBeaconData=P),U&&A==="viewend"&&(this.previousBeaconData=null);else{var M=A.indexOf("request")===0;Object.entries(I).forEach(function(Y){var Ee=Qn(Y,2),se=Ee[0],de=Ee[1];k.previousBeaconData&&(de!==k.previousBeaconData[se]||Er.indexOf(se)>-1||k.objectHasChanged(M,se,de,k.previousBeaconData[se])||k.eventRequiresKey(A,se))&&(P[se]=de,k.previousBeaconData[se]=de)})}return P}},{key:"objectHasChanged",value:function(A,I,k,P){return!(!A||I.indexOf("request_")!==0||I!=="request_response_headers"&&or(k)==="object"&&or(P)==="object"&&Object.keys(k||{}).length===Object.keys(P||{}).length)}},{key:"eventRequiresKey",value:function(A,I){return A==="renditionchange"&&I.indexOf("video_source_")===0||!(I.indexOf("ad_id")!==0||!cn.includes(A))}}])&&bi(c.prototype,g),_&&bi(c,_),Object.defineProperty(c,"prototype",{writable:!1}),m}();function _i(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function vn(m,c,g){return c&&_i(m.prototype,c),g&&_i(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var gn=vn(function m(c){(function(M,Y){if(!(M instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,m);var g=0,_=0,A=0,I=0,k=0,P=0,U=0;c.on("requestcompleted",function(M,Y){var Ee,se,de=Y.request_start,le=Y.request_response_start,fe=Y.request_response_end,De=Y.request_bytes_loaded;if(I++,le?(Ee=le-(de!=null?de:0),se=(fe!=null?fe:0)-le):se=(fe!=null?fe:0)-(de!=null?de:0),se>0&&De&&De>0){var $e=De/se*8e3;k++,_+=De,A+=se,c.data.view_min_request_throughput=Math.min(c.data.view_min_request_throughput||1/0,$e),c.data.view_average_request_throughput=_/A*8e3,c.data.view_request_count=I,Ee>0&&(g+=Ee,c.data.view_max_request_latency=Math.max(c.data.view_max_request_latency||0,Ee),c.data.view_average_request_latency=g/k)}}),c.on("requestfailed",function(M,Y){I++,P++,c.data.view_request_count=I,c.data.view_request_failed_count=P}),c.on("requestcanceled",function(M,Y){I++,U++,c.data.view_request_count=I,c.data.view_request_canceled_count=U})});function Si(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function lr(m,c,g){return c&&Si(m.prototype,c),g&&Si(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Jt=lr(function m(c){var g=this;(function(_,A){if(!(_ instanceof A))throw new TypeError("Cannot call a class as a function")})(this,m),c.on("before*",function(_,A){var I=A.viewer_time,k=Ke.now(),P=g._lastEventTime;if(g._lastEventTime=k,P&&k-P>36e5){var U=Object.keys(c.data).reduce(function(M,Y){return Y.indexOf("video_")===0?Object.assign(M,function(Ee,se,de){return se in Ee?Object.defineProperty(Ee,se,{value:de,enumerable:!0,configurable:!0,writable:!0}):Ee[se]=de,Ee}({},Y,c.data[Y])):M},{});c.mux.log.info("Received event after at least an hour inactivity, creating a new view"),c.emit("viewinit",Object.assign({viewer_time:I},U)),c.playbackHeartbeat._playheadShouldBeProgressing&&_.type!=="play"&&_.type!=="adbreakstart"&&(c.emit("play",{viewer_time:I}),_.type!=="playing"&&c.emit("playing",{viewer_time:I}))}})});function yt(m){return yt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},yt(m)}function Gt(m,c){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var A=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(A!=null){var I,k,P=[],U=!0,M=!1;try{for(A=A.call(g);!(U=(I=A.next()).done)&&(P.push(I.value),!_||P.length!==_);U=!0);}catch(Y){M=!0,k=Y}finally{try{U||A.return==null||A.return()}finally{if(M)throw k}}return P}}(m,c)||function(g,_){if(g){if(typeof g=="string")return Ne(g,_);var A=Object.prototype.toString.call(g).slice(8,-1);return A==="Object"&&g.constructor&&(A=g.constructor.name),A==="Map"||A==="Set"?Array.from(g):A==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(A)?Ne(g,_):void 0}}(m,c)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Ne(m,c){(c==null||c>m.length)&&(c=m.length);for(var g=0,_=new Array(c);g<c;g++)_[g]=m[g];return _}function kt(m,c){for(var g=0;g<c.length;g++){var _=c[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function It(m,c){return It=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,_){return g.__proto__=_,g},It(m,c)}function mn(m){var c=function(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var g,_=br(m);if(c){var A=br(this).constructor;g=Reflect.construct(_,arguments,A)}else g=_.apply(this,arguments);return Ai(this,g)}}function Ai(m,c){if(c&&(yt(c)==="object"||typeof c=="function"))return c;if(c!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Je(m)}function Je(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function br(m){return br=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(c){return c.__proto__||Object.getPrototypeOf(c)},br(m)}var pn=["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"],ur=function(m){(function(k,P){if(typeof P!="function"&&P!==null)throw new TypeError("Super expression must either be null or a function");k.prototype=Object.create(P&&P.prototype,{constructor:{value:k,writable:!0,configurable:!0}}),Object.defineProperty(k,"prototype",{writable:!1}),P&&It(k,P)})(I,m);var c,g,_,A=mn(I);function I(k,P,U){var M;(function(le,fe){if(!(le instanceof fe))throw new TypeError("Cannot call a class as a function")})(this,I),(M=A.call(this)).DOM_CONTENT_LOADED_EVENT_END=Z.domContentLoadedEventEnd(),M.NAVIGATION_START=Z.navigationStart(),M.mux=k,M.id=P,(U=Object.assign({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(le){return le}},U)).data=U.data||{},U.data.property_key&&(U.data.env_key=U.data.property_key,delete U.data.property_key),Re.setLevel(U.debug?"debug":"warn"),M.getPlayheadTime=U.getPlayheadTime,M.getStateData=U.getStateData||function(){return{}},M.getAdData=U.getAdData||function(){},M.minimumRebufferDuration=U.minimumRebufferDuration,M.sustainedRebufferThreshold=U.sustainedRebufferThreshold,M.playbackHeartbeatTime=U.playbackHeartbeatTime,M.disableRebufferTracking=U.disableRebufferTracking,M.disableRebufferTracking&&M.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."),M.disablePlayheadRebufferTracking=U.disablePlayheadRebufferTracking,M.errorTranslator=U.errorTranslator,M.playbackEventDispatcher=new $n(k,U.data.env_key,U),M.data={player_instance_id:ae(),mux_sample_rate:U.sampleRate,beacon_domain:U.beaconCollectionDomain?U.beaconCollectionDomain:U.beaconDomain},M.data.view_sequence_number=1,M.data.player_sequence_number=1,M.oldEmit=M.emit,M.emit=function(le,fe){fe=Object.assign({viewer_time:this.mux.utils.now()},fe),this.oldEmit(le,fe)};var Y=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Je(M));M.on("viewinit",function(le,fe){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,fe),this._initializeViewData(),this.one("play",Y),this.one("adbreakstart",Y)});var Ee=function(le){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",le)}.bind(Je(M));if(M.on("videochange",function(le,fe){Ee(fe)}),M.on("programchange",function(le,fe){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),Ee(Object.assign(fe,{view_program_changed:!0})),Y(),this.emit("play"),this.emit("playing")}),M.on("fragmentchange",function(le,fe){this.currentFragmentPDT=fe.currentFragmentPDT,this.currentFragmentStart=fe.currentFragmentStart}),M.on("destroy",M.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var se=function(){var le=M.data.view_start!==void 0;M.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",le&&M.mux.WINDOW_HIDDEN&&(M.data.player_is_paused||M.emit("hb"))};window.addEventListener("visibilitychange",se,!1);var de=function(le){le.persisted||M.destroy()};window.addEventListener("pagehide",de,!1),M.on("destroy",function(){window.removeEventListener("visibilitychange",se),window.removeEventListener("pagehide",de)})}return M.on("playerready",function(le,fe){Object.assign(this.data,fe)}),pn.forEach(function(le){M.on(le,function(fe,De){le.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,De),this._sanitizeData()}),M.on("after"+le,function(){(le!=="error"||this.errorTracker.viewErrored)&&this.send(le)})}),M.on("viewend",function(le,fe){Object.assign(M.data,fe)}),M.one("playerready",function(le){var fe=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=fe-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),M.longResumeTracker=new Jt(Je(M)),M.errorTracker=new Ye(Je(M)),new Se(Je(M)),M.seekingTracker=new Yn(Je(M)),M.playheadTime=new Wi(Je(M)),M.playbackHeartbeat=new oi(Je(M)),new jn(Je(M)),M.watchTimeTracker=new li(Je(M)),new Br(Je(M)),M.adTracker=new Dt(Je(M)),new zi(Je(M)),new zt(Je(M)),new Hr(Je(M)),new en(Je(M)),new gn(Je(M)),U.hlsjs&&M.addHLSJS(U),U.dashjs&&M.addDashJS(U),M.emit("viewinit",U.data),M}return c=I,g=[{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(k){if(this.data.view_id){var P=Object.assign({},this.data);if(P.video_source_is_live===void 0&&(P.player_source_duration===1/0||P.video_source_duration===1/0?P.video_source_is_live=!0:(P.player_source_duration>0||P.video_source_duration>0)&&(P.video_source_is_live=!1)),P.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){P[Ee]=void 0}),P.video_source_url=P.video_source_url||P.player_source_url,P.video_source_url){var U=Gt(be(P.video_source_url),2),M=U[0],Y=U[1];P.video_source_domain=Y,P.video_source_hostname=M}delete P.ad_request_id,this.playbackEventDispatcher.send(k,P),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),k==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var k=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(P){var U=parseInt(k.data[P],10);k.data[P]=isNaN(U)?void 0:U}),["player_source_url","video_source_url"].forEach(function(P){if(k.data[P]){var U=k.data[P].toLowerCase();U.indexOf("data:")!==0&&U.indexOf("blob:")!==0||(k.data[P]="MSE style URL")}})}},{key:"_resetVideoData",value:function(k,P){var U=this;Object.keys(this.data).forEach(function(M){M.indexOf("video_")===0&&delete U.data[M]})}},{key:"_resetViewData",value:function(){var k=this;Object.keys(this.data).forEach(function(P){P.indexOf("view_")===0&&delete k.data[P]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(k,P){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var k=this,P=this.data.view_id=ae(),U=function(){P===k.data.view_id&&E(k.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",U):U()}},{key:"_restartHeartBeat",value:function(){var k=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){k.data.player_is_paused||k.emit("hb")},1e4))}},{key:"addHLSJS",value:function(k){k.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=k.hlsjs,function(P,U,M){var Y=arguments.length>4?arguments[4]:void 0,Ee=P.log,se=P.utils.secondsToMs,de=function(Fe){var $,re=parseInt(Y.version);return re===1&&Fe.programDateTime!==null&&($=Fe.programDateTime),re===0&&Fe.pdt!==null&&($=Fe.pdt),$};if(Z.exists()){var le=function(Fe,$){return P.emit(U,Fe,$)},fe=function(Fe,$){var re=$.levels,ie=$.audioTracks,_e=$.url,Ie=$.stats,We=$.networkDetails,ct=$.sessionData,Ze={},ot={};re.forEach(function(he,er){Ze[er]={width:he.width,height:he.height,bitrate:he.bitrate,attrs:he.attrs}}),ie.forEach(function(he,er){ot[er]={name:he.name,language:he.lang,bitrate:he.bitrate}});var et=ar(Ie),tt=et.bytesLoaded,Ct=et.requestStart,Dr=et.responseStart,rt=et.responseEnd;le("requestcompleted",qe(qe({},Be(ct)),{},{request_event_type:Fe,request_bytes_loaded:tt,request_start:Ct,request_response_start:Dr,request_response_end:rt,request_type:"manifest",request_hostname:pe(_e),request_response_headers:Bt(We),request_rendition_lists:{media:Ze,audio:ot,video:{}}}))};M.on(Y.Events.MANIFEST_LOADED,fe);var De=function(Fe,$){var re=$.details,ie=$.level,_e=$.networkDetails,Ie=$.stats,We=ar(Ie),ct=We.bytesLoaded,Ze=We.requestStart,ot=We.responseStart,et=We.responseEnd,tt=re.fragments[re.fragments.length-1],Ct=de(tt)+se(tt.duration);le("requestcompleted",{request_event_type:Fe,request_bytes_loaded:ct,request_start:Ze,request_response_start:ot,request_response_end:et,request_current_level:ie,request_type:"manifest",request_hostname:pe(re.url),request_response_headers:Bt(_e),video_holdback:re.holdBack&&se(re.holdBack),video_part_holdback:re.partHoldBack&&se(re.partHoldBack),video_part_target_duration:re.partTarget&&se(re.partTarget),video_target_duration:re.targetduration&&se(re.targetduration),video_source_is_live:re.live,player_manifest_newest_program_time:isNaN(Ct)?void 0:Ct})};M.on(Y.Events.LEVEL_LOADED,De);var $e=function(Fe,$){var re=$.details,ie=$.networkDetails,_e=$.stats,Ie=ar(_e),We=Ie.bytesLoaded,ct=Ie.requestStart,Ze=Ie.responseStart,ot=Ie.responseEnd;le("requestcompleted",{request_event_type:Fe,request_bytes_loaded:We,request_start:ct,request_response_start:Ze,request_response_end:ot,request_type:"manifest",request_hostname:pe(re.url),request_response_headers:Bt(ie)})};M.on(Y.Events.AUDIO_TRACK_LOADED,$e);var it=function(Fe,$){var re=$.stats,ie=$.networkDetails,_e=$.frag;re=re||_e.stats;var Ie=ar(re),We=Ie.bytesLoaded,ct=Ie.requestStart,Ze=Ie.responseStart,ot=Ie.responseEnd,et=ie?Bt(ie):void 0,tt={request_event_type:Fe,request_bytes_loaded:We,request_start:ct,request_response_start:Ze,request_response_end:ot,request_hostname:ie?pe(ie.responseURL):void 0,request_id:et?Ue(et):void 0,request_response_headers:et,request_media_duration:_e.duration,request_url:ie==null?void 0:ie.responseURL};_e.type==="main"?(tt.request_type="media",tt.request_current_level=_e.level,tt.request_video_width=(M.levels[_e.level]||{}).width,tt.request_video_height=(M.levels[_e.level]||{}).height,tt.request_labeled_bitrate=(M.levels[_e.level]||{}).bitrate):tt.request_type=_e.type,le("requestcompleted",tt)};M.on(Y.Events.FRAG_LOADED,it);var st=function(Fe,$){var re=$.frag,ie=re.start,_e={currentFragmentPDT:de(re),currentFragmentStart:se(ie)};le("fragmentchange",_e)};M.on(Y.Events.FRAG_CHANGED,st);var pt=function(Fe,$){var re=$.type,ie=$.details,_e=$.response,Ie=$.fatal,We=$.frag,ct=$.networkDetails,Ze=(We==null?void 0:We.url)||$.url||"",ot=ct?Bt(ct):void 0;if(ie!==Y.ErrorDetails.MANIFEST_LOAD_ERROR&&ie!==Y.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.FRAG_LOAD_ERROR&&ie!==Y.ErrorDetails.FRAG_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.LEVEL_LOAD_ERROR&&ie!==Y.ErrorDetails.LEVEL_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&ie!==Y.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.SUBTITLE_LOAD_ERROR&&ie!==Y.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.KEY_LOAD_ERROR&&ie!==Y.ErrorDetails.KEY_LOAD_TIMEOUT||le("requestfailed",{request_error:ie,request_url:Ze,request_hostname:pe(Ze),request_id:ot?Ue(ot):void 0,request_type:ie===Y.ErrorDetails.FRAG_LOAD_ERROR||ie===Y.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":ie===Y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||ie===Y.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":ie===Y.ErrorDetails.SUBTITLE_LOAD_ERROR||ie===Y.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":ie===Y.ErrorDetails.KEY_LOAD_ERROR||ie===Y.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:_e==null?void 0:_e.code,request_error_text:_e==null?void 0:_e.text}),Ie){var et,tt="".concat(Ze?"url: ".concat(Ze,`
|
|
5
5
|
`):"")+"".concat(_e&&(_e.code||_e.text)?"response: ".concat(_e.code,", ").concat(_e.text,`
|
|
6
6
|
`):"")+"".concat($.reason?"failure reason: ".concat($.reason,`
|
|
7
7
|
`):"")+"".concat($.level?"level: ".concat($.level,`
|
|
@@ -10,41 +10,41 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
10
10
|
`):"")+"".concat($.error?"error: ".concat($.error,`
|
|
11
11
|
`):"")+"".concat($.event?"event: ".concat($.event,`
|
|
12
12
|
`):"")+"".concat($.err?"error message: ".concat((et=$.err)===null||et===void 0?void 0:et.message,`
|
|
13
|
-
`):"");le("error",{player_error_code:re,player_error_message:ie,player_error_context:tt})}};M.on(Y.Events.ERROR,pt);var
|
|
13
|
+
`):"");le("error",{player_error_code:re,player_error_message:ie,player_error_context:tt})}};M.on(Y.Events.ERROR,pt);var ke=function(Fe,$){var re=$.frag,ie=re&&re._url||"";le("requestcanceled",{request_event_type:Fe,request_url:ie,request_type:"media",request_hostname:pe(ie)})};M.on(Y.Events.FRAG_LOAD_EMERGENCY_ABORTED,ke);var ze=function(Fe,$){var re=$.level,ie=M.levels[re];if(ie&&ie.attrs&&ie.attrs.BANDWIDTH){var _e,Ie=ie.attrs.BANDWIDTH,We=parseFloat(ie.attrs["FRAME-RATE"]);isNaN(We)||(_e=We),Ie?le("renditionchange",{video_source_fps:_e,video_source_bitrate:Ie,video_source_width:ie.width,video_source_height:ie.height,video_source_rendition_name:ie.name,video_source_codec:ie==null?void 0:ie.videoCodec}):Ee.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};M.on(Y.Events.LEVEL_SWITCHED,ze),M._stopMuxMonitor=function(){M.off(Y.Events.MANIFEST_LOADED,fe),M.off(Y.Events.LEVEL_LOADED,De),M.off(Y.Events.AUDIO_TRACK_LOADED,$e),M.off(Y.Events.FRAG_LOADED,it),M.off(Y.Events.FRAG_CHANGED,st),M.off(Y.Events.ERROR,pt),M.off(Y.Events.FRAG_LOAD_EMERGENCY_ABORTED,ke),M.off(Y.Events.LEVEL_SWITCHED,ze),M.off(Y.Events.DESTROYING,M._stopMuxMonitor),delete M._stopMuxMonitor},M.on(Y.Events.DESTROYING,M._stopMuxMonitor)}else Ee.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,k.hlsjs,{},k.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var k;this.hlsjs&&((k=this.hlsjs)&&typeof k._stopMuxMonitor=="function"&&k._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(k){k.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=k.dashjs,function(P,U,M){var Y=P.log;if(M&&M.on){var Ee=function(ke,ze){return P.emit(U,ke,ze)},se=function(ke){var ze=ke.type,Fe=(ke.data||{}).url;Ee("requestcompleted",{request_event_type:ze,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:pe(Fe),request_url:Fe})};M.on("manifestLoaded",se);var de={},le=function(ke){var ze=ke.type,Fe=ke.fragmentModel,$=(ke.chunk||{}).mediaInfo||{},re=$.type,ie=$.bitrateList,_e={};(ie=ie||[]).forEach(function(rt,he){_e[he]={},_e[he].width=rt.width,_e[he].height=rt.height,_e[he].bitrate=rt.bandwidth,_e[he].attrs={}}),re==="video"?de.video=_e:re==="audio"?de.audio=_e:de.media=_e;var Ie=gt(Fe,M),We=Ie.requestStart,ct=Ie.requestResponseStart,Ze=Ie.requestResponseEnd,ot=Ie.requestResponseHeaders,et=Ie.requestMediaDuration,tt=Ie.requestHostname,Ct=Ie.requestUrl,Dr=Ie.requestId;Ee("requestcompleted",{request_event_type:ze,request_start:We,request_response_start:ct,request_response_end:Ze,request_bytes_loaded:-1,request_type:re+"_init",request_response_headers:ot,request_hostname:tt,request_id:Dr,request_url:Ct,request_media_duration:et,request_rendition_lists:de})};M.on("initFragmentLoaded",le);var fe=function(ke){var ze=ke.type,Fe=ke.fragmentModel,$=ke.chunk||{},re=$.mediaInfo,ie=$.start,_e=(re||{}).type,Ie=gt(Fe,M),We=Ie.requestStart,ct=Ie.requestResponseStart,Ze=Ie.requestResponseEnd,ot=Ie.requestBytesLoaded,et=Ie.requestResponseHeaders,tt=Ie.requestMediaDuration,Ct=Ie.requestHostname,Dr=Ie.requestUrl,rt=Ie.requestId,he=Xe(_e,M),er=he.currentLevel,dr=he.renditionWidth,hr=he.renditionHeight,Ir=he.renditionBitrate;Ee("requestcompleted",{request_event_type:ze,request_start:We,request_response_start:ct,request_response_end:Ze,request_bytes_loaded:ot,request_type:_e,request_response_headers:et,request_hostname:Ct,request_id:rt,request_url:Dr,request_media_start_time:ie,request_media_duration:tt,request_current_level:er,request_labeled_bitrate:Ir,request_video_width:dr,request_video_height:hr})};M.on("mediaFragmentLoaded",fe);var De={video:void 0,audio:void 0,totalBitrate:void 0},$e=function(){if(De.video&&typeof De.video.bitrate=="number"){if(De.video.width&&De.video.height){var ke=De.video.bitrate;return De.audio&&typeof De.audio.bitrate=="number"&&(ke+=De.audio.bitrate),ke!==De.totalBitrate?(De.totalBitrate=ke,{video_source_bitrate:ke,video_source_height:De.video.height,video_source_width:De.video.width,video_source_codec:mt(De.video.codec)}):void 0}Y.warn("have bitrate info for video but missing width/height")}},it=function(ke,ze,Fe){if(typeof ke.newQuality=="number"){var $=ke.mediaType;if($==="audio"||$==="video"){var re=M.getBitrateInfoListFor($).find(function(_e){return _e.qualityIndex===ke.newQuality});if(re&&typeof re.bitrate=="number"){De[$]=sr(sr({},re),{},{codec:M.getCurrentTrackFor($).codec});var ie=$e();ie&&Ee("renditionchange",ie)}else Y.warn("missing bitrate info for ".concat($))}}else Y.warn("missing evt.newQuality in qualityChangeRendered event",ke)};M.on("qualityChangeRendered",it);var st=function(ke){var ze=ke.request,Fe=ke.mediaType;Ee("requestcanceled",{request_event_type:(ze=ze||{}).type+"_"+ze.action,request_url:ze.url,request_type:Fe,request_hostname:pe(ze.url)})};M.on("fragmentLoadingAbandoned",st);var pt=function(ke){var ze,Fe,$=ke.error,re=($==null||(ze=$.data)===null||ze===void 0?void 0:ze.request)||{},ie=($==null||(Fe=$.data)===null||Fe===void 0?void 0:Fe.response)||{};($==null?void 0:$.code)===27&&Ee("requestfailed",{request_error:re.type+"_"+re.action,request_url:re.url,request_hostname:pe(re.url),request_type:re.mediaType,request_error_code:ie.status,request_error_text:ie.statusText});var _e="".concat(re!=null&&re.url?"url: ".concat(re.url,`
|
|
14
14
|
`):"")+"".concat(ie!=null&&ie.status||ie!=null&&ie.statusText?"response: ".concat(ie==null?void 0:ie.status,", ").concat(ie==null?void 0:ie.statusText,`
|
|
15
|
-
`):"");Ee("error",{player_error_code:$==null?void 0:$.code,player_error_message:$==null?void 0:$.message,player_error_context:_e})};M.on("error",pt),M._stopMuxMonitor=function(){M.off("manifestLoaded",se),M.off("initFragmentLoaded",le),M.off("mediaFragmentLoaded",fe),M.off("qualityChangeRendered",it),M.off("error",pt),M.off("fragmentLoadingAbandoned",st),delete M._stopMuxMonitor}}else Y.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,k.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var k;this.dashjs&&((k=this.dashjs)&&typeof k._stopMuxMonitor=="function"&&k._stopMuxMonitor(),this.dashjs=void 0)}}],g&&kt(
|
|
16
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Ar(m,
|
|
17
|
-
`);
|
|
18
|
-
`))this.processLine(this.buffer.substring(0,
|
|
19
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function zr(m,h){(h==null||h>m.length)&&(h=m.length);for(var g=0,_=new Array(h);g<h;g++)_[g]=m[g];return _}var Tt={},$t=function m(h){var g=arguments;typeof h=="string"?m.hasOwnProperty(h)?X().setTimeout(function(){g=Array.prototype.splice.call(g,1),m[h].apply(null,g)},0):Re.warn("`"+h+"` is an unknown task"):typeof h=="function"?X().setTimeout(function(){h(m)},0):Re.warn("`"+h+"` is invalid.")},ia={loaded:Ke.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(m,h){return function(g,_,A){var R=Vr(Ae(_),3),k=R[0],P=R[1],U=R[2],M=g.log,Y=g.utils.getComputedStyle,Ee=g.utils.secondsToMs;if(!k)return M.error("No element was found with the `"+P+"` query selector.");if(U!=="video"&&U!=="audio")return M.error("The element of `"+P+"` was not a media element.");k.mux&&(k.mux.destroy(),delete k.mux,M.warn("Already monitoring this video element, replacing existing event listeners")),(A=Object.assign({automaticErrorTracking:!0},A)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:g.VERSION},A.data),A.getPlayheadTime=function(){return Ee(k.currentTime)},A.getStateData=function(){var de,le,fe=this.hlsjs&&this.hlsjs.url,De=this.dashjs&&Jt(this.dashjs.getSource==="function")&&this.dashjs.getSource(),$e={player_is_paused:k.paused,player_playhead_time:Ee(k.currentTime),player_width:parseInt(Y(k,"width")),player_height:parseInt(Y(k,"height")),player_autoplay_on:k.autoplay,player_preload_on:k.preload,player_language_code:k.lang,player_is_fullscreen:Sr()&&!!(Sr().fullscreenElement||Sr().webkitFullscreenElement||Sr().mozFullScreenElement||Sr().msFullscreenElement),video_poster_url:k.poster,video_source_url:fe||De||k.currentSrc,video_source_duration:Ee(k.duration),video_source_height:k.videoHeight,video_source_width:k.videoWidth,view_dropped_frame_count:(de=k)===null||de===void 0||(le=de.getVideoPlaybackQuality)===null||le===void 0?void 0:le.call(de).droppedVideoFrames},it=A.getPlayheadTime();if(k.getStartDate&&it>0){var st=k.getStartDate();if(st&&typeof st.getTime=="function"&&st.getTime()){var pt=st.getTime();if($e.player_program_time=pt+it,k.seekable.length>0){var Le=pt+k.seekable.end(k.seekable.length-1);$e.player_live_edge_program_time=Le}}}return $e},k.mux=k.mux||{},k.mux.deleted=!1,k.mux.emit=function(de,le){g.emit(P,de,le)};var se=function(){M.error("The monitor for this video element has already been destroyed.")};k.mux.destroy=function(){Object.keys(k.mux.listeners).forEach(function(de){k.removeEventListener(de,k.mux.listeners[de],!1)}),delete k.mux.listeners,k.mux.destroy=se,k.mux.swapElement=se,k.mux.emit=se,k.mux.addHLSJS=se,k.mux.addDashJS=se,k.mux.removeHLSJS=se,k.mux.removeDashJS=se,k.mux.deleted=!0,g.emit(P,"destroy")},k.mux.swapElement=function(de){var le=Vr(Ae(de),3),fe=le[0],De=le[1],$e=le[2];return fe?$e!=="video"&&$e!=="audio"?g.log.error("The element of `"+De+"` was not a media element."):(fe.muxId=k.muxId,delete k.muxId,fe.mux=fe.mux||{},fe.mux.listeners=Object.assign({},k.mux.listeners),delete k.mux.listeners,Object.keys(fe.mux.listeners).forEach(function(it){k.removeEventListener(it,fe.mux.listeners[it],!1),fe.addEventListener(it,fe.mux.listeners[it],!1)}),fe.mux.swapElement=k.mux.swapElement,fe.mux.destroy=k.mux.destroy,delete k.mux,void(k=fe)):g.log.error("No element was found with the `"+De+"` query selector.")},k.mux.addHLSJS=function(de){g.addHLSJS(P,de)},k.mux.addDashJS=function(de){g.addDashJS(P,de)},k.mux.removeHLSJS=function(){g.removeHLSJS(P)},k.mux.removeDashJS=function(){g.removeDashJS(P)},g.init(P,A),g.emit(P,"playerready"),k.paused||(g.emit(P,"play"),k.readyState>2&&g.emit(P,"playing")),k.mux.listeners={},Zn.forEach(function(de){(de!=="error"||A.automaticErrorTracking)&&(k.mux.listeners[de]=function(){var le={};if(de==="error"){if(!k.error||k.error.code===1)return;le.player_error_code=k.error.code,le.player_error_message=ea[k.error.code]||k.error.message}g.emit(P,de,le)},k.addEventListener(de,k.mux.listeners[de],!1))})}($t,m,h)},destroyMonitor:function(m){var h=Rr(Ae(m),1)[0];h&&h.mux&&typeof h.mux.destroy=="function"?h.mux.destroy():Re.error("A video element monitor for `"+m+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(m,h){var g=ne(m);Tt[g]?Tt[g].addHLSJS(h):Re.error("A monitor for `"+g+"` has not been initialized.")},addDashJS:function(m,h){var g=ne(m);Tt[g]?Tt[g].addDashJS(h):Re.error("A monitor for `"+g+"` has not been initialized.")},removeHLSJS:function(m){var h=ne(m);Tt[h]?Tt[h].removeHLSJS():Re.error("A monitor for `"+h+"` has not been initialized.")},removeDashJS:function(m){var h=ne(m);Tt[h]?Tt[h].removeDashJS():Re.error("A monitor for `"+h+"` has not been initialized.")},init:function(m,h){dt()&&h&&h.respectDoNotTrack&&Re.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var g=ne(m);Tt[g]=new ki($t,g,h)},emit:function(m,h,g){var _=ne(m);Tt[_]?(Tt[_].emit(h,g),h==="destroy"&&delete Tt[_]):Re.error("A monitor for `"+_+"` has not been initialized.")},checkDoNotTrack:dt,log:Re,utils:Wr,events:Sn,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign($t,ia),X()!==void 0&&typeof X().addEventListener=="function"&&X().addEventListener("pagehide",function(m){m.persisted||($t.WINDOW_UNLOADING=!0)},!1);var An=$t},655:function(H,z,K){var ee,X;function ae(ge){return ae=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(ne){return typeof ne}:function(ne){return ne&&typeof Symbol=="function"&&ne.constructor===Symbol&&ne!==Symbol.prototype?"symbol":typeof ne},ae(ge);}(function(ge){var ne=!1;if((X=typeof(ee=ge)=="function"?ee.call(z,K,z,H):ee)===void 0||(H.exports=X),ne=!0,ae(z)==="object"&&(H.exports=ge(),ne=!0),!ne){var Ae=window.Cookies,ke=window.Cookies=ge();ke.noConflict=function(){return window.Cookies=Ae,ke}}})(function(){var ge=function(){for(var ne=0,Ae={};ne<arguments.length;ne++){var ke=arguments[ne];for(var xe in ke)Ae[xe]=ke[xe]}return Ae};return function ne(Ae){function ke(xe,je,Re){var dt;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(Re=ge({path:"/"},ke.defaults,Re)).expires=="number"){var Ke=new Date;Ke.setMilliseconds(Ke.getMilliseconds()+864e5*Re.expires),Re.expires=Ke}try{dt=JSON.stringify(je),/^[\{\[]/.test(dt)&&(je=dt)}catch{}return je=Ae.write?Ae.write(je,xe):encodeURIComponent(String(je)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),xe=(xe=(xe=encodeURIComponent(String(xe))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[xe,"=",je,Re.expires?"; expires="+Re.expires.toUTCString():"",Re.path?"; path="+Re.path:"",Re.domain?"; domain="+Re.domain:"",Re.secure?"; secure":""].join("")}xe||(dt={});for(var pe=document.cookie?document.cookie.split("; "):[],be=/(%[0-9A-Z]{2})+/g,Z=0;Z<pe.length;Z++){var E=pe[Z].split("="),Q=E.slice(1).join("=");Q.charAt(0)==='"'&&(Q=Q.slice(1,-1));try{var F=E[0].replace(be,decodeURIComponent);if(Q=Ae.read?Ae.read(Q,F):Ae(Q,F)||Q.replace(be,decodeURIComponent),this.json)try{Q=JSON.parse(Q)}catch{}if(xe===F){dt=Q;break}xe||(dt[F]=Q)}catch{}}return dt}}return ke.set=ke,ke.get=function(xe){return ke.call(ke,xe)},ke.getJSON=function(){return ke.apply({json:!0},[].slice.call(arguments))},ke.defaults={},ke.remove=function(xe,je){ke(xe,"",ge(je,{expires:-1}))},ke.withConverter=ne,ke}(function(){})})},153:function(H,z,K){var ee,X=K.g!==void 0?K.g:typeof window!="undefined"?window:{},ae=K(558);typeof document!="undefined"?ee=document:(ee=X["__GLOBAL_DOCUMENT_CACHE@4"])||(ee=X["__GLOBAL_DOCUMENT_CACHE@4"]=ae),H.exports=ee},48:function(H,z,K){var ee;ee=typeof window!="undefined"?window:K.g!==void 0?K.g:typeof self!="undefined"?self:{},H.exports=ee},640:function(H,z,K){var ee,X;(function(ae,ge){"use strict";ee=function(){var ne=function(){},Ae="undefined",ke=typeof window!==Ae&&typeof window.navigator!==Ae&&/Trident\/|MSIE /.test(window.navigator.userAgent),xe=["trace","debug","info","warn","error"];function je(he,Ue){var Be=he[Ue];if(typeof Be.bind=="function")return Be.bind(he);try{return Function.prototype.bind.call(Be,he)}catch{return function(){return Function.prototype.apply.apply(Be,[he,arguments])}}}function Re(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function dt(he){return he==="debug"&&(he="log"),typeof console!==Ae&&(he==="trace"&&ke?Re:console[he]!==void 0?je(console,he):console.log!==void 0?je(console,"log"):ne)}function Ke(he,Ue){for(var Be=0;Be<xe.length;Be++){var Ut=xe[Be];this[Ut]=Be<he?ne:this.methodFactory(Ut,he,Ue)}this.log=this.debug}function pe(he,Ue,Be){return function(){typeof console!==Ae&&(Ke.call(this,Ue,Be),this[he].apply(this,arguments))}}function be(he,Ue,Be){return dt(he)||pe.apply(this,arguments)}function Z(he,Ue,Be){var Ut,qe=this;Ue=Ue==null?"WARN":Ue;var x="loglevel";function nr(Me){var gt=(xe[Me]||"silent").toUpperCase();if(typeof window!==Ae&&x){try{return void(window.localStorage[x]=gt)}catch{}try{window.document.cookie=encodeURIComponent(x)+"="+gt+";"}catch{}}}function Bt(){var Me;if(typeof window!==Ae&&x){try{Me=window.localStorage[x]}catch{}if(typeof Me===Ae)try{var gt=window.document.cookie,Xe=gt.indexOf(encodeURIComponent(x)+"=");Xe!==-1&&(Me=/^([^;]+)/.exec(gt.slice(Xe))[1])}catch{}return qe.levels[Me]===void 0&&(Me=void 0),Me}}function Ve(){if(typeof window!==Ae&&x){try{return void window.localStorage.removeItem(x)}catch{}try{window.document.cookie=encodeURIComponent(x)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof he=="string"?x+=":"+he:typeof he=="symbol"&&(x=void 0),qe.name=he,qe.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},qe.methodFactory=Be||be,qe.getLevel=function(){return Ut},qe.setLevel=function(Me,gt){if(typeof Me=="string"&&qe.levels[Me.toUpperCase()]!==void 0&&(Me=qe.levels[Me.toUpperCase()]),!(typeof Me=="number"&&Me>=0&&Me<=qe.levels.SILENT))throw"log.setLevel() called with invalid level: "+Me;if(Ut=Me,gt!==!1&&nr(Me),Ke.call(qe,Me,he),typeof console===Ae&&Me<qe.levels.SILENT)return"No console available for logging"},qe.setDefaultLevel=function(Me){Ue=Me,Bt()||qe.setLevel(Me,!1)},qe.resetLevel=function(){qe.setLevel(Ue,!1),Ve()},qe.enableAll=function(Me){qe.setLevel(qe.levels.TRACE,Me)},qe.disableAll=function(Me){qe.setLevel(qe.levels.SILENT,Me)};var ar=Bt();ar==null&&(ar=Ue),qe.setLevel(ar,!1)}var E=new Z,Q={};E.getLogger=function(he){if(typeof he!="symbol"&&typeof he!="string"||he==="")throw new TypeError("You must supply a name when creating a logger.");var Ue=Q[he];return Ue||(Ue=Q[he]=new Z(he,E.getLevel(),E.methodFactory)),Ue};var F=typeof window!==Ae?window.log:void 0;return E.noConflict=function(){return typeof window!==Ae&&window.log===E&&(window.log=F),E},E.getLoggers=function(){return Q},E.default=E,E},(X=typeof ee=="function"?ee.call(z,K,z,H):ee)===void 0||(H.exports=X)})()},375:function(H,z){"use strict";var K=Object.prototype.hasOwnProperty;function ee(ae){try{return decodeURIComponent(ae.replace(/\+/g," "))}catch{return null}}function X(ae){try{return encodeURIComponent(ae)}catch{return null}}z.stringify=function(ae,ge){ge=ge||"";var ne,Ae,ke=[];for(Ae in typeof ge!="string"&&(ge="?"),ae)if(K.call(ae,Ae)){if((ne=ae[Ae])||ne!=null&&!isNaN(ne)||(ne=""),Ae=X(Ae),ne=X(ne),Ae===null||ne===null)continue;ke.push(Ae+"="+ne)}return ke.length?ge+ke.join("&"):""},z.parse=function(ae){for(var ge,ne=/([^=?#&]+)=?([^&]*)/g,Ae={};ge=ne.exec(ae);){var ke=ee(ge[1]),xe=ee(ge[2]);ke===null||xe===null||ke in Ae||(Ae[ke]=xe)}return Ae}},558:function(){}},B={};function j(H){var z=B[H];if(z!==void 0)return z.exports;var K=B[H]={exports:{}};return L[H].call(K.exports,K,K.exports,j),K.exports}return j.n=function(H){var z=H&&H.__esModule?function(){return H.default}:function(){return H};return j.d(z,{a:z}),z},j.d=function(H,z){for(var K in z)j.o(z,K)&&!j.o(H,K)&&Object.defineProperty(H,K,{enumerable:!0,get:z[K]})},j.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),j.o=function(H,z){return Object.prototype.hasOwnProperty.call(H,z)},j(80)}()},typeof Un=="object"&&typeof Ua=="object"?Ua.exports=C():typeof Un=="object"?Un.mux=C():I.mux=C()})()});var $s=Ys((Js,Ba)=>{(function I(C){var L,B;L=this,B=function(){"use strict";function j(s,n){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);n&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),e.push.apply(e,t)}return e}function H(s){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?j(Object(e),!0).forEach(function(t){ee(s,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):j(Object(e)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(e,t))})}return s}function z(s,n){for(var e=0;e<n.length;e++){var t=n[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,dt(t.key),t)}}function K(s,n,e){return n&&z(s.prototype,n),e&&z(s,e),Object.defineProperty(s,"prototype",{writable:!1}),s}function ee(s,n,e){return(n=dt(n))in s?Object.defineProperty(s,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[n]=e,s}function X(){return X=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(s[t]=e[t])}return s},X.apply(this,arguments)}function ae(s,n){s.prototype=Object.create(n.prototype),s.prototype.constructor=s,ne(s,n)}function ge(s){return ge=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ge(s)}function ne(s,n){return ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ne(s,n)}function Ae(){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 ke(s,n,e){return ke=Ae()?Reflect.construct.bind():function(t,r,i){var a=[null];a.push.apply(a,r);var o=new(Function.bind.apply(t,a));return i&&ne(o,i.prototype),o},ke.apply(null,arguments)}function xe(s){var n=typeof Map=="function"?new Map:void 0;return xe=function(e){if(e===null||(t=e,Function.toString.call(t).indexOf("[native code]")===-1))return e;var t;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(n!==void 0){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return ke(e,arguments,ge(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ne(r,e)},xe(s)}function je(s,n){(n==null||n>s.length)&&(n=s.length);for(var e=0,t=new Array(n);e<n;e++)t[e]=s[e];return t}function Re(s,n){var e=typeof Symbol!="undefined"&&s[Symbol.iterator]||s["@@iterator"];if(e)return(e=e.call(s)).next.bind(e);if(Array.isArray(s)||(e=function(r,i){if(r){if(typeof r=="string")return je(r,i);var a=Object.prototype.toString.call(r).slice(8,-1);return a==="Object"&&r.constructor&&(a=r.constructor.name),a==="Map"||a==="Set"?Array.from(r):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?je(r,i):void 0}}(s))||n&&s&&typeof s.length=="number"){e&&(s=e);var t=0;return function(){return t>=s.length?{done:!0}:{done:!1,value:s[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
20
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dt(s){var n=function(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}(s,"string");return typeof n=="symbol"?n:String(n)}function Ke(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var pe={exports:{}};(function(s,n){var e,t,r,i,a;e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(o,l,d){if(d=d||{},o=o.trim(),!(l=l.trim())){if(!d.alwaysNormalize)return o;var u=a.parseURL(o);if(!u)throw new Error("Error trying to parse base URL.");return u.path=a.normalizePath(u.path),a.buildURLFromParts(u)}var c=a.parseURL(l);if(!c)throw new Error("Error trying to parse relative URL.");if(c.scheme)return d.alwaysNormalize?(c.path=a.normalizePath(c.path),a.buildURLFromParts(c)):l;var f=a.parseURL(o);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var v=t.exec(f.path);f.netLoc=v[1],f.path=v[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:c.netLoc,path:null,params:c.params,query:c.query,fragment:c.fragment};if(!c.netLoc&&(p.netLoc=f.netLoc,c.path[0]!=="/"))if(c.path){var T=f.path,S=T.substring(0,T.lastIndexOf("/")+1)+c.path;p.path=a.normalizePath(S)}else p.path=f.path,c.params||(p.params=f.params,c.query||(p.query=f.query));return p.path===null&&(p.path=d.alwaysNormalize?a.normalizePath(c.path):c.path),a.buildURLFromParts(p)},parseURL:function(o){var l=e.exec(o);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(o){for(o=o.split("").reverse().join("").replace(r,"");o.length!==(o=o.replace(i,"")).length;);return o.split("").reverse().join("")},buildURLFromParts:function(o){return o.scheme+o.netLoc+o.path+o.params+o.query+o.fragment}},s.exports=a})(pe);var be=pe.exports,Z=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},E=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s}({}),Q=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),F=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown",s}({}),he=function(){},Ue={trace:he,debug:he,log:he,warn:he,info:he,error:he},Be=Ue;function Ut(s){var n=self.console[s];return n?n.bind(self.console,"["+s+"] >"):he}function qe(s,n){if(self.console&&s===!0||typeof s=="object"){(function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach(function(a){Be[a]=e[a]?e[a].bind(e):Ut(a)})})(s,"debug","log","info","warn","error");try{Be.log('Debug logs enabled for "'+n+'" in hls.js version 1.4.3')}catch{Be=Ue}}else Be=Ue}var x=Be,nr=/^(\d+)x(\d+)$/,Bt=/(.+?)=(".*?"|.*?)(?:,|$)/g,Ve=function(){function s(e){for(var t in typeof e=="string"&&(e=s.parseAttrList(e)),e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}var n=s.prototype;return n.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},n.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.decimalFloatingPoint=function(e){return parseFloat(this[e])},n.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},n.enumeratedString=function(e){return this[e]},n.bool=function(e){return this[e]==="YES"},n.decimalResolution=function(e){var t=nr.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},s.parseAttrList=function(e){var t,r={};for(Bt.lastIndex=0;(t=Bt.exec(e))!==null;){var i=t[2];i.indexOf('"')===0&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1].trim()]=i}return r},s}();function ar(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var Me=function(){function s(n,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var t=e.attr;for(var r in t)if(Object.prototype.hasOwnProperty.call(n,r)&&n[r]!==t[r]){x.warn('DATERANGE tag attribute: "'+r+'" does not match for tags with ID: "'+n.ID+'"'),this._badValueForSameId=r;break}n=X(new Ve({}),t,n)}if(this.attr=n,this._startDate=new Date(n["START-DATE"]),"END-DATE"in this.attr){var i=new Date(this.attr["END-DATE"]);Z(i.getTime())&&(this._endDate=i)}}return K(s,[{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 n=this.duration;return n!==null?new Date(this._startDate.getTime()+1e3*n):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var n=this.attr.decimalFloatingPoint("DURATION");if(Z(n))return n}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&&Z(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),s}(),gt=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}},Xe="audio",mt="video",Nr="audiovideo",ai=function(){function s(n){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[Xe]=null,e[mt]=null,e[Nr]=null,e),this.baseurl=n}return s.prototype.setByteRange=function(n,e){var t=n.split("@",2),r=[];t.length===1?r[0]=e?e.byteRangeEndOffset:0:r[0]=parseInt(t[1]),r[1]=parseInt(t[0])+r[0],this._byteRange=r},K(s,[{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=be.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(n){this._url=n}}]),s}(),si=function(s){function n(t,r){var i;return(i=s.call(this,r)||this)._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.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 gt,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.type=t,i}ae(n,s);var e=n.prototype;return e.setKeyFormat=function(t){if(this.levelkeys){var r=this.levelkeys[t];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},e.abortRequests=function(){var t,r;(t=this.loader)==null||t.abort(),(r=this.keyLoader)==null||r.abort()},e.setElementaryStreamInfo=function(t,r,i,a,o,l){l===void 0&&(l=!1);var d=this.elementaryStreams,u=d[t];u?(u.startPTS=Math.min(u.startPTS,r),u.endPTS=Math.max(u.endPTS,i),u.startDTS=Math.min(u.startDTS,a),u.endDTS=Math.max(u.endDTS,o)):d[t]={startPTS:r,endPTS:i,startDTS:a,endDTS:o,partial:l}},e.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[Xe]=null,t[mt]=null,t[Nr]=null},K(n,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{var r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Z(this.programDateTime))return null;var t=Z(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){var r=Object.keys(this.levelkeys),i=r.length;if(i>1||i===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}}]),n}(ai),qn=function(s){function n(e,t,r,i,a){var o;(o=s.call(this,r)||this).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.stats=new gt,o.duration=e.decimalFloatingPoint("DURATION"),o.gap=e.bool("GAP"),o.independent=e.bool("INDEPENDENT"),o.relurl=e.enumeratedString("URI"),o.fragment=t,o.index=i;var l=e.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,a),a&&(o.fragOffset=a.fragOffset+a.duration),o}return ae(n,s),K(n,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),n}(ai),ji=function(){function s(n){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.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=n}return s.prototype.reloaded=function(n){if(!n)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-n.lastPartSn,t=this.lastPartIndex-n.lastPartIndex;this.updated=this.endSN!==n.endSN||!!t||!!e,this.advanced=this.endSN>n.endSN||e>0||e===0&&t>0,this.updated||this.advanced?this.misses=Math.floor(.6*n.misses):this.misses=n.misses+1,this.availabilityDelay=n.availabilityDelay},K(s,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Z(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var n=this.driftEndTime-this.driftStartTime;return n>0?1e3*(this.driftEnd-this.driftStart)/n:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var n;return(n=this.partList)!=null&&n.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var n;return(n=this.fragments)!=null&&n.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 n;return(n=this.partList)!=null&&n.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var n;return(n=this.partList)!=null&&n.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),s}();function oi(s){return Uint8Array.from(atob(s),function(n){return n.charCodeAt(0)})}function Vi(s){var n,e,t=s.split(":"),r=null;if(t[0]==="data"&&t.length===2){var i=t[1].split(";"),a=i[i.length-1].split(",");if(a.length===2){var o=a[0]==="base64",l=a[1];o?(i.splice(-1,1),r=oi(l)):(n=Yi(l).subarray(0,16),(e=new Uint8Array(16)).set(n,16-n.length),r=e)}}return r}function Yi(s){return Uint8Array.from(unescape(encodeURIComponent(s)),function(n){return n.charCodeAt(0)})}var Ye={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Ur="org.w3.clearkey",li="com.apple.streamingkeydelivery",gr="com.microsoft.playready",Br="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function ui(s){switch(s){case li:return Ye.FAIRPLAY;case gr:return Ye.PLAYREADY;case Br:return Ye.WIDEVINE;case Ur:return Ye.CLEARKEY}}var Wi="edef8ba979d64acea3c827dcd51d21ed";function di(s){switch(s){case Ye.FAIRPLAY:return li;case Ye.PLAYREADY:return gr;case Ye.WIDEVINE:return Br;case Ye.CLEARKEY:return Ur}}function ci(s){var n=s.drmSystems,e=s.widevineLicenseUrl,t=n?[Ye.FAIRPLAY,Ye.WIDEVINE,Ye.PLAYREADY,Ye.CLEARKEY].filter(function(r){return!!n[r]}):[];return!t[Ye.WIDEVINE]&&e&&t.push(Ye.WIDEVINE),t}var hi=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function Wt(s,n,e){return Uint8Array.prototype.slice?s.slice(n,e):new Uint8Array(Array.prototype.slice.call(s,n,e))}var Gr,fi=function(s,n){return n+10<=s.length&&s[n]===73&&s[n+1]===68&&s[n+2]===51&&s[n+3]<255&&s[n+4]<255&&s[n+6]<128&&s[n+7]<128&&s[n+8]<128&&s[n+9]<128},zi=function(s,n){return n+10<=s.length&&s[n]===51&&s[n+1]===68&&s[n+2]===73&&s[n+3]<255&&s[n+4]<255&&s[n+6]<128&&s[n+7]<128&&s[n+8]<128&&s[n+9]<128},mr=function(s,n){for(var e=n,t=0;fi(s,n);)t+=10,t+=Hr(s,n+6),zi(s,n+10)&&(t+=10),n+=t;if(t>0)return s.subarray(e,e+t)},Hr=function(s,n){var e=0;return e=(127&s[n])<<21,e|=(127&s[n+1])<<14,e|=(127&s[n+2])<<7,e|=127&s[n+3]},Xi=function(s,n){return fi(s,n)&&Hr(s,n+6)+10<=s.length-n},Qi=function(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"},jn=function(s){var n=String.fromCharCode(s[0],s[1],s[2],s[3]),e=Hr(s,4);return{type:n,size:e,data:s.subarray(10,10+e)}},vi=function(s){for(var n=0,e=[];fi(s,n);){for(var t=Hr(s,n+6),r=(n+=10)+t;n+8<r;){var i=jn(s.subarray(n)),a=Vn(i);a&&e.push(a),n+=i.size+10}zi(s,n)&&(n+=10)}return e},Vn=function(s){return s.type==="PRIV"?Yn(s):s.type[0]==="W"?$i(s):Ji(s)},Yn=function(s){if(!(s.size<2)){var n=St(s.data,!0),e=new Uint8Array(s.data.subarray(n.length+1));return{key:s.type,info:n,data:e.buffer}}},Ji=function(s){if(!(s.size<2)){if(s.type==="TXXX"){var n=1,e=St(s.data.subarray(n),!0);n+=e.length+1;var t=St(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=St(s.data.subarray(1));return{key:s.type,data:r}}},$i=function(s){if(s.type==="WXXX"){if(s.size<2)return;var n=1,e=St(s.data.subarray(n),!0);n+=e.length+1;var t=St(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=St(s.data);return{key:s.type,data:r}},Zi=function(s){if(s.data.byteLength===8){var n=new Uint8Array(s.data),e=1&n[3],t=(n[4]<<23)+(n[5]<<15)+(n[6]<<7)+n[7];return t/=45,e&&(t+=4772185884e-2),Math.round(t)}},St=function(s,n){n===void 0&&(n=!1);var e=Wn();if(e){var t=e.decode(s);if(n){var r=t.indexOf("\0");return r!==-1?t.substring(0,r):t}return t.replace(/\0/g,"")}for(var i,a,o,l=s.length,d="",u=0;u<l;){if((i=s[u++])===0&&n)return d;if(i!==0&&i!==3)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(i);break;case 12:case 13:a=s[u++],d+=String.fromCharCode((31&i)<<6|63&a);break;case 14:a=s[u++],o=s[u++],d+=String.fromCharCode((15&i)<<12|(63&a)<<6|(63&o)<<0)}}return d};function Wn(){return Gr||self.TextDecoder===void 0||(Gr=new self.TextDecoder("utf-8")),Gr}var Dt=function(s){for(var n="",e=0;e<s.length;e++){var t=s[e].toString(16);t.length<2&&(t="0"+t),n+=t}return n},pr=Math.pow(2,32)-1,zn=[].push,en={video:1,audio:2,id3:3,text:4};function Qe(s){return String.fromCharCode.apply(null,s)}function tn(s,n){var e=s[n]<<8|s[n+1];return e<0?65536+e:e}function Se(s,n){var e=gi(s,n);return e<0?4294967296+e:e}function gi(s,n){return s[n]<<24|s[n+1]<<16|s[n+2]<<8|s[n+3]}function mi(s,n,e){s[n]=e>>24,s[n+1]=e>>16&255,s[n+2]=e>>8&255,s[n+3]=255&e}function Pe(s,n){var e=[];if(!n.length)return e;for(var t=s.byteLength,r=0;r<t;){var i=Se(s,r),a=i>1?r+i:t;if(Qe(s.subarray(r+4,r+8))===n[0])if(n.length===1)e.push(s.subarray(r+8,a));else{var o=Pe(s.subarray(r+8,a),n.slice(1));o.length&&zn.apply(e,o)}r=a}return e}function rn(s){var n=[],e=s[0],t=8,r=Se(s,t);t+=4,t+=e===0?8:16,t+=2;var i=s.length+0,a=tn(s,t);t+=2;for(var o=0;o<a;o++){var l=t,d=Se(s,l);l+=4;var u=2147483647&d;if((2147483648&d)>>>31==1)return x.warn("SIDX has hierarchical references (not supported)"),null;var c=Se(s,l);l+=4,n.push({referenceSize:u,subsegmentDuration:c,info:{duration:c/r,start:i,end:i+u-1}}),i+=u,t=l+=4}return{earliestPresentationTime:0,timescale:r,version:e,referencesCount:a,references:n}}function pi(s){for(var n=[],e=Pe(s,["moov","trak"]),t=0;t<e.length;t++){var r=e[t],i=Pe(r,["tkhd"])[0];if(i){var a=i[0],o=a===0?12:20,l=Se(i,o),d=Pe(r,["mdia","mdhd"])[0];if(d){var u=Se(d,o=(a=d[0])===0?12:20),c=Pe(r,["mdia","hdlr"])[0];if(c){var f=Qe(c.subarray(8,12)),v={soun:Xe,vide:mt}[f];if(v){var p=Pe(r,["mdia","minf","stbl","stsd"])[0],T=void 0;p&&(T=Qe(p.subarray(12,16))),n[l]={timescale:u,type:v},n[v]={timescale:u,id:l,codec:T}}}}}}return Pe(s,["moov","mvex","trex"]).forEach(function(S){var y=Se(S,4),b=n[y];b&&(b.default={duration:Se(S,12),flags:Se(S,20)})}),n}function yi(s){var n=Pe(s,["schm"])[0];if(n){var e=Qe(n.subarray(4,8));if(e==="cbcs"||e==="cenc")return Pe(s,["schi","tenc"])[0]}return x.error("[eme] missing 'schm' box"),null}function Xn(s){var n=Se(s,0),e=8;1&n&&(e+=4),4&n&&(e+=4);for(var t=0,r=Se(s,4),i=0;i<r;i++)256&n&&(t+=Se(s,e),e+=4),512&n&&(e+=4),1024&n&&(e+=4),2048&n&&(e+=4);return t}function zt(s,n){var e=new Uint8Array(s.length+n.length);return e.set(s),e.set(n,s.length),e}function Ti(s,n){var e=[],t=n.samples,r=n.timescale,i=n.id,a=!1;return Pe(t,["moof"]).map(function(o){var l=o.byteOffset-8;Pe(o,["traf"]).map(function(d){var u=Pe(d,["tfdt"]).map(function(c){var f=c[0],v=Se(c,4);return f===1&&(v*=Math.pow(2,32),v+=Se(c,8)),v/r})[0];return u!==void 0&&(s=u),Pe(d,["tfhd"]).map(function(c){var f=Se(c,4),v=16777215&Se(c,0),p=0,T=(16&v)!=0,S=0,y=(32&v)!=0,b=8;f===i&&((1&v)!=0&&(b+=8),(2&v)!=0&&(b+=4),(8&v)!=0&&(p=Se(c,b),b+=4),T&&(S=Se(c,b),b+=4),y&&(b+=4),n.type==="video"&&(a=function(D){if(!D)return!1;var w=D.indexOf("."),O=w<0?D:D.substring(0,w);return O==="hvc1"||O==="hev1"||O==="dvh1"||O==="dvhe"}(n.codec)),Pe(d,["trun"]).map(function(D){var w=D[0],O=16777215&Se(D,0),N=(1&O)!=0,G=0,W=(4&O)!=0,q=(256&O)!=0,V=0,te=(512&O)!=0,J=0,oe=(1024&O)!=0,me=(2048&O)!=0,ue=0,ve=Se(D,4),Te=8;N&&(G=Se(D,Te),Te+=4),W&&(Te+=4);for(var ye=G+l,we=0;we<ve;we++){if(q?(V=Se(D,Te),Te+=4):V=p,te?(J=Se(D,Te),Te+=4):J=S,oe&&(Te+=4),me&&(ue=w===0?Se(D,Te):gi(D,Te),Te+=4),n.type===mt)for(var Ce=0;Ce<J;){var Oe=Se(t,ye);nn(a,t[ye+=4])&&an(t.subarray(ye,ye+Oe),a?2:1,s+ue/r,e),ye+=Oe,Ce+=Oe+4}s+=V/r}}))})})}),e}function nn(s,n){if(s){var e=n>>1&63;return e===39||e===40}return(31&n)==6}function an(s,n,e,t){var r=sn(s),i=0;i+=n;for(var a=0,o=0,l=!1,d=0;i<r.length;){a=0;do{if(i>=r.length)break;a+=d=r[i++]}while(d===255);o=0;do{if(i>=r.length)break;o+=d=r[i++]}while(d===255);var u=r.length-i;if(!l&&a===4&&i<r.length){if(l=!0,r[i++]===181){var c=tn(r,i);if(i+=2,c===49){var f=Se(r,i);if(i+=4,f===1195456820){var v=r[i++];if(v===3){var p=r[i++],T=64&p,S=T?2+3*(31&p):0,y=new Uint8Array(S);if(T){y[0]=p;for(var b=1;b<S;b++)y[b]=r[i++]}t.push({type:v,payloadType:a,pts:e,bytes:y})}}}}}else if(a===5&&o<u){if(l=!0,o>16){for(var D=[],w=0;w<16;w++){var O=r[i++].toString(16);D.push(O.length==1?"0"+O:O),w!==3&&w!==5&&w!==7&&w!==9||D.push("-")}for(var N=o-16,G=new Uint8Array(N),W=0;W<N;W++)G[W]=r[i++];t.push({payloadType:a,pts:e,uuid:D.join(""),userData:St(G),userDataBytes:G})}}else if(o<u)i+=o;else if(o>u)break}}function sn(s){for(var n=s.byteLength,e=[],t=1;t<n-2;)s[t]===0&&s[t+1]===0&&s[t+2]===3?(e.push(t+2),t+=2):t++;if(e.length===0)return s;var r=n-e.length,i=new Uint8Array(r),a=0;for(t=0;t<r;a++,t++)a===e[0]&&(a++,e.shift()),i[t]=s[a];return i}function on(s,n,e){if(s.byteLength!==16)throw new RangeError("Invalid system id");var t,r,i;if(n){t=1,r=new Uint8Array(16*n.length);for(var a=0;a<n.length;a++){var o=n[a];if(o.byteLength!==16)throw new RangeError("Invalid key");r.set(o,16*a)}}else t=0,r=new Uint8Array;t>0?(i=new Uint8Array(4),n.length>0&&new DataView(i.buffer).setUint32(0,n.length,!1)):i=new Uint8Array;var l=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(l.buffer).setUint32(0,e.byteLength,!1),function(d){for(var u=arguments.length,c=new Array(u>1?u-1:0),f=1;f<u;f++)c[f-1]=arguments[f];for(var v=c.length,p=8,T=v;T--;)p+=c[T].byteLength;var S=new Uint8Array(p);for(S[0]=p>>24&255,S[1]=p>>16&255,S[2]=p>>8&255,S[3]=255&p,S.set(d,4),T=0,p=8;T<v;T++)S.set(c[T],p),p+=c[T].byteLength;return S}([112,115,115,104],new Uint8Array([t,0,0,0]),s,i,r,l,e||new Uint8Array)}var yr={},Tr=function(){function s(e,t,r,i,a){i===void 0&&(i=[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=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=a,this.encrypted=!!e&&e!=="NONE",this.isCommonEncryption=this.encrypted&&e!=="AES-128"}s.clearKeyUriToKeyIdMap=function(){yr={}};var n=s.prototype;return n.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case li:case Br:case gr:case Ur:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},n.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||x.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=function(S){for(var y=new Uint8Array(16),b=12;b<16;b++)y[b]=S>>8*(15-b)&255;return y}(e);return new s(this.method,this.uri,"identity",this.keyFormatVersions,t)}var r=Vi(this.uri);if(r)switch(this.keyFormat){case Br:this.pssh=r,r.length>=22&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case gr:var i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=on(i,null,r);var a=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),o=String.fromCharCode.apply(null,Array.from(a)),l=o.substring(o.indexOf("<"),o.length),d=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(d){var u=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(u){var c=oi(u).subarray(0,16);(function(S){var y=function(b,D,w){var O=b[D];b[D]=b[w],b[w]=O};y(S,0,3),y(S,1,2),y(S,4,5),y(S,6,7)})(c),this.keyId=c}}break;default:var f=r.subarray(0,16);if(f.length!==16){var v=new Uint8Array(16);v.set(f,16-f.length),f=v}this.keyId=f}if(!this.keyId||this.keyId.byteLength!==16){var p=yr[this.uri];if(!p){var T=Object.keys(yr).length%Number.MAX_SAFE_INTEGER;p=new Uint8Array(16),new DataView(p.buffer,12,4).setUint32(0,T),yr[this.uri]=p}this.keyId=p}return this},s}(),ln=/\{\$([a-zA-Z0-9-_]+)\}/g;function un(s){return ln.test(s)}function ct(s,n,e){if(s.variableList!==null||s.hasVariableRefs)for(var t=e.length;t--;){var r=e[t],i=n[r];i&&(n[r]=At(s,i))}}function At(s,n){if(s.variableList!==null||s.hasVariableRefs){var e=s.variableList;return n.replace(ln,function(t){var r=t.substring(2,t.length-1),i=e==null?void 0:e[r];return i===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+r+'"')),t):i})}return n}function dn(s,n,e){var t,r,i=s.variableList;if(i||(s.variableList=i={}),"QUERYPARAM"in n){t=n.QUERYPARAM;try{var a=new self.URL(e).searchParams;if(!a.has(t))throw new Error('"'+t+'" does not match any query parameter in URI: "'+e+'"');r=a.get(t)}catch(o){s.playlistParsingError||(s.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+o.message))}}else t=n.NAME,r=n.VALUE;t in i?s.playlistParsingError||(s.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+t+'"')):i[t]=r||""}function cn(s,n,e){var t=n.IMPORT;if(e&&t in e){var r=s.variableList;r||(s.variableList=r={}),r[t]=e[t]}else s.playlistParsingError||(s.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+t+'"'))}function Kr(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var Qn={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}},Ei=Kr();function qr(s,n){var e;return(e=Ei==null?void 0:Ei.isTypeSupported((n||"video")+'/mp4;codecs="'+s+'"'))!=null&&e}var Xt=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,sr=/#EXT-X-MEDIA:(.*)/g,Jn=/^#EXT(?:INF|-X-TARGETDURATION):/m,bi=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),jr=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|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("|")),Er=function(){function s(){}return s.findGroup=function(n,e){for(var t=0;t<n.length;t++){var r=n[t];if(r.id===e)return r}},s.convertAVC1ToAVCOTI=function(n){var e=n.split(".");if(e.length>2){var t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4)}return n},s.resolve=function(n,e){return be.buildAbsoluteURL(e,n,{alwaysNormalize:!0})},s.isMediaPlaylist=function(n){return Jn.test(n)},s.parseMasterPlaylist=function(n,e){var t,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:un(n)},i=[];for(Xt.lastIndex=0;(t=Xt.exec(n))!=null;)if(t[1]){var a,o=new Ve(t[1]);ct(r,o,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=At(r,t[2]),d={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:s.resolve(l,e)},u=o.decimalResolution("RESOLUTION");u&&(d.width=u.width,d.height=u.height),$n((o.CODECS||"").split(/[ ,]+/).filter(function(D){return D}),d),d.videoCodec&&d.videoCodec.indexOf("avc1")!==-1&&(d.videoCodec=s.convertAVC1ToAVCOTI(d.videoCodec)),(a=d.unknownCodecs)!=null&&a.length||i.push(d),r.levels.push(d)}else if(t[3]){var c=t[3],f=t[4];switch(c){case"SESSION-DATA":var v=new Ve(f);ct(r,v,["DATA-ID","LANGUAGE","VALUE","URI"]);var p=v["DATA-ID"];p&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[p]=v);break;case"SESSION-KEY":var T=hn(f,e,r);T.encrypted&&T.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(T)):x.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+f+'"');break;case"DEFINE":var S=new Ve(f);ct(r,S,["NAME","VALUE","QUERYPARAM"]),dn(r,S,e);break;case"CONTENT-STEERING":var y=new Ve(f);ct(r,y,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:s.resolve(y["SERVER-URI"],e),pathwayId:y["PATHWAY-ID"]||"."};break;case"START":r.startTimeOffset=fn(f)}}var b=i.length>0&&i.length<r.levels.length;return r.levels=b?i:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},s.parseMasterPlaylistMedia=function(n,e,t){var r,i={},a=t.levels,o={AUDIO:a.map(function(T){return{id:T.attrs.AUDIO,audioCodec:T.audioCodec}}),SUBTITLES:a.map(function(T){return{id:T.attrs.SUBTITLES,textCodec:T.textCodec}}),"CLOSED-CAPTIONS":[]},l=0;for(sr.lastIndex=0;(r=sr.exec(n))!==null;){var d=new Ve(r[1]),u=d.TYPE;if(u){var c=o[u],f=i[u]||[];i[u]=f,ct(t,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var v={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",instreamId:d["INSTREAM-ID"],name:d.NAME||d.LANGUAGE||"",type:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:d.LANGUAGE,url:d.URI?s.resolve(d.URI,e):""};if(c!=null&&c.length){var p=s.findGroup(c,v.groupId)||c[0];_i(v,p,"audioCodec"),_i(v,p,"textCodec")}f.push(v)}}return i},s.parseLevelPlaylist=function(n,e,t,r,i,a){var o,l,d,u=new ji(e),c=u.fragments,f=null,v=0,p=0,T=0,S=0,y=null,b=new si(r,e),D=-1,w=!1;for(bi.lastIndex=0,u.m3u8=n,u.hasVariableRefs=un(n);(o=bi.exec(n))!==null;){w&&(w=!1,(b=new si(r,e)).start=T,b.sn=v,b.cc=S,b.level=t,f&&(b.initSegment=f,b.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null));var O=o[1];if(O){b.duration=parseFloat(O);var N=(" "+o[2]).slice(1);b.title=N||null,b.tagList.push(N?["INF",O,N]:["INF",O])}else if(o[3]){if(Z(b.duration)){b.start=T,d&&Si(b,d,u),b.sn=v,b.level=t,b.cc=S,b.urlId=i,c.push(b);var G=(" "+o[3]).slice(1);b.relurl=At(u,G),vn(b,y),y=b,T+=b.duration,v++,p=0,w=!0}}else if(o[4]){var W=(" "+o[4]).slice(1);y?b.setByteRange(W,y):b.setByteRange(W)}else if(o[5])b.rawProgramDateTime=(" "+o[5]).slice(1),b.tagList.push(["PROGRAM-DATE-TIME",b.rawProgramDateTime]),D===-1&&(D=c.length);else{if(!(o=o[0].match(jr))){x.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<o.length&&o[l]===void 0;l++);var q=(" "+o[l]).slice(1),V=(" "+o[l+1]).slice(1),te=o[l+2]?(" "+o[l+2]).slice(1):"";switch(q){case"PLAYLIST-TYPE":u.type=V.toUpperCase();break;case"MEDIA-SEQUENCE":v=u.startSN=parseInt(V);break;case"SKIP":var J=new Ve(V);ct(u,J,["RECENTLY-REMOVED-DATERANGES"]);var oe=J.decimalInteger("SKIPPED-SEGMENTS");if(Z(oe)){u.skippedSegments=oe;for(var me=oe;me--;)c.unshift(null);v+=oe}var ue=J.enumeratedString("RECENTLY-REMOVED-DATERANGES");ue&&(u.recentlyRemovedDateranges=ue.split(" "));break;case"TARGETDURATION":u.targetduration=Math.max(parseInt(V),1);break;case"VERSION":u.version=parseInt(V);break;case"EXTM3U":break;case"ENDLIST":u.live=!1;break;case"#":(V||te)&&b.tagList.push(te?[V,te]:[V]);break;case"DISCONTINUITY":S++,b.tagList.push(["DIS"]);break;case"GAP":b.gap=!0,b.tagList.push([q]);break;case"BITRATE":b.tagList.push([q,V]);break;case"DATERANGE":var ve=new Ve(V);ct(u,ve,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),ct(u,ve,ve.clientAttrs);var Te=new Me(ve,u.dateRanges[ve.ID]);Te.isValid||u.skippedSegments?u.dateRanges[Te.id]=Te:x.warn('Ignoring invalid DATERANGE tag: "'+V+'"'),b.tagList.push(["EXT-X-DATERANGE",V]);break;case"DEFINE":var ye=new Ve(V);ct(u,ye,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in ye?cn(u,ye,a):dn(u,ye,e);break;case"DISCONTINUITY-SEQUENCE":S=parseInt(V);break;case"KEY":var we=hn(V,e,u);if(we.isSupported()){if(we.method==="NONE"){d=void 0;break}d||(d={}),d[we.keyFormat]&&(d=X({},d)),d[we.keyFormat]=we}else x.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+V+'"');break;case"START":u.startTimeOffset=fn(V);break;case"MAP":var Ce=new Ve(V);if(ct(u,Ce,["BYTERANGE","URI"]),b.duration){var Oe=new si(r,e);gn(Oe,Ce,t,d),f=Oe,b.initSegment=f,f.rawProgramDateTime&&!b.rawProgramDateTime&&(b.rawProgramDateTime=f.rawProgramDateTime)}else gn(b,Ce,t,d),f=b,w=!0;break;case"SERVER-CONTROL":var Ge=new Ve(V);u.canBlockReload=Ge.bool("CAN-BLOCK-RELOAD"),u.canSkipUntil=Ge.optionalFloat("CAN-SKIP-UNTIL",0),u.canSkipDateRanges=u.canSkipUntil>0&&Ge.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=Ge.optionalFloat("PART-HOLD-BACK",0),u.holdBack=Ge.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Et=new Ve(V);u.partTarget=Et.decimalFloatingPoint("PART-TARGET");break;case"PART":var nt=u.partList;nt||(nt=u.partList=[]);var Ht=p>0?nt[nt.length-1]:void 0,Ot=p++,Mt=new Ve(V);ct(u,Mt,["BYTERANGE","URI"]);var at=new qn(Mt,b,e,Ot,Ht);nt.push(at),b.duration+=at.duration;break;case"PRELOAD-HINT":var ut=new Ve(V);ct(u,ut,["URI"]),u.preloadHint=ut;break;case"RENDITION-REPORT":var Vt=new Ve(V);ct(u,Vt,["URI"]),u.renditionReports=u.renditionReports||[],u.renditionReports.push(Vt);break;default:x.warn("line parsed but not handled: "+o)}}}y&&!y.relurl?(c.pop(),T-=y.duration,u.partList&&(u.fragmentHint=y)):u.partList&&(vn(b,y),b.cc=S,u.fragmentHint=b,d&&Si(b,d,u));var hr=c.length,wt=c[0],Mi=c[hr-1];if((T+=u.skippedSegments*u.targetduration)>0&&hr&&Mi){u.averagetargetduration=T/hr;var Fi=Mi.sn;u.endSN=Fi!=="initSegment"?Fi:0,u.live||(Mi.endList=!0),wt&&(u.startCC=wt.cc)}else u.endSN=0,u.startCC=0;return u.fragmentHint&&(T+=u.fragmentHint.duration),u.totalduration=T,u.endCC=S,D>0&&function(Mn,ei){for(var Or=Mn[ei],Ni=ei;Ni--;){var ir=Mn[Ni];if(!ir)return;ir.programDateTime=Or.programDateTime-1e3*ir.duration,Or=ir}}(c,D),u},s}();function hn(s,n,e){var t,r,i=new Ve(s);ct(e,i,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var a=(t=i.METHOD)!=null?t:"",o=i.URI,l=i.hexadecimalInteger("IV"),d=i.KEYFORMATVERSIONS,u=(r=i.KEYFORMAT)!=null?r:"identity";o&&i.IV&&!l&&x.error("Invalid IV: "+i.IV);var c=o?Er.resolve(o,n):"",f=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Tr(a,c,u,f,l)}function fn(s){var n=new Ve(s).decimalFloatingPoint("TIME-OFFSET");return Z(n)?n:null}function $n(s,n){["video","audio","text"].forEach(function(e){var t=s.filter(function(i){return function(a,o){var l=Qn[o];return!!l&&l[a.slice(0,4)]===!0}(i,e)});if(t.length){var r=t.filter(function(i){return i.lastIndexOf("avc1",0)===0||i.lastIndexOf("mp4a",0)===0});n[e+"Codec"]=r.length>0?r[0]:t[0],s=s.filter(function(i){return t.indexOf(i)===-1})}}),n.unknownCodecs=s}function _i(s,n,e){var t=n[e];t&&(s[e]=t)}function vn(s,n){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):n!=null&&n.programDateTime&&(s.programDateTime=n.endProgramDateTime),Z(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function gn(s,n,e,t){s.relurl=n.URI,n.BYTERANGE&&s.setByteRange(n.BYTERANGE),s.level=e,s.sn="initSegment",t&&(s.levelkeys=t),s.initSegment=null}function Si(s,n,e){s.levelkeys=n;var t=e.encryptedFragments;t.length&&t[t.length-1].levelkeys===n||!Object.keys(n).some(function(r){return n[r].isCommonEncryption})||t.push(s)}var or="manifest",Qt="level",yt="audioTrack",Gt="subtitleTrack",Ne="main",kt="audio",It="subtitle";function mn(s){switch(s.type){case yt:return kt;case Gt:return It;default:return Ne}}function Ai(s,n){var e=s.url;return e!==void 0&&e.indexOf("data:")!==0||(e=n.url),e}var Je=function(){function s(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var n=s.prototype;return n.startLoad=function(e){},n.stopLoad=function(){this.destroyInternalLoaders()},n.registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.unregisterListeners=function(){var e=this.hls;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,a=new(r||i)(t);return this.loaders[e.type]=a,a},n.getInternalLoader=function(e){return this.loaders[e.type]},n.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},n.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},n.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},n.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:or,url:r,deliveryDirectives:null})},n.onLevelLoading=function(e,t){var r=t.id,i=t.level,a=t.url,o=t.deliveryDirectives;this.load({id:r,level:i,responseType:"text",type:Qt,url:a,deliveryDirectives:o})},n.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,o=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:yt,url:a,deliveryDirectives:o})},n.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,o=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:Gt,url:a,deliveryDirectives:o})},n.load=function(e){var t,r,i,a=this,o=this.hls.config,l=this.getInternalLoader(e);if(l){var d=l.context;if(d&&d.url===e.url)return void x.trace("[playlist-loader]: playlist request ongoing");x.log("[playlist-loader]: aborting previous loader for type: "+e.type),l.abort()}if(r=e.type===or?o.manifestLoadPolicy.default:X({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),l=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part&&(e.type===Qt&&e.level!==null?i=this.hls.levels[e.level].details:e.type===yt&&e.id!==null?i=this.hls.audioTracks[e.id].details:e.type===Gt&&e.id!==null&&(i=this.hls.subtitleTracks[e.id].details),i)){var u=i.partTarget,c=i.targetduration;if(u&&c){var f=1e3*Math.max(3*u,.8*c);r=X({},r,{maxTimeToFirstByteMs:Math.min(f,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,r.maxTimeToFirstByteMs)})}}var v=r.errorRetry||r.timeoutRetry||{},p={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:v.maxNumRetry||0,retryDelay:v.retryDelayMs||0,maxRetryDelay:v.maxRetryDelayMs||0},T={onSuccess:function(S,y,b,D){var w=a.getInternalLoader(b);a.resetInternalLoader(b.type);var O=S.data;O.indexOf("#EXTM3U")===0?(y.parsing.start=performance.now(),Er.isMediaPlaylist(O)?a.handleTrackOrLevelPlaylist(S,y,b,D||null,w):a.handleMasterPlaylist(S,y,b,D)):a.handleManifestParsingError(S,b,new Error("no EXTM3U delimiter"),D||null,y)},onError:function(S,y,b,D){a.handleNetworkError(y,b,!1,S,D)},onTimeout:function(S,y,b){a.handleNetworkError(y,b,!0,void 0,S)}};l.load(e,p,T)},n.handleMasterPlaylist=function(e,t,r,i){var a=this.hls,o=e.data,l=Ai(e,r),d=Er.parseMasterPlaylist(o,l);if(d.playlistParsingError)this.handleManifestParsingError(e,r,d.playlistParsingError,i,t);else{var u=d.contentSteering,c=d.levels,f=d.sessionData,v=d.sessionKeys,p=d.startTimeOffset,T=d.variableList;this.variableList=T;var S=Er.parseMasterPlaylistMedia(o,l,d),y=S.AUDIO,b=y===void 0?[]:y,D=S.SUBTITLES,w=S["CLOSED-CAPTIONS"];b.length&&(b.some(function(O){return!O.url})||!c[0].audioCodec||c[0].attrs.AUDIO||(x.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),b.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Ve({}),bitrate:0,url:""}))),a.trigger(E.MANIFEST_LOADED,{levels:c,audioTracks:b,subtitles:D,captions:w,contentSteering:u,url:l,stats:t,networkDetails:i,sessionData:f,sessionKeys:v,startTimeOffset:p,variableList:T})}},n.handleTrackOrLevelPlaylist=function(e,t,r,i,a){var o=this.hls,l=r.id,d=r.level,u=r.type,c=Ai(e,r),f=Z(l)?l:0,v=Z(d)?d:f,p=mn(r),T=Er.parseLevelPlaylist(e.data,c,v,p,f,this.variableList);if(u===or){var S={attrs:new Ve({}),bitrate:0,details:T,name:"",url:c};o.trigger(E.MANIFEST_LOADED,{levels:[S],audioTracks:[],url:c,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=T,this.handlePlaylistLoaded(T,e,t,r,i,a)},n.handleManifestParsingError=function(e,t,r,i,a){this.hls.trigger(E.ERROR,{type:Q.NETWORK_ERROR,details:F.MANIFEST_PARSING_ERROR,fatal:t.type===or,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:a})},n.handleNetworkError=function(e,t,r,i,a){r===void 0&&(r=!1);var o="A network "+(r?"timeout":"error"+(i?" (status "+i.code+")":""))+" occurred while loading "+e.type;e.type===Qt?o+=": "+e.level+" id: "+e.id:e.type!==yt&&e.type!==Gt||(o+=" id: "+e.id+' group-id: "'+e.groupId+'"');var l=new Error(o);x.warn("[playlist-loader]: "+o);var d=F.UNKNOWN,u=!1,c=this.getInternalLoader(e);switch(e.type){case or:d=r?F.MANIFEST_LOAD_TIMEOUT:F.MANIFEST_LOAD_ERROR,u=!0;break;case Qt:d=r?F.LEVEL_LOAD_TIMEOUT:F.LEVEL_LOAD_ERROR,u=!1;break;case yt:d=r?F.AUDIO_TRACK_LOAD_TIMEOUT:F.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case Gt:d=r?F.SUBTITLE_TRACK_LOAD_TIMEOUT:F.SUBTITLE_LOAD_ERROR,u=!1}c&&this.resetInternalLoader(e.type);var f={type:Q.NETWORK_ERROR,details:d,fatal:u,url:e.url,loader:c,context:e,error:l,networkDetails:t,stats:a};if(i){var v=(t==null?void 0:t.url)||e.url;f.response=H({url:v,data:void 0},i)}this.hls.trigger(E.ERROR,f)},n.handlePlaylistLoaded=function(e,t,r,i,a,o){var l=this.hls,d=i.type,u=i.level,c=i.id,f=i.groupId,v=i.deliveryDirectives,p=Ai(t,i),T=mn(i),S=typeof i.level=="number"&&T===Ne?u:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var y=e.playlistParsingError;if(y)l.trigger(E.ERROR,{type:Q.NETWORK_ERROR,details:F.LEVEL_PARSING_ERROR,fatal:!1,url:p,error:y,reason:y.message,response:t,context:i,level:S,parent:T,networkDetails:a,stats:r});else switch(e.live&&o&&(o.getCacheAge&&(e.ageHeader=o.getCacheAge()||0),o.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),d){case or:case Qt:l.trigger(E.LEVEL_LOADED,{details:e,level:S||0,id:c||0,stats:r,networkDetails:a,deliveryDirectives:v});break;case yt:l.trigger(E.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v});break;case Gt:l.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v})}}else{var b=new Error("No Segments found in Playlist");l.trigger(E.ERROR,{type:Q.NETWORK_ERROR,details:F.LEVEL_EMPTY_ERROR,fatal:!1,url:p,error:b,reason:b.message,response:t,context:i,level:S,parent:T,networkDetails:a,stats:r})}},s}();function br(s,n){var e;try{e=new Event("addtrack")}catch{(e=document.createEvent("Event")).initEvent("addtrack",!1,!1)}e.track=s,n.dispatchEvent(e)}function pn(s,n){var e=s.mode;if(e==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(n.id))try{if(s.addCue(n),!s.cues.getCueById(n.id))throw new Error("addCue is failed for: "+n)}catch(r){x.debug("[texttrack-utils]: "+r);var t=new self.TextTrackCue(n.startTime,n.endTime,n.text);t.id=n.id,s.addCue(t)}e==="disabled"&&(s.mode=e)}function lr(s){var n=s.mode;if(n==="disabled"&&(s.mode="hidden"),s.cues)for(var e=s.cues.length;e--;)s.removeCue(s.cues[e]);n==="disabled"&&(s.mode=n)}function ki(s,n,e,t){var r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0)for(var i=function(o,l,d){var u=[],c=function(T,S){if(S<T[0].startTime)return 0;var y=T.length-1;if(S>T[y].endTime)return-1;for(var b=0,D=y;b<=D;){var w=Math.floor((D+b)/2);if(S<T[w].startTime)D=w-1;else{if(!(S>T[w].startTime&&b<y))return w;b=w+1}}return T[b].startTime-S<S-T[D].startTime?b:D}(o,l);if(c>-1)for(var f=c,v=o.length;f<v;f++){var p=o[f];if(p.startTime>=l&&p.endTime<=d)u.push(p);else if(p.startTime>d)return u}return u}(s.cues,n,e),a=0;a<i.length;a++)t&&!t(i[a])||s.removeCue(i[a]);r==="disabled"&&(s.mode=r)}var _r="org.id3",Sr="com.apple.quicktime.HLS",Jt="https://aomedia.org/emsg/ID3";function Vr(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var Ar=function(){var s=Vr();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function qt(s,n){return s.getTime()/1e3-n}var Zn=function(){function s(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var n=s.prototype;return n.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},n._registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)},n._unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this)},n.onMediaAttached=function(e,t){this.media=t.media},n.onMediaDetaching=function(){this.id3Track&&(lr(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},n.onManifestLoading=function(){this.dateRangeCuesAppended={}},n.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},n.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if(r.kind==="metadata"&&r.label==="id3")return br(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},n.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(i||a){var o=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var l=Vr(),d=0;d<o.length;d++){var u=o[d].type;if((u!==Jt||i)&&a){var c=vi(o[d].data);if(c){var f=o[d].pts,v=f+o[d].duration;v>Ar&&(v=Ar),v-f<=0&&(v=f+.25);for(var p=0;p<c.length;p++){var T=c[p];if(!Qi(T)){this.updateId3CueEnds(f);var S=new l(f,v,"");S.value=T,u&&(S.type=u),this.id3Track.addCue(S)}}}}}}}},n.updateId3CueEnds=function(e){var t,r=(t=this.id3Track)==null?void 0:t.cues;if(r)for(var i=r.length;i--;){var a=r[i];a.startTime<e&&a.endTime===Ar&&(a.endTime=e)}},n.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.type,o=this.id3Track,l=this.hls;if(l){var d=l.config,u=d.enableEmsgMetadataCues,c=d.enableID3MetadataCues;o&&(u||c)&&ki(o,r,i,a==="audio"?function(f){return f.type===_r&&c}:a==="video"?function(f){return f.type===Jt&&u}:function(f){return f.type===_r&&c||f.type===Jt&&u})}},n.onLevelUpdated=function(e,t){var r=this,i=t.details;if(this.media&&i.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,o=this.id3Track,l=i.dateRanges,d=Object.keys(l);if(o)for(var u=Object.keys(a).filter(function(b){return!d.includes(b)}),c=function(){var b=u[f];Object.keys(a[b].cues).forEach(function(D){o.removeCue(a[b].cues[D])}),delete a[b]},f=u.length;f--;)c();var v=i.fragments[i.fragments.length-1];if(d.length!==0&&Z(v==null?void 0:v.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var p=v.programDateTime/1e3-v.start,T=Vr(),S=function(){var b=d[y],D=l[b],w=a[b],O=(w==null?void 0:w.cues)||{},N=(w==null?void 0:w.durationKnown)||!1,G=qt(D.startDate,p),W=Ar,q=D.endDate;if(q)W=qt(q,p),N=!0;else if(D.endOnNext&&!N){var V=d.reduce(function(ye,we){var Ce=l[we];return Ce.class===D.class&&Ce.id!==we&&Ce.startDate>D.startDate&&ye.push(Ce),ye},[]).sort(function(ye,we){return ye.startDate.getTime()-we.startDate.getTime()})[0];V&&(W=qt(V.startDate,p),N=!0)}for(var te,J,oe=Object.keys(D.attr),me=0;me<oe.length;me++){var ue=oe[me];if((J=ue)!=="ID"&&J!=="CLASS"&&J!=="START-DATE"&&J!=="DURATION"&&J!=="END-DATE"&&J!=="END-ON-NEXT"){var ve=O[ue];if(ve)N&&!w.durationKnown&&(ve.endTime=W);else{var Te=D.attr[ue];ve=new T(G,W,""),ar(ue)&&(te=Te,Te=Uint8Array.from(te.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),ve.value={key:ue,data:Te},ve.type=Sr,ve.id=b,r.id3Track.addCue(ve),O[ue]=ve}}}a[b]={cues:O,dateRange:D,durationKnown:N}},y=0;y<d.length;y++)S()}}},s}(),ea=function(){function s(e){var t=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 t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var n=s.prototype;return n.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},n.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(E.ERROR,this.onError,this)},n.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(E.ERROR,this.onError,this)},n.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},n.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},n.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},n.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},n.onError=function(e,t){var r;t.details===F.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&x.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},n.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(r!==null){this._latency=r;var i=this.config,a=i.lowLatencyMode,o=i.maxLiveSyncPlaybackRate;if(a&&o!==1){var l=this.targetLatency;if(l!==null){var d=r-l,u=d<Math.min(this.maxLatency,l+t.targetduration);if(t.live&&u&&d>.05&&this.forwardBufferLength>1){var c=Math.min(2,Math.max(1,o)),f=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,f))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}}}}},n.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},n.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},K(s,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(e===null)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,a=this.config,o=a.liveSyncDuration,l=a.liveSyncDurationCount,d=a.lowLatencyMode,u=this.hls.userConfig,c=d&&r||t;(u.liveSyncDuration||u.liveSyncDurationCount||c===0)&&(c=o!==void 0?o:l*i);var f=i;return c+Math.min(1*this.stallCount,f)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;var i=r.edge,a=e-t-this.edgeStalled,o=i-r.totalduration,l=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(o,a),l)}},{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 t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),s}(),Li=["NONE","TYPE-0","TYPE-1",null],wi="",ta="YES",ra="v2",yn=function(){function s(n,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=n,this.part=e,this.skip=t}return s.prototype.addDirectives=function(n){var e=new self.URL(n);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.href},s}(),kr=function(){function s(n){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=[n.url],this._attrs=[n.attrs],this.bitrate=n.bitrate,n.details&&(this.details=n.details),this.id=n.id||0,this.name=n.name,this.width=n.width||0,this.height=n.height||0,this.audioCodec=n.audioCodec,this.videoCodec=n.videoCodec,this.unknownCodecs=n.unknownCodecs,this.codecSet=[n.videoCodec,n.audioCodec].filter(function(e){return e}).join(",").replace(/\.[^.,]+/g,"")}return s.prototype.addFallback=function(n){this.url.push(n.url),this._attrs.push(n.attrs)},K(s,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"attrs",get:function(){return this._attrs[this._urlId]}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(n){var e=n%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}},{key:"audioGroupId",get:function(){var n;return(n=this.audioGroupIds)==null?void 0:n[this.urlId]}},{key:"textGroupId",get:function(){var n;return(n=this.textGroupIds)==null?void 0:n[this.urlId]}}]),s}();function Ri(s,n){var e=n.startPTS;if(Z(e)){var t,r=0;n.sn>s.sn?(r=e-s.start,t=s):(r=s.start-e,t=n),t.duration!==r&&(t.duration=r)}else n.sn>s.sn?s.cc===n.cc&&s.minEndPTS?n.start=s.start+(s.minEndPTS-s.start):n.start=s.start+s.duration:n.start=Math.max(s.start-n.duration,0)}function Lr(s,n,e,t,r,i){t-e<=0&&(x.warn("Fragment should have a positive duration",n),t=e+n.duration,i=r+n.duration);var a=e,o=t,l=n.startPTS,d=n.endPTS;if(Z(l)){var u=Math.abs(l-e);Z(n.deltaPTS)?n.deltaPTS=Math.max(u,n.deltaPTS):n.deltaPTS=u,a=Math.max(e,l),e=Math.min(e,l),r=Math.min(r,n.startDTS),o=Math.min(t,d),t=Math.max(t,d),i=Math.max(i,n.endDTS)}var c=e-n.start;n.start!==0&&(n.start=e),n.duration=t-n.start,n.startPTS=e,n.maxStartPTS=a,n.startDTS=r,n.endPTS=t,n.minEndPTS=o,n.endDTS=i;var f,v=n.sn;if(!s||v<s.startSN||v>s.endSN)return 0;var p=v-s.startSN,T=s.fragments;for(T[p]=n,f=p;f>0;f--)Ri(T[f],T[f-1]);for(f=p;f<T.length-1;f++)Ri(T[f],T[f+1]);return s.fragmentHint&&Ri(T[T.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,c}function Di(s,n){for(var e=null,t=s.fragments,r=t.length-1;r>=0;r--){var i=t[r].initSegment;if(i){e=i;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var a,o,l,d,u,c=0;if(function(y,b,D){for(var w=b.skippedSegments,O=Math.max(y.startSN,b.startSN)-b.startSN,N=(y.fragmentHint?1:0)+(w?b.endSN:Math.min(y.endSN,b.endSN))-b.startSN,G=b.startSN-y.startSN,W=b.fragmentHint?b.fragments.concat(b.fragmentHint):b.fragments,q=y.fragmentHint?y.fragments.concat(y.fragmentHint):y.fragments,V=O;V<=N;V++){var te=q[G+V],J=W[V];w&&!J&&V<w&&(J=b.fragments[V]=te),te&&J&&D(te,J)}}(s,n,function(y,b){y.relurl&&(c=y.cc-b.cc),Z(y.startPTS)&&Z(y.endPTS)&&(b.start=b.startPTS=y.startPTS,b.startDTS=y.startDTS,b.maxStartPTS=y.maxStartPTS,b.endPTS=y.endPTS,b.endDTS=y.endDTS,b.minEndPTS=y.minEndPTS,b.duration=y.endPTS-y.startPTS,b.duration&&(a=b),n.PTSKnown=n.alignedSliding=!0),b.elementaryStreams=y.elementaryStreams,b.loader=y.loader,b.stats=y.stats,b.urlId=y.urlId,y.initSegment&&(b.initSegment=y.initSegment,e=y.initSegment)}),e&&(n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments).forEach(function(y){var b;y.initSegment&&y.initSegment.relurl!==((b=e)==null?void 0:b.relurl)||(y.initSegment=e)}),n.skippedSegments)if(n.deltaUpdateFailed=n.fragments.some(function(y){return!y}),n.deltaUpdateFailed){x.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var f=n.skippedSegments;f--;)n.fragments.shift();n.startSN=n.fragments[0].sn,n.startCC=n.fragments[0].cc}else n.canSkipDateRanges&&(n.dateRanges=(o=s.dateRanges,l=n.dateRanges,d=n.recentlyRemovedDateranges,u=X({},o),d&&d.forEach(function(y){delete u[y]}),Object.keys(l).forEach(function(y){var b=new Me(l[y].attr,u[y]);b.isValid?u[y]=b:x.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(l[y].attr)+'"')}),u));var v=n.fragments;if(c){x.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<v.length;p++)v[p].cc+=c}n.skippedSegments&&(n.startCC=n.fragments[0].cc),function(y,b,D){if(y&&b)for(var w=0,O=0,N=y.length;O<=N;O++){var G=y[O],W=b[O+w];G&&W&&G.index===W.index&&G.fragment.sn===W.fragment.sn?D(G,W):w--}}(s.partList,n.partList,function(y,b){b.elementaryStreams=y.elementaryStreams,b.stats=y.stats}),a?Lr(n,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):Ii(s,n),v.length&&(n.totalduration=n.edge-v[0].start),n.driftStartTime=s.driftStartTime,n.driftStart=s.driftStart;var T=n.advancedDateTime;if(n.advanced&&T){var S=n.edge;n.driftStart||(n.driftStartTime=T,n.driftStart=S),n.driftEndTime=T,n.driftEnd=S}else n.driftEndTime=s.driftEndTime,n.driftEnd=s.driftEnd,n.advancedDateTime=s.advancedDateTime}function Ii(s,n){var e=n.startSN+n.skippedSegments-s.startSN,t=s.fragments;e<0||e>=t.length||wr(n,t[e].start)}function wr(s,n){if(n){for(var e=s.fragments,t=s.skippedSegments;t<e.length;t++)e[t].start+=n;s.fragmentHint&&(s.fragmentHint.start+=n)}}function Tn(s,n,e){var t;return s!=null&&s.details?En((t=s.details)==null?void 0:t.partList,n,e):null}function En(s,n,e){if(s)for(var t=s.length;t--;){var r=s[t];if(r.index===e&&r.fragment.sn===n)return r}return null}function Yr(s){switch(s.details){case F.FRAG_LOAD_TIMEOUT:case F.KEY_LOAD_TIMEOUT:case F.LEVEL_LOAD_TIMEOUT:case F.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function bn(s,n){var e=Yr(n);return s.default[(e?"timeout":"error")+"Retry"]}function Ci(s,n){var e=s.backoff==="linear"?1:Math.pow(2,n);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function _n(s){return H(H({},s),{errorRetry:null,timeoutRetry:null})}function Wr(s,n,e,t){return!!s&&n<s.maxNumRetry&&(function(r){return r===0&&navigator.onLine===!1||!!r&&(r<400||r>499)}(t)||!!e)}var Sn=function(s,n){for(var e=0,t=s.length-1,r=null,i=null;e<=t;){var a=n(i=s[r=(e+t)/2|0]);if(a>0)e=r+1;else{if(!(a<0))return i;t=r-1}}return null};function Rr(s,n,e,t){e===void 0&&(e=0),t===void 0&&(t=0);var r=null;if(s?r=n[s.sn-n[0].sn+1]||null:e===0&&n[0].start===0&&(r=n[0]),r&&zr(e,t,r)===0)return r;var i=Sn(n,zr.bind(null,e,t));return!i||i===s&&r?r:i}function zr(s,n,e){if(s===void 0&&(s=0),n===void 0&&(n=0),e.start<=s&&e.start+e.duration>s)return 0;var t=Math.min(n,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-t<=s?1:e.start-t>s&&e.start?-1:0}function Tt(s,n,e){var t=1e3*Math.min(n,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>s}var $t,ia=3e5,An=0,m=2,h=5,g=0,_=1,A=2,R=function(){function s(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=x.log.bind(x,"[info]:"),this.warn=x.warn.bind(x,"[warning]:"),this.error=x.error.bind(x,"[error]:"),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(E.ERROR,this.onError,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.ERROR,this.onError,this),e.off(E.ERROR,this.onErrorOut,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this))},n.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},n.startLoad=function(e){this.playlistError=0},n.stopLoad=function(){},n.getVariantLevelIndex=function(e){return(e==null?void 0:e.type)===Ne?e.level:this.hls.loadLevel},n.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},n.onError=function(e,t){var r;if(!t.fatal){var i=this.hls,a=t.context;switch(t.details){case F.FRAG_LOAD_ERROR:case F.FRAG_LOAD_TIMEOUT:case F.KEY_LOAD_ERROR:case F.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case F.FRAG_GAP:case F.FRAG_PARSING_ERROR:case F.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=m);case F.LEVEL_EMPTY_ERROR:case F.LEVEL_PARSING_ERROR:var o,l,d=t.parent===Ne?t.level:i.loadLevel;return void(t.details===F.LEVEL_EMPTY_ERROR&&(o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d)));case F.LEVEL_LOAD_ERROR:case F.LEVEL_LOAD_TIMEOUT:return void(typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case F.AUDIO_TRACK_LOAD_ERROR:case F.AUDIO_TRACK_LOAD_TIMEOUT:case F.SUBTITLE_LOAD_ERROR:case F.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var u=i.levels[i.loadLevel];if(u&&(a.type===yt&&a.groupId===u.audioGroupId||a.type===Gt&&a.groupId===u.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=m,void(t.errorAction.flags=_)}return;case F.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var c=i.levels[i.loadLevel],f=c==null?void 0:c.attrs["HDCP-LEVEL"];return void(f&&(t.errorAction={action:m,flags:A,hdcpLevel:f}));case F.BUFFER_ADD_CODEC_ERROR:case F.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:i.loadLevel));case F.INTERNAL_EXCEPTION:case F.BUFFER_APPENDING_ERROR:case F.BUFFER_APPEND_ERROR:case F.BUFFER_FULL_ERROR:case F.LEVEL_SWITCH_ERROR:case F.BUFFER_STALLED_ERROR:case F.BUFFER_SEEK_OVER_HOLE:case F.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:An,flags:g})}if(t.type===Q.KEY_SYSTEM_ERROR){var v=this.getVariantLevelIndex(t.frag);return t.levelRetry=!1,void(t.errorAction=this.getLevelSwitchAction(t,v))}}},n.getPlaylistRetryOrSwitchAction=function(e,t){var r,i=bn(this.hls.config.playlistLoadPolicy,e),a=this.playlistError++,o=(r=e.response)==null?void 0:r.code;if(Wr(i,a,Yr(e),o))return{action:h,flags:g,retryConfig:i,retryCount:a};var l=this.getLevelSwitchAction(e,t);return i&&(l.retryConfig=i,l.retryCount=a),l},n.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],a=t.config,o=a.fragLoadPolicy,l=a.keyLoadPolicy,d=bn(e.details.startsWith("key")?l:o,e),u=t.levels.reduce(function(p,T){return p+T.fragmentError},0);if(i){var c;e.details!==F.FRAG_GAP&&i.fragmentError++;var f=(c=e.response)==null?void 0:c.code;if(Wr(d,u,Yr(e),f))return{action:h,flags:g,retryConfig:d,retryCount:u}}var v=this.getLevelSwitchAction(e,r);return d&&(v.retryConfig=d,v.retryCount=u),v},n.getLevelSwitchAction=function(e,t){var r=this.hls;t==null&&(t=r.loadLevel);var i=this.hls.levels[t];if(i&&(i.loadError++,r.autoLevelEnabled)){for(var a,o,l=-1,d=r.levels,u=(a=e.frag)==null?void 0:a.type,c=(o=e.context)!=null?o:{},f=c.type,v=c.groupId,p=d.length;p--;){var T=(p+r.loadLevel)%d.length;if(T!==r.loadLevel&&d[T].loadError===0){var S=d[T];if(e.details===F.FRAG_GAP&&e.frag){var y=d[T].details;if(y){var b=Rr(e.frag,y.fragments,e.frag.start);if(b!=null&&b.gap)continue}}else if(f===yt&&v===S.audioGroupId||f===Gt&&v===S.textGroupId||u===kt&&i.audioGroupId===S.audioGroupId||u===It&&i.textGroupId===S.textGroupId)continue;l=T;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,{action:m,flags:g,nextAutoLevel:l}}return{action:m,flags:_}},n.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case An:break;case m:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===F.FRAG_GAP||(t.fatal=!0)}t.fatal&&this.hls.stopLoad()},n.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var i=r.flags,a=r.hdcpLevel,o=r.nextAutoLevel;switch(i){case g:this.switchLevel(e,o);break;case _:r.resolved||(r.resolved=this.redundantFailover(e));break;case A:a&&(t.maxHdcpLevel=Li[Li.indexOf(a)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(e,o)}},n.switchLevel=function(e,t){t!==void 0&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},n.redundantFailover=function(e){var t=this,r=this.hls,i=this.penalizedRenditions,a=e.parent===Ne?e.level:r.loadLevel,o=r.levels[a],l=o.url.length,d=e.frag?e.frag.urlId:o.urlId;o.urlId!==d||e.frag&&!o.details||this.penalizeRendition(o,e);for(var u=function(){var v=(d+c)%l,p=i[v];if(!p||function(T,S,y){if(performance.now()-T.lastErrorPerfMs>ia)return!0;var b=T.details;if(S.details===F.FRAG_GAP&&b&&S.frag){var D=S.frag.start,w=Rr(null,b.fragments,D);if(w&&!w.gap)return!0}if(y&&T.errors.length<y.errors.length){var O=T.errors[T.errors.length-1];if(b&&O.frag&&S.frag&&Math.abs(O.frag.start-S.frag.start)>3*b.targetduration)return!0}return!1}(p,e,i[d]))return t.warn("Switching to Redundant Stream "+(v+1)+"/"+l+': "'+o.url[v]+'" after '+e.details),t.playlistError=0,r.levels.forEach(function(T){T.urlId=v}),r.nextLoadLevel=a,{v:!0}},c=1;c<l;c++){var f=u();if(typeof f=="object")return f.v}return!1},n.penalizeRendition=function(e,t){var r=this.penalizedRenditions,i=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(t),i.details=e.details,r[e.urlId]=i},s}(),k=function(){function s(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=x.log.bind(x,t+":"),this.warn=x.warn.bind(x,t+":"),this.hls=e}var n=s.prototype;return n.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},n.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},n.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},n.stopLoad=function(){this.canLoad=!1,this.clearTimer()},n.switchParams=function(e,t){var r=t==null?void 0:t.renditionReports;if(r){for(var i=-1,a=0;a<r.length;a++){var o=r[a],l=void 0;try{l=new self.URL(o.URI,t.url).href}catch(v){x.warn("Could not construct new URL for Rendition Report: "+v),l=o.URI||""}if(l===e){i=a;break}l===e.substring(0,l.length)&&(i=a)}if(i!==-1){var d=r[i],u=parseInt(d["LAST-MSN"])||(t==null?void 0:t.lastPartSn),c=parseInt(d["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var f=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&f>t.partTarget&&(c+=1)}return new yn(u,c>=0?c:void 0,wi)}}},n.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},n.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},n.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)},n.playlistLoaded=function(e,t,r){var i=this,a=t.details,o=t.stats,l=self.performance.now(),d=o.loading.first?Math.max(0,l-o.loading.first):0;if(a.advancedDateTime=Date.now()-d,a.live||r!=null&&r.live){if(a.reloaded(r),r&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),r&&a.fragments.length>0&&Di(r,a),!this.canLoad||!a.live)return;var u,c=void 0,f=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var v=this.hls.config.lowLatencyMode,p=a.lastPartSn,T=a.endSN,S=a.lastPartIndex,y=p===T;S!==-1?(c=y?T+1:p,f=y?v?0:S:S+1):c=T+1;var b=a.age,D=b+a.ageHeader,w=Math.min(D-a.partTarget,1.5*a.targetduration);if(w>0){if(r&&w>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+w+" with playlist age: "+a.age),w=0;else{var O=Math.floor(w/a.targetduration);c+=O,f!==void 0&&(f+=Math.round(w%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+b.toFixed(2)+"s goal: "+w+" skip sn "+O+" to part "+f)}a.tuneInGoal=w}if(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,f),v||!y)return void this.loadPlaylist(u)}else a.canBlockReload&&(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,f));var N=this.hls.mainForwardBufferInfo,G=N?N.end-N.len:0,W=function(V,te){te===void 0&&(te=1/0);var J=1e3*V.targetduration;if(V.updated){var oe=V.fragments;if(oe.length&&4*J>te){var me=1e3*oe[oe.length-1].duration;me<J&&(J=me)}}else J/=2;return Math.round(J)}(a,1e3*(a.edge-G));a.updated&&l>this.requestScheduled+W&&(this.requestScheduled=o.loading.start),c!==void 0&&a.canBlockReload?this.requestScheduled=o.loading.first+W-(1e3*a.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+W<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=W);var q=this.requestScheduled-l;q=Math.max(0,q),this.log("reload live playlist "+e+" in "+Math.round(q)+" ms"),this.timer=self.setTimeout(function(){return i.loadPlaylist(u)},q)}else this.clearTimer()},n.getDeliveryDirectives=function(e,t,r,i){var a=function(o,l){var d=o.canSkipUntil,u=o.canSkipDateRanges,c=o.endSN;return d&&(l!==void 0?l-c:0)<d?u?ra:ta:wi}(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=wi),new yn(r,i,a)},n.checkRetry=function(e){var t=this,r=e.details,i=Yr(e),a=e.errorAction,o=a||{},l=o.action,d=o.retryCount,u=d===void 0?0:d,c=o.retryConfig,f=!!a&&!!c&&(l===h||!a.resolved&&l===m);if(f){var v;if(this.requestScheduled=-1,i&&(v=e.context)!=null&&v.deliveryDirectives)this.warn("Retrying playlist loading "+(u+1)+"/"+c.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var p=Ci(c,u);this.timer=self.setTimeout(function(){return t.loadPlaylist()},p),this.warn("Retrying playlist loading "+(u+1)+"/"+c.maxNumRetry+' after "'+r+'" in '+p+"ms")}e.levelRetry=!0,a.resolved=!0}return f},s}(),P=function(s){function n(t,r){var i;return(i=s.call(this,t,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}ae(n,s);var e=n.prototype;return e._registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(E.FRAG_LOADED,this.onFragLoaded,this),t.on(E.ERROR,this.onError,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(E.FRAG_LOADED,this.onFragLoaded,this),t.off(E.ERROR,this.onError,this)},e.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),s.prototype.destroy.call(this)},e.startLoad=function(){this._levels.forEach(function(t){t.loadError=0,t.fragmentError=0}),s.prototype.startLoad.call(this)},e.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},e.onManifestLoading=function(t,r){this.resetLevels()},e.onManifestLoaded=function(t,r){var i,a=[],o={};r.levels.forEach(function(l){var d,u=l.attrs;((d=l.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&($t||($t=/chrome|firefox/i.test(navigator.userAgent)),$t&&(l.audioCodec=void 0));var c=u.AUDIO,f=u.CODECS,v=u["FRAME-RATE"],p=u["PATHWAY-ID"],T=u.RESOLUTION,S=u.SUBTITLES,y=(p||".")+"-"+l.bitrate+"-"+T+"-"+v+"-"+f;(i=o[y])?i.addFallback(l):(i=new kr(l),o[y]=i,a.push(i)),U(i,"audio",c),U(i,"text",S)}),this.filterAndSortMediaOptions(a,r)},e.filterAndSortMediaOptions=function(t,r){var i=this,a=[],o=[],l=!1,d=!1,u=!1,c=t.filter(function(b){var D=b.audioCodec,w=b.videoCodec,O=b.width,N=b.height,G=b.unknownCodecs;return l||(l=!(!O||!N)),d||(d=!!w),u||(u=!!D),!(G!=null&&G.length)&&(!D||qr(D,"audio"))&&(!w||qr(w,"video"))});if((l||d)&&u&&(c=c.filter(function(b){var D=b.videoCodec,w=b.width,O=b.height;return!!D||!(!w||!O)})),c.length!==0){r.audioTracks&&M(a=r.audioTracks.filter(function(b){return!b.audioCodec||qr(b.audioCodec,"audio")})),r.subtitles&&M(o=r.subtitles);var f=c.slice(0);c.sort(function(b,D){return b.attrs["HDCP-LEVEL"]!==D.attrs["HDCP-LEVEL"]?(b.attrs["HDCP-LEVEL"]||"")>(D.attrs["HDCP-LEVEL"]||"")?1:-1:b.bitrate!==D.bitrate?b.bitrate-D.bitrate:b.attrs["FRAME-RATE"]!==D.attrs["FRAME-RATE"]?b.attrs.decimalFloatingPoint("FRAME-RATE")-D.attrs.decimalFloatingPoint("FRAME-RATE"):b.attrs.SCORE!==D.attrs.SCORE?b.attrs.decimalFloatingPoint("SCORE")-D.attrs.decimalFloatingPoint("SCORE"):l&&b.height!==D.height?b.height-D.height:0});var v=f[0];if(this.steering&&(c=this.steering.filterParsedLevels(c)).length!==f.length){for(var p=0;p<f.length;p++)if(f[p].pathwayId===c[0].pathwayId){v=f[p];break}}this._levels=c;for(var T=0;T<c.length;T++)if(c[T]===v){this._firstLevel=T,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+v.bitrate);break}var S=u&&!d,y={levels:c,audioTracks:a,subtitleTracks:o,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:u,video:d,altAudio:!S&&a.some(function(b){return!!b.url})};this.hls.trigger(E.MANIFEST_PARSED,y),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then(function(){if(i.hls){var b=new Error("no level with compatible codecs found in manifest");i.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:b,reason:b.message})}})},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===Qt&&r.context.level===this.level&&this.checkRetry(r)},e.onFragLoaded=function(t,r){var i=r.frag;if(i!==void 0&&i.type===Ne){var a=this._levels[i.level];a!==void 0&&(a.loadError=0)}},e.onLevelLoaded=function(t,r){var i,a,o=r.level,l=r.details,d=this._levels[o];if(!d)return this.warn("Invalid level index "+o),void((a=r.deliveryDirectives)!=null&&a.skip&&(l.deltaUpdateFailed=!0));o===this.currentLevelIndex?(d.fragmentError===0&&(d.loadError=0),this.playlistLoaded(o,r,d.details)):(i=r.deliveryDirectives)!=null&&i.skip&&(l.deltaUpdateFailed=!0)},e.onAudioTrackSwitched=function(t,r){var i=this.currentLevel;if(i){var a=this.hls.audioTracks[r.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==a){for(var o=-1,l=0;l<i.audioGroupIds.length;l++)if(i.audioGroupIds[l]===a){o=l;break}o!==-1&&o!==i.urlId&&(i.urlId=o,this.canLoad&&this.startLoad())}}},e.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var a=i.urlId,o=i.uri;if(t)try{o=t.addDirectives(o)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}var l=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+((t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:"")+" with"+(l?" Pathway "+l:"")+" URI "+(a+1)+"/"+i.url.length+" "+o),this.clearTimer(),this.hls.trigger(E.LEVEL_LOADING,{url:o,level:r,id:a,deliveryDirectives:t||null})}},e.removeLevel=function(t,r){var i=this,a=function(l,d){return d!==r},o=this._levels.filter(function(l,d){return d!==t||(l.url.length>1&&r!==void 0?(l.url=l.url.filter(a),l.audioGroupIds&&(l.audioGroupIds=l.audioGroupIds.filter(a)),l.textGroupIds&&(l.textGroupIds=l.textGroupIds.filter(a)),l.urlId=0,!0):(i.steering&&i.steering.removeLevel(l),!1))});this.hls.trigger(E.LEVELS_UPDATED,{levels:o})},e.onLevelsUpdated=function(t,r){var i=r.levels;i.forEach(function(a,o){var l=a.details;l!=null&&l.fragments&&l.fragments.forEach(function(d){d.level=o})}),this._levels=i},K(n,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var r=this._levels;if(r.length!==0){if(t<0||t>=r.length){var i=new Error("invalid level idx"),a=t<0;if(this.hls.trigger(E.ERROR,{type:Q.OTHER_ERROR,details:F.LEVEL_SWITCH_ERROR,level:t,fatal:a,error:i,reason:i.message}),a)return;t=Math.min(t,r.length-1)}var o=this.currentLevelIndex,l=this.currentLevel,d=l?l.attrs["PATHWAY-ID"]:void 0,u=r[t],c=u.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=u,o!==t||!u.details||!l||d!==c){this.log("Switching to level "+t+(c?" with Pathway "+c:"")+" from level "+o+(d?" with Pathway "+d:""));var f=X({},u,{level:t,maxBitrate:u.maxBitrate,attrs:u.attrs,uri:u.uri,urlId:u.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(E.LEVEL_SWITCHING,f);var v=u.details;if(!v||v.live){var p=this.switchParams(u.uri,l==null?void 0:l.details);this.loadPlaylist(p)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}]),n}(k);function U(s,n,e){e&&(n==="audio"?(s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds[s.url.length-1]=e):n==="text"&&(s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds[s.url.length-1]=e))}function M(s){var n={};s.forEach(function(e){var t=e.groupId||"";e.id=n[t]=n[t]||0,n[t]++})}var Y="NOT_LOADED",Ee="APPENDING",se="PARTIAL",de="OK",le=function(){function s(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var n=s.prototype;return n._registerListeners=function(){var e=this.hls;e.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this)},n._unregisterListeners=function(){var e=this.hls;e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this)},n.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},n.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var i=r.length;i--;){var a=r[i];if(!a)break;var o=a.end;if(a.start<=e&&o!==null&&e<=o)return a}return this.getBufferedFrag(e,t)},n.getBufferedFrag=function(e,t){for(var r=this.fragments,i=Object.keys(r),a=i.length;a--;){var o=r[i[a]];if((o==null?void 0:o.body.type)===t&&o.buffered){var l=o.body;if(l.start<=e&&e<=l.end)return l}}return null},n.detectEvictedFragments=function(e,t,r,i){var a=this;this.timeRanges&&(this.timeRanges[e]=t);var o=(i==null?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(function(l){var d=a.fragments[l];if(d&&!(o>=d.body.sn))if(d.buffered||d.loaded){var u=d.range[e];u&&u.time.some(function(c){var f=!a.isTimeBuffered(c.startPTS,c.endPTS,t);return f&&a.removeFragment(d.body),f})}else d.body.type===r&&a.removeFragment(d.body)})},n.detectPartialFragments=function(e){var t=this,r=this.timeRanges,i=e.frag,a=e.part;if(r&&i.sn!=="initSegment"){var o=De(i),l=this.fragments[o];if(l){var d=!i.relurl;Object.keys(r).forEach(function(u){var c=i.elementaryStreams[u];if(c){var f=r[u],v=d||c.partial===!0;l.range[u]=t.getBufferedTimes(i,a,v,f)}}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,l.body.endList&&(this.endListFragments[l.body.type]=l),fe(l)||this.removeParts(i.sn-1,i.type)):this.removeFragment(l.body)}}},n.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(function(i){return i.fragment.sn>=e}))},n.fragBuffered=function(e,t){var r=De(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},n.getBufferedTimes=function(e,t,r,i){for(var a={time:[],partial:r},o=e.start,l=e.end,d=e.minEndPTS||l,u=e.maxStartPTS||o,c=0;c<i.length;c++){var f=i.start(c)-this.bufferPadding,v=i.end(c)+this.bufferPadding;if(u>=f&&d<=v){a.time.push({startPTS:Math.max(o,i.start(c)),endPTS:Math.min(l,i.end(c))});break}if(o<v&&l>f)a.partial=!0,a.time.push({startPTS:Math.max(o,i.start(c)),endPTS:Math.min(l,i.end(c))});else if(l<=f)break}return a},n.getPartialFragment=function(e){var t,r,i,a=null,o=0,l=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(u){var c=d[u];c&&fe(c)&&(r=c.body.start-l,i=c.body.end+l,e>=r&&e<=i&&(t=Math.min(e-r,i-e),o<=t&&(a=c.body,o=t)))}),a},n.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||fe(t))},n.getState=function(e){var t=De(e),r=this.fragments[t];return r?r.buffered?fe(r)?se:de:Ee:Y},n.isTimeBuffered=function(e,t,r){for(var i,a,o=0;o<r.length;o++){if(i=r.start(o)-this.bufferPadding,a=r.end(o)+this.bufferPadding,e>=i&&t<=a)return!0;if(t<=i)return!1}return!1},n.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if(r.sn!=="initSegment"&&!r.bitrateTest){var a=i?null:t,o=De(r);this.fragments[o]={body:r,appendedPTS:null,loaded:a,buffered:!1,range:Object.create(null)}}},n.onBufferAppended=function(e,t){var r=this,i=t.frag,a=t.part,o=t.timeRanges;if(i.sn!=="initSegment"){var l=i.type;if(a){var d=this.activePartLists[l];d||(this.activePartLists[l]=d=[]),d.push(a)}this.timeRanges=o,Object.keys(o).forEach(function(u){var c=o[u];r.detectEvictedFragments(u,c,l,a)})}},n.onFragBuffered=function(e,t){this.detectPartialFragments(t)},n.hasFragment=function(e){var t=De(e);return!!this.fragments[t]},n.hasParts=function(e){var t;return!((t=this.activePartLists[e])==null||!t.length)},n.removeFragmentsInRange=function(e,t,r,i,a){var o=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach(function(l){var d=o.fragments[l];if(d){var u=d.body;u.type!==r||i&&!u.gap||u.start<t&&u.end>e&&(d.buffered||a)&&o.removeFragment(u)}})},n.removeFragment=function(e){var t=De(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=r.filter(function(a){return a.fragment.sn!==i})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},n.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},s}();function fe(s){var n,e,t;return s.buffered&&(s.body.gap||((n=s.range.video)==null?void 0:n.partial)||((e=s.range.audio)==null?void 0:e.partial)||((t=s.range.audiovideo)==null?void 0:t.partial))}function De(s){return s.type+"_"+s.level+"_"+s.urlId+"_"+s.sn}var $e=Math.pow(2,17),it=function(){function s(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var n=s.prototype;return n.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},n.abort=function(){this.loader&&this.loader.abort()},n.load=function(e,t){var r=this,i=e.url;if(!i)return Promise.reject(new Le({type:Q.NETWORK_ERROR,details:F.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,o=a.fLoader,l=a.loader;return new Promise(function(d,u){if(r.loader&&r.loader.destroy(),e.gap)u(pt(e));else{var c=r.loader=e.loader=o?new o(a):new l(a),f=st(e),v=_n(a.fragLoadPolicy.default),p={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:$e};e.stats=c.stats,c.load(f,p,{onSuccess:function(T,S,y,b){r.resetLoader(e,c);var D=T.data;y.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(D.slice(0,16)),D=D.slice(16)),d({frag:e,part:null,payload:D,networkDetails:b})},onError:function(T,S,y,b){r.resetLoader(e,c),u(new Le({type:Q.NETWORK_ERROR,details:F.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:H({url:i,data:void 0},T),error:new Error("HTTP Error "+T.code+" "+T.text),networkDetails:y,stats:b}))},onAbort:function(T,S,y){r.resetLoader(e,c),u(new Le({type:Q.NETWORK_ERROR,details:F.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:y,stats:T}))},onTimeout:function(T,S,y){r.resetLoader(e,c),u(new Le({type:Q.NETWORK_ERROR,details:F.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+p.timeout+"ms"),networkDetails:y,stats:T}))},onProgress:function(T,S,y,b){t&&t({frag:e,part:null,payload:y,networkDetails:b})}})}})},n.loadPart=function(e,t,r){var i=this;this.abort();var a=this.config,o=a.fLoader,l=a.loader;return new Promise(function(d,u){if(i.loader&&i.loader.destroy(),e.gap||t.gap)u(pt(e,t));else{var c=i.loader=e.loader=o?new o(a):new l(a),f=st(e,t),v=_n(a.fragLoadPolicy.default),p={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:$e};t.stats=c.stats,c.load(f,p,{onSuccess:function(T,S,y,b){i.resetLoader(e,c),i.updateStatsFromPart(e,t);var D={frag:e,part:t,payload:T.data,networkDetails:b};r(D),d(D)},onError:function(T,S,y,b){i.resetLoader(e,c),u(new Le({type:Q.NETWORK_ERROR,details:F.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:H({url:f.url,data:void 0},T),error:new Error("HTTP Error "+T.code+" "+T.text),networkDetails:y,stats:b}))},onAbort:function(T,S,y){e.stats.aborted=t.stats.aborted,i.resetLoader(e,c),u(new Le({type:Q.NETWORK_ERROR,details:F.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:y,stats:T}))},onTimeout:function(T,S,y){i.resetLoader(e,c),u(new Le({type:Q.NETWORK_ERROR,details:F.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+p.timeout+"ms"),networkDetails:y,stats:T}))}})}})},n.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,a=i.total;if(r.loaded+=i.loaded,a){var o=Math.round(e.duration/t.duration),l=Math.min(Math.round(r.loaded/a),o),d=(o-l)*Math.round(r.loaded/l);r.total=r.loaded+d}else r.total=Math.max(r.loaded,r.total);var u=r.loading,c=i.loading;u.start?u.first+=c.first-c.start:(u.start=c.start,u.first=c.first),u.end=c.end},n.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},s}();function st(s,n){n===void 0&&(n=null);var e=n||s,t={frag:s,part:n,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},r=e.byteRangeStartOffset,i=e.byteRangeEndOffset;if(Z(r)&&Z(i)){var a,o=r,l=i;if(s.sn==="initSegment"&&((a=s.decryptdata)==null?void 0:a.method)==="AES-128"){var d=i-r;d%16&&(l=i+(16-d%16)),r!==0&&(t.resetIV=!0,o=r-16)}t.rangeStart=o,t.rangeEnd=l}return t}function pt(s,n){var e=new Error("GAP "+(s.gap?"tag":"attribute")+" found"),t={type:Q.MEDIA_ERROR,details:F.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return n&&(t.part=n),(n||s).stats.aborted=!0,new Le(t)}var Le=function(s){function n(e){var t;return(t=s.call(this,e.error.message)||this).data=void 0,t.data=e,t}return ae(n,s),n}(xe(Error)),ze=function(){function s(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var n=s.prototype;return n.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){if(e&&e!==r.context.frag.type)return;r.abort()}}},n.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},n.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},n.createKeyLoadError=function(e,t,r,i,a){return t===void 0&&(t=F.KEY_LOAD_ERROR),new Le({type:Q.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:r,networkDetails:i})},n.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,a=e.cc,o=function(){var d=t[l];if(a<=d.cc&&(i==="initSegment"||d.sn==="initSegment"||i<d.sn))return r.emeController.selectKeySystemFormat(d).then(function(u){d.setKeyFormat(u)}),"break"},l=0;l<t.length&&o()!=="break";l++);},n.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(r){return t.loadInternal(e,r)}):this.loadInternal(e)},n.loadInternal=function(e,t){var r,i;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var o=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,F.KEY_LOAD_ERROR,o))}var l=a.uri;if(!l)return Promise.reject(this.createKeyLoadError(e,F.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+l+'"')));var d,u=this.keyUriToKeyInfo[l];if((r=u)!=null&&r.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if((i=u)!=null&&i.keyLoadPromise)switch((d=u.mediaKeySessionContext)==null?void 0:d.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise.then(function(c){return a.key=c.keyInfo.decryptdata.key,{frag:e,keyInfo:u}})}switch(u=this.keyUriToKeyInfo[l]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return a.keyFormat==="identity"?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,F.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+a.method+'"')))}},n.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then(function(a){return e.mediaKeySessionContext=a,r})).catch(function(a){throw e.keyLoadPromise=null,a})}return Promise.resolve(r)},n.loadKeyHTTP=function(e,t){var r=this,i=this.config,a=new i.loader(i);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise(function(o,l){var d={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},u=i.keyLoadPolicy.default,c={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:function(v,p,T,S){var y=T.frag,b=T.keyInfo,D=T.url;if(!y.decryptdata||b!==r.keyUriToKeyInfo[D])return l(r.createKeyLoadError(y,F.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),S));b.decryptdata.key=y.decryptdata.key=new Uint8Array(v.data),y.keyLoader=null,b.loader=null,o({frag:y,keyInfo:b})},onError:function(v,p,T,S){r.resetLoader(p),l(r.createKeyLoadError(t,F.KEY_LOAD_ERROR,new Error("HTTP Error "+v.code+" loading key "+v.text),T,H({url:d.url,data:void 0},v)))},onTimeout:function(v,p,T){r.resetLoader(p),l(r.createKeyLoadError(t,F.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:function(v,p,T){r.resetLoader(p),l(r.createKeyLoadError(t,F.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};a.load(d,c,f)})},n.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url,a=r.loader;t.keyLoader===a&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],a&&a.destroy()},s}(),Fe=function(){function s(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var n=s.prototype;return n.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},n.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},n.onHandlerDestroyed=function(){},n.hasInterval=function(){return!!this._tickInterval},n.hasNextTick=function(){return!!this._tickTimer},n.setInterval=function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},n.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},n.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},n.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},n.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},n.doTick=function(){},s}(),$={length:0,start:function(){return 0},end:function(){return 0}},re=function(){function s(){}return s.isBuffered=function(n,e){try{if(n){for(var t=s.getBuffered(n),r=0;r<t.length;r++)if(e>=t.start(r)&&e<=t.end(r))return!0}}catch{}return!1},s.bufferInfo=function(n,e,t){try{if(n){var r,i=s.getBuffered(n),a=[];for(r=0;r<i.length;r++)a.push({start:i.start(r),end:i.end(r)});return this.bufferedInfo(a,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},s.bufferedInfo=function(n,e,t){e=Math.max(0,e),n.sort(function(T,S){var y=T.start-S.start;return y||S.end-T.end});var r=[];if(t)for(var i=0;i<n.length;i++){var a=r.length;if(a){var o=r[a-1].end;n[i].start-o<t?n[i].end>o&&(r[a-1].end=n[i].end):r.push(n[i])}else r.push(n[i])}else r=n;for(var l,d=0,u=e,c=e,f=0;f<r.length;f++){var v=r[f].start,p=r[f].end;if(e+t>=v&&e<p)u=v,d=(c=p)-e;else if(e+t<v){l=v;break}}return{len:d,start:u||0,end:c||0,nextStart:l}},s.getBuffered=function(n){try{return n.buffered}catch(e){return x.log("failed to get media.buffered",e),$}},s}(),ie=function(s,n,e,t,r,i){t===void 0&&(t=0),r===void 0&&(r=-1),i===void 0&&(i=!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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=s,this.sn=n,this.id=e,this.size=t,this.part=r,this.partial=i};function _e(s,n){for(var e=null,t=0,r=s.length;t<r;t++){var i=s[t];if(i&&i.cc===n){e=i;break}}return e}function Ie(s,n){if(s){var e=s.start+n;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function We(s,n){for(var e=n.fragments,t=0,r=e.length;t<r;t++)Ie(e[t],s);n.fragmentHint&&Ie(n.fragmentHint,s),n.alignedSliding=!0}function ht(s,n,e){n&&(function(t,r,i){if(function(o,l,d){return!(!l.details||!(d.endCC>d.startCC||o&&o.cc<d.startCC))}(t,i,r)){var a=function(o,l,d){var u=o.fragments,c=l.fragments;if(c.length&&u.length){var f=_e(u,c[0].cc);if(f&&(!f||f.startPTS))return f;x.log("No frag in previous level to align on")}else x.log("No fragments to align")}(i.details,r);a&&Z(a.start)&&(x.log("Adjusting PTS using last level due to CC increase within current level "+r.url),We(a.start,r))}}(s,e,n),!e.alignedSliding&&n.details&&function(t,r){if(r.fragments.length&&t.hasProgramDateTime&&r.hasProgramDateTime){var i=r.fragments[0].programDateTime,a=t.fragments[0].programDateTime,o=(a-i)/1e3+r.fragments[0].start;o&&Z(o)&&(x.log("Adjusting PTS using programDateTime delta "+(a-i)+"ms, sliding:"+o.toFixed(3)+" "+t.url+" "),We(o,t))}}(e,n.details),e.alignedSliding||!n.details||e.skippedSegments||Ii(n.details,e))}function Ze(s,n){if(s.hasProgramDateTime&&n.hasProgramDateTime){var e=s.fragments,t=n.fragments;if(e.length&&t.length){var r=t[Math.round(t.length/2)-1],i=_e(e,r.cc)||e[Math.round(e.length/2)-1],a=r.programDateTime,o=i.programDateTime;a!==null&&o!==null&&We((o-a)/1e3-(i.start-r.start),s)}}}var ot=function(){function s(n,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=n,this.aesIV=e}return s.prototype.decrypt=function(n,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,n)},s}(),et=function(){function s(n,e){this.subtle=void 0,this.key=void 0,this.subtle=n,this.key=e}return s.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},s}(),tt=function(){function s(){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 n=s.prototype;return n.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},n.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],o=r[2],l=r[3],d=this.invSubMix,u=d[0],c=d[1],f=d[2],v=d[3],p=new Uint32Array(256),T=0,S=0,y=0;for(y=0;y<256;y++)p[y]=y<128?y<<1:y<<1^283;for(y=0;y<256;y++){var b=S^S<<1^S<<2^S<<3^S<<4;b=b>>>8^255&b^99,e[T]=b,t[b]=T;var D=p[T],w=p[D],O=p[w],N=257*p[b]^16843008*b;i[T]=N<<24|N>>>8,a[T]=N<<16|N>>>16,o[T]=N<<8|N>>>24,l[T]=N,N=16843009*O^65537*w^257*D^16843008*T,u[b]=N<<24|N>>>8,c[b]=N<<16|N>>>16,f[b]=N<<8|N>>>24,v[b]=N,T?(T=D^p[p[p[O^D]]],S^=p[p[S]]):T=S=1}},n.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var a=this.keySize=t.length;if(a!==4&&a!==6&&a!==8)throw new Error("Invalid aes key size="+a);var o,l,d,u,c=this.ksRows=4*(a+6+1),f=this.keySchedule=new Uint32Array(c),v=this.invKeySchedule=new Uint32Array(c),p=this.sBox,T=this.rcon,S=this.invSubMix,y=S[0],b=S[1],D=S[2],w=S[3];for(o=0;o<c;o++)o<a?d=f[o]=t[o]:(u=d,o%a==0?(u=p[(u=u<<8|u>>>24)>>>24]<<24|p[u>>>16&255]<<16|p[u>>>8&255]<<8|p[255&u],u^=T[o/a|0]<<24):a>6&&o%a==4&&(u=p[u>>>24]<<24|p[u>>>16&255]<<16|p[u>>>8&255]<<8|p[255&u]),f[o]=d=(f[o-a]^u)>>>0);for(l=0;l<c;l++)o=c-l,u=3&l?f[o]:f[o-4],v[l]=l<4||o<=4?u:y[p[u>>>24]]^b[p[u>>>16&255]]^D[p[u>>>8&255]]^w[p[255&u]],v[l]=v[l]>>>0}},n.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},n.decrypt=function(e,t,r){for(var i,a,o,l,d,u,c,f,v,p,T,S,y,b,D=this.keySize+6,w=this.invKeySchedule,O=this.invSBox,N=this.invSubMix,G=N[0],W=N[1],q=N[2],V=N[3],te=this.uint8ArrayToUint32Array_(r),J=te[0],oe=te[1],me=te[2],ue=te[3],ve=new Int32Array(e),Te=new Int32Array(ve.length),ye=this.networkToHostOrderSwap;t<ve.length;){for(v=ye(ve[t]),p=ye(ve[t+1]),T=ye(ve[t+2]),S=ye(ve[t+3]),d=v^w[0],u=S^w[1],c=T^w[2],f=p^w[3],y=4,b=1;b<D;b++)i=G[d>>>24]^W[u>>16&255]^q[c>>8&255]^V[255&f]^w[y],a=G[u>>>24]^W[c>>16&255]^q[f>>8&255]^V[255&d]^w[y+1],o=G[c>>>24]^W[f>>16&255]^q[d>>8&255]^V[255&u]^w[y+2],l=G[f>>>24]^W[d>>16&255]^q[u>>8&255]^V[255&c]^w[y+3],d=i,u=a,c=o,f=l,y+=4;i=O[d>>>24]<<24^O[u>>16&255]<<16^O[c>>8&255]<<8^O[255&f]^w[y],a=O[u>>>24]<<24^O[c>>16&255]<<16^O[f>>8&255]<<8^O[255&d]^w[y+1],o=O[c>>>24]<<24^O[f>>16&255]<<16^O[d>>8&255]<<8^O[255&u]^w[y+2],l=O[f>>>24]<<24^O[d>>16&255]<<16^O[u>>8&255]<<8^O[255&c]^w[y+3],Te[t]=ye(i^J),Te[t+1]=ye(l^oe),Te[t+2]=ye(o^me),Te[t+3]=ye(a^ue),J=v,oe=p,me=T,ue=S,t+=4}return Te.buffer},s}(),Ct=function(){function s(e,t){var r=(t===void 0?{}:t).removePKCS7Padding,i=r===void 0||r;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=e.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var n=s.prototype;return n.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},n.isSync=function(){return this.useSoftware},n.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,a,o=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=o).byteLength,(a=i&&new DataView(r.buffer).getUint8(i-1))?Wt(r,0,i-a):r):o},n.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},n.decrypt=function(e,t,r){var i=this;return this.useSoftware?new Promise(function(a,o){i.softwareDecrypt(new Uint8Array(e),t,r);var l=i.flush();l?a(l.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)},n.softwareDecrypt=function(e,t,r){var i=this.currentIV,a=this.currentResult,o=this.remainderData;this.logOnce("JS AES decrypt"),o&&(e=zt(o,e),this.remainderData=null);var l=this.getValidChunk(e);if(!l.length)return null;i&&(r=i);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new tt),d.expandKey(t);var u=a;return this.currentResult=d.decrypt(l.buffer,0,r),this.currentIV=Wt(l,-16).buffer,u||null},n.webCryptoDecrypt=function(e,t,r){var i=this,a=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new et(a,t)),this.fastAesKey.expandKey().then(function(o){return a?(i.logOnce("WebCrypto AES decrypt"),new ot(a,new Uint8Array(r)).decrypt(e.buffer,o)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(o){return x.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+o.name+": "+o.message),i.onWebCryptoError(e,t,r)})},n.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},n.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=Wt(e,0,r),this.remainderData=Wt(e,r)),t},n.logOnce=function(e){this.logEnabled&&(x.log("[decrypter]: "+e),this.logEnabled=!1)},s}(),Dr=function(s){for(var n="",e=s.length,t=0;t<e;t++)n+="["+s.start(t).toFixed(3)+"-"+s.end(t).toFixed(3)+"]";return n},rt="STOPPED",ce="IDLE",Zt="KEY_LOADING",ur="FRAG_LOADING",dr="FRAG_LOADING_WAITING_RETRY",Ir="WAITING_TRACK",er="PARSING",kn="PARSED",xi="ENDED",Xr="ERROR",Pi="WAITING_INIT_PTS",Qr="WAITING_LEVEL",na=function(s){function n(t,r,i,a,o){var l;return(l=s.call(this)||this).hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=rt,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.loadedmetadata=!1,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.onvseeking=null,l.onvended=null,l.logPrefix="",l.log=void 0,l.warn=void 0,l.playlistType=o,l.logPrefix=a,l.log=x.log.bind(x,a+":"),l.warn=x.warn.bind(x,a+":"),l.hls=t,l.fragmentLoader=new it(t.config),l.keyLoader=i,l.fragmentTracker=r,l.config=t.config,l.decrypter=new Ct(t.config),t.on(E.MANIFEST_LOADED,l.onManifestLoaded,function(d){if(d===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d}(l)),l}ae(n,s);var e=n.prototype;return e.doTick=function(){this.onTickEnd()},e.onTickEnd=function(){},e.startLoad=function(t){},e.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=rt},e._streamEnded=function(t,r){if(r.live||t.nextStart||!t.end||!this.media)return!1;var i=r.partList;if(i!=null&&i.length){var a=i[i.length-1];return re.isBuffered(this.media,a.start+a.duration/2)}var o=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)},e.getLevelDetails=function(){var t;if(this.levels&&this.levelLastLoaded!==null)return(t=this.levels[this.levelLastLoaded])==null?void 0:t.details},e.onMediaAttached=function(t,r){var i=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);var a=this.config;this.levels&&a.autoStartLoad&&this.state===rt&&this.startLoad(a.startPosition)},e.onMediaDetaching=function(){var t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.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()},e.onMediaSeeking=function(){var t=this.config,r=this.fragCurrent,i=this.media,a=this.mediaBuffer,o=this.state,l=i?i.currentTime:0,d=re.bufferInfo(a||i,l,t.maxBufferHole);if(this.log("media seeking to "+(Z(l)?l.toFixed(3):l)+", state: "+o),this.state===xi)this.resetLoadingState();else if(r){var u=t.maxFragLookUpTolerance,c=r.start-u,f=r.start+r.duration+u;if(!d.len||f<d.start||c>d.end){var v=l>f;(l<c||v)&&(v&&r.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(l,1/0,this.playlistType,!0),this.lastCurrentTime=l),this.loadedmetadata||d.len||(this.nextLoadPosition=this.startPosition=l),this.tickImmediate()},e.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},e.onManifestLoaded=function(t,r){this.startTimeOffset=r.startTimeOffset,this.initPTS=[]},e.onHandlerDestroying=function(){this.stopLoad(),s.prototype.onHandlerDestroying.call(this)},e.onHandlerDestroyed=function(){this.state=rt,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,s.prototype.onHandlerDestroyed.call(this)},e.loadFragment=function(t,r,i){this._loadFragForPlayback(t,r,i)},e._loadFragForPlayback=function(t,r,i){var a=this;this._doFragLoad(t,r,i,function(o){if(a.fragContextChanged(t))return a.warn("Fragment "+t.sn+(o.part?" p: "+o.part.index:"")+" of level "+t.level+" was dropped during download."),void a.fragmentTracker.removeFragment(t);t.stats.chunkCount++,a._handleFragmentLoadProgress(o)}).then(function(o){if(o){var l=a.state;a.fragContextChanged(t)?(l===ur||!a.fragCurrent&&l===er)&&(a.fragmentTracker.removeFragment(t),a.state=ce):("payload"in o&&(a.log("Loaded fragment "+t.sn+" of level "+t.level),a.hls.trigger(E.FRAG_LOADED,o)),a._handleFragmentLoadComplete(o))}}).catch(function(o){a.state!==rt&&a.state!==Xr&&(a.warn(o),a.resetFragmentLoading(t))})},e.clearTrackerIfNeeded=function(t){var r,i=this.fragmentTracker;if(i.getState(t)===Ee){var a=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,a),l=Math.max(t.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(l)&&i.removeFragment(t)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===se&&i.removeFragment(t))},e.flushMainBuffer=function(t,r,i){if(i===void 0&&(i=null),t-r){var a={startOffset:t,endOffset:r,type:i};this.hls.trigger(E.BUFFER_FLUSHING,a)}},e._loadInitSegment=function(t,r){var i=this;this._doFragLoad(t,r).then(function(a){if(!a||i.fragContextChanged(t)||!i.levels)throw new Error("init load aborted");return a}).then(function(a){var o=i.hls,l=a.payload,d=t.decryptdata;if(l&&l.byteLength>0&&d&&d.key&&d.iv&&d.method==="AES-128"){var u=self.performance.now();return i.decrypter.decrypt(new Uint8Array(l),d.key.buffer,d.iv.buffer).catch(function(c){throw o.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_DECRYPT_ERROR,fatal:!1,error:c,reason:c.message,frag:t}),c}).then(function(c){var f=self.performance.now();return o.trigger(E.FRAG_DECRYPTED,{frag:t,payload:c,stats:{tstart:u,tdecrypt:f}}),a.payload=c,a})}return a}).then(function(a){var o=i.fragCurrent,l=i.hls;if(!i.levels)throw new Error("init load aborted, missing levels");var d=t.stats;i.state=ce,r.fragmentError=0,t.data=new Uint8Array(a.payload),d.parsing.start=d.buffering.start=self.performance.now(),d.parsing.end=d.buffering.end=self.performance.now(),a.frag===o&&l.trigger(E.FRAG_BUFFERED,{stats:d,frag:o,part:null,id:t.type}),i.tick()}).catch(function(a){i.state!==rt&&i.state!==Xr&&(i.warn(a),i.resetFragmentLoading(t))})},e.fragContextChanged=function(t){var r=this.fragCurrent;return!t||!r||t.level!==r.level||t.sn!==r.sn||t.urlId!==r.urlId},e.fragBufferedComplete=function(t,r){var i,a,o,l,d=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+(this.playlistType===Ne?"level":"track")+" "+t.level+" (frag:["+((i=t.startPTS)!=null?i:NaN).toFixed(3)+"-"+((a=t.endPTS)!=null?a:NaN).toFixed(3)+"] > buffer:"+(d?Dr(re.getBuffered(d)):"(detached)")+")"),this.state=ce,d&&(!this.loadedmetadata&&t.type==Ne&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},e.seekToStartPos=function(){},e._handleFragmentLoadComplete=function(t){var r=this.transmuxer;if(r){var i=t.frag,a=t.part,o=t.partsLoaded,l=!o||o.length===0||o.some(function(u){return!u}),d=new ie(i.level,i.sn,i.stats.chunkCount+1,0,a?a.index:-1,!l);r.flush(d)}},e._handleFragmentLoadProgress=function(t){},e._doFragLoad=function(t,r,i,a){var o,l=this;i===void 0&&(i=null);var d=r==null?void 0:r.details;if(!this.levels||!d)throw new Error("frag load aborted, missing level"+(d?"":" detail")+"s");var u=null;if(!t.encrypted||(o=t.decryptdata)!=null&&o.key?!t.encrypted&&d.encryptedFragments.length&&this.keyLoader.loadClear(t,d.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+d.startSN+"-"+d.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=Zt,this.fragCurrent=t,u=this.keyLoader.load(t).then(function(y){if(!l.fragContextChanged(y.frag))return l.hls.trigger(E.KEY_LOADED,y),l.state===Zt&&(l.state=ce),y}),this.hls.trigger(E.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(u=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){var c=d.partList;if(c&&a){i>t.end&&d.fragmentHint&&(t=d.fragmentHint);var f=this.getNextPart(c,t,i);if(f>-1){var v,p=c[f];return this.log("Loading part sn: "+t.sn+" p: "+p.index+" cc: "+t.cc+" of playlist ["+d.startSN+"-"+d.endSN+"] parts [0-"+f+"-"+(c.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=p.start+p.duration,this.state=ur,v=u?u.then(function(y){return!y||l.fragContextChanged(y.frag)?null:l.doFragPartsLoad(t,p,r,a)}).catch(function(y){return l.handleFragLoadError(y)}):this.doFragPartsLoad(t,p,r,a).catch(function(y){return l.handleFragLoadError(y)}),this.hls.trigger(E.FRAG_LOADING,{frag:t,part:p,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):v}if(!t.url||this.loadedEndOfParts(c,i))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(d?"of ["+d.startSN+"-"+d.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),Z(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=ur;var T,S=this.config.progressive;return T=S&&u?u.then(function(y){return!y||l.fragContextChanged(y==null?void 0:y.frag)?null:l.fragmentLoader.load(t,a)}).catch(function(y){return l.handleFragLoadError(y)}):Promise.all([this.fragmentLoader.load(t,S?a:void 0),u]).then(function(y){var b=y[0];return!S&&b&&a&&a(b),b}).catch(function(y){return l.handleFragLoadError(y)}),this.hls.trigger(E.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):T},e.doFragPartsLoad=function(t,r,i,a){var o=this;return new Promise(function(l,d){var u,c=[],f=(u=i.details)==null?void 0:u.partList;(function v(p){o.fragmentLoader.loadPart(t,p,a).then(function(T){c[p.index]=T;var S=T.part;o.hls.trigger(E.FRAG_LOADED,T);var y=Tn(i,t.sn,p.index+1)||En(f,t.sn,p.index+1);if(!y)return l({frag:t,part:S,partsLoaded:c});v(y)}).catch(d)})(r)})},e.handleFragLoadError=function(t){if("data"in t){var r=t.data;t.data&&r.details===F.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(E.ERROR,r)}else this.hls.trigger(E.ERROR,{type:Q.OTHER_ERROR,details:F.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},e._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(r&&this.state===er){var i=r.frag,a=r.part,o=r.level,l=self.performance.now();i.stats.parsing.end=l,a&&(a.stats.parsing.end=l),this.updateLevelTiming(i,a,o,t.partial)}else this.fragCurrent||this.state===rt||this.state===Xr||(this.state=ce)},e.getCurrentContext=function(t){var r=this.levels,i=this.fragCurrent,a=t.level,o=t.sn,l=t.part;if(r==null||!r[a])return this.warn("Levels object was unset while buffering fragment "+o+" of level "+a+". The current chunk will not be buffered."),null;var d=r[a],u=l>-1?Tn(d,o,l):null,c=u?u.fragment:function(f,v,p){if(f==null||!f.details)return null;var T=f.details,S=T.fragments[v-T.startSN];return S||((S=T.fragmentHint)&&S.sn===v?S:v<T.startSN&&p&&p.sn===v?p:null)}(d,o,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:u,level:d}):null},e.bufferFragmentData=function(t,r,i,a){var o;if(t&&this.state===er){var l=t.data1,d=t.data2,u=l;if(l&&d&&(u=zt(l,d)),(o=u)!=null&&o.length){var c={type:t.type,frag:r,part:i,chunkMeta:a,parent:r.type,data:u};this.hls.trigger(E.BUFFER_APPENDING,c),t.dropped&&t.independent&&!i&&this.flushBufferGap(r)}}},e.flushBufferGap=function(t){var r=this.media;if(r)if(re.isBuffered(r,r.currentTime)){var i=r.currentTime,a=re.bufferInfo(r,i,0),o=t.duration,l=Math.min(2*this.config.maxFragLookUpTolerance,.25*o),d=Math.max(Math.min(t.start-l,a.end-l),i+l);t.start-d>l&&this.flushMainBuffer(d,t.start)}else this.flushMainBuffer(0,t.start)},e.getFwdBufferInfo=function(t,r){var i=this.getLoadPosition();return Z(i)?this.getFwdBufferInfoAtPos(t,i,r):null},e.getFwdBufferInfoAtPos=function(t,r,i){var a=this.config.maxBufferHole,o=re.bufferInfo(t,r,a);if(o.len===0&&o.nextStart!==void 0){var l=this.fragmentTracker.getBufferedFrag(r,i);if(l&&o.nextStart<l.end)return re.bufferInfo(t,r,Math.max(o.nextStart,a))}return o},e.getMaxBufferLength=function(t){var r,i=this.config;return r=t?Math.max(8*i.maxBufferSize/t,i.maxBufferLength):i.maxBufferLength,Math.min(r,i.maxMaxBufferLength)},e.reduceMaxBufferLength=function(t){var r=this.config,i=t||r.maxBufferLength;return r.maxMaxBufferLength>=i&&(r.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+r.maxMaxBufferLength+"s"),!0)},e.getAppendedFrag=function(t,r){var i=this.fragmentTracker.getAppendedFrag(t,Ne);return i&&"fragment"in i?i.fragment:i},e.getNextFragment=function(t,r){var i=r.fragments,a=i.length;if(!a)return null;var o,l=this.config,d=i[0].start;if(r.live){var u=l.initialLiveManifestSize;if(a<u)return this.warn("Not enough fragments to start playback (have: "+a+", need: "+u+")"),null;r.PTSKnown||this.startFragRequested||this.startPosition!==-1||(o=this.getInitialLiveFragment(r,i),this.startPosition=o?this.hls.liveSyncPosition||o.start:t)}else t<=d&&(o=i[0]);if(!o){var c=l.lowLatencyMode?r.partEnd:r.fragmentEnd;o=this.getFragmentAtPosition(t,c,r)}return this.mapToInitFragWhenRequired(o)},e.isLoopLoading=function(t,r){var i=this.fragmentTracker.getState(t);return(i===de||i===se&&!!t.gap)&&this.nextLoadPosition>r},e.getNextFragmentLoopLoading=function(t,r,i,a,o){var l=t.gap,d=this.getNextFragment(this.nextLoadPosition,r);if(d===null)return d;if(t=d,l&&t&&!t.gap&&i.nextStart){var u=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,a);if(u!==null&&i.len+u.len>=o)return this.log('buffer full after gaps in "'+a+'" playlist starting at sn: '+t.sn),null}return t},e.mapToInitFragWhenRequired=function(t){return t==null||!t.initSegment||t!=null&&t.initSegment.data||this.bitrateTest?t:t.initSegment},e.getNextPart=function(t,r,i){for(var a=-1,o=!1,l=!0,d=0,u=t.length;d<u;d++){var c=t[d];if(l=l&&!c.independent,a>-1&&i<c.start)break;var f=c.loaded;f?a=-1:(o||c.independent||l)&&c.fragment===r&&(a=d),o=f}return a},e.loadedEndOfParts=function(t,r){var i=t[t.length-1];return i&&r>i.start&&i.loaded},e.getInitialLiveFragment=function(t,r){var i=this.fragPrevious,a=null;if(i){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),a=function(u,c,f){if(c===null||!Array.isArray(u)||!u.length||!Z(c)||c<(u[0].programDateTime||0)||c>=(u[u.length-1].endProgramDateTime||0))return null;f=f||0;for(var v=0;v<u.length;++v){var p=u[v];if(Tt(c,f,p))return p}return null}(r,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!a){var o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){var l=r[o-t.startSN];i.cc===l.cc&&(a=l,this.log("Live playlist, switching playlist, load frag with next SN: "+a.sn))}a||(a=function(u,c){return Sn(u,function(f){return f.cc<c?1:f.cc>c?-1:0})}(r,i.cc),a&&this.log("Live playlist, switching playlist, load frag with same CC: "+a.sn))}}else{var d=this.hls.liveSyncPosition;d!==null&&(a=this.getFragmentAtPosition(d,this.bitrateTest?t.fragmentEnd:t.edge,t))}return a},e.getFragmentAtPosition=function(t,r,i){var a,o=this.config,l=this.fragPrevious,d=i.fragments,u=i.endSN,c=i.fragmentHint,f=o.maxFragLookUpTolerance,v=i.partList,p=!!(o.lowLatencyMode&&v!=null&&v.length&&c);if(p&&c&&!this.bitrateTest&&(d=d.concat(c),u=c.sn),a=t<r?Rr(l,d,t,t>r-f?0:f):d[d.length-1]){var T=a.sn-i.startSN,S=this.fragmentTracker.getState(a);if((S===de||S===se&&a.gap)&&(l=a),l&&a.sn===l.sn&&(!p||v[0].fragment.sn>a.sn)&&l&&a.level===l.level){var y=d[T+1];a=a.sn<u&&this.fragmentTracker.getState(y)!==de?y:null}}return a},e.synchronizeToLiveEdge=function(t){var r=this.config,i=this.media;if(i){var a=this.hls.liveSyncPosition,o=i.currentTime,l=t.fragments[0].start,d=t.edge,u=o>=l-r.maxFragLookUpTolerance&&o<=d;if(a!==null&&i.duration>a&&(o<a||!u)){var c=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;(!u&&i.readyState<4||o<d-c)&&(this.loadedmetadata||(this.nextLoadPosition=a),i.readyState&&(this.warn("Playback: "+o.toFixed(3)+" is located too far from the end of live sliding playlist: "+d+", reset currentTime to : "+a.toFixed(3)),i.currentTime=a))}}},e.alignPlaylists=function(t,r){var i=this.levels,a=this.levelLastLoaded,o=this.fragPrevious,l=a!==null?i[a]:null,d=t.fragments.length;if(!d)return this.warn("No fragments in live playlist"),0;var u=t.fragments[0].start,c=!r,f=t.alignedSliding&&Z(u);if(c||!f&&!u){ht(o,l,t);var v=t.fragments[0].start;return this.log("Live playlist sliding: "+v.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+t.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+d),v}return u},e.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},e.setStartPosition=function(t,r){var i=this.startPosition;if(i<r&&(i=-1),i===-1||this.lastCurrentTime===-1){var a=this.startTimeOffset!==null,o=a?this.startTimeOffset:t.startTimeOffset;o!==null&&Z(o)?(i=r+o,o<0&&(i+=t.totalduration),i=Math.min(Math.max(r,i),r+t.totalduration),this.log("Start time offset "+o+" found in "+(a?"multivariant":"media")+" playlist, adjust startPosition to "+i),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||r:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i},e.getLoadPosition=function(){var t=this.media,r=0;return this.loadedmetadata&&t?r=t.currentTime:this.nextLoadPosition&&(r=this.nextLoadPosition),r},e.handleFragLoadAborted=function(t,r){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},e.resetFragmentLoading=function(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===dr)||(this.state=ce)},e.onFragmentOrKeyLoadError=function(t,r){if(r.chunkMeta&&!r.frag){var i=this.getCurrentContext(r.chunkMeta);i&&(r.frag=i.frag)}var a=r.frag;if(a&&a.type===t&&this.levels)if(this.fragContextChanged(a)){var o;this.warn("Frag load error must match current frag to retry "+a.url+" > "+((o=this.fragCurrent)==null?void 0:o.url))}else{var l=r.details===F.FRAG_GAP;l&&this.fragmentTracker.fragBuffered(a,!0);var d=r.errorAction,u=d||{},c=u.action,f=u.retryCount,v=f===void 0?0:f,p=u.retryConfig;if(d&&c===h&&p){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var T=Ci(p,v);this.warn("Fragment "+a.sn+" of "+t+" "+a.level+" errored with "+r.details+", retrying loading "+(v+1)+"/"+p.maxNumRetry+" in "+T+"ms"),d.resolved=!0,this.retryDate=self.performance.now()+T,this.state=dr}else p&&d?(this.resetFragmentErrors(t),v<p.maxNumRetry?l||(d.resolved=!0):x.warn(r.details+" reached or exceeded max retry ("+v+")")):this.state=Xr;this.tickImmediate()}},e.reduceLengthAndFlushBuffer=function(t){if(this.state===er||this.state===kn){var r=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),a=i&&i.len>.5;a&&this.reduceMaxBufferLength(i.len);var o=!a;return o&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+r+" buffer"),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),o}return!1},e.resetFragmentErrors=function(t){t===kt&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==rt&&(this.state=ce)},e.afterBufferFlushed=function(t,r,i){if(t){var a=re.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,a,i),this.state===xi&&this.resetLoadingState()}},e.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=ce},e.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var r=this.levels?this.levels[t].details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},e.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(t.level),this.resetLoadingState()},e.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},e.updateLevelTiming=function(t,r,i,a){var o,l=this,d=i.details;if(d){if(Object.keys(t.elementaryStreams).reduce(function(c,f){var v=t.elementaryStreams[f];if(v){var p=v.endPTS-v.startPTS;if(p<=0)return l.warn("Could not parse fragment "+t.sn+" "+f+" duration reliably ("+p+")"),c||!1;var T=a?0:Lr(d,t,v.startPTS,v.endPTS,v.startDTS,v.endDTS);return l.hls.trigger(E.LEVEL_PTS_UPDATED,{details:d,level:i,drift:T,type:f,frag:t,start:v.startPTS,end:v.endPTS}),!0}return c},!1))i.fragmentError=0;else if(((o=this.transmuxer)==null?void 0:o.error)===null){var u=new Error("Found no media in fragment "+t.sn+" of level "+i.id+" resetting transmuxer to fallback to playlist timing");if(this.warn(u.message),this.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,fatal:!1,error:u,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+i.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=kn,this.hls.trigger(E.FRAG_PARSED,{frag:t,part:r})}else this.warn("level.details undefined")},e.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},e.recoverWorkerError=function(t){t.event==="demuxerWorker"&&(this.resetTransmuxer(),this.resetLoadingState())},K(n,[{key:"state",get:function(){return this._state},set:function(t){var r=this._state;r!==t&&(this._state=t,this.log(r+"->"+t))}}]),n}(Fe);function Qa(){return self.SourceBuffer||self.WebKitSourceBuffer}function jt(s,n){return s===void 0&&(s=""),n===void 0&&(n=9e4),{type:s,id:-1,pid:-1,inputTimeScale:n,sequenceNumber:-1,samples:[],dropped:0}}var Ja=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 n=s.prototype;return n.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},n.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},n.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},n.canParse=function(e,t){return!1},n.appendFrame=function(e,t,r){},n.demux=function(e,t){this.cachedData&&(e=zt(this.cachedData,e),this.cachedData=null);var r,i=mr(e,0),a=i?i.length:0,o=this._audioTrack,l=this._id3Track,d=i?function(v){for(var p=vi(v),T=0;T<p.length;T++){var S=p[T];if(Qi(S))return Zi(S)}}(i):void 0,u=e.length;for((this.basePTS===null||this.frameIndex===0&&Z(d))&&(this.basePTS=Co(d,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:_r,duration:Number.POSITIVE_INFINITY});a<u;){if(this.canParse(e,a)){var c=this.appendFrame(o,e,a);c?(this.frameIndex++,this.lastPTS=c.sample.pts,r=a+=c.length):a=u}else Xi(e,a)?(i=mr(e,a),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:_r,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===u&&r!==u){var f=Wt(e,r);this.cachedData?this.cachedData=zt(this.cachedData,f):this.cachedData=f}}return{audioTrack:o,videoTrack:jt(),id3Track:l,textTrack:jt()}},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},n.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:jt(),id3Track:this._id3Track,textTrack:jt()}},n.destroy=function(){},s}(),Co=function(s,n,e){return Z(s)?90*s:9e4*n+(e?9e4*e.baseTime/e.timescale:0)};function $a(s,n){return s[n]===255&&(246&s[n+1])==240}function Za(s,n){return 1&s[n+1]?7:9}function aa(s,n){return(3&s[n+3])<<11|s[n+4]<<3|(224&s[n+5])>>>5}function Ln(s,n){return n+1<s.length&&$a(s,n)}function xo(s,n){if(Ln(s,n)){var e=Za(s,n);if(n+e>=s.length)return!1;var t=aa(s,n);if(t<=e)return!1;var r=n+t;return r===s.length||Ln(s,r)}return!1}function es(s,n,e,t,r){if(!s.samplerate){var i=function(a,o,l,d){var u,c,f,v,p=navigator.userAgent.toLowerCase(),T=d,S=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];u=1+((192&o[l+2])>>>6);var y=(60&o[l+2])>>>2;if(!(y>S.length-1))return f=(1&o[l+2])<<2,f|=(192&o[l+3])>>>6,x.log("manifest codec:"+d+", ADTS type:"+u+", samplingIndex:"+y),/firefox/i.test(p)?y>=6?(u=5,v=new Array(4),c=y-3):(u=2,v=new Array(2),c=y):p.indexOf("android")!==-1?(u=2,v=new Array(2),c=y):(u=5,v=new Array(4),d&&(d.indexOf("mp4a.40.29")!==-1||d.indexOf("mp4a.40.5")!==-1)||!d&&y>=6?c=y-3:((d&&d.indexOf("mp4a.40.2")!==-1&&(y>=6&&f===1||/vivaldi/i.test(p))||!d&&f===1)&&(u=2,v=new Array(2)),c=y)),v[0]=u<<3,v[0]|=(14&y)>>1,v[1]|=(1&y)<<7,v[1]|=f<<3,u===5&&(v[1]|=(14&c)>>1,v[2]=(1&c)<<7,v[2]|=8,v[3]=0),{config:v,samplerate:S[y],channelCount:f,codec:"mp4a.40."+u,manifestCodec:T};a.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+y})}(n,e,t,r);if(!i)return;s.config=i.config,s.samplerate=i.samplerate,s.channelCount=i.channelCount,s.codec=i.codec,s.manifestCodec=i.manifestCodec,x.log("parsed codec:"+s.codec+", rate:"+i.samplerate+", channels:"+i.channelCount)}}function ts(s){return 9216e4/s}function rs(s,n,e,t,r){var i,a=t+r*ts(s.samplerate),o=function(p,T){var S=Za(p,T);if(T+S<=p.length){var y=aa(p,T)-S;if(y>0)return{headerLength:S,frameLength:y}}}(n,e);if(o){var l=o.frameLength,d=o.headerLength,u=d+l,c=Math.max(0,e+u-n.length);c?(i=new Uint8Array(u-d)).set(n.subarray(e+d,n.length),0):i=n.subarray(e+d,e+u);var f={unit:i,pts:a};return c||s.samples.push(f),{sample:f,length:u,missing:c}}var v=n.length-e;return(i=new Uint8Array(v)).set(n.subarray(e,n.length),0),{sample:{unit:i,pts:a},length:v,missing:-1}}var Po=function(s){function n(t,r){var i;return(i=s.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}ae(n,s);var e=n.prototype;return e.resetInitSegment=function(t,r,i,a){s.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var r=(mr(t,0)||[]).length,i=t.length;r<i;r++)if(xo(t,r))return x.log("ADTS sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return function(o,l){return l+5<o.length}(i,a)&&$a(i,a)&&aa(i,a)<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){es(t,this.observer,r,i,t.manifestCodec);var a=rs(t,r,i,this.basePTS,this.frameIndex);if(a&&a.missing===0)return a},n}(Ja),Oo=/\/emsg[-/]ID3/i,Mo=function(){function s(e,t){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=t}var n=s.prototype;return n.resetTimeStamp=function(){},n.resetInitSegment=function(e,t,r,i){var a=this.videoTrack=jt("video",1),o=this.audioTrack=jt("audio",1),l=this.txtTrack=jt("text",1);if(this.id3Track=jt("id3",1),this.timeOffset=0,e!=null&&e.byteLength){var d=pi(e);if(d.video){var u=d.video,c=u.id,f=u.timescale,v=u.codec;a.id=c,a.timescale=l.timescale=f,a.codec=v}if(d.audio){var p=d.audio,T=p.id,S=p.timescale,y=p.codec;o.id=T,o.timescale=S,o.codec=y}l.id=en.text,a.sampleDuration=0,a.duration=o.duration=i}},n.resetContiguity=function(){this.remainderData=null},s.probe=function(e){return Pe(e=e.length>16384?e.subarray(0,16384):e,["moof"]).length>0},n.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=zt(this.remainderData,e));var o=function(d){var u={valid:null,remainder:null},c=Pe(d,["moof"]);if(!c)return u;if(c.length<2)return u.remainder=d,u;var f=c[c.length-1];return u.valid=Wt(d,0,f.byteOffset-8),u.remainder=Wt(d,f.byteOffset-8),u}(r);this.remainderData=o.remainder,i.samples=o.valid||new Uint8Array}else i.samples=r;var l=this.extractID3Track(i,t);return a.samples=Ti(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}},n.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=Ti(e,t),{videoTrack:t,audioTrack:jt(),id3Track:i,textTrack:jt()}},n.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=Pe(e.samples,["emsg"]);i&&i.forEach(function(a){var o=function(c){var f=c[0],v="",p="",T=0,S=0,y=0,b=0,D=0,w=0;if(f===0){for(;Qe(c.subarray(w,w+1))!=="\0";)v+=Qe(c.subarray(w,w+1)),w+=1;for(v+=Qe(c.subarray(w,w+1)),w+=1;Qe(c.subarray(w,w+1))!=="\0";)p+=Qe(c.subarray(w,w+1)),w+=1;p+=Qe(c.subarray(w,w+1)),w+=1,T=Se(c,12),S=Se(c,16),b=Se(c,20),D=Se(c,24),w=28}else if(f===1){T=Se(c,w+=4);var O=Se(c,w+=4),N=Se(c,w+=4);for(w+=4,y=Math.pow(2,32)*O+N,Number.isSafeInteger(y)||(y=Number.MAX_SAFE_INTEGER,x.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),b=Se(c,w),D=Se(c,w+=4),w+=4;Qe(c.subarray(w,w+1))!=="\0";)v+=Qe(c.subarray(w,w+1)),w+=1;for(v+=Qe(c.subarray(w,w+1)),w+=1;Qe(c.subarray(w,w+1))!=="\0";)p+=Qe(c.subarray(w,w+1)),w+=1;p+=Qe(c.subarray(w,w+1)),w+=1}return{schemeIdUri:v,value:p,timeScale:T,presentationTime:y,presentationTimeDelta:S,eventDuration:b,id:D,payload:c.subarray(w,c.byteLength)}}(a);if(Oo.test(o.schemeIdUri)){var l=Z(o.presentationTime)?o.presentationTime/o.timeScale:t+o.presentationTimeDelta/o.timeScale,d=o.eventDuration===4294967295?Number.POSITIVE_INFINITY:o.eventDuration/o.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);var u=o.payload;r.samples.push({data:u,len:u.byteLength,dts:l,pts:l,type:Jt,duration:d})}})}return r},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},n.destroy=function(){},s}(),wn=null,Fo=[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],No=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Uo=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Bo=[0,1,1,4];function is(s,n,e,t,r){if(!(e+24>n.length)){var i=ns(n,e);if(i&&e+i.frameLength<=n.length){var a=t+r*(9e4*i.samplesPerFrame/i.sampleRate),o={unit:n.subarray(e,e+i.frameLength),pts:a,dts:a};return s.config=[],s.channelCount=i.channelCount,s.samplerate=i.sampleRate,s.samples.push(o),{sample:o,length:i.frameLength,missing:0}}}}function ns(s,n){var e=s[n+1]>>3&3,t=s[n+1]>>1&3,r=s[n+2]>>4&15,i=s[n+2]>>2&3;if(e!==1&&r!==0&&r!==15&&i!==3){var a=s[n+2]>>1&1,o=s[n+3]>>6,l=1e3*Fo[14*(e===3?3-t:t===3?3:4)+r-1],d=No[3*(e===3?0:e===2?1:2)+i],u=o===3?1:2,c=Uo[e][t],f=Bo[t],v=8*c*f,p=Math.floor(c*l/d+a)*f;if(wn===null){var T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);wn=T?parseInt(T[1]):0}return!!wn&&wn<=87&&t===2&&l>=224e3&&o===0&&(s[n+3]=128|s[n+3]),{sampleRate:d,channelCount:u,frameLength:p,samplesPerFrame:v}}}function sa(s,n){return s[n]===255&&(224&s[n+1])==224&&(6&s[n+1])!=0}function as(s,n){return n+1<s.length&&sa(s,n)}function Go(s,n){if(n+1<s.length&&sa(s,n)){var e=ns(s,n),t=4;e!=null&&e.frameLength&&(t=e.frameLength);var r=n+t;return r===s.length||as(s,r)}return!1}var ss=function(){function s(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var n=s.prototype;return n.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),a=Math.min(4,t);if(a===0)throw new Error("no bytes available");i.set(e.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a},n.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},n.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&x.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},n.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!=0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},n.skipUEG=function(){this.skipBits(1+this.skipLZ())},n.skipEG=function(){this.skipBits(1+this.skipLZ())},n.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},n.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},n.readBoolean=function(){return this.readBits(1)===1},n.readUByte=function(){return this.readBits(8)},n.readUShort=function(){return this.readBits(16)},n.readUInt=function(){return this.readBits(32)},n.skipScalingList=function(e){for(var t=8,r=8,i=0;i<e;i++)r!==0&&(r=(t+this.readEG()+256)%256),t=r===0?t:r},n.readSPS=function(){var e,t,r,i=0,a=0,o=0,l=0,d=this.readUByte.bind(this),u=this.readBits.bind(this),c=this.readUEG.bind(this),f=this.readBoolean.bind(this),v=this.skipBits.bind(this),p=this.skipEG.bind(this),T=this.skipUEG.bind(this),S=this.skipScalingList.bind(this);d();var y=d();if(u(5),v(3),d(),T(),y===100||y===110||y===122||y===244||y===44||y===83||y===86||y===118||y===128){var b=c();if(b===3&&v(1),T(),T(),v(1),f())for(t=b!==3?8:12,r=0;r<t;r++)f()&&S(r<6?16:64)}T();var D=c();if(D===0)c();else if(D===1)for(v(1),p(),p(),e=c(),r=0;r<e;r++)p();T(),v(1);var w=c(),O=c(),N=u(1);N===0&&v(1),v(1),f()&&(i=c(),a=c(),o=c(),l=c());var G=[1,1];if(f()&&f())switch(d()){case 1:G=[1,1];break;case 2:G=[12,11];break;case 3:G=[10,11];break;case 4:G=[16,11];break;case 5:G=[40,33];break;case 6:G=[24,11];break;case 7:G=[20,11];break;case 8:G=[32,11];break;case 9:G=[80,33];break;case 10:G=[18,11];break;case 11:G=[15,11];break;case 12:G=[64,33];break;case 13:G=[160,99];break;case 14:G=[4,3];break;case 15:G=[3,2];break;case 16:G=[2,1];break;case 255:G=[d()<<8|d(),d()<<8|d()]}return{width:Math.ceil(16*(w+1)-2*i-2*a),height:(2-N)*(O+1)*16-(N?2:4)*(o+l),pixelRatio:G}},n.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},s}(),Ho=function(){function s(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Ct(t,{removePKCS7Padding:!1})}var n=s.prototype;return n.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},n.decryptAacSample=function(e,t,r){var i=this,a=e[t].unit;if(!(a.length<=16)){var o=a.subarray(16,a.length-a.length%16),l=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(l).then(function(d){var u=new Uint8Array(d);a.set(u,16),i.decrypter.isSync()||i.decryptAacSamples(e,t+1,r)})}},n.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},n.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r},n.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)e.set(r.subarray(i,i+16),a);return e},n.decryptAvcSample=function(e,t,r,i,a){var o=this,l=sn(a.data),d=this.getAvcEncryptedData(l);this.decryptBuffer(d.buffer).then(function(u){a.data=o.getAvcDecryptedUnit(l,u),o.decrypter.isSync()||o.decryptAvcSamples(e,t,r+1,i)})},n.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var o=a[r];if(!(o.data.length<=48||o.type!==1&&o.type!==5||(this.decryptAvcSample(e,t,r,i,o),this.decrypter.isSync())))return}}},s}(),Lt=188,Ko=function(){function s(e,t,r){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=e,this.config=t,this.typeSupported=r}s.probe=function(e){var t=s.syncOffset(e);return t>0&&x.warn("MPEG2-TS detected but first sync word found @ offset "+t),t!==-1},s.syncOffset=function(e){for(var t=e.length,r=Math.min(940,e.length-Lt)+1,i=0;i<r;){for(var a=!1,o=i;o<t&&e[o]===71;o+=Lt)if(a||oa(e,o)!==0||(a=!0),a&&o+Lt>r)return i;i++}return-1},s.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:en[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var n=s.prototype;return n.resetInitSegment=function(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=s.createTrack("video"),this._audioTrack=s.createTrack("audio",i),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=i},n.resetTimeStamp=function(){},n.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},n.demux=function(e,t,r,i){var a;r===void 0&&(r=!1),i===void 0&&(i=!1),r||(this.sampleAes=null);var o=this._avcTrack,l=this._audioTrack,d=this._id3Track,u=this._txtTrack,c=o.pid,f=o.pesData,v=l.pid,p=d.pid,T=l.pesData,S=d.pesData,y=null,b=this.pmtParsed,D=this._pmtId,w=e.length;if(this.remainderData&&(w=(e=zt(this.remainderData,e)).length,this.remainderData=null),w<Lt&&!i)return this.remainderData=e,{audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};var O=Math.max(0,s.syncOffset(e));(w-=(w-O)%Lt)<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,w,e.buffer.byteLength-w));for(var N=0,G=O;G<w;G+=Lt)if(e[G]===71){var W=!!(64&e[G+1]),q=oa(e,G),V=void 0;if((48&e[G+3])>>4>1){if((V=G+5+e[G+4])===G+Lt)continue}else V=G+4;switch(q){case c:W&&(f&&(a=Jr(f))&&this.parseAVCPES(o,u,a,!1),f={data:[],size:0}),f&&(f.data.push(e.subarray(V,G+Lt)),f.size+=G+Lt-V);break;case v:if(W){if(T&&(a=Jr(T)))switch(l.segmentCodec){case"aac":this.parseAACPES(l,a);break;case"mp3":this.parseMPEGPES(l,a)}T={data:[],size:0}}T&&(T.data.push(e.subarray(V,G+Lt)),T.size+=G+Lt-V);break;case p:W&&(S&&(a=Jr(S))&&this.parseID3PES(d,a),S={data:[],size:0}),S&&(S.data.push(e.subarray(V,G+Lt)),S.size+=G+Lt-V);break;case 0:W&&(V+=e[V]+1),D=this._pmtId=qo(e,V);break;case D:W&&(V+=e[V]+1);var te=jo(e,V,this.typeSupported,r);(c=te.avc)>0&&(o.pid=c),(v=te.audio)>0&&(l.pid=v,l.segmentCodec=te.segmentCodec),(p=te.id3)>0&&(d.pid=p),y===null||b||(x.warn("MPEG-TS PMT found at "+G+" after unknown PID '"+y+"'. Backtracking to sync byte @"+O+" to parse all TS packets."),y=null,G=O-188),b=this.pmtParsed=!0;break;case 17:case 8191:break;default:y=q}}else N++;if(N>0){var J=new Error("Found "+N+" TS packet/s that do not start with 0x47");this.observer.emit(E.ERROR,E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,fatal:!1,error:J,reason:J.message})}o.pesData=f,l.pesData=T,d.pesData=S;var oe={audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};return i&&this.extractRemainingSamples(oe),oe},n.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},n.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,a=e.id3Track,o=e.textTrack,l=i.pesData,d=r.pesData,u=a.pesData;if(l&&(t=Jr(l))?(this.parseAVCPES(i,o,t,!0),i.pesData=null):i.pesData=l,d&&(t=Jr(d))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else d!=null&&d.size&&x.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=d;u&&(t=Jr(u))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=u},n.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),a=this.sampleAes=new Ho(this.observer,this.config,t);return this.decrypt(i,a)},n.decrypt=function(e,t){return new Promise(function(r){var i=e.audioTrack,a=e.videoTrack;i.samples&&i.segmentCodec==="aac"?t.decryptAacSamples(i.samples,0,function(){a.samples?t.decryptAvcSamples(a.samples,0,0,function(){r(e)}):r(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,function(){r(e)})})},n.destroy=function(){this._duration=0},n.parseAVCPES=function(e,t,r,i){var a,o=this,l=this.parseAVCNALu(e,r.data),d=this.avcSample,u=!1;r.data=null,d&&l.length&&!e.audFound&&(la(d,e),d=this.avcSample=Rn(!1,r.pts,r.dts,"")),l.forEach(function(c){switch(c.type){case 1:a=!0,d||(d=o.avcSample=Rn(!0,r.pts,r.dts,"")),d.frame=!0;var f=c.data;if(u&&f.length>4){var v=new ss(f).readSliceType();v!==2&&v!==4&&v!==7&&v!==9||(d.key=!0)}break;case 5:a=!0,d||(d=o.avcSample=Rn(!0,r.pts,r.dts,"")),d.key=!0,d.frame=!0;break;case 6:a=!0,an(c.data,1,r.pts,t.samples);break;case 7:if(a=!0,u=!0,!e.sps){var p=c.data,T=new ss(p).readSPS();e.width=T.width,e.height=T.height,e.pixelRatio=T.pixelRatio,e.sps=[p],e.duration=o._duration;for(var S=p.subarray(1,4),y="avc1.",b=0;b<3;b++){var D=S[b].toString(16);D.length<2&&(D="0"+D),y+=D}e.codec=y}break;case 8:a=!0,e.pps||(e.pps=[c.data]);break;case 9:a=!1,e.audFound=!0,d&&la(d,e),d=o.avcSample=Rn(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,d&&(d.debug+="unknown NAL "+c.type+" ")}d&&a&&d.units.push(c)}),i&&d&&(la(d,e),this.avcSample=null)},n.getLastNalUnit=function(e){var t,r,i=this.avcSample;if(i&&i.units.length!==0||(i=e[e.length-1]),(t=i)!=null&&t.units){var a=i.units;r=a[a.length-1]}return r},n.parseAVCNALu=function(e,t){var r,i,a=t.byteLength,o=e.naluState||0,l=o,d=[],u=0,c=-1,f=0;for(o===-1&&(c=0,f=31&t[0],o=0,u=1);u<a;)if(r=t[u++],o)if(o!==1)if(r)if(r===1){if(c>=0){var v={data:t.subarray(c,u-o-1),type:f};d.push(v)}else{var p=this.getLastNalUnit(e.samples);if(p&&(l&&u<=4-l&&p.state&&(p.data=p.data.subarray(0,p.data.byteLength-l)),(i=u-o-1)>0)){var T=new Uint8Array(p.data.byteLength+i);T.set(p.data,0),T.set(t.subarray(0,i),p.data.byteLength),p.data=T,p.state=0}}u<a?(c=u,f=31&t[u],o=0):o=-1}else o=0;else o=3;else o=r?0:2;else o=r?0:1;if(c>=0&&o>=0){var S={data:t.subarray(c,a),type:f,state:o};d.push(S)}if(d.length===0){var y=this.getLastNalUnit(e.samples);if(y){var b=new Uint8Array(y.data.byteLength+t.byteLength);b.set(y.data,0),b.set(t,y.data.byteLength),y.data=b}}return e.naluState=o,d},n.parseAACPES=function(e,t){var r,i,a,o=0,l=this.aacOverFlow,d=t.data;if(l){this.aacOverFlow=null;var u=l.missing,c=l.sample.unit.byteLength;if(u===-1){var f=new Uint8Array(c+d.byteLength);f.set(l.sample.unit,0),f.set(d,c),d=f}else{var v=c-u;l.sample.unit.set(d.subarray(0,u),v),e.samples.push(l.sample),o=l.missing}}for(r=o,i=d.length;r<i-1&&!Ln(d,r);r++);if(r!==o){var p,T=r<i-1;p=T?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES";var S=new Error(p);if(x.warn("parsing error: "+p),this.observer.emit(E.ERROR,E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,fatal:!1,levelRetry:T,error:S,reason:p}),!T)return}if(es(e,this.observer,d,r,this.audioCodec),t.pts!==void 0)a=t.pts;else{if(!l)return void x.warn("[tsdemuxer]: AAC PES unknown PTS");var y=ts(e.samplerate);a=l.sample.pts+y}for(var b,D=0;r<i;){if(r+=(b=rs(e,d,r,a,D)).length,b.missing){this.aacOverFlow=b;break}for(D++;r<i-1&&!Ln(d,r);r++);}},n.parseMPEGPES=function(e,t){var r=t.data,i=r.length,a=0,o=0,l=t.pts;if(l!==void 0)for(;o<i;)if(as(r,o)){var d=is(e,r,o,l,a);if(!d)break;o+=d.length,a++}else o++;else x.warn("[tsdemuxer]: MPEG PES unknown PTS")},n.parseID3PES=function(e,t){if(t.pts!==void 0){var r=X({},t,{type:this._avcTrack?Jt:_r,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else x.warn("[tsdemuxer]: ID3 PES unknown PTS")},s}();function Rn(s,n,e,t){return{key:s,frame:!1,pts:n,dts:e,units:[],debug:t,length:0}}function oa(s,n){return((31&s[n+1])<<8)+s[n+2]}function qo(s,n){return(31&s[n+10])<<8|s[n+11]}function jo(s,n,e,t){var r={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},i=n+3+((15&s[n+1])<<8|s[n+2])-4;for(n+=12+((15&s[n+10])<<8|s[n+11]);n<i;){var a=oa(s,n);switch(s[n]){case 207:if(!t){x.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:r.audio===-1&&(r.audio=a);break;case 21:r.id3===-1&&(r.id3=a);break;case 219:if(!t){x.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:r.avc===-1&&(r.avc=a);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?x.log("MPEG audio found, not supported in this browser"):r.audio===-1&&(r.audio=a,r.segmentCodec="mp3");break;case 36:x.warn("Unsupported HEVC stream type found")}n+=5+((15&s[n+3])<<8|s[n+4])}return r}function Jr(s){var n,e,t,r,i,a=0,o=s.data;if(!s||s.size===0)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(((n=o[0])[0]<<16)+(n[1]<<8)+n[2]===1){if((e=(n[4]<<8)+n[5])&&e>s.size-6)return null;var d=n[7];192&d&&(r=536870912*(14&n[9])+4194304*(255&n[10])+16384*(254&n[11])+128*(255&n[12])+(254&n[13])/2,64&d?r-(i=536870912*(14&n[14])+4194304*(255&n[15])+16384*(254&n[16])+128*(255&n[17])+(254&n[18])/2)>54e5&&(x.warn(Math.round((r-i)/9e4)+"s delta between PTS and DTS, align them"),r=i):i=r);var u=(t=n[8])+9;if(s.size<=u)return null;s.size-=u;for(var c=new Uint8Array(s.size),f=0,v=o.length;f<v;f++){var p=(n=o[f]).byteLength;if(u){if(u>p){u-=p;continue}n=n.subarray(u),p-=u,u=0}c.set(n,a),a+=p}return e&&(e-=t+3),{data:c,pts:r,dts:i,len:e}}return null}function la(s,n){if(s.units.length&&s.frame){if(s.pts===void 0){var e=n.samples,t=e.length;if(!t)return void n.dropped++;var r=e[t-1];s.pts=r.pts,s.dts=r.dts}n.samples.push(s)}s.debug.length&&x.log(s.pts+"/"+s.dts+":"+s.debug)}var Vo=function(s){function n(){return s.apply(this,arguments)||this}ae(n,s);var e=n.prototype;return e.resetInitSegment=function(t,r,i,a){s.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var r=(mr(t,0)||[]).length,i=t.length;r<i;r++)if(Go(t,r))return x.log("MPEG Audio sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return sa(i,a)&&4<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){if(this.basePTS!==null)return is(t,r,i,this.basePTS,this.frameIndex)},n}(Ja),os=function(){function s(){}return s.getSilentFrame=function(n,e){if(n==="mp4a.40.2"){if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===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(e===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])}else{if(e===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(e===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(e===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])}},s}(),cr=Math.pow(2,32)-1,lt=function(){function s(){}return s.init=function(){var n;for(n in s.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:[]},s.types)s.types.hasOwnProperty(n)&&(s.types[n]=[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]);var e=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]),t=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]);s.HDLR_TYPES={video:e,audio:t};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);s.STTS=s.STSC=s.STCO=i,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);s.FTYP=s.box(s.types.ftyp,a,l,a,o),s.DINF=s.box(s.types.dinf,s.box(s.types.dref,r))},s.box=function(n){for(var e=8,t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var a=r.length,o=a;a--;)e+=r[a].byteLength;var l=new Uint8Array(e);for(l[0]=e>>24&255,l[1]=e>>16&255,l[2]=e>>8&255,l[3]=255&e,l.set(n,4),a=0,e=8;a<o;a++)l.set(r[a],e),e+=r[a].byteLength;return l},s.hdlr=function(n){return s.box(s.types.hdlr,s.HDLR_TYPES[n])},s.mdat=function(n){return s.box(s.types.mdat,n)},s.mdhd=function(n,e){e*=n;var t=Math.floor(e/(cr+1)),r=Math.floor(e%(cr+1));return s.box(s.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,85,196,0,0]))},s.mdia=function(n){return s.box(s.types.mdia,s.mdhd(n.timescale,n.duration),s.hdlr(n.type),s.minf(n))},s.mfhd=function(n){return s.box(s.types.mfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n]))},s.minf=function(n){return n.type==="audio"?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(n)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(n))},s.moof=function(n,e,t){return s.box(s.types.moof,s.mfhd(n),s.traf(t,e))},s.moov=function(n){for(var e=n.length,t=[];e--;)t[e]=s.trak(n[e]);return s.box.apply(null,[s.types.moov,s.mvhd(n[0].timescale,n[0].duration)].concat(t).concat(s.mvex(n)))},s.mvex=function(n){for(var e=n.length,t=[];e--;)t[e]=s.trex(n[e]);return s.box.apply(null,[s.types.mvex].concat(t))},s.mvhd=function(n,e){e*=n;var t=Math.floor(e/(cr+1)),r=Math.floor(e%(cr+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,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 s.box(s.types.mvhd,i)},s.sdtp=function(n){var e,t,r=n.samples||[],i=new Uint8Array(4+r.length);for(e=0;e<r.length;e++)t=r[e].flags,i[e+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return s.box(s.types.sdtp,i)},s.stbl=function(n){return s.box(s.types.stbl,s.stsd(n),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))},s.avc1=function(n){var e,t,r,i=[],a=[];for(e=0;e<n.sps.length;e++)r=(t=n.sps[e]).byteLength,i.push(r>>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(e=0;e<n.pps.length;e++)r=(t=n.pps[e]).byteLength,a.push(r>>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(t));var o=s.box(s.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|n.sps.length].concat(i).concat([n.pps.length]).concat(a))),l=n.width,d=n.height,u=n.pixelRatio[0],c=n.pixelRatio[1];return s.box(s.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,d>>8&255,255&d,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,c>>24,c>>16&255,c>>8&255,255&c])))},s.esds=function(n){var e=n.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(n.config).concat([6,1,2]))},s.mp4a=function(n){var e=n.samplerate;return s.box(s.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),s.box(s.types.esds,s.esds(n)))},s.mp3=function(n){var e=n.samplerate;return s.box(s.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))},s.stsd=function(n){return n.type==="audio"?n.segmentCodec==="mp3"&&n.codec==="mp3"?s.box(s.types.stsd,s.STSD,s.mp3(n)):s.box(s.types.stsd,s.STSD,s.mp4a(n)):s.box(s.types.stsd,s.STSD,s.avc1(n))},s.tkhd=function(n){var e=n.id,t=n.duration*n.timescale,r=n.width,i=n.height,a=Math.floor(t/(cr+1)),o=Math.floor(t%(cr+1));return s.box(s.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,255&r,0,0,i>>8&255,255&i,0,0]))},s.traf=function(n,e){var t=s.sdtp(n),r=n.id,i=Math.floor(e/(cr+1)),a=Math.floor(e%(cr+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a])),s.trun(n,t.length+16+20+8+16+8+8),t)},s.trak=function(n){return n.duration=n.duration||4294967295,s.box(s.types.trak,s.tkhd(n),s.mdia(n))},s.trex=function(n){var e=n.id;return s.box(s.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},s.trun=function(n,e){var t,r,i,a,o,l,d=n.samples||[],u=d.length,c=12+16*u,f=new Uint8Array(c);for(e+=8+c,f.set([n.type==="video"?1:0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),t=0;t<u;t++)i=(r=d[t]).duration,a=r.size,o=r.flags,l=r.cts,f.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*t);return s.box(s.types.trun,f)},s.initSegment=function(n){s.types||s.init();var e=s.moov(n),t=new Uint8Array(s.FTYP.byteLength+e.byteLength);return t.set(s.FTYP),t.set(e,s.FTYP.byteLength),t},s}();function ua(s,n,e,t){e===void 0&&(e=1),t===void 0&&(t=!1);var r=s*n*e;return t?Math.round(r):r}function Oi(s,n){return n===void 0&&(n=!1),ua(s,1e3,1/9e4,n)}lt.types=void 0,lt.HDLR_TYPES=void 0,lt.STTS=void 0,lt.STSC=void 0,lt.STCO=void 0,lt.STSZ=void 0,lt.VMHD=void 0,lt.SMHD=void 0,lt.STSD=void 0,lt.FTYP=void 0,lt.DINF=void 0;var Dn=null,da=null,ca=function(){function s(e,t,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,Dn===null){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Dn=a?parseInt(a[1]):0}if(da===null){var o=navigator.userAgent.match(/Safari\/(\d+)/i);da=o?parseInt(o[1]):0}}var n=s.prototype;return n.destroy=function(){},n.resetTimeStamp=function(e){x.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},n.resetNextTimestamp=function(){x.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},n.resetInitSegment=function(){x.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},n.getVideoStartPts=function(e){var t=!1,r=e.reduce(function(i,a){var o=a.pts-i;return o<-4294967296?(t=!0,xt(i,a.pts)):o>0?i:a.pts},e[0].pts);return t&&x.debug("PTS rollover detected"),r},n.remux=function(e,t,r,i,a,o,l,d){var u,c,f,v,p,T,S=a,y=a,b=e.pid>-1,D=t.pid>-1,w=t.samples.length,O=e.samples.length>0,N=l&&w>0||w>1;if((!b||O)&&(!D||N)||this.ISGenerated||l){this.ISGenerated||(f=this.generateIS(e,t,a,o));var G,W=this.isVideoContiguous,q=-1;if(N&&(q=function(me){for(var ue=0;ue<me.length;ue++)if(me[ue].key)return ue;return-1}(t.samples),!W&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,q>0){x.warn("[mp4-remuxer]: Dropped "+q+" out of "+w+" video samples due to a missing keyframe");var V=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(q),t.dropped+=q,G=y+=(t.samples[0].pts-V)/t.inputTimeScale}else q===-1&&(x.warn("[mp4-remuxer]: No keyframe found out of "+w+" video samples"),T=!1);if(this.ISGenerated){if(O&&N){var te=this.getVideoStartPts(t.samples),J=(xt(e.samples[0].pts,te)-te)/t.inputTimeScale;S+=Math.max(0,J),y+=Math.max(0,-J)}if(O){if(e.samplerate||(x.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),f=this.generateIS(e,t,a,o)),c=this.remuxAudio(e,S,this.isAudioContiguous,o,D||N||d===kt?y:void 0),N){var oe=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(x.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),f=this.generateIS(e,t,a,o)),u=this.remuxVideo(t,y,W,oe)}}else N&&(u=this.remuxVideo(t,y,W,0));u&&(u.firstKeyFrame=q,u.independent=q!==-1,u.firstKeyFramePTS=G)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(p=ls(r,a,this._initPTS,this._initDTS)),i.samples.length&&(v=us(i,a,this._initPTS))),{audio:c,video:u,initSegment:f,independent:T,text:v,id3:p}},n.generateIS=function(e,t,r,i){var a,o,l,d=e.samples,u=t.samples,c=this.typeSupported,f={},v=this._initPTS,p=!v||i,T="audio/mp4";if(p&&(a=o=1/0),e.config&&d.length&&(e.timescale=e.samplerate,e.segmentCodec==="mp3"&&(c.mpeg?(T="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3")),f.audio={id:"audio",container:T,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&c.mpeg?new Uint8Array(0):lt.initSegment([e]),metadata:{channelCount:e.channelCount}},p&&(l=e.inputTimeScale,v&&l===v.timescale?p=!1:a=o=d[0].pts-Math.round(l*r))),t.sps&&t.pps&&u.length&&(t.timescale=t.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:lt.initSegment([t]),metadata:{width:t.width,height:t.height}},p))if(l=t.inputTimeScale,v&&l===v.timescale)p=!1;else{var S=this.getVideoStartPts(u),y=Math.round(l*r);o=Math.min(o,xt(u[0].dts,S)-y),a=Math.min(a,S-y)}if(Object.keys(f).length)return this.ISGenerated=!0,p?(this._initPTS={baseTime:a,timescale:l},this._initDTS={baseTime:o,timescale:l}):a=l=void 0,{tracks:f,initPTS:a,timescale:l}},n.remuxVideo=function(e,t,r,i){var a,o,l=e.inputTimeScale,d=e.samples,u=[],c=d.length,f=this._initPTS,v=this.nextAvcDts,p=8,T=this.videoSampleDuration,S=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,b=!1;r&&v!==null||(v=t*l-(d[0].pts-xt(d[0].dts,d[0].pts)));for(var D=f.baseTime*l/f.timescale,w=0;w<c;w++){var O=d[w];O.pts=xt(O.pts-D,v),O.dts=xt(O.dts-D,v),O.dts<d[w>0?w-1:w].dts&&(b=!0)}b&&d.sort(function(Fn,Vs){var ql=Fn.dts-Vs.dts,jl=Fn.pts-Vs.pts;return ql||jl}),a=d[0].dts;var N=(o=d[d.length-1].dts)-a,G=N?Math.round(N/(c-1)):T||e.inputTimeScale/30;if(r){var W=a-v,q=W>G,V=W<-1;if((q||V)&&(q?x.warn("AVC: "+Oi(W,!0)+" ms ("+W+"dts) hole between fragments detected, filling it"):x.warn("AVC: "+Oi(-W,!0)+" ms ("+W+"dts) overlapping between fragments detected"),!V||v>d[0].pts)){a=v;var te=d[0].pts-W;d[0].dts=a,d[0].pts=te,x.log("Video: First PTS/DTS adjusted: "+Oi(te,!0)+"/"+Oi(a,!0)+", delta: "+Oi(W,!0)+" ms")}}a=Math.max(0,a);for(var J=0,oe=0,me=0;me<c;me++){for(var ue=d[me],ve=ue.units,Te=ve.length,ye=0,we=0;we<Te;we++)ye+=ve[we].data.length;oe+=ye,J+=Te,ue.length=ye,ue.dts=Math.max(ue.dts,a),S=Math.min(ue.pts,S),y=Math.max(ue.pts,y)}o=d[c-1].dts;var Ce,Oe=oe+4*J+8;try{Ce=new Uint8Array(Oe)}catch(Fn){return void this.observer.emit(E.ERROR,E.ERROR,{type:Q.MUX_ERROR,details:F.REMUX_ALLOC_ERROR,fatal:!1,error:Fn,bytes:Oe,reason:"fail allocating video mdat "+Oe})}var Ge=new DataView(Ce.buffer);Ge.setUint32(0,Oe),Ce.set(lt.types.mdat,4);for(var Et=!1,nt=Number.POSITIVE_INFINITY,Ht=Number.POSITIVE_INFINITY,Ot=Number.NEGATIVE_INFINITY,Mt=Number.NEGATIVE_INFINITY,at=0;at<c;at++){for(var ut=d[at],Vt=ut.units,hr=0,wt=0,Mi=Vt.length;wt<Mi;wt++){var Fi=Vt[wt],Mn=Fi.data,ei=Fi.data.byteLength;Ge.setUint32(p,ei),p+=4,Ce.set(Mn,p),p+=ei,hr+=4+ei}var Or=void 0;if(at<c-1)T=d[at+1].dts-ut.dts,Or=d[at+1].pts-ut.pts;else{var Ni=this.config,ir=at>0?ut.dts-d[at-1].dts:G;if(Or=at>0?ut.pts-d[at-1].pts:G,Ni.stretchShortVideoTrack&&this.nextAudioPts!==null){var Ul=Math.floor(Ni.maxBufferHole*l),Ca=(i?S+i*l:this.nextAudioPts)-ut.pts;Ca>Ul?((T=Ca-ir)<0?T=ir:Et=!0,x.log("[mp4-remuxer]: It is approximately "+Ca/90+" ms to the next segment; using duration "+T/90+" ms for the last video frame.")):T=ir}else T=ir}var Bl=Math.round(ut.pts-ut.dts);nt=Math.min(nt,T),Ot=Math.max(Ot,T),Ht=Math.min(Ht,Or),Mt=Math.max(Mt,Or),u.push(new ds(ut.key,T,hr,Bl))}if(u.length){if(Dn){if(Dn<70){var Ks=u[0].flags;Ks.dependsOn=2,Ks.isNonSync=0}}else if(da&&Mt-Ht<Ot-nt&&G/Ot<.025&&u[0].cts===0){x.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var xa=a,Kt=0,qs=u.length;Kt<qs;Kt++){var js=xa+u[Kt].duration,Gl=xa+u[Kt].cts;if(Kt<qs-1){var Hl=js+u[Kt+1].cts;u[Kt].duration=Hl-Gl}else u[Kt].duration=Kt?u[Kt-1].duration:G;u[Kt].cts=0,xa=js}}}T=Et||!T?G:T,this.nextAvcDts=v=o+T,this.videoSampleDuration=T,this.isVideoContiguous=!0;var Kl={data1:lt.moof(e.sequenceNumber++,a,X({},e,{samples:u})),data2:Ce,startPTS:S/l,endPTS:(y+T)/l,startDTS:a/l,endDTS:v/l,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Kl},n.remuxAudio=function(e,t,r,i,a){var o=e.inputTimeScale,l=o/(e.samplerate?e.samplerate:o),d=e.segmentCodec==="aac"?1024:1152,u=d*l,c=this._initPTS,f=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,v=[],p=a!==void 0,T=e.samples,S=f?0:8,y=this.nextAudioPts||-1,b=t*o,D=c.baseTime*o/c.timescale;if(this.isAudioContiguous=r=r||T.length&&y>0&&(i&&Math.abs(b-y)<9e3||Math.abs(xt(T[0].pts-D,b)-y)<20*u),T.forEach(function(wt){wt.pts=xt(wt.pts-D,b)}),!r||y<0){if(T=T.filter(function(wt){return wt.pts>=0}),!T.length)return;y=a===0?0:i&&!p?Math.max(0,b):T[0].pts}if(e.segmentCodec==="aac")for(var w=this.config.maxAudioFramesDrift,O=0,N=y;O<T.length;O++){var G=T[O],W=G.pts,q=W-N,V=Math.abs(1e3*q/o);if(q<=-w*u&&p)O===0&&(x.warn("Audio frame @ "+(W/o).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*q/o)+" ms."),this.nextAudioPts=y=N=W);else if(q>=w*u&&V<1e4&&p){var te=Math.round(q/u);(N=W-te*u)<0&&(te--,N+=u),O===0&&(this.nextAudioPts=y=N),x.warn("[mp4-remuxer]: Injecting "+te+" audio frame @ "+(N/o).toFixed(3)+"s due to "+Math.round(1e3*q/o)+" ms gap.");for(var J=0;J<te;J++){var oe=Math.max(N,0),me=os.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);me||(x.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),me=G.unit.subarray()),T.splice(O,0,{unit:me,pts:oe}),N+=u,O++}}G.pts=N,N+=u}for(var ue,ve=null,Te=null,ye=0,we=T.length;we--;)ye+=T[we].unit.byteLength;for(var Ce=0,Oe=T.length;Ce<Oe;Ce++){var Ge=T[Ce],Et=Ge.unit,nt=Ge.pts;if(Te!==null)v[Ce-1].duration=Math.round((nt-Te)/l);else{if(r&&e.segmentCodec==="aac"&&(nt=y),ve=nt,!(ye>0))return;ye+=S;try{ue=new Uint8Array(ye)}catch(wt){return void this.observer.emit(E.ERROR,E.ERROR,{type:Q.MUX_ERROR,details:F.REMUX_ALLOC_ERROR,fatal:!1,error:wt,bytes:ye,reason:"fail allocating audio mdat "+ye})}f||(new DataView(ue.buffer).setUint32(0,ye),ue.set(lt.types.mdat,4))}ue.set(Et,S);var Ht=Et.byteLength;S+=Ht,v.push(new ds(!0,d,Ht,0)),Te=nt}var Ot=v.length;if(Ot){var Mt=v[v.length-1];this.nextAudioPts=y=Te+l*Mt.duration;var at=f?new Uint8Array(0):lt.moof(e.sequenceNumber++,ve/l,X({},e,{samples:v}));e.samples=[];var ut=ve/o,Vt=y/o,hr={data1:at,data2:ue,startPTS:ut,endPTS:Vt,startDTS:ut,endDTS:Vt,type:"audio",hasAudio:!0,hasVideo:!1,nb:Ot};return this.isAudioContiguous=!0,hr}},n.remuxEmptyAudio=function(e,t,r,i){var a=e.inputTimeScale,o=a/(e.samplerate?e.samplerate:a),l=this.nextAudioPts,d=this._initDTS,u=9e4*d.baseTime/d.timescale,c=(l!==null?l:i.startDTS*a)+u,f=i.endDTS*a+u,v=1024*o,p=Math.ceil((f-c)/v),T=os.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(x.warn("[mp4-remuxer]: remux empty Audio"),T){for(var S=[],y=0;y<p;y++){var b=c+y*v;S.push({unit:T,pts:b,dts:b})}return e.samples=S,this.remuxAudio(e,t,r,!1)}x.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},s}();function xt(s,n){var e;if(n===null)return s;for(e=n<s?-8589934592:8589934592;Math.abs(s-n)>4294967296;)s+=e;return s}function ls(s,n,e,t){var r=s.samples.length;if(r){for(var i=s.inputTimeScale,a=0;a<r;a++){var o=s.samples[a];o.pts=xt(o.pts-9e4*e.baseTime/e.timescale,n*i)/i,o.dts=xt(o.dts-9e4*t.baseTime/t.timescale,n*i)/i}var l=s.samples;return s.samples=[],{samples:l}}}function us(s,n,e){var t=s.samples.length;if(t){for(var r=s.inputTimeScale,i=0;i<t;i++){var a=s.samples[i];a.pts=xt(a.pts-9e4*e.baseTime/e.timescale,n*r)/r}s.samples.sort(function(l,d){return l.pts-d.pts});var o=s.samples;return s.samples=[],{samples:o}}}var tr,ds=function(s,n,e,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=n,this.size=e,this.cts=t,this.flags=new Yo(s)},Yo=function(s){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=s?2:1,this.isNonSync=s?0:1},Wo=function(){function s(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var n=s.prototype;return n.destroy=function(){},n.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},n.resetNextTimestamp=function(){this.lastEndTime=null},n.resetInitSegment=function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(a,o){if(!a||!o)return a;var l=o.keyId;return l&&o.isCommonEncryption&&Pe(a,["moov","trak"]).forEach(function(d){var u=Pe(d,["mdia","minf","stbl","stsd"])[0].subarray(8),c=Pe(u,["enca"]),f=c.length>0;f||(c=Pe(u,["encv"])),c.forEach(function(v){Pe(f?v.subarray(28):v.subarray(78),["sinf"]).forEach(function(p){var T=yi(p);if(T){var S=T.subarray(8,24);S.some(function(y){return y!==0})||(x.log("[eme] Patching keyId in 'enc"+(f?"a":"v")+">sinf>>tenc' box: "+Dt(S)+" -> "+Dt(l)),T.set(l,8))}})})}),a}(e,i)),this.emitInitSegment=!0},n.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(e==null||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=pi(e);t||(t=cs(i.audio,Xe)),r||(r=cs(i.video,mt));var a={};i.audio&&i.video?a.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?a.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?a.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:x.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},n.remux=function(e,t,r,i,a,o){var l,d,u=this.initPTS,c=this.lastEndTime,f={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};Z(c)||(c=this.lastEndTime=a||0);var v=t.samples;if(v==null||!v.length)return f;var p={initPTS:void 0,timescale:1},T=this.initData;if((l=T)!=null&&l.length||(this.generateInitSegment(v),T=this.initData),(d=T)==null||!d.length)return x.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),f;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1);var S=function(q,V){for(var te=0,J=0,oe=0,me=Pe(q,["moof","traf"]),ue=0;ue<me.length;ue++){var ve=me[ue],Te=Pe(ve,["tfhd"])[0],ye=V[Se(Te,4)];if(ye){var we=ye.default,Ce=Se(Te,0)|(we==null?void 0:we.flags),Oe=we==null?void 0:we.duration;8&Ce&&(Oe=Se(Te,2&Ce?12:8));for(var Ge=ye.timescale||9e4,Et=Pe(ve,["trun"]),nt=0;nt<Et.length;nt++)!(te=Xn(Et[nt]))&&Oe&&(te=Oe*Se(Et[nt],4)),ye.type===mt?J+=te/Ge:ye.type===Xe&&(oe+=te/Ge)}}if(J===0&&oe===0){for(var Ht=0,Ot=Pe(q,["sidx"]),Mt=0;Mt<Ot.length;Mt++){var at=rn(Ot[Mt]);at!=null&&at.references&&(Ht+=at.references.reduce(function(ut,Vt){return ut+Vt.info.duration||0},0))}return Ht}return J||oe}(v,T),y=function(q,V){return Pe(V,["moof","traf"]).reduce(function(te,J){var oe=Pe(J,["tfdt"])[0],me=oe[0],ue=Pe(J,["tfhd"]).reduce(function(ve,Te){var ye=Se(Te,4),we=q[ye];if(we){var Ce=Se(oe,4);if(me===1){if(Ce===pr)return x.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),ve;Ce*=pr+1,Ce+=Se(oe,8)}var Oe=Ce/(we.timescale||9e4);if(isFinite(Oe)&&(ve===null||Oe<ve))return Oe}return ve},null);return ue!==null&&isFinite(ue)&&(te===null||ue<te)?ue:te},null)}(T,v),b=y===null?a:y;(function(q,V,te,J){if(q===null)return!0;var oe=Math.max(J,1),me=V-q.baseTime/q.timescale;return Math.abs(me-te)>oe}(u,b,a,S)||p.timescale!==u.timescale&&o)&&(p.initPTS=b-a,u&&u.timescale===1&&x.warn("Adjusting initPTS by "+(p.initPTS-u.baseTime)),this.initPTS=u={baseTime:p.initPTS,timescale:1});var D=e?b-u.baseTime/u.timescale:c,w=D+S;(function(q,V,te){Pe(V,["moof","traf"]).forEach(function(J){Pe(J,["tfhd"]).forEach(function(oe){var me=Se(oe,4),ue=q[me];if(ue){var ve=ue.timescale||9e4;Pe(J,["tfdt"]).forEach(function(Te){var ye=Te[0],we=Se(Te,4);if(ye===0)we-=te*ve,mi(Te,4,we=Math.max(we,0));else{we*=Math.pow(2,32),we+=Se(Te,8),we-=te*ve,we=Math.max(we,0);var Ce=Math.floor(we/(pr+1)),Oe=Math.floor(we%(pr+1));mi(Te,4,Ce),mi(Te,8,Oe)}})}})})})(T,v,u.baseTime/u.timescale),S>0?this.lastEndTime=w:(x.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var O=!!T.audio,N=!!T.video,G="";O&&(G+="audio"),N&&(G+="video");var W={data1:v,startPTS:D,startDTS:D,endPTS:w,endDTS:w,type:G,hasAudio:O,hasVideo:N,nb:1,dropped:0};return f.audio=W.type==="audio"?W:void 0,f.video=W.type!=="audio"?W:void 0,f.initSegment=p,f.id3=ls(r,a,u,u),i.samples.length&&(f.text=us(i,a,u)),f},s}();function cs(s,n){var e=s==null?void 0:s.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||n===mt?"avc1.42e01e":"mp4a.40.5"}try{tr=self.performance.now.bind(self.performance)}catch{x.debug("Unable to use Performance API on this environment"),tr=typeof self!="undefined"&&self.Date.now}var ha=[{demux:Mo,remux:Wo},{demux:Ko,remux:ca},{demux:Po,remux:ca},{demux:Vo,remux:ca}],fa=function(){function s(e,t,r,i,a){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=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=a}var n=s.prototype;return n.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},n.push=function(e,t,r,i){var a=this,o=r.transmuxing;o.executeStart=tr();var l=new Uint8Array(e),d=this.currentTransmuxState,u=this.transmuxConfig;i&&(this.currentTransmuxState=i);var c=i||d,f=c.contiguous,v=c.discontinuity,p=c.trackSwitch,T=c.accurateTimeOffset,S=c.timeOffset,y=c.initSegmentChange,b=u.audioCodec,D=u.videoCodec,w=u.defaultInitPts,O=u.duration,N=u.initSegmentData,G=function(me,ue){var ve=null;return me.byteLength>0&&ue!=null&&ue.key!=null&&ue.iv!==null&&ue.method!=null&&(ve=ue),ve}(l,t);if(G&&G.method==="AES-128"){var W=this.getDecrypter();if(!W.isSync())return this.decryptionPromise=W.webCryptoDecrypt(l,G.key.buffer,G.iv.buffer).then(function(me){var ue=a.push(me,null,r);return a.decryptionPromise=null,ue}),this.decryptionPromise;var q=W.softwareDecrypt(l,G.key.buffer,G.iv.buffer);if(r.part>-1&&(q=W.flush()),!q)return o.executeEnd=tr(),va(r);l=new Uint8Array(q)}var V=this.needsProbing(v,p);if(V){var te=this.configureTransmuxer(l);if(te)return x.warn("[transmuxer] "+te.message),this.observer.emit(E.ERROR,E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,fatal:!1,error:te,reason:te.message}),o.executeEnd=tr(),va(r)}(v||p||y||V)&&this.resetInitSegment(N,b,D,O,t),(v||y||V)&&this.resetInitialTimestamp(w),f||this.resetContiguity();var J=this.transmux(l,G,S,T,r),oe=this.currentTransmuxState;return oe.contiguous=!0,oe.discontinuity=!1,oe.trackSwitch=!1,o.executeEnd=tr(),J},n.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=tr();var i=this.decrypter,a=this.currentTransmuxState,o=this.decryptionPromise;if(o)return o.then(function(){return t.flush(e)});var l=[],d=a.timeOffset;if(i){var u=i.flush();u&&l.push(this.push(u,null,e))}var c=this.demuxer,f=this.remuxer;if(!c||!f)return r.executeEnd=tr(),[va(e)];var v=c.flush(d);return Cr(v)?v.then(function(p){return t.flushRemux(l,p,e),l}):(this.flushRemux(l,v,e),l)},n.flushRemux=function(e,t,r){var i=t.audioTrack,a=t.videoTrack,o=t.id3Track,l=t.textTrack,d=this.currentTransmuxState,u=d.accurateTimeOffset,c=d.timeOffset;x.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var f=this.remuxer.remux(i,a,o,l,c,u,!0,this.id);e.push({remuxResult:f,chunkMeta:r}),r.transmuxing.executeEnd=tr()},n.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},n.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},n.resetInitSegment=function(e,t,r,i,a){var o=this.demuxer,l=this.remuxer;o&&l&&(o.resetInitSegment(e,t,r,i),l.resetInitSegment(e,t,r,a))},n.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},n.transmux=function(e,t,r,i,a){return t&&t.method==="SAMPLE-AES"?this.transmuxSampleAes(e,t,r,i,a):this.transmuxUnencrypted(e,r,i,a)},n.transmuxUnencrypted=function(e,t,r,i){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),o=a.audioTrack,l=a.videoTrack,d=a.id3Track,u=a.textTrack;return{remuxResult:this.remuxer.remux(o,l,d,u,t,r,!1,this.id),chunkMeta:i}},n.transmuxSampleAes=function(e,t,r,i,a){var o=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(l){return{remuxResult:o.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,r,i,!1,o.id),chunkMeta:a}})},n.configureTransmuxer=function(e){for(var t,r=this.config,i=this.observer,a=this.typeSupported,o=this.vendor,l=0,d=ha.length;l<d;l++)if(ha[l].demux.probe(e)){t=ha[l];break}if(!t)return new Error("Failed to find demuxer by probing fragment data");var u=this.demuxer,c=this.remuxer,f=t.remux,v=t.demux;c&&c instanceof f||(this.remuxer=new f(i,r,a,o)),u&&u instanceof v||(this.demuxer=new v(i,r,a),this.probe=v.probe)},n.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},n.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new Ct(this.config)),e},s}(),va=function(s){return{remuxResult:{},chunkMeta:s}};function Cr(s){return"then"in s&&s.then instanceof Function}var zo=function(s,n,e,t,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=s,this.videoCodec=n,this.initSegmentData=e,this.duration=t,this.defaultInitPts=r||null},Xo=function(s,n,e,t,r,i){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=s,this.contiguous=n,this.accurateTimeOffset=e,this.trackSwitch=t,this.timeOffset=r,this.initSegmentChange=i},hs={exports:{}};(function(s){var n=Object.prototype.hasOwnProperty,e="~";function t(){}function r(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function i(l,d,u,c,f){if(typeof u!="function")throw new TypeError("The listener must be a function");var v=new r(u,c||l,f),p=e?e+d:d;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],v]:l._events[p].push(v):(l._events[p]=v,l._eventsCount++),l}function a(l,d){--l._eventsCount==0?l._events=new t:delete l._events[d]}function o(){this._events=new t,this._eventsCount=0}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1)),o.prototype.eventNames=function(){var l,d,u=[];if(this._eventsCount===0)return u;for(d in l=this._events)n.call(l,d)&&u.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(l)):u},o.prototype.listeners=function(l){var d=e?e+l:l,u=this._events[d];if(!u)return[];if(u.fn)return[u.fn];for(var c=0,f=u.length,v=new Array(f);c<f;c++)v[c]=u[c].fn;return v},o.prototype.listenerCount=function(l){var d=e?e+l:l,u=this._events[d];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,d,u,c,f,v){var p=e?e+l:l;if(!this._events[p])return!1;var T,S,y=this._events[p],b=arguments.length;if(y.fn){switch(y.once&&this.removeListener(l,y.fn,void 0,!0),b){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,u),!0;case 4:return y.fn.call(y.context,d,u,c),!0;case 5:return y.fn.call(y.context,d,u,c,f),!0;case 6:return y.fn.call(y.context,d,u,c,f,v),!0}for(S=1,T=new Array(b-1);S<b;S++)T[S-1]=arguments[S];y.fn.apply(y.context,T)}else{var D,w=y.length;for(S=0;S<w;S++)switch(y[S].once&&this.removeListener(l,y[S].fn,void 0,!0),b){case 1:y[S].fn.call(y[S].context);break;case 2:y[S].fn.call(y[S].context,d);break;case 3:y[S].fn.call(y[S].context,d,u);break;case 4:y[S].fn.call(y[S].context,d,u,c);break;default:if(!T)for(D=1,T=new Array(b-1);D<b;D++)T[D-1]=arguments[D];y[S].fn.apply(y[S].context,T)}}return!0},o.prototype.on=function(l,d,u){return i(this,l,d,u,!1)},o.prototype.once=function(l,d,u){return i(this,l,d,u,!0)},o.prototype.removeListener=function(l,d,u,c){var f=e?e+l:l;if(!this._events[f])return this;if(!d)return a(this,f),this;var v=this._events[f];if(v.fn)v.fn!==d||c&&!v.once||u&&v.context!==u||a(this,f);else{for(var p=0,T=[],S=v.length;p<S;p++)(v[p].fn!==d||c&&!v[p].once||u&&v[p].context!==u)&&T.push(v[p]);T.length?this._events[f]=T.length===1?T[0]:T:a(this,f)}return this},o.prototype.removeAllListeners=function(l){var d;return l?(d=e?e+l:l,this._events[d]&&a(this,d)):(this._events=new t,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,s.exports=o})(hs);var In=Ke(hs.exports);function ga(s,n){if(!((e=n.remuxResult).audio||e.video||e.text||e.id3||e.initSegment))return!1;var e,t=[],r=n.remuxResult,i=r.audio,a=r.video;return i&&fs(t,i),a&&fs(t,a),s.postMessage({event:"transmuxComplete",data:n},t),!0}function fs(s,n){n.data1&&s.push(n.data1.buffer),n.data2&&s.push(n.data2.buffer)}function vs(s,n,e){n.reduce(function(t,r){return ga(s,r)||t},!1)||s.postMessage({event:"transmuxComplete",data:n[0]}),s.postMessage({event:"flush",data:e})}C!==void 0&&C&&function(s){var n=new In,e=function(r,i){s.postMessage({event:r,data:i})};n.on(E.FRAG_DECRYPTED,e),n.on(E.ERROR,e);var t=function(){var r=function(a){var o=function(l){e("workerLog",{logType:a,message:l})};x[a]=o};for(var i in x)r(i)};s.addEventListener("message",function(r){var i=r.data;switch(i.cmd){case"init":var a=JSON.parse(i.config);s.transmuxer=new fa(n,i.typeSupported,a,i.vendor,i.id),qe(a.debug,i.id),t(),e("init",null);break;case"configure":s.transmuxer.configure(i.config);break;case"demux":var o=s.transmuxer.push(i.data,i.decryptdata,i.chunkMeta,i.state);Cr(o)?(s.transmuxer.async=!0,o.then(function(u){ga(s,u)}).catch(function(u){e(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker push error"})})):(s.transmuxer.async=!1,ga(s,o));break;case"flush":var l=i.chunkMeta,d=s.transmuxer.flush(l);Cr(d)||s.transmuxer.async?(Cr(d)||(d=Promise.resolve(d)),d.then(function(u){vs(s,u,l)}).catch(function(u){e(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker flush error"})})):vs(s,d,l)}})}(self);var ma=Kr()||{isTypeSupported:function(){return!1}},gs=function(){function s(e,t,r,i){var a=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var o=e.config;this.hls=e,this.id=t,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;var l=function(S,y){(y=y||{}).frag=a.frag,y.id=a.id,S===E.ERROR&&(a.error=y.error),a.hls.trigger(S,y)};this.observer=new In,this.observer.on(E.FRAG_DECRYPTED,l),this.observer.on(E.ERROR,l);var d,u,c,f,v={mp4:ma.isTypeSupported("video/mp4"),mpeg:ma.isTypeSupported("audio/mpeg"),mp3:ma.isTypeSupported('audio/mp4; codecs="mp3"')},p=navigator.vendor;if(!this.useWorker||typeof Worker=="undefined"||(o.workerPath,0))this.transmuxer=new fa(this.observer,v,o,p,t);else try{o.workerPath?(x.log("loading Web Worker "+o.workerPath+' for "'+t+'"'),this.workerContext=(c=o.workerPath,f=new self.URL(c,self.location.href).href,{worker:new self.Worker(f),scriptURL:f})):(x.log('injecting Web Worker for "'+t+'"'),this.workerContext=(d=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+I.toString()+")(true);"],{type:"text/javascript"}),u=self.URL.createObjectURL(d),{worker:new self.Worker(u),objectURL:u})),this.onwmsg=function(S){return a.onWorkerMessage(S)};var T=this.workerContext.worker;T.addEventListener("message",this.onwmsg),T.onerror=function(S){var y=new Error(S.message+" ("+S.filename+":"+S.lineno+")");o.enableWorker=!1,x.warn('Error in "'+t+'" Web Worker, fallback to inline'),a.hls.trigger(E.ERROR,{type:Q.OTHER_ERROR,details:F.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:y})},T.postMessage({cmd:"init",typeSupported:v,vendor:p,id:t,config:JSON.stringify(o)})}catch(S){x.warn('Error setting up "'+t+'" Web Worker, fallback to inline',S),this.resetWorker(),this.error=null,this.transmuxer=new fa(this.observer,v,o,p,t)}}var n=s.prototype;return n.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},n.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},n.push=function(e,t,r,i,a,o,l,d,u,c){var f,v,p=this;u.transmuxing.start=self.performance.now();var T=this.transmuxer,S=o?o.start:a.start,y=a.decryptdata,b=this.frag,D=!(b&&a.cc===b.cc),w=!(b&&u.level===b.level),O=b?u.sn-b.sn:-1,N=this.part?u.part-this.part.index:-1,G=O===0&&u.id>1&&u.id===(b==null?void 0:b.stats.chunkCount),W=!w&&(O===1||O===0&&(N===1||G&&N<=0)),q=self.performance.now();(w||O||a.stats.parsing.start===0)&&(a.stats.parsing.start=q),!o||!N&&W||(o.stats.parsing.start=q);var V=!(b&&((f=a.initSegment)==null?void 0:f.url)===((v=b.initSegment)==null?void 0:v.url)),te=new Xo(D,W,d,w,S,V);if(!W||D||V){x.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
|
21
|
-
discontinuity: `+
|
|
22
|
-
trackSwitch: `+
|
|
15
|
+
`):"");Ee("error",{player_error_code:$==null?void 0:$.code,player_error_message:$==null?void 0:$.message,player_error_context:_e})};M.on("error",pt),M._stopMuxMonitor=function(){M.off("manifestLoaded",se),M.off("initFragmentLoaded",le),M.off("mediaFragmentLoaded",fe),M.off("qualityChangeRendered",it),M.off("error",pt),M.off("fragmentLoadingAbandoned",st),delete M._stopMuxMonitor}}else Y.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,k.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var k;this.dashjs&&((k=this.dashjs)&&typeof k._stopMuxMonitor=="function"&&k._stopMuxMonitor(),this.dashjs=void 0)}}],g&&kt(c.prototype,g),_&&kt(c,_),Object.defineProperty(c,"prototype",{writable:!1}),I}(qn),Li=ur,_r=K(153),Sr=K.n(_r);function $t(m){return $t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},$t(m)}function Vr(m,c){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var A=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(A!=null){var I,k,P=[],U=!0,M=!1;try{for(A=A.call(g);!(U=(I=A.next()).done)&&(P.push(I.value),!_||P.length!==_);U=!0);}catch(Y){M=!0,k=Y}finally{try{U||A.return==null||A.return()}finally{if(M)throw k}}return P}}(m,c)||function(g,_){if(g){if(typeof g=="string")return Ar(g,_);var A=Object.prototype.toString.call(g).slice(8,-1);return A==="Object"&&g.constructor&&(A=g.constructor.name),A==="Map"||A==="Set"?Array.from(g):A==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(A)?Ar(g,_):void 0}}(m,c)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
16
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Ar(m,c){(c==null||c>m.length)&&(c=m.length);for(var g=0,_=new Array(c);g<c;g++)_[g]=m[g];return _}var qt,Zn=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],ea={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};X()&&X().WeakMap&&(qt=new WeakMap);var ki="#EXT-X-TARGETDURATION",wi="#EXT-X-PART-INF",ta="#EXT-X-SERVER-CONTROL",ra="#EXTINF",yn="#EXT-X-PROGRAM-DATE-TIME",Lr="#EXT-X-VERSION",Ri="#EXT-X-SESSION-DATA",kr=function(m){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(m),this.manifest};kr.prototype.process=function(m){var c;for(this.buffer+=m,c=this.buffer.indexOf(`
|
|
17
|
+
`);c>-1;c=this.buffer.indexOf(`
|
|
18
|
+
`))this.processLine(this.buffer.substring(0,c)),this.buffer=this.buffer.substring(c+1)},kr.prototype.processLine=function(m){var c=m.indexOf(":"),g=bn(m,c),_=g[0],A=g.length===2?wr(g[1]):void 0;if(_[0]!=="#")this.currentUri.uri=_,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(_){case ki:if(!isFinite(A)||A<0)return;this.manifest.targetDuration=A,this.setHoldBack();break;case wi:Di(this.manifest,g),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case ta:Di(this.manifest,g),this.setHoldBack();break;case ra:A===0?this.currentUri.duration=.01:A>0&&(this.currentUri.duration=A);break;case yn:var I=A,k=new Date(I);this.manifest.dateTimeString||(this.manifest.dateTimeString=I,this.manifest.dateTimeObject=k),this.currentUri.dateTimeString=I,this.currentUri.dateTimeObject=k;break;case Lr:Di(this.manifest,g);break;case Ri:var P=Ci(g[1]),U=Be(P);Object.assign(this.manifest.sessionData,U)}},kr.prototype.setHoldBack=function(){var m=this.manifest,c=m.serverControl,g=m.targetDuration,_=m.partTargetDuration;if(c){var A="holdBack",I="partHoldBack",k=g&&3*g,P=_&&2*_;g&&!c.hasOwnProperty(A)&&(c[A]=k),k&&c[A]<k&&(c[A]=k),_&&!c.hasOwnProperty(I)&&(c[I]=3*_),_&&c[I]<P&&(c[I]=P)}};var Di=function(m,c){var g,_=Ii(c[0].replace("#EXT-X-",""));Yr(c[1])?(g={},g=Object.assign(En(c[1]),g)):g=wr(c[1]),m[_]=g},Ii=function(m){return m.toLowerCase().replace(/-(\w)/g,function(c){return c[1].toUpperCase()})},wr=function(m){if(m.toLowerCase()==="yes"||m.toLowerCase()==="no")return m.toLowerCase()==="yes";var c=m.indexOf(":")!==-1?m:parseFloat(m);return isNaN(c)?m:c},Tn=function(m){var c={},g=m.split("=");return g.length>1&&(c[Ii(g[0])]=wr(g[1])),c},En=function(m){for(var c=m.split(","),g={},_=0;c.length>_;_++){var A=c[_],I=Tn(A);g=Object.assign(I,g)}return g},Yr=function(m){return m.indexOf("=")>-1},bn=function(m,c){return c===-1?[m]:[m.substring(0,c),m.substring(c+1)]},Ci=function(m){var c={};if(m){var g=m.search(",");return[m.slice(0,g),m.slice(g+1)].forEach(function(_,A){for(var I=_.replace(/['"]+/g,"").split("="),k=0;k<I.length;k++)I[k]==="DATA-ID"&&(c["DATA-ID"]=I[1-k]),I[k]==="VALUE"&&(c.VALUE=I[1-k])}),{data:c}}},_n=kr,Wr={safeCall:function(m,c,g,_){var A=_;if(m&&typeof m[c]=="function")try{A=m[c].apply(m,g)}catch(I){Re.info("safeCall error",I)}return A},safeIncrement:E,getComputedStyle:function(m,c){var g;if(m&&c&&X()&&typeof X().getComputedStyle=="function")return qt&&qt.has(m)&&(g=qt.get(m)),g||(g=X().getComputedStyle(m,null),qt&&qt.set(m,g)),g.getPropertyValue(c)},secondsToMs:function(m){return Math.floor(1e3*m)},assign:Object.assign,headersStringToObject:ce,cdnHeadersToRequestId:Ue,extractHostnameAndDomain:be,extractHostname:pe,manifestParser:_n,generateShortID:ge,generateUUID:ae,now:Ke.now},Sn={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 Rr(m,c){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var A=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(A!=null){var I,k,P=[],U=!0,M=!1;try{for(A=A.call(g);!(U=(I=A.next()).done)&&(P.push(I.value),!_||P.length!==_);U=!0);}catch(Y){M=!0,k=Y}finally{try{U||A.return==null||A.return()}finally{if(M)throw k}}return P}}(m,c)||function(g,_){if(g){if(typeof g=="string")return zr(g,_);var A=Object.prototype.toString.call(g).slice(8,-1);return A==="Object"&&g.constructor&&(A=g.constructor.name),A==="Map"||A==="Set"?Array.from(g):A==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(A)?zr(g,_):void 0}}(m,c)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
19
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function zr(m,c){(c==null||c>m.length)&&(c=m.length);for(var g=0,_=new Array(c);g<c;g++)_[g]=m[g];return _}var Tt={},Zt=function m(c){var g=arguments;typeof c=="string"?m.hasOwnProperty(c)?X().setTimeout(function(){g=Array.prototype.splice.call(g,1),m[c].apply(null,g)},0):Re.warn("`"+c+"` is an unknown task"):typeof c=="function"?X().setTimeout(function(){c(m)},0):Re.warn("`"+c+"` is invalid.")},ia={loaded:Ke.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(m,c){return function(g,_,A){var I=Vr(Ae(_),3),k=I[0],P=I[1],U=I[2],M=g.log,Y=g.utils.getComputedStyle,Ee=g.utils.secondsToMs;if(!k)return M.error("No element was found with the `"+P+"` query selector.");if(U!=="video"&&U!=="audio")return M.error("The element of `"+P+"` was not a media element.");k.mux&&(k.mux.destroy(),delete k.mux,M.warn("Already monitoring this video element, replacing existing event listeners")),(A=Object.assign({automaticErrorTracking:!0},A)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:g.VERSION},A.data),A.getPlayheadTime=function(){return Ee(k.currentTime)},A.getStateData=function(){var de,le,fe=this.hlsjs&&this.hlsjs.url,De=this.dashjs&&$t(this.dashjs.getSource==="function")&&this.dashjs.getSource(),$e={player_is_paused:k.paused,player_playhead_time:Ee(k.currentTime),player_width:parseInt(Y(k,"width")),player_height:parseInt(Y(k,"height")),player_autoplay_on:k.autoplay,player_preload_on:k.preload,player_language_code:k.lang,player_is_fullscreen:Sr()&&!!(Sr().fullscreenElement||Sr().webkitFullscreenElement||Sr().mozFullScreenElement||Sr().msFullscreenElement),video_poster_url:k.poster,video_source_url:fe||De||k.currentSrc,video_source_duration:Ee(k.duration),video_source_height:k.videoHeight,video_source_width:k.videoWidth,view_dropped_frame_count:(de=k)===null||de===void 0||(le=de.getVideoPlaybackQuality)===null||le===void 0?void 0:le.call(de).droppedVideoFrames},it=A.getPlayheadTime();if(k.getStartDate&&it>0){var st=k.getStartDate();if(st&&typeof st.getTime=="function"&&st.getTime()){var pt=st.getTime();if($e.player_program_time=pt+it,k.seekable.length>0){var ke=pt+k.seekable.end(k.seekable.length-1);$e.player_live_edge_program_time=ke}}}return $e},k.mux=k.mux||{},k.mux.deleted=!1,k.mux.emit=function(de,le){g.emit(P,de,le)};var se=function(){M.error("The monitor for this video element has already been destroyed.")};k.mux.destroy=function(){Object.keys(k.mux.listeners).forEach(function(de){k.removeEventListener(de,k.mux.listeners[de],!1)}),delete k.mux.listeners,k.mux.destroy=se,k.mux.swapElement=se,k.mux.emit=se,k.mux.addHLSJS=se,k.mux.addDashJS=se,k.mux.removeHLSJS=se,k.mux.removeDashJS=se,k.mux.deleted=!0,g.emit(P,"destroy")},k.mux.swapElement=function(de){var le=Vr(Ae(de),3),fe=le[0],De=le[1],$e=le[2];return fe?$e!=="video"&&$e!=="audio"?g.log.error("The element of `"+De+"` was not a media element."):(fe.muxId=k.muxId,delete k.muxId,fe.mux=fe.mux||{},fe.mux.listeners=Object.assign({},k.mux.listeners),delete k.mux.listeners,Object.keys(fe.mux.listeners).forEach(function(it){k.removeEventListener(it,fe.mux.listeners[it],!1),fe.addEventListener(it,fe.mux.listeners[it],!1)}),fe.mux.swapElement=k.mux.swapElement,fe.mux.destroy=k.mux.destroy,delete k.mux,void(k=fe)):g.log.error("No element was found with the `"+De+"` query selector.")},k.mux.addHLSJS=function(de){g.addHLSJS(P,de)},k.mux.addDashJS=function(de){g.addDashJS(P,de)},k.mux.removeHLSJS=function(){g.removeHLSJS(P)},k.mux.removeDashJS=function(){g.removeDashJS(P)},g.init(P,A),g.emit(P,"playerready"),k.paused||(g.emit(P,"play"),k.readyState>2&&g.emit(P,"playing")),k.mux.listeners={},Zn.forEach(function(de){(de!=="error"||A.automaticErrorTracking)&&(k.mux.listeners[de]=function(){var le={};if(de==="error"){if(!k.error||k.error.code===1)return;le.player_error_code=k.error.code,le.player_error_message=ea[k.error.code]||k.error.message}g.emit(P,de,le)},k.addEventListener(de,k.mux.listeners[de],!1))})}(Zt,m,c)},destroyMonitor:function(m){var c=Rr(Ae(m),1)[0];c&&c.mux&&typeof c.mux.destroy=="function"?c.mux.destroy():Re.error("A video element monitor for `"+m+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(m,c){var g=ne(m);Tt[g]?Tt[g].addHLSJS(c):Re.error("A monitor for `"+g+"` has not been initialized.")},addDashJS:function(m,c){var g=ne(m);Tt[g]?Tt[g].addDashJS(c):Re.error("A monitor for `"+g+"` has not been initialized.")},removeHLSJS:function(m){var c=ne(m);Tt[c]?Tt[c].removeHLSJS():Re.error("A monitor for `"+c+"` has not been initialized.")},removeDashJS:function(m){var c=ne(m);Tt[c]?Tt[c].removeDashJS():Re.error("A monitor for `"+c+"` has not been initialized.")},init:function(m,c){dt()&&c&&c.respectDoNotTrack&&Re.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var g=ne(m);Tt[g]=new Li(Zt,g,c)},emit:function(m,c,g){var _=ne(m);Tt[_]?(Tt[_].emit(c,g),c==="destroy"&&delete Tt[_]):Re.error("A monitor for `"+_+"` has not been initialized.")},checkDoNotTrack:dt,log:Re,utils:Wr,events:Sn,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Zt,ia),X()!==void 0&&typeof X().addEventListener=="function"&&X().addEventListener("pagehide",function(m){m.persisted||(Zt.WINDOW_UNLOADING=!0)},!1);var An=Zt},655:function(H,z,K){var ee,X;function ae(ge){return ae=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(ne){return typeof ne}:function(ne){return ne&&typeof Symbol=="function"&&ne.constructor===Symbol&&ne!==Symbol.prototype?"symbol":typeof ne},ae(ge);}(function(ge){var ne=!1;if((X=typeof(ee=ge)=="function"?ee.call(z,K,z,H):ee)===void 0||(H.exports=X),ne=!0,ae(z)==="object"&&(H.exports=ge(),ne=!0),!ne){var Ae=window.Cookies,Le=window.Cookies=ge();Le.noConflict=function(){return window.Cookies=Ae,Le}}})(function(){var ge=function(){for(var ne=0,Ae={};ne<arguments.length;ne++){var Le=arguments[ne];for(var xe in Le)Ae[xe]=Le[xe]}return Ae};return function ne(Ae){function Le(xe,je,Re){var dt;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(Re=ge({path:"/"},Le.defaults,Re)).expires=="number"){var Ke=new Date;Ke.setMilliseconds(Ke.getMilliseconds()+864e5*Re.expires),Re.expires=Ke}try{dt=JSON.stringify(je),/^[\{\[]/.test(dt)&&(je=dt)}catch{}return je=Ae.write?Ae.write(je,xe):encodeURIComponent(String(je)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),xe=(xe=(xe=encodeURIComponent(String(xe))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[xe,"=",je,Re.expires?"; expires="+Re.expires.toUTCString():"",Re.path?"; path="+Re.path:"",Re.domain?"; domain="+Re.domain:"",Re.secure?"; secure":""].join("")}xe||(dt={});for(var pe=document.cookie?document.cookie.split("; "):[],be=/(%[0-9A-Z]{2})+/g,Z=0;Z<pe.length;Z++){var E=pe[Z].split("="),Q=E.slice(1).join("=");Q.charAt(0)==='"'&&(Q=Q.slice(1,-1));try{var F=E[0].replace(be,decodeURIComponent);if(Q=Ae.read?Ae.read(Q,F):Ae(Q,F)||Q.replace(be,decodeURIComponent),this.json)try{Q=JSON.parse(Q)}catch{}if(xe===F){dt=Q;break}xe||(dt[F]=Q)}catch{}}return dt}}return Le.set=Le,Le.get=function(xe){return Le.call(Le,xe)},Le.getJSON=function(){return Le.apply({json:!0},[].slice.call(arguments))},Le.defaults={},Le.remove=function(xe,je){Le(xe,"",ge(je,{expires:-1}))},Le.withConverter=ne,Le}(function(){})})},153:function(H,z,K){var ee,X=K.g!==void 0?K.g:typeof window!="undefined"?window:{},ae=K(558);typeof document!="undefined"?ee=document:(ee=X["__GLOBAL_DOCUMENT_CACHE@4"])||(ee=X["__GLOBAL_DOCUMENT_CACHE@4"]=ae),H.exports=ee},48:function(H,z,K){var ee;ee=typeof window!="undefined"?window:K.g!==void 0?K.g:typeof self!="undefined"?self:{},H.exports=ee},640:function(H,z,K){var ee,X;(function(ae,ge){"use strict";ee=function(){var ne=function(){},Ae="undefined",Le=typeof window!==Ae&&typeof window.navigator!==Ae&&/Trident\/|MSIE /.test(window.navigator.userAgent),xe=["trace","debug","info","warn","error"];function je(ce,Ue){var Be=ce[Ue];if(typeof Be.bind=="function")return Be.bind(ce);try{return Function.prototype.bind.call(Be,ce)}catch{return function(){return Function.prototype.apply.apply(Be,[ce,arguments])}}}function Re(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function dt(ce){return ce==="debug"&&(ce="log"),typeof console!==Ae&&(ce==="trace"&&Le?Re:console[ce]!==void 0?je(console,ce):console.log!==void 0?je(console,"log"):ne)}function Ke(ce,Ue){for(var Be=0;Be<xe.length;Be++){var Ut=xe[Be];this[Ut]=Be<ce?ne:this.methodFactory(Ut,ce,Ue)}this.log=this.debug}function pe(ce,Ue,Be){return function(){typeof console!==Ae&&(Ke.call(this,Ue,Be),this[ce].apply(this,arguments))}}function be(ce,Ue,Be){return dt(ce)||pe.apply(this,arguments)}function Z(ce,Ue,Be){var Ut,qe=this;Ue=Ue==null?"WARN":Ue;var x="loglevel";function ar(Me){var gt=(xe[Me]||"silent").toUpperCase();if(typeof window!==Ae&&x){try{return void(window.localStorage[x]=gt)}catch{}try{window.document.cookie=encodeURIComponent(x)+"="+gt+";"}catch{}}}function Bt(){var Me;if(typeof window!==Ae&&x){try{Me=window.localStorage[x]}catch{}if(typeof Me===Ae)try{var gt=window.document.cookie,Xe=gt.indexOf(encodeURIComponent(x)+"=");Xe!==-1&&(Me=/^([^;]+)/.exec(gt.slice(Xe))[1])}catch{}return qe.levels[Me]===void 0&&(Me=void 0),Me}}function Ve(){if(typeof window!==Ae&&x){try{return void window.localStorage.removeItem(x)}catch{}try{window.document.cookie=encodeURIComponent(x)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof ce=="string"?x+=":"+ce:typeof ce=="symbol"&&(x=void 0),qe.name=ce,qe.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},qe.methodFactory=Be||be,qe.getLevel=function(){return Ut},qe.setLevel=function(Me,gt){if(typeof Me=="string"&&qe.levels[Me.toUpperCase()]!==void 0&&(Me=qe.levels[Me.toUpperCase()]),!(typeof Me=="number"&&Me>=0&&Me<=qe.levels.SILENT))throw"log.setLevel() called with invalid level: "+Me;if(Ut=Me,gt!==!1&&ar(Me),Ke.call(qe,Me,ce),typeof console===Ae&&Me<qe.levels.SILENT)return"No console available for logging"},qe.setDefaultLevel=function(Me){Ue=Me,Bt()||qe.setLevel(Me,!1)},qe.resetLevel=function(){qe.setLevel(Ue,!1),Ve()},qe.enableAll=function(Me){qe.setLevel(qe.levels.TRACE,Me)},qe.disableAll=function(Me){qe.setLevel(qe.levels.SILENT,Me)};var sr=Bt();sr==null&&(sr=Ue),qe.setLevel(sr,!1)}var E=new Z,Q={};E.getLogger=function(ce){if(typeof ce!="symbol"&&typeof ce!="string"||ce==="")throw new TypeError("You must supply a name when creating a logger.");var Ue=Q[ce];return Ue||(Ue=Q[ce]=new Z(ce,E.getLevel(),E.methodFactory)),Ue};var F=typeof window!==Ae?window.log:void 0;return E.noConflict=function(){return typeof window!==Ae&&window.log===E&&(window.log=F),E},E.getLoggers=function(){return Q},E.default=E,E},(X=typeof ee=="function"?ee.call(z,K,z,H):ee)===void 0||(H.exports=X)})()},375:function(H,z){"use strict";var K=Object.prototype.hasOwnProperty;function ee(ae){try{return decodeURIComponent(ae.replace(/\+/g," "))}catch{return null}}function X(ae){try{return encodeURIComponent(ae)}catch{return null}}z.stringify=function(ae,ge){ge=ge||"";var ne,Ae,Le=[];for(Ae in typeof ge!="string"&&(ge="?"),ae)if(K.call(ae,Ae)){if((ne=ae[Ae])||ne!=null&&!isNaN(ne)||(ne=""),Ae=X(Ae),ne=X(ne),Ae===null||ne===null)continue;Le.push(Ae+"="+ne)}return Le.length?ge+Le.join("&"):""},z.parse=function(ae){for(var ge,ne=/([^=?#&]+)=?([^&]*)/g,Ae={};ge=ne.exec(ae);){var Le=ee(ge[1]),xe=ee(ge[2]);Le===null||xe===null||Le in Ae||(Ae[Le]=xe)}return Ae}},558:function(){}},B={};function j(H){var z=B[H];if(z!==void 0)return z.exports;var K=B[H]={exports:{}};return R[H].call(K.exports,K,K.exports,j),K.exports}return j.n=function(H){var z=H&&H.__esModule?function(){return H.default}:function(){return H};return j.d(z,{a:z}),z},j.d=function(H,z){for(var K in z)j.o(z,K)&&!j.o(H,K)&&Object.defineProperty(H,K,{enumerable:!0,get:z[K]})},j.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),j.o=function(H,z){return Object.prototype.hasOwnProperty.call(H,z)},j(80)}()},typeof Un=="object"&&typeof Ua=="object"?Ua.exports=w():typeof Un=="object"?Un.mux=w():L.mux=w()})()});var Zs=Ws(($s,Ba)=>{(function L(w){var R,B;R=this,B=function(){"use strict";function j(s,n){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);n&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),e.push.apply(e,t)}return e}function H(s){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?j(Object(e),!0).forEach(function(t){ee(s,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):j(Object(e)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(e,t))})}return s}function z(s,n){for(var e=0;e<n.length;e++){var t=n[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,dt(t.key),t)}}function K(s,n,e){return n&&z(s.prototype,n),e&&z(s,e),Object.defineProperty(s,"prototype",{writable:!1}),s}function ee(s,n,e){return(n=dt(n))in s?Object.defineProperty(s,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[n]=e,s}function X(){return X=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(s[t]=e[t])}return s},X.apply(this,arguments)}function ae(s,n){s.prototype=Object.create(n.prototype),s.prototype.constructor=s,ne(s,n)}function ge(s){return ge=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ge(s)}function ne(s,n){return ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ne(s,n)}function Ae(){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 Le(s,n,e){return Le=Ae()?Reflect.construct.bind():function(t,r,i){var a=[null];a.push.apply(a,r);var o=new(Function.bind.apply(t,a));return i&&ne(o,i.prototype),o},Le.apply(null,arguments)}function xe(s){var n=typeof Map=="function"?new Map:void 0;return xe=function(e){if(e===null||(t=e,Function.toString.call(t).indexOf("[native code]")===-1))return e;var t;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(n!==void 0){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return Le(e,arguments,ge(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ne(r,e)},xe(s)}function je(s,n){(n==null||n>s.length)&&(n=s.length);for(var e=0,t=new Array(n);e<n;e++)t[e]=s[e];return t}function Re(s,n){var e=typeof Symbol!="undefined"&&s[Symbol.iterator]||s["@@iterator"];if(e)return(e=e.call(s)).next.bind(e);if(Array.isArray(s)||(e=function(r,i){if(r){if(typeof r=="string")return je(r,i);var a=Object.prototype.toString.call(r).slice(8,-1);return a==="Object"&&r.constructor&&(a=r.constructor.name),a==="Map"||a==="Set"?Array.from(r):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?je(r,i):void 0}}(s))||n&&s&&typeof s.length=="number"){e&&(s=e);var t=0;return function(){return t>=s.length?{done:!0}:{done:!1,value:s[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
20
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dt(s){var n=function(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}(s,"string");return typeof n=="symbol"?n:String(n)}function Ke(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var pe={exports:{}};(function(s,n){var e,t,r,i,a;e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(o,l,u){if(u=u||{},o=o.trim(),!(l=l.trim())){if(!u.alwaysNormalize)return o;var d=a.parseURL(o);if(!d)throw new Error("Error trying to parse base URL.");return d.path=a.normalizePath(d.path),a.buildURLFromParts(d)}var h=a.parseURL(l);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.alwaysNormalize?(h.path=a.normalizePath(h.path),a.buildURLFromParts(h)):l;var f=a.parseURL(o);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var v=t.exec(f.path);f.netLoc=v[1],f.path=v[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(p.netLoc=f.netLoc,h.path[0]!=="/"))if(h.path){var T=f.path,S=T.substring(0,T.lastIndexOf("/")+1)+h.path;p.path=a.normalizePath(S)}else p.path=f.path,h.params||(p.params=f.params,h.query||(p.query=f.query));return p.path===null&&(p.path=u.alwaysNormalize?a.normalizePath(h.path):h.path),a.buildURLFromParts(p)},parseURL:function(o){var l=e.exec(o);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(o){for(o=o.split("").reverse().join("").replace(r,"");o.length!==(o=o.replace(i,"")).length;);return o.split("").reverse().join("")},buildURLFromParts:function(o){return o.scheme+o.netLoc+o.path+o.params+o.query+o.fragment}},s.exports=a})(pe);var be=pe.exports,Z=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},E=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s}({}),Q=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),F=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown",s}({}),ce=function(){},Ue={trace:ce,debug:ce,log:ce,warn:ce,info:ce,error:ce},Be=Ue;function Ut(s){var n=self.console[s];return n?n.bind(self.console,"["+s+"] >"):ce}function qe(s,n){if(self.console&&s===!0||typeof s=="object"){(function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach(function(a){Be[a]=e[a]?e[a].bind(e):Ut(a)})})(s,"debug","log","info","warn","error");try{Be.log('Debug logs enabled for "'+n+'" in hls.js version 1.4.5')}catch{Be=Ue}}else Be=Ue}var x=Be,ar=/^(\d+)x(\d+)$/,Bt=/(.+?)=(".*?"|.*?)(?:,|$)/g,Ve=function(){function s(e){for(var t in typeof e=="string"&&(e=s.parseAttrList(e)),e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}var n=s.prototype;return n.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},n.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.decimalFloatingPoint=function(e){return parseFloat(this[e])},n.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},n.enumeratedString=function(e){return this[e]},n.bool=function(e){return this[e]==="YES"},n.decimalResolution=function(e){var t=ar.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},s.parseAttrList=function(e){var t,r={};for(Bt.lastIndex=0;(t=Bt.exec(e))!==null;){var i=t[2];i.indexOf('"')===0&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1].trim()]=i}return r},s}();function sr(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var Me=function(){function s(n,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var t=e.attr;for(var r in t)if(Object.prototype.hasOwnProperty.call(n,r)&&n[r]!==t[r]){x.warn('DATERANGE tag attribute: "'+r+'" does not match for tags with ID: "'+n.ID+'"'),this._badValueForSameId=r;break}n=X(new Ve({}),t,n)}if(this.attr=n,this._startDate=new Date(n["START-DATE"]),"END-DATE"in this.attr){var i=new Date(this.attr["END-DATE"]);Z(i.getTime())&&(this._endDate=i)}}return K(s,[{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 n=this.duration;return n!==null?new Date(this._startDate.getTime()+1e3*n):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var n=this.attr.decimalFloatingPoint("DURATION");if(Z(n))return n}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&&Z(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),s}(),gt=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}},Xe="audio",mt="video",Nr="audiovideo",ai=function(){function s(n){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[Xe]=null,e[mt]=null,e[Nr]=null,e),this.baseurl=n}return s.prototype.setByteRange=function(n,e){var t=n.split("@",2),r=[];t.length===1?r[0]=e?e.byteRangeEndOffset:0:r[0]=parseInt(t[1]),r[1]=parseInt(t[0])+r[0],this._byteRange=r},K(s,[{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=be.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(n){this._url=n}}]),s}(),si=function(s){function n(t,r){var i;return(i=s.call(this,r)||this)._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.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 gt,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.type=t,i}ae(n,s);var e=n.prototype;return e.setKeyFormat=function(t){if(this.levelkeys){var r=this.levelkeys[t];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},e.abortRequests=function(){var t,r;(t=this.loader)==null||t.abort(),(r=this.keyLoader)==null||r.abort()},e.setElementaryStreamInfo=function(t,r,i,a,o,l){l===void 0&&(l=!1);var u=this.elementaryStreams,d=u[t];d?(d.startPTS=Math.min(d.startPTS,r),d.endPTS=Math.max(d.endPTS,i),d.startDTS=Math.min(d.startDTS,a),d.endDTS=Math.max(d.endDTS,o)):u[t]={startPTS:r,endPTS:i,startDTS:a,endDTS:o,partial:l}},e.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[Xe]=null,t[mt]=null,t[Nr]=null},K(n,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{var r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Z(this.programDateTime))return null;var t=Z(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){var r=Object.keys(this.levelkeys),i=r.length;if(i>1||i===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}}]),n}(ai),qn=function(s){function n(e,t,r,i,a){var o;(o=s.call(this,r)||this).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.stats=new gt,o.duration=e.decimalFloatingPoint("DURATION"),o.gap=e.bool("GAP"),o.independent=e.bool("INDEPENDENT"),o.relurl=e.enumeratedString("URI"),o.fragment=t,o.index=i;var l=e.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,a),a&&(o.fragOffset=a.fragOffset+a.duration),o}return ae(n,s),K(n,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),n}(ai),ji=function(){function s(n){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.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=n}return s.prototype.reloaded=function(n){if(!n)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-n.lastPartSn,t=this.lastPartIndex-n.lastPartIndex;this.updated=this.endSN!==n.endSN||!!t||!!e,this.advanced=this.endSN>n.endSN||e>0||e===0&&t>0,this.updated||this.advanced?this.misses=Math.floor(.6*n.misses):this.misses=n.misses+1,this.availabilityDelay=n.availabilityDelay},K(s,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Z(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var n=this.driftEndTime-this.driftStartTime;return n>0?1e3*(this.driftEnd-this.driftStart)/n:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var n;return(n=this.partList)!=null&&n.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var n;return(n=this.fragments)!=null&&n.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 n;return(n=this.partList)!=null&&n.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var n;return(n=this.partList)!=null&&n.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),s}();function oi(s){return Uint8Array.from(atob(s),function(n){return n.charCodeAt(0)})}function Vi(s){var n,e,t=s.split(":"),r=null;if(t[0]==="data"&&t.length===2){var i=t[1].split(";"),a=i[i.length-1].split(",");if(a.length===2){var o=a[0]==="base64",l=a[1];o?(i.splice(-1,1),r=oi(l)):(n=Yi(l).subarray(0,16),(e=new Uint8Array(16)).set(n,16-n.length),r=e)}}return r}function Yi(s){return Uint8Array.from(unescape(encodeURIComponent(s)),function(n){return n.charCodeAt(0)})}var Ye={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Ur="org.w3.clearkey",li="com.apple.streamingkeydelivery",gr="com.microsoft.playready",Br="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function ui(s){switch(s){case li:return Ye.FAIRPLAY;case gr:return Ye.PLAYREADY;case Br:return Ye.WIDEVINE;case Ur:return Ye.CLEARKEY}}var Wi="edef8ba979d64acea3c827dcd51d21ed";function di(s){switch(s){case Ye.FAIRPLAY:return li;case Ye.PLAYREADY:return gr;case Ye.WIDEVINE:return Br;case Ye.CLEARKEY:return Ur}}function hi(s){var n=s.drmSystems,e=s.widevineLicenseUrl,t=n?[Ye.FAIRPLAY,Ye.WIDEVINE,Ye.PLAYREADY,Ye.CLEARKEY].filter(function(r){return!!n[r]}):[];return!t[Ye.WIDEVINE]&&e&&t.push(Ye.WIDEVINE),t}var ci=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function zt(s,n,e){return Uint8Array.prototype.slice?s.slice(n,e):new Uint8Array(Array.prototype.slice.call(s,n,e))}var Gr,fi=function(s,n){return n+10<=s.length&&s[n]===73&&s[n+1]===68&&s[n+2]===51&&s[n+3]<255&&s[n+4]<255&&s[n+6]<128&&s[n+7]<128&&s[n+8]<128&&s[n+9]<128},zi=function(s,n){return n+10<=s.length&&s[n]===51&&s[n+1]===68&&s[n+2]===73&&s[n+3]<255&&s[n+4]<255&&s[n+6]<128&&s[n+7]<128&&s[n+8]<128&&s[n+9]<128},mr=function(s,n){for(var e=n,t=0;fi(s,n);)t+=10,t+=Hr(s,n+6),zi(s,n+10)&&(t+=10),n+=t;if(t>0)return s.subarray(e,e+t)},Hr=function(s,n){var e=0;return e=(127&s[n])<<21,e|=(127&s[n+1])<<14,e|=(127&s[n+2])<<7,e|=127&s[n+3]},Xi=function(s,n){return fi(s,n)&&Hr(s,n+6)+10<=s.length-n},Qi=function(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"},jn=function(s){var n=String.fromCharCode(s[0],s[1],s[2],s[3]),e=Hr(s,4);return{type:n,size:e,data:s.subarray(10,10+e)}},vi=function(s){for(var n=0,e=[];fi(s,n);){for(var t=Hr(s,n+6),r=(n+=10)+t;n+8<r;){var i=jn(s.subarray(n)),a=Vn(i);a&&e.push(a),n+=i.size+10}zi(s,n)&&(n+=10)}return e},Vn=function(s){return s.type==="PRIV"?Yn(s):s.type[0]==="W"?$i(s):Ji(s)},Yn=function(s){if(!(s.size<2)){var n=At(s.data,!0),e=new Uint8Array(s.data.subarray(n.length+1));return{key:s.type,info:n,data:e.buffer}}},Ji=function(s){if(!(s.size<2)){if(s.type==="TXXX"){var n=1,e=At(s.data.subarray(n),!0);n+=e.length+1;var t=At(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=At(s.data.subarray(1));return{key:s.type,data:r}}},$i=function(s){if(s.type==="WXXX"){if(s.size<2)return;var n=1,e=At(s.data.subarray(n),!0);n+=e.length+1;var t=At(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=At(s.data);return{key:s.type,data:r}},Zi=function(s){if(s.data.byteLength===8){var n=new Uint8Array(s.data),e=1&n[3],t=(n[4]<<23)+(n[5]<<15)+(n[6]<<7)+n[7];return t/=45,e&&(t+=4772185884e-2),Math.round(t)}},At=function(s,n){n===void 0&&(n=!1);var e=Wn();if(e){var t=e.decode(s);if(n){var r=t.indexOf("\0");return r!==-1?t.substring(0,r):t}return t.replace(/\0/g,"")}for(var i,a,o,l=s.length,u="",d=0;d<l;){if((i=s[d++])===0&&n)return u;if(i!==0&&i!==3)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(i);break;case 12:case 13:a=s[d++],u+=String.fromCharCode((31&i)<<6|63&a);break;case 14:a=s[d++],o=s[d++],u+=String.fromCharCode((15&i)<<12|(63&a)<<6|(63&o)<<0)}}return u};function Wn(){return Gr||self.TextDecoder===void 0||(Gr=new self.TextDecoder("utf-8")),Gr}var Dt=function(s){for(var n="",e=0;e<s.length;e++){var t=s[e].toString(16);t.length<2&&(t="0"+t),n+=t}return n},pr=Math.pow(2,32)-1,zn=[].push,en={video:1,audio:2,id3:3,text:4};function Qe(s){return String.fromCharCode.apply(null,s)}function tn(s,n){var e=s[n]<<8|s[n+1];return e<0?65536+e:e}function Se(s,n){var e=gi(s,n);return e<0?4294967296+e:e}function gi(s,n){return s[n]<<24|s[n+1]<<16|s[n+2]<<8|s[n+3]}function mi(s,n,e){s[n]=e>>24,s[n+1]=e>>16&255,s[n+2]=e>>8&255,s[n+3]=255&e}function Pe(s,n){var e=[];if(!n.length)return e;for(var t=s.byteLength,r=0;r<t;){var i=Se(s,r),a=i>1?r+i:t;if(Qe(s.subarray(r+4,r+8))===n[0])if(n.length===1)e.push(s.subarray(r+8,a));else{var o=Pe(s.subarray(r+8,a),n.slice(1));o.length&&zn.apply(e,o)}r=a}return e}function rn(s){var n=[],e=s[0],t=8,r=Se(s,t);t+=4,t+=e===0?8:16,t+=2;var i=s.length+0,a=tn(s,t);t+=2;for(var o=0;o<a;o++){var l=t,u=Se(s,l);l+=4;var d=2147483647&u;if((2147483648&u)>>>31==1)return x.warn("SIDX has hierarchical references (not supported)"),null;var h=Se(s,l);l+=4,n.push({referenceSize:d,subsegmentDuration:h,info:{duration:h/r,start:i,end:i+d-1}}),i+=d,t=l+=4}return{earliestPresentationTime:0,timescale:r,version:e,referencesCount:a,references:n}}function pi(s){for(var n=[],e=Pe(s,["moov","trak"]),t=0;t<e.length;t++){var r=e[t],i=Pe(r,["tkhd"])[0];if(i){var a=i[0],o=a===0?12:20,l=Se(i,o),u=Pe(r,["mdia","mdhd"])[0];if(u){var d=Se(u,o=(a=u[0])===0?12:20),h=Pe(r,["mdia","hdlr"])[0];if(h){var f=Qe(h.subarray(8,12)),v={soun:Xe,vide:mt}[f];if(v){var p=Pe(r,["mdia","minf","stbl","stsd"])[0],T=void 0;p&&(T=Qe(p.subarray(12,16))),n[l]={timescale:d,type:v},n[v]={timescale:d,id:l,codec:T}}}}}}return Pe(s,["moov","mvex","trex"]).forEach(function(S){var y=Se(S,4),b=n[y];b&&(b.default={duration:Se(S,12),flags:Se(S,20)})}),n}function yi(s){var n=Pe(s,["schm"])[0];if(n){var e=Qe(n.subarray(4,8));if(e==="cbcs"||e==="cenc")return Pe(s,["schi","tenc"])[0]}return x.error("[eme] missing 'schm' box"),null}function Xn(s){var n=Se(s,0),e=8;1&n&&(e+=4),4&n&&(e+=4);for(var t=0,r=Se(s,4),i=0;i<r;i++)256&n&&(t+=Se(s,e),e+=4),512&n&&(e+=4),1024&n&&(e+=4),2048&n&&(e+=4);return t}function Xt(s,n){var e=new Uint8Array(s.length+n.length);return e.set(s),e.set(n,s.length),e}function Ti(s,n){var e=[],t=n.samples,r=n.timescale,i=n.id,a=!1;return Pe(t,["moof"]).map(function(o){var l=o.byteOffset-8;Pe(o,["traf"]).map(function(u){var d=Pe(u,["tfdt"]).map(function(h){var f=h[0],v=Se(h,4);return f===1&&(v*=Math.pow(2,32),v+=Se(h,8)),v/r})[0];return d!==void 0&&(s=d),Pe(u,["tfhd"]).map(function(h){var f=Se(h,4),v=16777215&Se(h,0),p=0,T=(16&v)!=0,S=0,y=(32&v)!=0,b=8;f===i&&((1&v)!=0&&(b+=8),(2&v)!=0&&(b+=4),(8&v)!=0&&(p=Se(h,b),b+=4),T&&(S=Se(h,b),b+=4),y&&(b+=4),n.type==="video"&&(a=function(C){if(!C)return!1;var D=C.indexOf("."),O=D<0?C:C.substring(0,D);return O==="hvc1"||O==="hev1"||O==="dvh1"||O==="dvhe"}(n.codec)),Pe(u,["trun"]).map(function(C){var D=C[0],O=16777215&Se(C,0),N=(1&O)!=0,G=0,W=(4&O)!=0,q=(256&O)!=0,V=0,te=(512&O)!=0,J=0,oe=(1024&O)!=0,me=(2048&O)!=0,ue=0,ve=Se(C,4),Te=8;N&&(G=Se(C,Te),Te+=4),W&&(Te+=4);for(var ye=G+l,we=0;we<ve;we++){if(q?(V=Se(C,Te),Te+=4):V=p,te?(J=Se(C,Te),Te+=4):J=S,oe&&(Te+=4),me&&(ue=D===0?Se(C,Te):gi(C,Te),Te+=4),n.type===mt)for(var Ce=0;Ce<J;){var Oe=Se(t,ye);nn(a,t[ye+=4])&&an(t.subarray(ye,ye+Oe),a?2:1,s+ue/r,e),ye+=Oe,Ce+=Oe+4}s+=V/r}}))})})}),e}function nn(s,n){if(s){var e=n>>1&63;return e===39||e===40}return(31&n)==6}function an(s,n,e,t){var r=sn(s),i=0;i+=n;for(var a=0,o=0,l=!1,u=0;i<r.length;){a=0;do{if(i>=r.length)break;a+=u=r[i++]}while(u===255);o=0;do{if(i>=r.length)break;o+=u=r[i++]}while(u===255);var d=r.length-i;if(!l&&a===4&&i<r.length){if(l=!0,r[i++]===181){var h=tn(r,i);if(i+=2,h===49){var f=Se(r,i);if(i+=4,f===1195456820){var v=r[i++];if(v===3){var p=r[i++],T=64&p,S=T?2+3*(31&p):0,y=new Uint8Array(S);if(T){y[0]=p;for(var b=1;b<S;b++)y[b]=r[i++]}t.push({type:v,payloadType:a,pts:e,bytes:y})}}}}}else if(a===5&&o<d){if(l=!0,o>16){for(var C=[],D=0;D<16;D++){var O=r[i++].toString(16);C.push(O.length==1?"0"+O:O),D!==3&&D!==5&&D!==7&&D!==9||C.push("-")}for(var N=o-16,G=new Uint8Array(N),W=0;W<N;W++)G[W]=r[i++];t.push({payloadType:a,pts:e,uuid:C.join(""),userData:At(G),userDataBytes:G})}}else if(o<d)i+=o;else if(o>d)break}}function sn(s){for(var n=s.byteLength,e=[],t=1;t<n-2;)s[t]===0&&s[t+1]===0&&s[t+2]===3?(e.push(t+2),t+=2):t++;if(e.length===0)return s;var r=n-e.length,i=new Uint8Array(r),a=0;for(t=0;t<r;a++,t++)a===e[0]&&(a++,e.shift()),i[t]=s[a];return i}function on(s,n,e){if(s.byteLength!==16)throw new RangeError("Invalid system id");var t,r,i;if(n){t=1,r=new Uint8Array(16*n.length);for(var a=0;a<n.length;a++){var o=n[a];if(o.byteLength!==16)throw new RangeError("Invalid key");r.set(o,16*a)}}else t=0,r=new Uint8Array;t>0?(i=new Uint8Array(4),n.length>0&&new DataView(i.buffer).setUint32(0,n.length,!1)):i=new Uint8Array;var l=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(l.buffer).setUint32(0,e.byteLength,!1),function(u){for(var d=arguments.length,h=new Array(d>1?d-1:0),f=1;f<d;f++)h[f-1]=arguments[f];for(var v=h.length,p=8,T=v;T--;)p+=h[T].byteLength;var S=new Uint8Array(p);for(S[0]=p>>24&255,S[1]=p>>16&255,S[2]=p>>8&255,S[3]=255&p,S.set(u,4),T=0,p=8;T<v;T++)S.set(h[T],p),p+=h[T].byteLength;return S}([112,115,115,104],new Uint8Array([t,0,0,0]),s,i,r,l,e||new Uint8Array)}var yr={},Tr=function(){function s(e,t,r,i,a){i===void 0&&(i=[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=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=a,this.encrypted=!!e&&e!=="NONE",this.isCommonEncryption=this.encrypted&&e!=="AES-128"}s.clearKeyUriToKeyIdMap=function(){yr={}};var n=s.prototype;return n.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case li:case Br:case gr:case Ur:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},n.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||x.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=function(S){for(var y=new Uint8Array(16),b=12;b<16;b++)y[b]=S>>8*(15-b)&255;return y}(e);return new s(this.method,this.uri,"identity",this.keyFormatVersions,t)}var r=Vi(this.uri);if(r)switch(this.keyFormat){case Br:this.pssh=r,r.length>=22&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case gr:var i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=on(i,null,r);var a=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),o=String.fromCharCode.apply(null,Array.from(a)),l=o.substring(o.indexOf("<"),o.length),u=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(u){var d=u.childNodes[0]?u.childNodes[0].nodeValue:u.getAttribute("VALUE");if(d){var h=oi(d).subarray(0,16);(function(S){var y=function(b,C,D){var O=b[C];b[C]=b[D],b[D]=O};y(S,0,3),y(S,1,2),y(S,4,5),y(S,6,7)})(h),this.keyId=h}}break;default:var f=r.subarray(0,16);if(f.length!==16){var v=new Uint8Array(16);v.set(f,16-f.length),f=v}this.keyId=f}if(!this.keyId||this.keyId.byteLength!==16){var p=yr[this.uri];if(!p){var T=Object.keys(yr).length%Number.MAX_SAFE_INTEGER;p=new Uint8Array(16),new DataView(p.buffer,12,4).setUint32(0,T),yr[this.uri]=p}this.keyId=p}return this},s}(),ln=/\{\$([a-zA-Z0-9-_]+)\}/g;function un(s){return ln.test(s)}function ht(s,n,e){if(s.variableList!==null||s.hasVariableRefs)for(var t=e.length;t--;){var r=e[t],i=n[r];i&&(n[r]=Lt(s,i))}}function Lt(s,n){if(s.variableList!==null||s.hasVariableRefs){var e=s.variableList;return n.replace(ln,function(t){var r=t.substring(2,t.length-1),i=e==null?void 0:e[r];return i===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+r+'"')),t):i})}return n}function dn(s,n,e){var t,r,i=s.variableList;if(i||(s.variableList=i={}),"QUERYPARAM"in n){t=n.QUERYPARAM;try{var a=new self.URL(e).searchParams;if(!a.has(t))throw new Error('"'+t+'" does not match any query parameter in URI: "'+e+'"');r=a.get(t)}catch(o){s.playlistParsingError||(s.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+o.message))}}else t=n.NAME,r=n.VALUE;t in i?s.playlistParsingError||(s.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+t+'"')):i[t]=r||""}function hn(s,n,e){var t=n.IMPORT;if(e&&t in e){var r=s.variableList;r||(s.variableList=r={}),r[t]=e[t]}else s.playlistParsingError||(s.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+t+'"'))}function Kr(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var Qn={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}},Ei=Kr();function qr(s,n){var e;return(e=Ei==null?void 0:Ei.isTypeSupported((n||"video")+'/mp4;codecs="'+s+'"'))!=null&&e}var Qt=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,or=/#EXT-X-MEDIA:(.*)/g,Jn=/^#EXT(?:INF|-X-TARGETDURATION):/m,bi=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),jr=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|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("|")),Er=function(){function s(){}return s.findGroup=function(n,e){for(var t=0;t<n.length;t++){var r=n[t];if(r.id===e)return r}},s.convertAVC1ToAVCOTI=function(n){var e=n.split(".");if(e.length>2){var t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4)}return n},s.resolve=function(n,e){return be.buildAbsoluteURL(e,n,{alwaysNormalize:!0})},s.isMediaPlaylist=function(n){return Jn.test(n)},s.parseMasterPlaylist=function(n,e){var t,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:un(n)},i=[];for(Qt.lastIndex=0;(t=Qt.exec(n))!=null;)if(t[1]){var a,o=new Ve(t[1]);ht(r,o,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=Lt(r,t[2]),u={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:s.resolve(l,e)},d=o.decimalResolution("RESOLUTION");d&&(u.width=d.width,u.height=d.height),$n((o.CODECS||"").split(/[ ,]+/).filter(function(C){return C}),u),u.videoCodec&&u.videoCodec.indexOf("avc1")!==-1&&(u.videoCodec=s.convertAVC1ToAVCOTI(u.videoCodec)),(a=u.unknownCodecs)!=null&&a.length||i.push(u),r.levels.push(u)}else if(t[3]){var h=t[3],f=t[4];switch(h){case"SESSION-DATA":var v=new Ve(f);ht(r,v,["DATA-ID","LANGUAGE","VALUE","URI"]);var p=v["DATA-ID"];p&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[p]=v);break;case"SESSION-KEY":var T=cn(f,e,r);T.encrypted&&T.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(T)):x.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+f+'"');break;case"DEFINE":var S=new Ve(f);ht(r,S,["NAME","VALUE","QUERYPARAM"]),dn(r,S,e);break;case"CONTENT-STEERING":var y=new Ve(f);ht(r,y,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:s.resolve(y["SERVER-URI"],e),pathwayId:y["PATHWAY-ID"]||"."};break;case"START":r.startTimeOffset=fn(f)}}var b=i.length>0&&i.length<r.levels.length;return r.levels=b?i:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},s.parseMasterPlaylistMedia=function(n,e,t){var r,i={},a=t.levels,o={AUDIO:a.map(function(T){return{id:T.attrs.AUDIO,audioCodec:T.audioCodec}}),SUBTITLES:a.map(function(T){return{id:T.attrs.SUBTITLES,textCodec:T.textCodec}}),"CLOSED-CAPTIONS":[]},l=0;for(or.lastIndex=0;(r=or.exec(n))!==null;){var u=new Ve(r[1]),d=u.TYPE;if(d){var h=o[d],f=i[d]||[];i[d]=f,ht(t,u,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var v={attrs:u,bitrate:0,id:l++,groupId:u["GROUP-ID"]||"",instreamId:u["INSTREAM-ID"],name:u.NAME||u.LANGUAGE||"",type:d,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:u.LANGUAGE,url:u.URI?s.resolve(u.URI,e):""};if(h!=null&&h.length){var p=s.findGroup(h,v.groupId)||h[0];_i(v,p,"audioCodec"),_i(v,p,"textCodec")}f.push(v)}}return i},s.parseLevelPlaylist=function(n,e,t,r,i,a){var o,l,u,d=new ji(e),h=d.fragments,f=null,v=0,p=0,T=0,S=0,y=null,b=new si(r,e),C=-1,D=!1;for(bi.lastIndex=0,d.m3u8=n,d.hasVariableRefs=un(n);(o=bi.exec(n))!==null;){D&&(D=!1,(b=new si(r,e)).start=T,b.sn=v,b.cc=S,b.level=t,f&&(b.initSegment=f,b.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null));var O=o[1];if(O){b.duration=parseFloat(O);var N=(" "+o[2]).slice(1);b.title=N||null,b.tagList.push(N?["INF",O,N]:["INF",O])}else if(o[3]){if(Z(b.duration)){b.start=T,u&&Si(b,u,d),b.sn=v,b.level=t,b.cc=S,b.urlId=i,h.push(b);var G=(" "+o[3]).slice(1);b.relurl=Lt(d,G),vn(b,y),y=b,T+=b.duration,v++,p=0,D=!0}}else if(o[4]){var W=(" "+o[4]).slice(1);y?b.setByteRange(W,y):b.setByteRange(W)}else if(o[5])b.rawProgramDateTime=(" "+o[5]).slice(1),b.tagList.push(["PROGRAM-DATE-TIME",b.rawProgramDateTime]),C===-1&&(C=h.length);else{if(!(o=o[0].match(jr))){x.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<o.length&&o[l]===void 0;l++);var q=(" "+o[l]).slice(1),V=(" "+o[l+1]).slice(1),te=o[l+2]?(" "+o[l+2]).slice(1):"";switch(q){case"PLAYLIST-TYPE":d.type=V.toUpperCase();break;case"MEDIA-SEQUENCE":v=d.startSN=parseInt(V);break;case"SKIP":var J=new Ve(V);ht(d,J,["RECENTLY-REMOVED-DATERANGES"]);var oe=J.decimalInteger("SKIPPED-SEGMENTS");if(Z(oe)){d.skippedSegments=oe;for(var me=oe;me--;)h.unshift(null);v+=oe}var ue=J.enumeratedString("RECENTLY-REMOVED-DATERANGES");ue&&(d.recentlyRemovedDateranges=ue.split(" "));break;case"TARGETDURATION":d.targetduration=Math.max(parseInt(V),1);break;case"VERSION":d.version=parseInt(V);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(V||te)&&b.tagList.push(te?[V,te]:[V]);break;case"DISCONTINUITY":S++,b.tagList.push(["DIS"]);break;case"GAP":b.gap=!0,b.tagList.push([q]);break;case"BITRATE":b.tagList.push([q,V]);break;case"DATERANGE":var ve=new Ve(V);ht(d,ve,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),ht(d,ve,ve.clientAttrs);var Te=new Me(ve,d.dateRanges[ve.ID]);Te.isValid||d.skippedSegments?d.dateRanges[Te.id]=Te:x.warn('Ignoring invalid DATERANGE tag: "'+V+'"'),b.tagList.push(["EXT-X-DATERANGE",V]);break;case"DEFINE":var ye=new Ve(V);ht(d,ye,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in ye?hn(d,ye,a):dn(d,ye,e);break;case"DISCONTINUITY-SEQUENCE":S=parseInt(V);break;case"KEY":var we=cn(V,e,d);if(we.isSupported()){if(we.method==="NONE"){u=void 0;break}u||(u={}),u[we.keyFormat]&&(u=X({},u)),u[we.keyFormat]=we}else x.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+V+'"');break;case"START":d.startTimeOffset=fn(V);break;case"MAP":var Ce=new Ve(V);if(ht(d,Ce,["BYTERANGE","URI"]),b.duration){var Oe=new si(r,e);gn(Oe,Ce,t,u),f=Oe,b.initSegment=f,f.rawProgramDateTime&&!b.rawProgramDateTime&&(b.rawProgramDateTime=f.rawProgramDateTime)}else gn(b,Ce,t,u),f=b,D=!0;break;case"SERVER-CONTROL":var Ge=new Ve(V);d.canBlockReload=Ge.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=Ge.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&Ge.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=Ge.optionalFloat("PART-HOLD-BACK",0),d.holdBack=Ge.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var bt=new Ve(V);d.partTarget=bt.decimalFloatingPoint("PART-TARGET");break;case"PART":var nt=d.partList;nt||(nt=d.partList=[]);var Ht=p>0?nt[nt.length-1]:void 0,Ot=p++,Mt=new Ve(V);ht(d,Mt,["BYTERANGE","URI"]);var at=new qn(Mt,b,e,Ot,Ht);nt.push(at),b.duration+=at.duration;break;case"PRELOAD-HINT":var ut=new Ve(V);ht(d,ut,["URI"]),d.preloadHint=ut;break;case"RENDITION-REPORT":var Vt=new Ve(V);ht(d,Vt,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(Vt);break;default:x.warn("line parsed but not handled: "+o)}}}y&&!y.relurl?(h.pop(),T-=y.duration,d.partList&&(d.fragmentHint=y)):d.partList&&(vn(b,y),b.cc=S,d.fragmentHint=b,u&&Si(b,u,d));var fr=h.length,wt=h[0],Mi=h[fr-1];if((T+=d.skippedSegments*d.targetduration)>0&&fr&&Mi){d.averagetargetduration=T/fr;var Fi=Mi.sn;d.endSN=Fi!=="initSegment"?Fi:0,d.live||(Mi.endList=!0),wt&&(d.startCC=wt.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(T+=d.fragmentHint.duration),d.totalduration=T,d.endCC=S,C>0&&function(Mn,ei){for(var Or=Mn[ei],Ni=ei;Ni--;){var nr=Mn[Ni];if(!nr)return;nr.programDateTime=Or.programDateTime-1e3*nr.duration,Or=nr}}(h,C),d},s}();function cn(s,n,e){var t,r,i=new Ve(s);ht(e,i,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var a=(t=i.METHOD)!=null?t:"",o=i.URI,l=i.hexadecimalInteger("IV"),u=i.KEYFORMATVERSIONS,d=(r=i.KEYFORMAT)!=null?r:"identity";o&&i.IV&&!l&&x.error("Invalid IV: "+i.IV);var h=o?Er.resolve(o,n):"",f=(u||"1").split("/").map(Number).filter(Number.isFinite);return new Tr(a,h,d,f,l)}function fn(s){var n=new Ve(s).decimalFloatingPoint("TIME-OFFSET");return Z(n)?n:null}function $n(s,n){["video","audio","text"].forEach(function(e){var t=s.filter(function(i){return function(a,o){var l=Qn[o];return!!l&&l[a.slice(0,4)]===!0}(i,e)});if(t.length){var r=t.filter(function(i){return i.lastIndexOf("avc1",0)===0||i.lastIndexOf("mp4a",0)===0});n[e+"Codec"]=r.length>0?r[0]:t[0],s=s.filter(function(i){return t.indexOf(i)===-1})}}),n.unknownCodecs=s}function _i(s,n,e){var t=n[e];t&&(s[e]=t)}function vn(s,n){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):n!=null&&n.programDateTime&&(s.programDateTime=n.endProgramDateTime),Z(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function gn(s,n,e,t){s.relurl=n.URI,n.BYTERANGE&&s.setByteRange(n.BYTERANGE),s.level=e,s.sn="initSegment",t&&(s.levelkeys=t),s.initSegment=null}function Si(s,n,e){s.levelkeys=n;var t=e.encryptedFragments;t.length&&t[t.length-1].levelkeys===n||!Object.keys(n).some(function(r){return n[r].isCommonEncryption})||t.push(s)}var lr="manifest",Jt="level",yt="audioTrack",Gt="subtitleTrack",Ne="main",kt="audio",It="subtitle";function mn(s){switch(s.type){case yt:return kt;case Gt:return It;default:return Ne}}function Ai(s,n){var e=s.url;return e!==void 0&&e.indexOf("data:")!==0||(e=n.url),e}var Je=function(){function s(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var n=s.prototype;return n.startLoad=function(e){},n.stopLoad=function(){this.destroyInternalLoaders()},n.registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.unregisterListeners=function(){var e=this.hls;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,a=new(r||i)(t);return this.loaders[e.type]=a,a},n.getInternalLoader=function(e){return this.loaders[e.type]},n.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},n.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},n.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},n.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:lr,url:r,deliveryDirectives:null})},n.onLevelLoading=function(e,t){var r=t.id,i=t.level,a=t.url,o=t.deliveryDirectives;this.load({id:r,level:i,responseType:"text",type:Jt,url:a,deliveryDirectives:o})},n.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,o=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:yt,url:a,deliveryDirectives:o})},n.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,o=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:Gt,url:a,deliveryDirectives:o})},n.load=function(e){var t,r,i,a=this,o=this.hls.config,l=this.getInternalLoader(e);if(l){var u=l.context;if(u&&u.url===e.url)return void x.trace("[playlist-loader]: playlist request ongoing");x.log("[playlist-loader]: aborting previous loader for type: "+e.type),l.abort()}if(r=e.type===lr?o.manifestLoadPolicy.default:X({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),l=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part&&(e.type===Jt&&e.level!==null?i=this.hls.levels[e.level].details:e.type===yt&&e.id!==null?i=this.hls.audioTracks[e.id].details:e.type===Gt&&e.id!==null&&(i=this.hls.subtitleTracks[e.id].details),i)){var d=i.partTarget,h=i.targetduration;if(d&&h){var f=1e3*Math.max(3*d,.8*h);r=X({},r,{maxTimeToFirstByteMs:Math.min(f,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,r.maxTimeToFirstByteMs)})}}var v=r.errorRetry||r.timeoutRetry||{},p={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:v.maxNumRetry||0,retryDelay:v.retryDelayMs||0,maxRetryDelay:v.maxRetryDelayMs||0},T={onSuccess:function(S,y,b,C){var D=a.getInternalLoader(b);a.resetInternalLoader(b.type);var O=S.data;O.indexOf("#EXTM3U")===0?(y.parsing.start=performance.now(),Er.isMediaPlaylist(O)?a.handleTrackOrLevelPlaylist(S,y,b,C||null,D):a.handleMasterPlaylist(S,y,b,C)):a.handleManifestParsingError(S,b,new Error("no EXTM3U delimiter"),C||null,y)},onError:function(S,y,b,C){a.handleNetworkError(y,b,!1,S,C)},onTimeout:function(S,y,b){a.handleNetworkError(y,b,!0,void 0,S)}};l.load(e,p,T)},n.handleMasterPlaylist=function(e,t,r,i){var a=this.hls,o=e.data,l=Ai(e,r),u=Er.parseMasterPlaylist(o,l);if(u.playlistParsingError)this.handleManifestParsingError(e,r,u.playlistParsingError,i,t);else{var d=u.contentSteering,h=u.levels,f=u.sessionData,v=u.sessionKeys,p=u.startTimeOffset,T=u.variableList;this.variableList=T;var S=Er.parseMasterPlaylistMedia(o,l,u),y=S.AUDIO,b=y===void 0?[]:y,C=S.SUBTITLES,D=S["CLOSED-CAPTIONS"];b.length&&(b.some(function(O){return!O.url})||!h[0].audioCodec||h[0].attrs.AUDIO||(x.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),b.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Ve({}),bitrate:0,url:""}))),a.trigger(E.MANIFEST_LOADED,{levels:h,audioTracks:b,subtitles:C,captions:D,contentSteering:d,url:l,stats:t,networkDetails:i,sessionData:f,sessionKeys:v,startTimeOffset:p,variableList:T})}},n.handleTrackOrLevelPlaylist=function(e,t,r,i,a){var o=this.hls,l=r.id,u=r.level,d=r.type,h=Ai(e,r),f=Z(l)?l:0,v=Z(u)?u:f,p=mn(r),T=Er.parseLevelPlaylist(e.data,h,v,p,f,this.variableList);if(d===lr){var S={attrs:new Ve({}),bitrate:0,details:T,name:"",url:h};o.trigger(E.MANIFEST_LOADED,{levels:[S],audioTracks:[],url:h,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=T,this.handlePlaylistLoaded(T,e,t,r,i,a)},n.handleManifestParsingError=function(e,t,r,i,a){this.hls.trigger(E.ERROR,{type:Q.NETWORK_ERROR,details:F.MANIFEST_PARSING_ERROR,fatal:t.type===lr,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:a})},n.handleNetworkError=function(e,t,r,i,a){r===void 0&&(r=!1);var o="A network "+(r?"timeout":"error"+(i?" (status "+i.code+")":""))+" occurred while loading "+e.type;e.type===Jt?o+=": "+e.level+" id: "+e.id:e.type!==yt&&e.type!==Gt||(o+=" id: "+e.id+' group-id: "'+e.groupId+'"');var l=new Error(o);x.warn("[playlist-loader]: "+o);var u=F.UNKNOWN,d=!1,h=this.getInternalLoader(e);switch(e.type){case lr:u=r?F.MANIFEST_LOAD_TIMEOUT:F.MANIFEST_LOAD_ERROR,d=!0;break;case Jt:u=r?F.LEVEL_LOAD_TIMEOUT:F.LEVEL_LOAD_ERROR,d=!1;break;case yt:u=r?F.AUDIO_TRACK_LOAD_TIMEOUT:F.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Gt:u=r?F.SUBTITLE_TRACK_LOAD_TIMEOUT:F.SUBTITLE_LOAD_ERROR,d=!1}h&&this.resetInternalLoader(e.type);var f={type:Q.NETWORK_ERROR,details:u,fatal:d,url:e.url,loader:h,context:e,error:l,networkDetails:t,stats:a};if(i){var v=(t==null?void 0:t.url)||e.url;f.response=H({url:v,data:void 0},i)}this.hls.trigger(E.ERROR,f)},n.handlePlaylistLoaded=function(e,t,r,i,a,o){var l=this.hls,u=i.type,d=i.level,h=i.id,f=i.groupId,v=i.deliveryDirectives,p=Ai(t,i),T=mn(i),S=typeof i.level=="number"&&T===Ne?d:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var y=e.playlistParsingError;if(y)l.trigger(E.ERROR,{type:Q.NETWORK_ERROR,details:F.LEVEL_PARSING_ERROR,fatal:!1,url:p,error:y,reason:y.message,response:t,context:i,level:S,parent:T,networkDetails:a,stats:r});else switch(e.live&&o&&(o.getCacheAge&&(e.ageHeader=o.getCacheAge()||0),o.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),u){case lr:case Jt:l.trigger(E.LEVEL_LOADED,{details:e,level:S||0,id:h||0,stats:r,networkDetails:a,deliveryDirectives:v});break;case yt:l.trigger(E.AUDIO_TRACK_LOADED,{details:e,id:h||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v});break;case Gt:l.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,id:h||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v})}}else{var b=new Error("No Segments found in Playlist");l.trigger(E.ERROR,{type:Q.NETWORK_ERROR,details:F.LEVEL_EMPTY_ERROR,fatal:!1,url:p,error:b,reason:b.message,response:t,context:i,level:S,parent:T,networkDetails:a,stats:r})}},s}();function br(s,n){var e;try{e=new Event("addtrack")}catch{(e=document.createEvent("Event")).initEvent("addtrack",!1,!1)}e.track=s,n.dispatchEvent(e)}function pn(s,n){var e=s.mode;if(e==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(n.id))try{if(s.addCue(n),!s.cues.getCueById(n.id))throw new Error("addCue is failed for: "+n)}catch(r){x.debug("[texttrack-utils]: "+r);var t=new self.TextTrackCue(n.startTime,n.endTime,n.text);t.id=n.id,s.addCue(t)}e==="disabled"&&(s.mode=e)}function ur(s){var n=s.mode;if(n==="disabled"&&(s.mode="hidden"),s.cues)for(var e=s.cues.length;e--;)s.removeCue(s.cues[e]);n==="disabled"&&(s.mode=n)}function Li(s,n,e,t){var r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0)for(var i=function(o,l,u){var d=[],h=function(T,S){if(S<T[0].startTime)return 0;var y=T.length-1;if(S>T[y].endTime)return-1;for(var b=0,C=y;b<=C;){var D=Math.floor((C+b)/2);if(S<T[D].startTime)C=D-1;else{if(!(S>T[D].startTime&&b<y))return D;b=D+1}}return T[b].startTime-S<S-T[C].startTime?b:C}(o,l);if(h>-1)for(var f=h,v=o.length;f<v;f++){var p=o[f];if(p.startTime>=l&&p.endTime<=u)d.push(p);else if(p.startTime>u)return d}return d}(s.cues,n,e),a=0;a<i.length;a++)t&&!t(i[a])||s.removeCue(i[a]);r==="disabled"&&(s.mode=r)}var _r="org.id3",Sr="com.apple.quicktime.HLS",$t="https://aomedia.org/emsg/ID3";function Vr(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var Ar=function(){var s=Vr();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function qt(s,n){return s.getTime()/1e3-n}var Zn=function(){function s(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var n=s.prototype;return n.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},n._registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)},n._unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this)},n.onMediaAttached=function(e,t){this.media=t.media},n.onMediaDetaching=function(){this.id3Track&&(ur(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},n.onManifestLoading=function(){this.dateRangeCuesAppended={}},n.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},n.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if(r.kind==="metadata"&&r.label==="id3")return br(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},n.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(i||a){var o=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var l=Vr(),u=0;u<o.length;u++){var d=o[u].type;if((d!==$t||i)&&a){var h=vi(o[u].data);if(h){var f=o[u].pts,v=f+o[u].duration;v>Ar&&(v=Ar),v-f<=0&&(v=f+.25);for(var p=0;p<h.length;p++){var T=h[p];if(!Qi(T)){this.updateId3CueEnds(f,d);var S=new l(f,v,"");S.value=T,d&&(S.type=d),this.id3Track.addCue(S)}}}}}}}},n.updateId3CueEnds=function(e,t){var r,i=(r=this.id3Track)==null?void 0:r.cues;if(i)for(var a=i.length;a--;){var o=i[a];o.type===t&&o.startTime<e&&o.endTime===Ar&&(o.endTime=e)}},n.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.type,o=this.id3Track,l=this.hls;if(l){var u=l.config,d=u.enableEmsgMetadataCues,h=u.enableID3MetadataCues;o&&(d||h)&&Li(o,r,i,a==="audio"?function(f){return f.type===_r&&h}:a==="video"?function(f){return f.type===$t&&d}:function(f){return f.type===_r&&h||f.type===$t&&d})}},n.onLevelUpdated=function(e,t){var r=this,i=t.details;if(this.media&&i.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,o=this.id3Track,l=i.dateRanges,u=Object.keys(l);if(o)for(var d=Object.keys(a).filter(function(b){return!u.includes(b)}),h=function(){var b=d[f];Object.keys(a[b].cues).forEach(function(C){o.removeCue(a[b].cues[C])}),delete a[b]},f=d.length;f--;)h();var v=i.fragments[i.fragments.length-1];if(u.length!==0&&Z(v==null?void 0:v.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var p=v.programDateTime/1e3-v.start,T=Vr(),S=function(){var b=u[y],C=l[b],D=a[b],O=(D==null?void 0:D.cues)||{},N=(D==null?void 0:D.durationKnown)||!1,G=qt(C.startDate,p),W=Ar,q=C.endDate;if(q)W=qt(q,p),N=!0;else if(C.endOnNext&&!N){var V=u.reduce(function(ye,we){var Ce=l[we];return Ce.class===C.class&&Ce.id!==we&&Ce.startDate>C.startDate&&ye.push(Ce),ye},[]).sort(function(ye,we){return ye.startDate.getTime()-we.startDate.getTime()})[0];V&&(W=qt(V.startDate,p),N=!0)}for(var te,J,oe=Object.keys(C.attr),me=0;me<oe.length;me++){var ue=oe[me];if((J=ue)!=="ID"&&J!=="CLASS"&&J!=="START-DATE"&&J!=="DURATION"&&J!=="END-DATE"&&J!=="END-ON-NEXT"){var ve=O[ue];if(ve)N&&!D.durationKnown&&(ve.endTime=W);else{var Te=C.attr[ue];ve=new T(G,W,""),sr(ue)&&(te=Te,Te=Uint8Array.from(te.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),ve.value={key:ue,data:Te},ve.type=Sr,ve.id=b,r.id3Track.addCue(ve),O[ue]=ve}}}a[b]={cues:O,dateRange:C,durationKnown:N}},y=0;y<u.length;y++)S()}}},s}(),ea=function(){function s(e){var t=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 t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var n=s.prototype;return n.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},n.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(E.ERROR,this.onError,this)},n.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(E.ERROR,this.onError,this)},n.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},n.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},n.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},n.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},n.onError=function(e,t){var r;t.details===F.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&x.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},n.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(r!==null){this._latency=r;var i=this.config,a=i.lowLatencyMode,o=i.maxLiveSyncPlaybackRate;if(a&&o!==1){var l=this.targetLatency;if(l!==null){var u=r-l,d=u<Math.min(this.maxLatency,l+t.targetduration);if(t.live&&d&&u>.05&&this.forwardBufferLength>1){var h=Math.min(2,Math.max(1,o)),f=Math.round(2/(1+Math.exp(-.75*u-this.edgeStalled))*20)/20;e.playbackRate=Math.min(h,Math.max(1,f))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}}}}},n.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},n.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},K(s,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(e===null)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,a=this.config,o=a.liveSyncDuration,l=a.liveSyncDurationCount,u=a.lowLatencyMode,d=this.hls.userConfig,h=u&&r||t;(d.liveSyncDuration||d.liveSyncDurationCount||h===0)&&(h=o!==void 0?o:l*i);var f=i;return h+Math.min(1*this.stallCount,f)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;var i=r.edge,a=e-t-this.edgeStalled,o=i-r.totalduration,l=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(o,a),l)}},{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 t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),s}(),ki=["NONE","TYPE-0","TYPE-1",null],wi="",ta="YES",ra="v2",yn=function(){function s(n,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=n,this.part=e,this.skip=t}return s.prototype.addDirectives=function(n){var e=new self.URL(n);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.href},s}(),Lr=function(){function s(n){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=[n.url],this._attrs=[n.attrs],this.bitrate=n.bitrate,n.details&&(this.details=n.details),this.id=n.id||0,this.name=n.name,this.width=n.width||0,this.height=n.height||0,this.audioCodec=n.audioCodec,this.videoCodec=n.videoCodec,this.unknownCodecs=n.unknownCodecs,this.codecSet=[n.videoCodec,n.audioCodec].filter(function(e){return e}).join(",").replace(/\.[^.,]+/g,"")}return s.prototype.addFallback=function(n){this.url.push(n.url),this._attrs.push(n.attrs)},K(s,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"attrs",get:function(){return this._attrs[this._urlId]}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(n){var e=n%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}},{key:"audioGroupId",get:function(){var n;return(n=this.audioGroupIds)==null?void 0:n[this.urlId]}},{key:"textGroupId",get:function(){var n;return(n=this.textGroupIds)==null?void 0:n[this.urlId]}}]),s}();function Ri(s,n){var e=n.startPTS;if(Z(e)){var t,r=0;n.sn>s.sn?(r=e-s.start,t=s):(r=s.start-e,t=n),t.duration!==r&&(t.duration=r)}else n.sn>s.sn?s.cc===n.cc&&s.minEndPTS?n.start=s.start+(s.minEndPTS-s.start):n.start=s.start+s.duration:n.start=Math.max(s.start-n.duration,0)}function kr(s,n,e,t,r,i){t-e<=0&&(x.warn("Fragment should have a positive duration",n),t=e+n.duration,i=r+n.duration);var a=e,o=t,l=n.startPTS,u=n.endPTS;if(Z(l)){var d=Math.abs(l-e);Z(n.deltaPTS)?n.deltaPTS=Math.max(d,n.deltaPTS):n.deltaPTS=d,a=Math.max(e,l),e=Math.min(e,l),r=Math.min(r,n.startDTS),o=Math.min(t,u),t=Math.max(t,u),i=Math.max(i,n.endDTS)}var h=e-n.start;n.start!==0&&(n.start=e),n.duration=t-n.start,n.startPTS=e,n.maxStartPTS=a,n.startDTS=r,n.endPTS=t,n.minEndPTS=o,n.endDTS=i;var f,v=n.sn;if(!s||v<s.startSN||v>s.endSN)return 0;var p=v-s.startSN,T=s.fragments;for(T[p]=n,f=p;f>0;f--)Ri(T[f],T[f-1]);for(f=p;f<T.length-1;f++)Ri(T[f],T[f+1]);return s.fragmentHint&&Ri(T[T.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,h}function Di(s,n){for(var e=null,t=s.fragments,r=t.length-1;r>=0;r--){var i=t[r].initSegment;if(i){e=i;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var a,o,l,u,d,h=0;if(function(y,b,C){for(var D=b.skippedSegments,O=Math.max(y.startSN,b.startSN)-b.startSN,N=(y.fragmentHint?1:0)+(D?b.endSN:Math.min(y.endSN,b.endSN))-b.startSN,G=b.startSN-y.startSN,W=b.fragmentHint?b.fragments.concat(b.fragmentHint):b.fragments,q=y.fragmentHint?y.fragments.concat(y.fragmentHint):y.fragments,V=O;V<=N;V++){var te=q[G+V],J=W[V];D&&!J&&V<D&&(J=b.fragments[V]=te),te&&J&&C(te,J)}}(s,n,function(y,b){y.relurl&&(h=y.cc-b.cc),Z(y.startPTS)&&Z(y.endPTS)&&(b.start=b.startPTS=y.startPTS,b.startDTS=y.startDTS,b.maxStartPTS=y.maxStartPTS,b.endPTS=y.endPTS,b.endDTS=y.endDTS,b.minEndPTS=y.minEndPTS,b.duration=y.endPTS-y.startPTS,b.duration&&(a=b),n.PTSKnown=n.alignedSliding=!0),b.elementaryStreams=y.elementaryStreams,b.loader=y.loader,b.stats=y.stats,b.urlId=y.urlId,y.initSegment&&(b.initSegment=y.initSegment,e=y.initSegment)}),e&&(n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments).forEach(function(y){var b;y.initSegment&&y.initSegment.relurl!==((b=e)==null?void 0:b.relurl)||(y.initSegment=e)}),n.skippedSegments)if(n.deltaUpdateFailed=n.fragments.some(function(y){return!y}),n.deltaUpdateFailed){x.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var f=n.skippedSegments;f--;)n.fragments.shift();n.startSN=n.fragments[0].sn,n.startCC=n.fragments[0].cc}else n.canSkipDateRanges&&(n.dateRanges=(o=s.dateRanges,l=n.dateRanges,u=n.recentlyRemovedDateranges,d=X({},o),u&&u.forEach(function(y){delete d[y]}),Object.keys(l).forEach(function(y){var b=new Me(l[y].attr,d[y]);b.isValid?d[y]=b:x.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(l[y].attr)+'"')}),d));var v=n.fragments;if(h){x.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<v.length;p++)v[p].cc+=h}n.skippedSegments&&(n.startCC=n.fragments[0].cc),function(y,b,C){if(y&&b)for(var D=0,O=0,N=y.length;O<=N;O++){var G=y[O],W=b[O+D];G&&W&&G.index===W.index&&G.fragment.sn===W.fragment.sn?C(G,W):D--}}(s.partList,n.partList,function(y,b){b.elementaryStreams=y.elementaryStreams,b.stats=y.stats}),a?kr(n,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):Ii(s,n),v.length&&(n.totalduration=n.edge-v[0].start),n.driftStartTime=s.driftStartTime,n.driftStart=s.driftStart;var T=n.advancedDateTime;if(n.advanced&&T){var S=n.edge;n.driftStart||(n.driftStartTime=T,n.driftStart=S),n.driftEndTime=T,n.driftEnd=S}else n.driftEndTime=s.driftEndTime,n.driftEnd=s.driftEnd,n.advancedDateTime=s.advancedDateTime}function Ii(s,n){var e=n.startSN+n.skippedSegments-s.startSN,t=s.fragments;e<0||e>=t.length||wr(n,t[e].start)}function wr(s,n){if(n){for(var e=s.fragments,t=s.skippedSegments;t<e.length;t++)e[t].start+=n;s.fragmentHint&&(s.fragmentHint.start+=n)}}function Tn(s,n,e){var t;return s!=null&&s.details?En((t=s.details)==null?void 0:t.partList,n,e):null}function En(s,n,e){if(s)for(var t=s.length;t--;){var r=s[t];if(r.index===e&&r.fragment.sn===n)return r}return null}function Yr(s){switch(s.details){case F.FRAG_LOAD_TIMEOUT:case F.KEY_LOAD_TIMEOUT:case F.LEVEL_LOAD_TIMEOUT:case F.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function bn(s,n){var e=Yr(n);return s.default[(e?"timeout":"error")+"Retry"]}function Ci(s,n){var e=s.backoff==="linear"?1:Math.pow(2,n);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function _n(s){return H(H({},s),{errorRetry:null,timeoutRetry:null})}function Wr(s,n,e,t){return!!s&&n<s.maxNumRetry&&(function(r){return r===0&&navigator.onLine===!1||!!r&&(r<400||r>499)}(t)||!!e)}var Sn=function(s,n){for(var e=0,t=s.length-1,r=null,i=null;e<=t;){var a=n(i=s[r=(e+t)/2|0]);if(a>0)e=r+1;else{if(!(a<0))return i;t=r-1}}return null};function Rr(s,n,e,t){e===void 0&&(e=0),t===void 0&&(t=0);var r=null;if(s?r=n[s.sn-n[0].sn+1]||null:e===0&&n[0].start===0&&(r=n[0]),r&&zr(e,t,r)===0)return r;var i=Sn(n,zr.bind(null,e,t));return!i||i===s&&r?r:i}function zr(s,n,e){if(s===void 0&&(s=0),n===void 0&&(n=0),e.start<=s&&e.start+e.duration>s)return 0;var t=Math.min(n,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-t<=s?1:e.start-t>s&&e.start?-1:0}function Tt(s,n,e){var t=1e3*Math.min(n,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>s}var Zt,ia=3e5,An=0,m=2,c=5,g=0,_=1,A=2,I=function(){function s(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=x.log.bind(x,"[info]:"),this.warn=x.warn.bind(x,"[warning]:"),this.error=x.error.bind(x,"[error]:"),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(E.ERROR,this.onError,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.ERROR,this.onError,this),e.off(E.ERROR,this.onErrorOut,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this))},n.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},n.startLoad=function(e){this.playlistError=0},n.stopLoad=function(){},n.getVariantLevelIndex=function(e){return(e==null?void 0:e.type)===Ne?e.level:this.hls.loadLevel},n.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},n.onLevelUpdated=function(){this.playlistError=0},n.onError=function(e,t){var r;if(!t.fatal){var i=this.hls,a=t.context;switch(t.details){case F.FRAG_LOAD_ERROR:case F.FRAG_LOAD_TIMEOUT:case F.KEY_LOAD_ERROR:case F.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case F.FRAG_GAP:case F.FRAG_PARSING_ERROR:case F.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=m);case F.LEVEL_EMPTY_ERROR:case F.LEVEL_PARSING_ERROR:var o,l,u=t.parent===Ne?t.level:i.loadLevel;return void(t.details===F.LEVEL_EMPTY_ERROR&&(o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,u):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,u)));case F.LEVEL_LOAD_ERROR:case F.LEVEL_LOAD_TIMEOUT:return void(typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case F.AUDIO_TRACK_LOAD_ERROR:case F.AUDIO_TRACK_LOAD_TIMEOUT:case F.SUBTITLE_LOAD_ERROR:case F.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var d=i.levels[i.loadLevel];if(d&&(a.type===yt&&a.groupId===d.audioGroupId||a.type===Gt&&a.groupId===d.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=m,void(t.errorAction.flags=_)}return;case F.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var h=i.levels[i.loadLevel],f=h==null?void 0:h.attrs["HDCP-LEVEL"];return void(f&&(t.errorAction={action:m,flags:A,hdcpLevel:f}));case F.BUFFER_ADD_CODEC_ERROR:case F.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:i.loadLevel));case F.INTERNAL_EXCEPTION:case F.BUFFER_APPENDING_ERROR:case F.BUFFER_APPEND_ERROR:case F.BUFFER_FULL_ERROR:case F.LEVEL_SWITCH_ERROR:case F.BUFFER_STALLED_ERROR:case F.BUFFER_SEEK_OVER_HOLE:case F.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:An,flags:g})}if(t.type===Q.KEY_SYSTEM_ERROR){var v=this.getVariantLevelIndex(t.frag);return t.levelRetry=!1,void(t.errorAction=this.getLevelSwitchAction(t,v))}}},n.getPlaylistRetryOrSwitchAction=function(e,t){var r,i=bn(this.hls.config.playlistLoadPolicy,e),a=this.playlistError++,o=(r=e.response)==null?void 0:r.code;if(Wr(i,a,Yr(e),o))return{action:c,flags:g,retryConfig:i,retryCount:a};var l=this.getLevelSwitchAction(e,t);return i&&(l.retryConfig=i,l.retryCount=a),l},n.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],a=t.config,o=a.fragLoadPolicy,l=a.keyLoadPolicy,u=bn(e.details.startsWith("key")?l:o,e),d=t.levels.reduce(function(p,T){return p+T.fragmentError},0);if(i){var h;e.details!==F.FRAG_GAP&&i.fragmentError++;var f=(h=e.response)==null?void 0:h.code;if(Wr(u,d,Yr(e),f))return{action:c,flags:g,retryConfig:u,retryCount:d}}var v=this.getLevelSwitchAction(e,r);return u&&(v.retryConfig=u,v.retryCount=d),v},n.getLevelSwitchAction=function(e,t){var r=this.hls;t==null&&(t=r.loadLevel);var i=this.hls.levels[t];if(i&&(i.loadError++,r.autoLevelEnabled)){for(var a,o,l=-1,u=r.levels,d=(a=e.frag)==null?void 0:a.type,h=(o=e.context)!=null?o:{},f=h.type,v=h.groupId,p=u.length;p--;){var T=(p+r.loadLevel)%u.length;if(T!==r.loadLevel&&u[T].loadError===0){var S=u[T];if(e.details===F.FRAG_GAP&&e.frag){var y=u[T].details;if(y){var b=Rr(e.frag,y.fragments,e.frag.start);if(b!=null&&b.gap)continue}}else if(f===yt&&v===S.audioGroupId||f===Gt&&v===S.textGroupId||d===kt&&i.audioGroupId===S.audioGroupId||d===It&&i.textGroupId===S.textGroupId)continue;l=T;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:m,flags:g,nextAutoLevel:l}}return{action:m,flags:_}},n.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case An:break;case m:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===F.FRAG_GAP||(t.fatal=!0)}t.fatal&&this.hls.stopLoad()},n.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var i=r.flags,a=r.hdcpLevel,o=r.nextAutoLevel;switch(i){case g:this.switchLevel(e,o);break;case _:r.resolved||(r.resolved=this.redundantFailover(e));break;case A:a&&(t.maxHdcpLevel=ki[ki.indexOf(a)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(e,o)}},n.switchLevel=function(e,t){t!==void 0&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},n.redundantFailover=function(e){var t=this,r=this.hls,i=this.penalizedRenditions,a=e.parent===Ne?e.level:r.loadLevel,o=r.levels[a],l=o.url.length,u=e.frag?e.frag.urlId:o.urlId;o.urlId!==u||e.frag&&!o.details||this.penalizeRendition(o,e);for(var d=function(){var v=(u+h)%l,p=i[v];if(!p||function(T,S,y){if(performance.now()-T.lastErrorPerfMs>ia)return!0;var b=T.details;if(S.details===F.FRAG_GAP&&b&&S.frag){var C=S.frag.start,D=Rr(null,b.fragments,C);if(D&&!D.gap)return!0}if(y&&T.errors.length<y.errors.length){var O=T.errors[T.errors.length-1];if(b&&O.frag&&S.frag&&Math.abs(O.frag.start-S.frag.start)>3*b.targetduration)return!0}return!1}(p,e,i[u]))return t.warn("Switching to Redundant Stream "+(v+1)+"/"+l+': "'+o.url[v]+'" after '+e.details),t.playlistError=0,r.levels.forEach(function(T){T.urlId=v}),r.nextLoadLevel=a,{v:!0}},h=1;h<l;h++){var f=d();if(typeof f=="object")return f.v}return!1},n.penalizeRendition=function(e,t){var r=this.penalizedRenditions,i=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(t),i.details=e.details,r[e.urlId]=i},s}(),k=function(){function s(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=x.log.bind(x,t+":"),this.warn=x.warn.bind(x,t+":"),this.hls=e}var n=s.prototype;return n.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},n.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},n.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},n.stopLoad=function(){this.canLoad=!1,this.clearTimer()},n.switchParams=function(e,t){var r=t==null?void 0:t.renditionReports;if(r){for(var i=-1,a=0;a<r.length;a++){var o=r[a],l=void 0;try{l=new self.URL(o.URI,t.url).href}catch(v){x.warn("Could not construct new URL for Rendition Report: "+v),l=o.URI||""}if(l===e){i=a;break}l===e.substring(0,l.length)&&(i=a)}if(i!==-1){var u=r[i],d=parseInt(u["LAST-MSN"])||(t==null?void 0:t.lastPartSn),h=parseInt(u["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var f=Math.min(t.age-t.partTarget,t.targetduration);h>=0&&f>t.partTarget&&(h+=1)}return new yn(d,h>=0?h:void 0,wi)}}},n.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},n.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},n.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)},n.playlistLoaded=function(e,t,r){var i=this,a=t.details,o=t.stats,l=self.performance.now(),u=o.loading.first?Math.max(0,l-o.loading.first):0;if(a.advancedDateTime=Date.now()-u,a.live||r!=null&&r.live){if(a.reloaded(r),r&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),r&&a.fragments.length>0&&Di(r,a),!this.canLoad||!a.live)return;var d,h=void 0,f=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var v=this.hls.config.lowLatencyMode,p=a.lastPartSn,T=a.endSN,S=a.lastPartIndex,y=p===T;S!==-1?(h=y?T+1:p,f=y?v?0:S:S+1):h=T+1;var b=a.age,C=b+a.ageHeader,D=Math.min(C-a.partTarget,1.5*a.targetduration);if(D>0){if(r&&D>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+D+" with playlist age: "+a.age),D=0;else{var O=Math.floor(D/a.targetduration);h+=O,f!==void 0&&(f+=Math.round(D%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+b.toFixed(2)+"s goal: "+D+" skip sn "+O+" to part "+f)}a.tuneInGoal=D}if(d=this.getDeliveryDirectives(a,t.deliveryDirectives,h,f),v||!y)return void this.loadPlaylist(d)}else a.canBlockReload&&(d=this.getDeliveryDirectives(a,t.deliveryDirectives,h,f));var N=this.hls.mainForwardBufferInfo,G=N?N.end-N.len:0,W=function(V,te){te===void 0&&(te=1/0);var J=1e3*V.targetduration;if(V.updated){var oe=V.fragments;if(oe.length&&4*J>te){var me=1e3*oe[oe.length-1].duration;me<J&&(J=me)}}else J/=2;return Math.round(J)}(a,1e3*(a.edge-G));a.updated&&l>this.requestScheduled+W&&(this.requestScheduled=o.loading.start),h!==void 0&&a.canBlockReload?this.requestScheduled=o.loading.first+W-(1e3*a.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+W<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=W);var q=this.requestScheduled-l;q=Math.max(0,q),this.log("reload live playlist "+e+" in "+Math.round(q)+" ms"),this.timer=self.setTimeout(function(){return i.loadPlaylist(d)},q)}else this.clearTimer()},n.getDeliveryDirectives=function(e,t,r,i){var a=function(o,l){var u=o.canSkipUntil,d=o.canSkipDateRanges,h=o.endSN;return u&&(l!==void 0?l-h:0)<u?d?ra:ta:wi}(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=wi),new yn(r,i,a)},n.checkRetry=function(e){var t=this,r=e.details,i=Yr(e),a=e.errorAction,o=a||{},l=o.action,u=o.retryCount,d=u===void 0?0:u,h=o.retryConfig,f=!!a&&!!h&&(l===c||!a.resolved&&l===m);if(f){var v;if(this.requestScheduled=-1,d>=h.maxNumRetry)return!1;if(i&&(v=e.context)!=null&&v.deliveryDirectives)this.warn("Retrying playlist loading "+(d+1)+"/"+h.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var p=Ci(h,d);this.timer=self.setTimeout(function(){return t.loadPlaylist()},p),this.warn("Retrying playlist loading "+(d+1)+"/"+h.maxNumRetry+' after "'+r+'" in '+p+"ms")}e.levelRetry=!0,a.resolved=!0}return f},s}(),P=function(s){function n(t,r){var i;return(i=s.call(this,t,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}ae(n,s);var e=n.prototype;return e._registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(E.FRAG_LOADED,this.onFragLoaded,this),t.on(E.ERROR,this.onError,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(E.FRAG_LOADED,this.onFragLoaded,this),t.off(E.ERROR,this.onError,this)},e.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),s.prototype.destroy.call(this)},e.startLoad=function(){this._levels.forEach(function(t){t.loadError=0,t.fragmentError=0}),s.prototype.startLoad.call(this)},e.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},e.onManifestLoading=function(t,r){this.resetLevels()},e.onManifestLoaded=function(t,r){var i,a=[],o={};r.levels.forEach(function(l){var u,d=l.attrs;((u=l.audioCodec)==null?void 0:u.indexOf("mp4a.40.34"))!==-1&&(Zt||(Zt=/chrome|firefox/i.test(navigator.userAgent)),Zt&&(l.audioCodec=void 0));var h=d.AUDIO,f=d.CODECS,v=d["FRAME-RATE"],p=d["PATHWAY-ID"],T=d.RESOLUTION,S=d.SUBTITLES,y=(p||".")+"-"+l.bitrate+"-"+T+"-"+v+"-"+f;(i=o[y])?i.addFallback(l):(i=new Lr(l),o[y]=i,a.push(i)),U(i,"audio",h),U(i,"text",S)}),this.filterAndSortMediaOptions(a,r)},e.filterAndSortMediaOptions=function(t,r){var i=this,a=[],o=[],l=!1,u=!1,d=!1,h=t.filter(function(b){var C=b.audioCodec,D=b.videoCodec,O=b.width,N=b.height,G=b.unknownCodecs;return l||(l=!(!O||!N)),u||(u=!!D),d||(d=!!C),!(G!=null&&G.length)&&(!C||qr(C,"audio"))&&(!D||qr(D,"video"))});if((l||u)&&d&&(h=h.filter(function(b){var C=b.videoCodec,D=b.width,O=b.height;return!!C||!(!D||!O)})),h.length!==0){r.audioTracks&&M(a=r.audioTracks.filter(function(b){return!b.audioCodec||qr(b.audioCodec,"audio")})),r.subtitles&&M(o=r.subtitles);var f=h.slice(0);h.sort(function(b,C){return b.attrs["HDCP-LEVEL"]!==C.attrs["HDCP-LEVEL"]?(b.attrs["HDCP-LEVEL"]||"")>(C.attrs["HDCP-LEVEL"]||"")?1:-1:b.bitrate!==C.bitrate?b.bitrate-C.bitrate:b.attrs["FRAME-RATE"]!==C.attrs["FRAME-RATE"]?b.attrs.decimalFloatingPoint("FRAME-RATE")-C.attrs.decimalFloatingPoint("FRAME-RATE"):b.attrs.SCORE!==C.attrs.SCORE?b.attrs.decimalFloatingPoint("SCORE")-C.attrs.decimalFloatingPoint("SCORE"):l&&b.height!==C.height?b.height-C.height:0});var v=f[0];if(this.steering&&(h=this.steering.filterParsedLevels(h)).length!==f.length){for(var p=0;p<f.length;p++)if(f[p].pathwayId===h[0].pathwayId){v=f[p];break}}this._levels=h;for(var T=0;T<h.length;T++)if(h[T]===v){this._firstLevel=T,this.log("manifest loaded, "+h.length+" level(s) found, first bitrate: "+v.bitrate);break}var S=d&&!u,y={levels:h,audioTracks:a,subtitleTracks:o,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:d,video:u,altAudio:!S&&a.some(function(b){return!!b.url})};this.hls.trigger(E.MANIFEST_PARSED,y),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then(function(){if(i.hls){var b=new Error("no level with compatible codecs found in manifest");i.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:b,reason:b.message})}})},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===Jt&&r.context.level===this.level&&this.checkRetry(r)},e.onFragLoaded=function(t,r){var i=r.frag;if(i!==void 0&&i.type===Ne){var a=this._levels[i.level];a!==void 0&&(a.loadError=0)}},e.onLevelLoaded=function(t,r){var i,a,o=r.level,l=r.details,u=this._levels[o];if(!u)return this.warn("Invalid level index "+o),void((a=r.deliveryDirectives)!=null&&a.skip&&(l.deltaUpdateFailed=!0));o===this.currentLevelIndex?(u.fragmentError===0&&(u.loadError=0),this.playlistLoaded(o,r,u.details)):(i=r.deliveryDirectives)!=null&&i.skip&&(l.deltaUpdateFailed=!0)},e.onAudioTrackSwitched=function(t,r){var i=this.currentLevel;if(i){var a=this.hls.audioTracks[r.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==a){for(var o=-1,l=0;l<i.audioGroupIds.length;l++)if(i.audioGroupIds[l]===a){o=l;break}o!==-1&&o!==i.urlId&&(i.urlId=o,this.canLoad&&this.startLoad())}}},e.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var a=i.urlId,o=i.uri;if(t)try{o=t.addDirectives(o)}catch(u){this.warn("Could not construct new URL with HLS Delivery Directives: "+u)}var l=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+((t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:"")+" with"+(l?" Pathway "+l:"")+" URI "+(a+1)+"/"+i.url.length+" "+o),this.clearTimer(),this.hls.trigger(E.LEVEL_LOADING,{url:o,level:r,id:a,deliveryDirectives:t||null})}},e.removeLevel=function(t,r){var i=this,a=function(l,u){return u!==r},o=this._levels.filter(function(l,u){return u!==t||(l.url.length>1&&r!==void 0?(l.url=l.url.filter(a),l.audioGroupIds&&(l.audioGroupIds=l.audioGroupIds.filter(a)),l.textGroupIds&&(l.textGroupIds=l.textGroupIds.filter(a)),l.urlId=0,!0):(i.steering&&i.steering.removeLevel(l),!1))});this.hls.trigger(E.LEVELS_UPDATED,{levels:o})},e.onLevelsUpdated=function(t,r){var i=r.levels;i.forEach(function(a,o){var l=a.details;l!=null&&l.fragments&&l.fragments.forEach(function(u){u.level=o})}),this._levels=i},K(n,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var r=this._levels;if(r.length!==0){if(t<0||t>=r.length){var i=new Error("invalid level idx"),a=t<0;if(this.hls.trigger(E.ERROR,{type:Q.OTHER_ERROR,details:F.LEVEL_SWITCH_ERROR,level:t,fatal:a,error:i,reason:i.message}),a)return;t=Math.min(t,r.length-1)}var o=this.currentLevelIndex,l=this.currentLevel,u=l?l.attrs["PATHWAY-ID"]:void 0,d=r[t],h=d.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=d,o!==t||!d.details||!l||u!==h){this.log("Switching to level "+t+(h?" with Pathway "+h:"")+" from level "+o+(u?" with Pathway "+u:""));var f=X({},d,{level:t,maxBitrate:d.maxBitrate,attrs:d.attrs,uri:d.uri,urlId:d.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(E.LEVEL_SWITCHING,f);var v=d.details;if(!v||v.live){var p=this.switchParams(d.uri,l==null?void 0:l.details);this.loadPlaylist(p)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}]),n}(k);function U(s,n,e){e&&(n==="audio"?(s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds[s.url.length-1]=e):n==="text"&&(s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds[s.url.length-1]=e))}function M(s){var n={};s.forEach(function(e){var t=e.groupId||"";e.id=n[t]=n[t]||0,n[t]++})}var Y="NOT_LOADED",Ee="APPENDING",se="PARTIAL",de="OK",le=function(){function s(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var n=s.prototype;return n._registerListeners=function(){var e=this.hls;e.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this)},n._unregisterListeners=function(){var e=this.hls;e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this)},n.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},n.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var i=r.length;i--;){var a=r[i];if(!a)break;var o=a.end;if(a.start<=e&&o!==null&&e<=o)return a}return this.getBufferedFrag(e,t)},n.getBufferedFrag=function(e,t){for(var r=this.fragments,i=Object.keys(r),a=i.length;a--;){var o=r[i[a]];if((o==null?void 0:o.body.type)===t&&o.buffered){var l=o.body;if(l.start<=e&&e<=l.end)return l}}return null},n.detectEvictedFragments=function(e,t,r,i){var a=this;this.timeRanges&&(this.timeRanges[e]=t);var o=(i==null?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(function(l){var u=a.fragments[l];if(u&&!(o>=u.body.sn))if(u.buffered||u.loaded){var d=u.range[e];d&&d.time.some(function(h){var f=!a.isTimeBuffered(h.startPTS,h.endPTS,t);return f&&a.removeFragment(u.body),f})}else u.body.type===r&&a.removeFragment(u.body)})},n.detectPartialFragments=function(e){var t=this,r=this.timeRanges,i=e.frag,a=e.part;if(r&&i.sn!=="initSegment"){var o=De(i),l=this.fragments[o];if(l){var u=!i.relurl;Object.keys(r).forEach(function(d){var h=i.elementaryStreams[d];if(h){var f=r[d],v=u||h.partial===!0;l.range[d]=t.getBufferedTimes(i,a,v,f)}}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,l.body.endList&&(this.endListFragments[l.body.type]=l),fe(l)||this.removeParts(i.sn-1,i.type)):this.removeFragment(l.body)}}},n.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(function(i){return i.fragment.sn>=e}))},n.fragBuffered=function(e,t){var r=De(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},n.getBufferedTimes=function(e,t,r,i){for(var a={time:[],partial:r},o=e.start,l=e.end,u=e.minEndPTS||l,d=e.maxStartPTS||o,h=0;h<i.length;h++){var f=i.start(h)-this.bufferPadding,v=i.end(h)+this.bufferPadding;if(d>=f&&u<=v){a.time.push({startPTS:Math.max(o,i.start(h)),endPTS:Math.min(l,i.end(h))});break}if(o<v&&l>f)a.partial=!0,a.time.push({startPTS:Math.max(o,i.start(h)),endPTS:Math.min(l,i.end(h))});else if(l<=f)break}return a},n.getPartialFragment=function(e){var t,r,i,a=null,o=0,l=this.bufferPadding,u=this.fragments;return Object.keys(u).forEach(function(d){var h=u[d];h&&fe(h)&&(r=h.body.start-l,i=h.body.end+l,e>=r&&e<=i&&(t=Math.min(e-r,i-e),o<=t&&(a=h.body,o=t)))}),a},n.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||fe(t))},n.getState=function(e){var t=De(e),r=this.fragments[t];return r?r.buffered?fe(r)?se:de:Ee:Y},n.isTimeBuffered=function(e,t,r){for(var i,a,o=0;o<r.length;o++){if(i=r.start(o)-this.bufferPadding,a=r.end(o)+this.bufferPadding,e>=i&&t<=a)return!0;if(t<=i)return!1}return!1},n.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if(r.sn!=="initSegment"&&!r.bitrateTest){var a=i?null:t,o=De(r);this.fragments[o]={body:r,appendedPTS:null,loaded:a,buffered:!1,range:Object.create(null)}}},n.onBufferAppended=function(e,t){var r=this,i=t.frag,a=t.part,o=t.timeRanges;if(i.sn!=="initSegment"){var l=i.type;if(a){var u=this.activePartLists[l];u||(this.activePartLists[l]=u=[]),u.push(a)}this.timeRanges=o,Object.keys(o).forEach(function(d){var h=o[d];r.detectEvictedFragments(d,h,l,a)})}},n.onFragBuffered=function(e,t){this.detectPartialFragments(t)},n.hasFragment=function(e){var t=De(e);return!!this.fragments[t]},n.hasParts=function(e){var t;return!((t=this.activePartLists[e])==null||!t.length)},n.removeFragmentsInRange=function(e,t,r,i,a){var o=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach(function(l){var u=o.fragments[l];if(u){var d=u.body;d.type!==r||i&&!d.gap||d.start<t&&d.end>e&&(u.buffered||a)&&o.removeFragment(d)}})},n.removeFragment=function(e){var t=De(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=r.filter(function(a){return a.fragment.sn!==i})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},n.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},s}();function fe(s){var n,e,t;return s.buffered&&(s.body.gap||((n=s.range.video)==null?void 0:n.partial)||((e=s.range.audio)==null?void 0:e.partial)||((t=s.range.audiovideo)==null?void 0:t.partial))}function De(s){return s.type+"_"+s.level+"_"+s.urlId+"_"+s.sn}var $e=Math.pow(2,17),it=function(){function s(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var n=s.prototype;return n.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},n.abort=function(){this.loader&&this.loader.abort()},n.load=function(e,t){var r=this,i=e.url;if(!i)return Promise.reject(new ke({type:Q.NETWORK_ERROR,details:F.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,o=a.fLoader,l=a.loader;return new Promise(function(u,d){if(r.loader&&r.loader.destroy(),e.gap)d(pt(e));else{var h=r.loader=e.loader=o?new o(a):new l(a),f=st(e),v=_n(a.fragLoadPolicy.default),p={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:$e};e.stats=h.stats,h.load(f,p,{onSuccess:function(T,S,y,b){r.resetLoader(e,h);var C=T.data;y.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(C.slice(0,16)),C=C.slice(16)),u({frag:e,part:null,payload:C,networkDetails:b})},onError:function(T,S,y,b){r.resetLoader(e,h),d(new ke({type:Q.NETWORK_ERROR,details:F.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:H({url:i,data:void 0},T),error:new Error("HTTP Error "+T.code+" "+T.text),networkDetails:y,stats:b}))},onAbort:function(T,S,y){r.resetLoader(e,h),d(new ke({type:Q.NETWORK_ERROR,details:F.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:y,stats:T}))},onTimeout:function(T,S,y){r.resetLoader(e,h),d(new ke({type:Q.NETWORK_ERROR,details:F.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+p.timeout+"ms"),networkDetails:y,stats:T}))},onProgress:function(T,S,y,b){t&&t({frag:e,part:null,payload:y,networkDetails:b})}})}})},n.loadPart=function(e,t,r){var i=this;this.abort();var a=this.config,o=a.fLoader,l=a.loader;return new Promise(function(u,d){if(i.loader&&i.loader.destroy(),e.gap||t.gap)d(pt(e,t));else{var h=i.loader=e.loader=o?new o(a):new l(a),f=st(e,t),v=_n(a.fragLoadPolicy.default),p={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:$e};t.stats=h.stats,h.load(f,p,{onSuccess:function(T,S,y,b){i.resetLoader(e,h),i.updateStatsFromPart(e,t);var C={frag:e,part:t,payload:T.data,networkDetails:b};r(C),u(C)},onError:function(T,S,y,b){i.resetLoader(e,h),d(new ke({type:Q.NETWORK_ERROR,details:F.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:H({url:f.url,data:void 0},T),error:new Error("HTTP Error "+T.code+" "+T.text),networkDetails:y,stats:b}))},onAbort:function(T,S,y){e.stats.aborted=t.stats.aborted,i.resetLoader(e,h),d(new ke({type:Q.NETWORK_ERROR,details:F.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:y,stats:T}))},onTimeout:function(T,S,y){i.resetLoader(e,h),d(new ke({type:Q.NETWORK_ERROR,details:F.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+p.timeout+"ms"),networkDetails:y,stats:T}))}})}})},n.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,a=i.total;if(r.loaded+=i.loaded,a){var o=Math.round(e.duration/t.duration),l=Math.min(Math.round(r.loaded/a),o),u=(o-l)*Math.round(r.loaded/l);r.total=r.loaded+u}else r.total=Math.max(r.loaded,r.total);var d=r.loading,h=i.loading;d.start?d.first+=h.first-h.start:(d.start=h.start,d.first=h.first),d.end=h.end},n.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},s}();function st(s,n){n===void 0&&(n=null);var e=n||s,t={frag:s,part:n,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},r=e.byteRangeStartOffset,i=e.byteRangeEndOffset;if(Z(r)&&Z(i)){var a,o=r,l=i;if(s.sn==="initSegment"&&((a=s.decryptdata)==null?void 0:a.method)==="AES-128"){var u=i-r;u%16&&(l=i+(16-u%16)),r!==0&&(t.resetIV=!0,o=r-16)}t.rangeStart=o,t.rangeEnd=l}return t}function pt(s,n){var e=new Error("GAP "+(s.gap?"tag":"attribute")+" found"),t={type:Q.MEDIA_ERROR,details:F.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return n&&(t.part=n),(n||s).stats.aborted=!0,new ke(t)}var ke=function(s){function n(e){var t;return(t=s.call(this,e.error.message)||this).data=void 0,t.data=e,t}return ae(n,s),n}(xe(Error)),ze=function(){function s(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var n=s.prototype;return n.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){if(e&&e!==r.context.frag.type)return;r.abort()}}},n.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},n.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},n.createKeyLoadError=function(e,t,r,i,a){return t===void 0&&(t=F.KEY_LOAD_ERROR),new ke({type:Q.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:r,networkDetails:i})},n.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,a=e.cc,o=function(){var u=t[l];if(a<=u.cc&&(i==="initSegment"||u.sn==="initSegment"||i<u.sn))return r.emeController.selectKeySystemFormat(u).then(function(d){u.setKeyFormat(d)}),"break"},l=0;l<t.length&&o()!=="break";l++);},n.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(r){return t.loadInternal(e,r)}):this.loadInternal(e)},n.loadInternal=function(e,t){var r,i;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var o=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,F.KEY_LOAD_ERROR,o))}var l=a.uri;if(!l)return Promise.reject(this.createKeyLoadError(e,F.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+l+'"')));var u,d=this.keyUriToKeyInfo[l];if((r=d)!=null&&r.decryptdata.key)return a.key=d.decryptdata.key,Promise.resolve({frag:e,keyInfo:d});if((i=d)!=null&&i.keyLoadPromise)switch((u=d.mediaKeySessionContext)==null?void 0:u.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return d.keyLoadPromise.then(function(h){return a.key=h.keyInfo.decryptdata.key,{frag:e,keyInfo:d}})}switch(d=this.keyUriToKeyInfo[l]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return a.keyFormat==="identity"?this.loadKeyHTTP(d,e):this.loadKeyEME(d,e);case"AES-128":return this.loadKeyHTTP(d,e);default:return Promise.reject(this.createKeyLoadError(e,F.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+a.method+'"')))}},n.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then(function(a){return e.mediaKeySessionContext=a,r})).catch(function(a){throw e.keyLoadPromise=null,a})}return Promise.resolve(r)},n.loadKeyHTTP=function(e,t){var r=this,i=this.config,a=new i.loader(i);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise(function(o,l){var u={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=i.keyLoadPolicy.default,h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:function(v,p,T,S){var y=T.frag,b=T.keyInfo,C=T.url;if(!y.decryptdata||b!==r.keyUriToKeyInfo[C])return l(r.createKeyLoadError(y,F.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),S));b.decryptdata.key=y.decryptdata.key=new Uint8Array(v.data),y.keyLoader=null,b.loader=null,o({frag:y,keyInfo:b})},onError:function(v,p,T,S){r.resetLoader(p),l(r.createKeyLoadError(t,F.KEY_LOAD_ERROR,new Error("HTTP Error "+v.code+" loading key "+v.text),T,H({url:u.url,data:void 0},v)))},onTimeout:function(v,p,T){r.resetLoader(p),l(r.createKeyLoadError(t,F.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:function(v,p,T){r.resetLoader(p),l(r.createKeyLoadError(t,F.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};a.load(u,h,f)})},n.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url,a=r.loader;t.keyLoader===a&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],a&&a.destroy()},s}(),Fe=function(){function s(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var n=s.prototype;return n.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},n.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},n.onHandlerDestroyed=function(){},n.hasInterval=function(){return!!this._tickInterval},n.hasNextTick=function(){return!!this._tickTimer},n.setInterval=function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},n.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},n.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},n.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},n.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},n.doTick=function(){},s}(),$={length:0,start:function(){return 0},end:function(){return 0}},re=function(){function s(){}return s.isBuffered=function(n,e){try{if(n){for(var t=s.getBuffered(n),r=0;r<t.length;r++)if(e>=t.start(r)&&e<=t.end(r))return!0}}catch{}return!1},s.bufferInfo=function(n,e,t){try{if(n){var r,i=s.getBuffered(n),a=[];for(r=0;r<i.length;r++)a.push({start:i.start(r),end:i.end(r)});return this.bufferedInfo(a,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},s.bufferedInfo=function(n,e,t){e=Math.max(0,e),n.sort(function(T,S){var y=T.start-S.start;return y||S.end-T.end});var r=[];if(t)for(var i=0;i<n.length;i++){var a=r.length;if(a){var o=r[a-1].end;n[i].start-o<t?n[i].end>o&&(r[a-1].end=n[i].end):r.push(n[i])}else r.push(n[i])}else r=n;for(var l,u=0,d=e,h=e,f=0;f<r.length;f++){var v=r[f].start,p=r[f].end;if(e+t>=v&&e<p)d=v,u=(h=p)-e;else if(e+t<v){l=v;break}}return{len:u,start:d||0,end:h||0,nextStart:l}},s.getBuffered=function(n){try{return n.buffered}catch(e){return x.log("failed to get media.buffered",e),$}},s}(),ie=function(s,n,e,t,r,i){t===void 0&&(t=0),r===void 0&&(r=-1),i===void 0&&(i=!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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=s,this.sn=n,this.id=e,this.size=t,this.part=r,this.partial=i};function _e(s,n){for(var e=null,t=0,r=s.length;t<r;t++){var i=s[t];if(i&&i.cc===n){e=i;break}}return e}function Ie(s,n){if(s){var e=s.start+n;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function We(s,n){for(var e=n.fragments,t=0,r=e.length;t<r;t++)Ie(e[t],s);n.fragmentHint&&Ie(n.fragmentHint,s),n.alignedSliding=!0}function ct(s,n,e){n&&(function(t,r,i){if(function(o,l,u){return!(!l.details||!(u.endCC>u.startCC||o&&o.cc<u.startCC))}(t,i,r)){var a=function(o,l,u){var d=o.fragments,h=l.fragments;if(h.length&&d.length){var f=_e(d,h[0].cc);if(f&&(!f||f.startPTS))return f;x.log("No frag in previous level to align on")}else x.log("No fragments to align")}(i.details,r);a&&Z(a.start)&&(x.log("Adjusting PTS using last level due to CC increase within current level "+r.url),We(a.start,r))}}(s,e,n),!e.alignedSliding&&n.details&&function(t,r){if(r.fragments.length&&t.hasProgramDateTime&&r.hasProgramDateTime){var i=r.fragments[0].programDateTime,a=t.fragments[0].programDateTime,o=(a-i)/1e3+r.fragments[0].start;o&&Z(o)&&(x.log("Adjusting PTS using programDateTime delta "+(a-i)+"ms, sliding:"+o.toFixed(3)+" "+t.url+" "),We(o,t))}}(e,n.details),e.alignedSliding||!n.details||e.skippedSegments||Ii(n.details,e))}function Ze(s,n){if(s.hasProgramDateTime&&n.hasProgramDateTime){var e=s.fragments,t=n.fragments;if(e.length&&t.length){var r=t[Math.round(t.length/2)-1],i=_e(e,r.cc)||e[Math.round(e.length/2)-1],a=r.programDateTime,o=i.programDateTime;a!==null&&o!==null&&We((o-a)/1e3-(i.start-r.start),s)}}}var ot=function(){function s(n,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=n,this.aesIV=e}return s.prototype.decrypt=function(n,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,n)},s}(),et=function(){function s(n,e){this.subtle=void 0,this.key=void 0,this.subtle=n,this.key=e}return s.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},s}(),tt=function(){function s(){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 n=s.prototype;return n.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},n.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],o=r[2],l=r[3],u=this.invSubMix,d=u[0],h=u[1],f=u[2],v=u[3],p=new Uint32Array(256),T=0,S=0,y=0;for(y=0;y<256;y++)p[y]=y<128?y<<1:y<<1^283;for(y=0;y<256;y++){var b=S^S<<1^S<<2^S<<3^S<<4;b=b>>>8^255&b^99,e[T]=b,t[b]=T;var C=p[T],D=p[C],O=p[D],N=257*p[b]^16843008*b;i[T]=N<<24|N>>>8,a[T]=N<<16|N>>>16,o[T]=N<<8|N>>>24,l[T]=N,N=16843009*O^65537*D^257*C^16843008*T,d[b]=N<<24|N>>>8,h[b]=N<<16|N>>>16,f[b]=N<<8|N>>>24,v[b]=N,T?(T=C^p[p[p[O^C]]],S^=p[p[S]]):T=S=1}},n.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var a=this.keySize=t.length;if(a!==4&&a!==6&&a!==8)throw new Error("Invalid aes key size="+a);var o,l,u,d,h=this.ksRows=4*(a+6+1),f=this.keySchedule=new Uint32Array(h),v=this.invKeySchedule=new Uint32Array(h),p=this.sBox,T=this.rcon,S=this.invSubMix,y=S[0],b=S[1],C=S[2],D=S[3];for(o=0;o<h;o++)o<a?u=f[o]=t[o]:(d=u,o%a==0?(d=p[(d=d<<8|d>>>24)>>>24]<<24|p[d>>>16&255]<<16|p[d>>>8&255]<<8|p[255&d],d^=T[o/a|0]<<24):a>6&&o%a==4&&(d=p[d>>>24]<<24|p[d>>>16&255]<<16|p[d>>>8&255]<<8|p[255&d]),f[o]=u=(f[o-a]^d)>>>0);for(l=0;l<h;l++)o=h-l,d=3&l?f[o]:f[o-4],v[l]=l<4||o<=4?d:y[p[d>>>24]]^b[p[d>>>16&255]]^C[p[d>>>8&255]]^D[p[255&d]],v[l]=v[l]>>>0}},n.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},n.decrypt=function(e,t,r){for(var i,a,o,l,u,d,h,f,v,p,T,S,y,b,C=this.keySize+6,D=this.invKeySchedule,O=this.invSBox,N=this.invSubMix,G=N[0],W=N[1],q=N[2],V=N[3],te=this.uint8ArrayToUint32Array_(r),J=te[0],oe=te[1],me=te[2],ue=te[3],ve=new Int32Array(e),Te=new Int32Array(ve.length),ye=this.networkToHostOrderSwap;t<ve.length;){for(v=ye(ve[t]),p=ye(ve[t+1]),T=ye(ve[t+2]),S=ye(ve[t+3]),u=v^D[0],d=S^D[1],h=T^D[2],f=p^D[3],y=4,b=1;b<C;b++)i=G[u>>>24]^W[d>>16&255]^q[h>>8&255]^V[255&f]^D[y],a=G[d>>>24]^W[h>>16&255]^q[f>>8&255]^V[255&u]^D[y+1],o=G[h>>>24]^W[f>>16&255]^q[u>>8&255]^V[255&d]^D[y+2],l=G[f>>>24]^W[u>>16&255]^q[d>>8&255]^V[255&h]^D[y+3],u=i,d=a,h=o,f=l,y+=4;i=O[u>>>24]<<24^O[d>>16&255]<<16^O[h>>8&255]<<8^O[255&f]^D[y],a=O[d>>>24]<<24^O[h>>16&255]<<16^O[f>>8&255]<<8^O[255&u]^D[y+1],o=O[h>>>24]<<24^O[f>>16&255]<<16^O[u>>8&255]<<8^O[255&d]^D[y+2],l=O[f>>>24]<<24^O[u>>16&255]<<16^O[d>>8&255]<<8^O[255&h]^D[y+3],Te[t]=ye(i^J),Te[t+1]=ye(l^oe),Te[t+2]=ye(o^me),Te[t+3]=ye(a^ue),J=v,oe=p,me=T,ue=S,t+=4}return Te.buffer},s}(),Ct=function(){function s(e,t){var r=(t===void 0?{}:t).removePKCS7Padding,i=r===void 0||r;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=e.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var n=s.prototype;return n.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},n.isSync=function(){return this.useSoftware},n.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,a,o=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=o).byteLength,(a=i&&new DataView(r.buffer).getUint8(i-1))?zt(r,0,i-a):r):o},n.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},n.decrypt=function(e,t,r){var i=this;return this.useSoftware?new Promise(function(a,o){i.softwareDecrypt(new Uint8Array(e),t,r);var l=i.flush();l?a(l.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)},n.softwareDecrypt=function(e,t,r){var i=this.currentIV,a=this.currentResult,o=this.remainderData;this.logOnce("JS AES decrypt"),o&&(e=Xt(o,e),this.remainderData=null);var l=this.getValidChunk(e);if(!l.length)return null;i&&(r=i);var u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new tt),u.expandKey(t);var d=a;return this.currentResult=u.decrypt(l.buffer,0,r),this.currentIV=zt(l,-16).buffer,d||null},n.webCryptoDecrypt=function(e,t,r){var i=this,a=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new et(a,t)),this.fastAesKey.expandKey().then(function(o){return a?(i.logOnce("WebCrypto AES decrypt"),new ot(a,new Uint8Array(r)).decrypt(e.buffer,o)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(o){return x.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+o.name+": "+o.message),i.onWebCryptoError(e,t,r)})},n.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},n.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=zt(e,0,r),this.remainderData=zt(e,r)),t},n.logOnce=function(e){this.logEnabled&&(x.log("[decrypter]: "+e),this.logEnabled=!1)},s}(),Dr=function(s){for(var n="",e=s.length,t=0;t<e;t++)n+="["+s.start(t).toFixed(3)+"-"+s.end(t).toFixed(3)+"]";return n},rt="STOPPED",he="IDLE",er="KEY_LOADING",dr="FRAG_LOADING",hr="FRAG_LOADING_WAITING_RETRY",Ir="WAITING_TRACK",tr="PARSING",Ln="PARSED",xi="ENDED",Xr="ERROR",Pi="WAITING_INIT_PTS",Qr="WAITING_LEVEL",na=function(s){function n(t,r,i,a,o){var l;return(l=s.call(this)||this).hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=rt,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.loadedmetadata=!1,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.onvseeking=null,l.onvended=null,l.logPrefix="",l.log=void 0,l.warn=void 0,l.playlistType=o,l.logPrefix=a,l.log=x.log.bind(x,a+":"),l.warn=x.warn.bind(x,a+":"),l.hls=t,l.fragmentLoader=new it(t.config),l.keyLoader=i,l.fragmentTracker=r,l.config=t.config,l.decrypter=new Ct(t.config),t.on(E.MANIFEST_LOADED,l.onManifestLoaded,function(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(l)),l}ae(n,s);var e=n.prototype;return e.doTick=function(){this.onTickEnd()},e.onTickEnd=function(){},e.startLoad=function(t){},e.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=rt},e._streamEnded=function(t,r){if(r.live||t.nextStart||!t.end||!this.media)return!1;var i=r.partList;if(i!=null&&i.length){var a=i[i.length-1];return re.isBuffered(this.media,a.start+a.duration/2)}var o=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)},e.getLevelDetails=function(){var t;if(this.levels&&this.levelLastLoaded!==null)return(t=this.levels[this.levelLastLoaded])==null?void 0:t.details},e.onMediaAttached=function(t,r){var i=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);var a=this.config;this.levels&&a.autoStartLoad&&this.state===rt&&this.startLoad(a.startPosition)},e.onMediaDetaching=function(){var t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.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()},e.onMediaSeeking=function(){var t=this.config,r=this.fragCurrent,i=this.media,a=this.mediaBuffer,o=this.state,l=i?i.currentTime:0,u=re.bufferInfo(a||i,l,t.maxBufferHole);if(this.log("media seeking to "+(Z(l)?l.toFixed(3):l)+", state: "+o),this.state===xi)this.resetLoadingState();else if(r){var d=t.maxFragLookUpTolerance,h=r.start-d,f=r.start+r.duration+d;if(!u.len||f<u.start||h>u.end){var v=l>f;(l<h||v)&&(v&&r.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(l,1/0,this.playlistType,!0),this.lastCurrentTime=l),this.loadedmetadata||u.len||(this.nextLoadPosition=this.startPosition=l),this.tickImmediate()},e.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},e.onManifestLoaded=function(t,r){this.startTimeOffset=r.startTimeOffset,this.initPTS=[]},e.onHandlerDestroying=function(){this.stopLoad(),s.prototype.onHandlerDestroying.call(this)},e.onHandlerDestroyed=function(){this.state=rt,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,s.prototype.onHandlerDestroyed.call(this)},e.loadFragment=function(t,r,i){this._loadFragForPlayback(t,r,i)},e._loadFragForPlayback=function(t,r,i){var a=this;this._doFragLoad(t,r,i,function(o){if(a.fragContextChanged(t))return a.warn("Fragment "+t.sn+(o.part?" p: "+o.part.index:"")+" of level "+t.level+" was dropped during download."),void a.fragmentTracker.removeFragment(t);t.stats.chunkCount++,a._handleFragmentLoadProgress(o)}).then(function(o){if(o){var l=a.state;a.fragContextChanged(t)?(l===dr||!a.fragCurrent&&l===tr)&&(a.fragmentTracker.removeFragment(t),a.state=he):("payload"in o&&(a.log("Loaded fragment "+t.sn+" of level "+t.level),a.hls.trigger(E.FRAG_LOADED,o)),a._handleFragmentLoadComplete(o))}}).catch(function(o){a.state!==rt&&a.state!==Xr&&(a.warn(o),a.resetFragmentLoading(t))})},e.clearTrackerIfNeeded=function(t){var r,i=this.fragmentTracker;if(i.getState(t)===Ee){var a=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,a),l=Math.max(t.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(l)&&i.removeFragment(t)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===se&&i.removeFragment(t))},e.flushMainBuffer=function(t,r,i){if(i===void 0&&(i=null),t-r){var a={startOffset:t,endOffset:r,type:i};this.hls.trigger(E.BUFFER_FLUSHING,a)}},e._loadInitSegment=function(t,r){var i=this;this._doFragLoad(t,r).then(function(a){if(!a||i.fragContextChanged(t)||!i.levels)throw new Error("init load aborted");return a}).then(function(a){var o=i.hls,l=a.payload,u=t.decryptdata;if(l&&l.byteLength>0&&u&&u.key&&u.iv&&u.method==="AES-128"){var d=self.performance.now();return i.decrypter.decrypt(new Uint8Array(l),u.key.buffer,u.iv.buffer).catch(function(h){throw o.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_DECRYPT_ERROR,fatal:!1,error:h,reason:h.message,frag:t}),h}).then(function(h){var f=self.performance.now();return o.trigger(E.FRAG_DECRYPTED,{frag:t,payload:h,stats:{tstart:d,tdecrypt:f}}),a.payload=h,a})}return a}).then(function(a){var o=i.fragCurrent,l=i.hls;if(!i.levels)throw new Error("init load aborted, missing levels");var u=t.stats;i.state=he,r.fragmentError=0,t.data=new Uint8Array(a.payload),u.parsing.start=u.buffering.start=self.performance.now(),u.parsing.end=u.buffering.end=self.performance.now(),a.frag===o&&l.trigger(E.FRAG_BUFFERED,{stats:u,frag:o,part:null,id:t.type}),i.tick()}).catch(function(a){i.state!==rt&&i.state!==Xr&&(i.warn(a),i.resetFragmentLoading(t))})},e.fragContextChanged=function(t){var r=this.fragCurrent;return!t||!r||t.level!==r.level||t.sn!==r.sn||t.urlId!==r.urlId},e.fragBufferedComplete=function(t,r){var i,a,o,l,u=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+(this.playlistType===Ne?"level":"track")+" "+t.level+" (frag:["+((i=t.startPTS)!=null?i:NaN).toFixed(3)+"-"+((a=t.endPTS)!=null?a:NaN).toFixed(3)+"] > buffer:"+(u?Dr(re.getBuffered(u)):"(detached)")+")"),this.state=he,u&&(!this.loadedmetadata&&t.type==Ne&&u.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},e.seekToStartPos=function(){},e._handleFragmentLoadComplete=function(t){var r=this.transmuxer;if(r){var i=t.frag,a=t.part,o=t.partsLoaded,l=!o||o.length===0||o.some(function(d){return!d}),u=new ie(i.level,i.sn,i.stats.chunkCount+1,0,a?a.index:-1,!l);r.flush(u)}},e._handleFragmentLoadProgress=function(t){},e._doFragLoad=function(t,r,i,a){var o,l=this;i===void 0&&(i=null);var u=r==null?void 0:r.details;if(!this.levels||!u)throw new Error("frag load aborted, missing level"+(u?"":" detail")+"s");var d=null;if(!t.encrypted||(o=t.decryptdata)!=null&&o.key?!t.encrypted&&u.encryptedFragments.length&&this.keyLoader.loadClear(t,u.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+u.startSN+"-"+u.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=er,this.fragCurrent=t,d=this.keyLoader.load(t).then(function(y){if(!l.fragContextChanged(y.frag))return l.hls.trigger(E.KEY_LOADED,y),l.state===er&&(l.state=he),y}),this.hls.trigger(E.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(d=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){var h=u.partList;if(h&&a){i>t.end&&u.fragmentHint&&(t=u.fragmentHint);var f=this.getNextPart(h,t,i);if(f>-1){var v,p=h[f];return this.log("Loading part sn: "+t.sn+" p: "+p.index+" cc: "+t.cc+" of playlist ["+u.startSN+"-"+u.endSN+"] parts [0-"+f+"-"+(h.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=p.start+p.duration,this.state=dr,v=d?d.then(function(y){return!y||l.fragContextChanged(y.frag)?null:l.doFragPartsLoad(t,p,r,a)}).catch(function(y){return l.handleFragLoadError(y)}):this.doFragPartsLoad(t,p,r,a).catch(function(y){return l.handleFragLoadError(y)}),this.hls.trigger(E.FRAG_LOADING,{frag:t,part:p,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):v}if(!t.url||this.loadedEndOfParts(h,i))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(u?"of ["+u.startSN+"-"+u.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),Z(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=dr;var T,S=this.config.progressive;return T=S&&d?d.then(function(y){return!y||l.fragContextChanged(y==null?void 0:y.frag)?null:l.fragmentLoader.load(t,a)}).catch(function(y){return l.handleFragLoadError(y)}):Promise.all([this.fragmentLoader.load(t,S?a:void 0),d]).then(function(y){var b=y[0];return!S&&b&&a&&a(b),b}).catch(function(y){return l.handleFragLoadError(y)}),this.hls.trigger(E.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):T},e.doFragPartsLoad=function(t,r,i,a){var o=this;return new Promise(function(l,u){var d,h=[],f=(d=i.details)==null?void 0:d.partList;(function v(p){o.fragmentLoader.loadPart(t,p,a).then(function(T){h[p.index]=T;var S=T.part;o.hls.trigger(E.FRAG_LOADED,T);var y=Tn(i,t.sn,p.index+1)||En(f,t.sn,p.index+1);if(!y)return l({frag:t,part:S,partsLoaded:h});v(y)}).catch(u)})(r)})},e.handleFragLoadError=function(t){if("data"in t){var r=t.data;t.data&&r.details===F.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(E.ERROR,r)}else this.hls.trigger(E.ERROR,{type:Q.OTHER_ERROR,details:F.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},e._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(r&&this.state===tr){var i=r.frag,a=r.part,o=r.level,l=self.performance.now();i.stats.parsing.end=l,a&&(a.stats.parsing.end=l),this.updateLevelTiming(i,a,o,t.partial)}else this.fragCurrent||this.state===rt||this.state===Xr||(this.state=he)},e.getCurrentContext=function(t){var r=this.levels,i=this.fragCurrent,a=t.level,o=t.sn,l=t.part;if(r==null||!r[a])return this.warn("Levels object was unset while buffering fragment "+o+" of level "+a+". The current chunk will not be buffered."),null;var u=r[a],d=l>-1?Tn(u,o,l):null,h=d?d.fragment:function(f,v,p){if(f==null||!f.details)return null;var T=f.details,S=T.fragments[v-T.startSN];return S||((S=T.fragmentHint)&&S.sn===v?S:v<T.startSN&&p&&p.sn===v?p:null)}(u,o,i);return h?(i&&i!==h&&(h.stats=i.stats),{frag:h,part:d,level:u}):null},e.bufferFragmentData=function(t,r,i,a){var o;if(t&&this.state===tr){var l=t.data1,u=t.data2,d=l;if(l&&u&&(d=Xt(l,u)),(o=d)!=null&&o.length){var h={type:t.type,frag:r,part:i,chunkMeta:a,parent:r.type,data:d};this.hls.trigger(E.BUFFER_APPENDING,h),t.dropped&&t.independent&&!i&&this.flushBufferGap(r)}}},e.flushBufferGap=function(t){var r=this.media;if(r)if(re.isBuffered(r,r.currentTime)){var i=r.currentTime,a=re.bufferInfo(r,i,0),o=t.duration,l=Math.min(2*this.config.maxFragLookUpTolerance,.25*o),u=Math.max(Math.min(t.start-l,a.end-l),i+l);t.start-u>l&&this.flushMainBuffer(u,t.start)}else this.flushMainBuffer(0,t.start)},e.getFwdBufferInfo=function(t,r){var i=this.getLoadPosition();return Z(i)?this.getFwdBufferInfoAtPos(t,i,r):null},e.getFwdBufferInfoAtPos=function(t,r,i){var a=this.config.maxBufferHole,o=re.bufferInfo(t,r,a);if(o.len===0&&o.nextStart!==void 0){var l=this.fragmentTracker.getBufferedFrag(r,i);if(l&&o.nextStart<l.end)return re.bufferInfo(t,r,Math.max(o.nextStart,a))}return o},e.getMaxBufferLength=function(t){var r,i=this.config;return r=t?Math.max(8*i.maxBufferSize/t,i.maxBufferLength):i.maxBufferLength,Math.min(r,i.maxMaxBufferLength)},e.reduceMaxBufferLength=function(t){var r=this.config,i=t||r.maxBufferLength;return r.maxMaxBufferLength>=i&&(r.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+r.maxMaxBufferLength+"s"),!0)},e.getAppendedFrag=function(t,r){var i=this.fragmentTracker.getAppendedFrag(t,Ne);return i&&"fragment"in i?i.fragment:i},e.getNextFragment=function(t,r){var i=r.fragments,a=i.length;if(!a)return null;var o,l=this.config,u=i[0].start;if(r.live){var d=l.initialLiveManifestSize;if(a<d)return this.warn("Not enough fragments to start playback (have: "+a+", need: "+d+")"),null;r.PTSKnown||this.startFragRequested||this.startPosition!==-1||(o=this.getInitialLiveFragment(r,i),this.startPosition=o?this.hls.liveSyncPosition||o.start:t)}else t<=u&&(o=i[0]);if(!o){var h=l.lowLatencyMode?r.partEnd:r.fragmentEnd;o=this.getFragmentAtPosition(t,h,r)}return this.mapToInitFragWhenRequired(o)},e.isLoopLoading=function(t,r){var i=this.fragmentTracker.getState(t);return(i===de||i===se&&!!t.gap)&&this.nextLoadPosition>r},e.getNextFragmentLoopLoading=function(t,r,i,a,o){var l=t.gap,u=this.getNextFragment(this.nextLoadPosition,r);if(u===null)return u;if(t=u,l&&t&&!t.gap&&i.nextStart){var d=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,a);if(d!==null&&i.len+d.len>=o)return this.log('buffer full after gaps in "'+a+'" playlist starting at sn: '+t.sn),null}return t},e.mapToInitFragWhenRequired=function(t){return t==null||!t.initSegment||t!=null&&t.initSegment.data||this.bitrateTest?t:t.initSegment},e.getNextPart=function(t,r,i){for(var a=-1,o=!1,l=!0,u=0,d=t.length;u<d;u++){var h=t[u];if(l=l&&!h.independent,a>-1&&i<h.start)break;var f=h.loaded;f?a=-1:(o||h.independent||l)&&h.fragment===r&&(a=u),o=f}return a},e.loadedEndOfParts=function(t,r){var i=t[t.length-1];return i&&r>i.start&&i.loaded},e.getInitialLiveFragment=function(t,r){var i=this.fragPrevious,a=null;if(i){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),a=function(d,h,f){if(h===null||!Array.isArray(d)||!d.length||!Z(h)||h<(d[0].programDateTime||0)||h>=(d[d.length-1].endProgramDateTime||0))return null;f=f||0;for(var v=0;v<d.length;++v){var p=d[v];if(Tt(h,f,p))return p}return null}(r,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!a){var o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){var l=r[o-t.startSN];i.cc===l.cc&&(a=l,this.log("Live playlist, switching playlist, load frag with next SN: "+a.sn))}a||(a=function(d,h){return Sn(d,function(f){return f.cc<h?1:f.cc>h?-1:0})}(r,i.cc),a&&this.log("Live playlist, switching playlist, load frag with same CC: "+a.sn))}}else{var u=this.hls.liveSyncPosition;u!==null&&(a=this.getFragmentAtPosition(u,this.bitrateTest?t.fragmentEnd:t.edge,t))}return a},e.getFragmentAtPosition=function(t,r,i){var a,o=this.config,l=this.fragPrevious,u=i.fragments,d=i.endSN,h=i.fragmentHint,f=o.maxFragLookUpTolerance,v=i.partList,p=!!(o.lowLatencyMode&&v!=null&&v.length&&h);if(p&&h&&!this.bitrateTest&&(u=u.concat(h),d=h.sn),a=t<r?Rr(l,u,t,t>r-f?0:f):u[u.length-1]){var T=a.sn-i.startSN,S=this.fragmentTracker.getState(a);if((S===de||S===se&&a.gap)&&(l=a),l&&a.sn===l.sn&&(!p||v[0].fragment.sn>a.sn)&&l&&a.level===l.level){var y=u[T+1];a=a.sn<d&&this.fragmentTracker.getState(y)!==de?y:null}}return a},e.synchronizeToLiveEdge=function(t){var r=this.config,i=this.media;if(i){var a=this.hls.liveSyncPosition,o=i.currentTime,l=t.fragments[0].start,u=t.edge,d=o>=l-r.maxFragLookUpTolerance&&o<=u;if(a!==null&&i.duration>a&&(o<a||!d)){var h=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;(!d&&i.readyState<4||o<u-h)&&(this.loadedmetadata||(this.nextLoadPosition=a),i.readyState&&(this.warn("Playback: "+o.toFixed(3)+" is located too far from the end of live sliding playlist: "+u+", reset currentTime to : "+a.toFixed(3)),i.currentTime=a))}}},e.alignPlaylists=function(t,r){var i=this.levels,a=this.levelLastLoaded,o=this.fragPrevious,l=a!==null?i[a]:null,u=t.fragments.length;if(!u)return this.warn("No fragments in live playlist"),0;var d=t.fragments[0].start,h=!r,f=t.alignedSliding&&Z(d);if(h||!f&&!d){ct(o,l,t);var v=t.fragments[0].start;return this.log("Live playlist sliding: "+v.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+t.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+u),v}return d},e.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},e.setStartPosition=function(t,r){var i=this.startPosition;if(i<r&&(i=-1),i===-1||this.lastCurrentTime===-1){var a=this.startTimeOffset!==null,o=a?this.startTimeOffset:t.startTimeOffset;o!==null&&Z(o)?(i=r+o,o<0&&(i+=t.totalduration),i=Math.min(Math.max(r,i),r+t.totalduration),this.log("Start time offset "+o+" found in "+(a?"multivariant":"media")+" playlist, adjust startPosition to "+i),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||r:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i},e.getLoadPosition=function(){var t=this.media,r=0;return this.loadedmetadata&&t?r=t.currentTime:this.nextLoadPosition&&(r=this.nextLoadPosition),r},e.handleFragLoadAborted=function(t,r){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},e.resetFragmentLoading=function(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===hr)||(this.state=he)},e.onFragmentOrKeyLoadError=function(t,r){if(r.chunkMeta&&!r.frag){var i=this.getCurrentContext(r.chunkMeta);i&&(r.frag=i.frag)}var a=r.frag;if(a&&a.type===t&&this.levels)if(this.fragContextChanged(a)){var o;this.warn("Frag load error must match current frag to retry "+a.url+" > "+((o=this.fragCurrent)==null?void 0:o.url))}else{var l=r.details===F.FRAG_GAP;l&&this.fragmentTracker.fragBuffered(a,!0);var u=r.errorAction,d=u||{},h=d.action,f=d.retryCount,v=f===void 0?0:f,p=d.retryConfig;if(u&&h===c&&p){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var T=Ci(p,v);this.warn("Fragment "+a.sn+" of "+t+" "+a.level+" errored with "+r.details+", retrying loading "+(v+1)+"/"+p.maxNumRetry+" in "+T+"ms"),u.resolved=!0,this.retryDate=self.performance.now()+T,this.state=hr}else p&&u?(this.resetFragmentErrors(t),v<p.maxNumRetry?l||(u.resolved=!0):x.warn(r.details+" reached or exceeded max retry ("+v+")")):this.state=Xr;this.tickImmediate()}},e.reduceLengthAndFlushBuffer=function(t){if(this.state===tr||this.state===Ln){var r=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),a=i&&i.len>.5;a&&this.reduceMaxBufferLength(i.len);var o=!a;return o&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+r+" buffer"),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),o}return!1},e.resetFragmentErrors=function(t){t===kt&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==rt&&(this.state=he)},e.afterBufferFlushed=function(t,r,i){if(t){var a=re.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,a,i),this.state===xi&&this.resetLoadingState()}},e.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=he},e.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var r=this.levels?this.levels[t].details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},e.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(t.level),this.resetLoadingState()},e.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},e.updateLevelTiming=function(t,r,i,a){var o,l=this,u=i.details;if(u){if(Object.keys(t.elementaryStreams).reduce(function(h,f){var v=t.elementaryStreams[f];if(v){var p=v.endPTS-v.startPTS;if(p<=0)return l.warn("Could not parse fragment "+t.sn+" "+f+" duration reliably ("+p+")"),h||!1;var T=a?0:kr(u,t,v.startPTS,v.endPTS,v.startDTS,v.endDTS);return l.hls.trigger(E.LEVEL_PTS_UPDATED,{details:u,level:i,drift:T,type:f,frag:t,start:v.startPTS,end:v.endPTS}),!0}return h},!1))i.fragmentError=0;else if(((o=this.transmuxer)==null?void 0:o.error)===null){var d=new Error("Found no media in fragment "+t.sn+" of level "+i.id+" resetting transmuxer to fallback to playlist timing");if(this.warn(d.message),this.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+i.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=Ln,this.hls.trigger(E.FRAG_PARSED,{frag:t,part:r})}else this.warn("level.details undefined")},e.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},e.recoverWorkerError=function(t){t.event==="demuxerWorker"&&(this.resetTransmuxer(),this.resetLoadingState())},K(n,[{key:"state",get:function(){return this._state},set:function(t){var r=this._state;r!==t&&(this._state=t,this.log(r+"->"+t))}}]),n}(Fe);function Ja(){return self.SourceBuffer||self.WebKitSourceBuffer}function jt(s,n){return s===void 0&&(s=""),n===void 0&&(n=9e4),{type:s,id:-1,pid:-1,inputTimeScale:n,sequenceNumber:-1,samples:[],dropped:0}}var $a=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 n=s.prototype;return n.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},n.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},n.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},n.canParse=function(e,t){return!1},n.appendFrame=function(e,t,r){},n.demux=function(e,t){this.cachedData&&(e=Xt(this.cachedData,e),this.cachedData=null);var r,i=mr(e,0),a=i?i.length:0,o=this._audioTrack,l=this._id3Track,u=i?function(v){for(var p=vi(v),T=0;T<p.length;T++){var S=p[T];if(Qi(S))return Zi(S)}}(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&Z(u))&&(this.basePTS=Po(u,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:_r,duration:Number.POSITIVE_INFINITY});a<d;){if(this.canParse(e,a)){var h=this.appendFrame(o,e,a);h?(this.frameIndex++,this.lastPTS=h.sample.pts,r=a+=h.length):a=d}else Xi(e,a)?(i=mr(e,a),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:_r,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===d&&r!==d){var f=zt(e,r);this.cachedData?this.cachedData=Xt(this.cachedData,f):this.cachedData=f}}return{audioTrack:o,videoTrack:jt(),id3Track:l,textTrack:jt()}},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},n.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:jt(),id3Track:this._id3Track,textTrack:jt()}},n.destroy=function(){},s}(),Po=function(s,n,e){return Z(s)?90*s:9e4*n+(e?9e4*e.baseTime/e.timescale:0)};function Za(s,n){return s[n]===255&&(246&s[n+1])==240}function es(s,n){return 1&s[n+1]?7:9}function aa(s,n){return(3&s[n+3])<<11|s[n+4]<<3|(224&s[n+5])>>>5}function kn(s,n){return n+1<s.length&&Za(s,n)}function Oo(s,n){if(kn(s,n)){var e=es(s,n);if(n+e>=s.length)return!1;var t=aa(s,n);if(t<=e)return!1;var r=n+t;return r===s.length||kn(s,r)}return!1}function ts(s,n,e,t,r){if(!s.samplerate){var i=function(a,o,l,u){var d,h,f,v,p=navigator.userAgent.toLowerCase(),T=u,S=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];d=1+((192&o[l+2])>>>6);var y=(60&o[l+2])>>>2;if(!(y>S.length-1))return f=(1&o[l+2])<<2,f|=(192&o[l+3])>>>6,x.log("manifest codec:"+u+", ADTS type:"+d+", samplingIndex:"+y),/firefox/i.test(p)?y>=6?(d=5,v=new Array(4),h=y-3):(d=2,v=new Array(2),h=y):p.indexOf("android")!==-1?(d=2,v=new Array(2),h=y):(d=5,v=new Array(4),u&&(u.indexOf("mp4a.40.29")!==-1||u.indexOf("mp4a.40.5")!==-1)||!u&&y>=6?h=y-3:((u&&u.indexOf("mp4a.40.2")!==-1&&(y>=6&&f===1||/vivaldi/i.test(p))||!u&&f===1)&&(d=2,v=new Array(2)),h=y)),v[0]=d<<3,v[0]|=(14&y)>>1,v[1]|=(1&y)<<7,v[1]|=f<<3,d===5&&(v[1]|=(14&h)>>1,v[2]=(1&h)<<7,v[2]|=8,v[3]=0),{config:v,samplerate:S[y],channelCount:f,codec:"mp4a.40."+d,manifestCodec:T};a.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+y})}(n,e,t,r);if(!i)return;s.config=i.config,s.samplerate=i.samplerate,s.channelCount=i.channelCount,s.codec=i.codec,s.manifestCodec=i.manifestCodec,x.log("parsed codec:"+s.codec+", rate:"+i.samplerate+", channels:"+i.channelCount)}}function rs(s){return 9216e4/s}function is(s,n,e,t,r){var i,a=t+r*rs(s.samplerate),o=function(p,T){var S=es(p,T);if(T+S<=p.length){var y=aa(p,T)-S;if(y>0)return{headerLength:S,frameLength:y}}}(n,e);if(o){var l=o.frameLength,u=o.headerLength,d=u+l,h=Math.max(0,e+d-n.length);h?(i=new Uint8Array(d-u)).set(n.subarray(e+u,n.length),0):i=n.subarray(e+u,e+d);var f={unit:i,pts:a};return h||s.samples.push(f),{sample:f,length:d,missing:h}}var v=n.length-e;return(i=new Uint8Array(v)).set(n.subarray(e,n.length),0),{sample:{unit:i,pts:a},length:v,missing:-1}}var Mo=function(s){function n(t,r){var i;return(i=s.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}ae(n,s);var e=n.prototype;return e.resetInitSegment=function(t,r,i,a){s.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var r=(mr(t,0)||[]).length,i=t.length;r<i;r++)if(Oo(t,r))return x.log("ADTS sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return function(o,l){return l+5<o.length}(i,a)&&Za(i,a)&&aa(i,a)<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){ts(t,this.observer,r,i,t.manifestCodec);var a=is(t,r,i,this.basePTS,this.frameIndex);if(a&&a.missing===0)return a},n}($a),Fo=/\/emsg[-/]ID3/i,No=function(){function s(e,t){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=t}var n=s.prototype;return n.resetTimeStamp=function(){},n.resetInitSegment=function(e,t,r,i){var a=this.videoTrack=jt("video",1),o=this.audioTrack=jt("audio",1),l=this.txtTrack=jt("text",1);if(this.id3Track=jt("id3",1),this.timeOffset=0,e!=null&&e.byteLength){var u=pi(e);if(u.video){var d=u.video,h=d.id,f=d.timescale,v=d.codec;a.id=h,a.timescale=l.timescale=f,a.codec=v}if(u.audio){var p=u.audio,T=p.id,S=p.timescale,y=p.codec;o.id=T,o.timescale=S,o.codec=y}l.id=en.text,a.sampleDuration=0,a.duration=o.duration=i}},n.resetContiguity=function(){this.remainderData=null},s.probe=function(e){return Pe(e=e.length>16384?e.subarray(0,16384):e,["moof"]).length>0},n.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Xt(this.remainderData,e));var o=function(u){var d={valid:null,remainder:null},h=Pe(u,["moof"]);if(!h)return d;if(h.length<2)return d.remainder=u,d;var f=h[h.length-1];return d.valid=zt(u,0,f.byteOffset-8),d.remainder=zt(u,f.byteOffset-8),d}(r);this.remainderData=o.remainder,i.samples=o.valid||new Uint8Array}else i.samples=r;var l=this.extractID3Track(i,t);return a.samples=Ti(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}},n.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=Ti(e,t),{videoTrack:t,audioTrack:jt(),id3Track:i,textTrack:jt()}},n.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=Pe(e.samples,["emsg"]);i&&i.forEach(function(a){var o=function(h){var f=h[0],v="",p="",T=0,S=0,y=0,b=0,C=0,D=0;if(f===0){for(;Qe(h.subarray(D,D+1))!=="\0";)v+=Qe(h.subarray(D,D+1)),D+=1;for(v+=Qe(h.subarray(D,D+1)),D+=1;Qe(h.subarray(D,D+1))!=="\0";)p+=Qe(h.subarray(D,D+1)),D+=1;p+=Qe(h.subarray(D,D+1)),D+=1,T=Se(h,12),S=Se(h,16),b=Se(h,20),C=Se(h,24),D=28}else if(f===1){T=Se(h,D+=4);var O=Se(h,D+=4),N=Se(h,D+=4);for(D+=4,y=Math.pow(2,32)*O+N,Number.isSafeInteger(y)||(y=Number.MAX_SAFE_INTEGER,x.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),b=Se(h,D),C=Se(h,D+=4),D+=4;Qe(h.subarray(D,D+1))!=="\0";)v+=Qe(h.subarray(D,D+1)),D+=1;for(v+=Qe(h.subarray(D,D+1)),D+=1;Qe(h.subarray(D,D+1))!=="\0";)p+=Qe(h.subarray(D,D+1)),D+=1;p+=Qe(h.subarray(D,D+1)),D+=1}return{schemeIdUri:v,value:p,timeScale:T,presentationTime:y,presentationTimeDelta:S,eventDuration:b,id:C,payload:h.subarray(D,h.byteLength)}}(a);if(Fo.test(o.schemeIdUri)){var l=Z(o.presentationTime)?o.presentationTime/o.timeScale:t+o.presentationTimeDelta/o.timeScale,u=o.eventDuration===4294967295?Number.POSITIVE_INFINITY:o.eventDuration/o.timeScale;u<=.001&&(u=Number.POSITIVE_INFINITY);var d=o.payload;r.samples.push({data:d,len:d.byteLength,dts:l,pts:l,type:$t,duration:u})}})}return r},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},n.destroy=function(){},s}(),wn=null,Uo=[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],Bo=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Go=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Ho=[0,1,1,4];function ns(s,n,e,t,r){if(!(e+24>n.length)){var i=as(n,e);if(i&&e+i.frameLength<=n.length){var a=t+r*(9e4*i.samplesPerFrame/i.sampleRate),o={unit:n.subarray(e,e+i.frameLength),pts:a,dts:a};return s.config=[],s.channelCount=i.channelCount,s.samplerate=i.sampleRate,s.samples.push(o),{sample:o,length:i.frameLength,missing:0}}}}function as(s,n){var e=s[n+1]>>3&3,t=s[n+1]>>1&3,r=s[n+2]>>4&15,i=s[n+2]>>2&3;if(e!==1&&r!==0&&r!==15&&i!==3){var a=s[n+2]>>1&1,o=s[n+3]>>6,l=1e3*Uo[14*(e===3?3-t:t===3?3:4)+r-1],u=Bo[3*(e===3?0:e===2?1:2)+i],d=o===3?1:2,h=Go[e][t],f=Ho[t],v=8*h*f,p=Math.floor(h*l/u+a)*f;if(wn===null){var T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);wn=T?parseInt(T[1]):0}return!!wn&&wn<=87&&t===2&&l>=224e3&&o===0&&(s[n+3]=128|s[n+3]),{sampleRate:u,channelCount:d,frameLength:p,samplesPerFrame:v}}}function sa(s,n){return s[n]===255&&(224&s[n+1])==224&&(6&s[n+1])!=0}function ss(s,n){return n+1<s.length&&sa(s,n)}function Ko(s,n){if(n+1<s.length&&sa(s,n)){var e=as(s,n),t=4;e!=null&&e.frameLength&&(t=e.frameLength);var r=n+t;return r===s.length||ss(s,r)}return!1}var os=function(){function s(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var n=s.prototype;return n.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),a=Math.min(4,t);if(a===0)throw new Error("no bytes available");i.set(e.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a},n.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},n.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&x.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},n.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!=0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},n.skipUEG=function(){this.skipBits(1+this.skipLZ())},n.skipEG=function(){this.skipBits(1+this.skipLZ())},n.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},n.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},n.readBoolean=function(){return this.readBits(1)===1},n.readUByte=function(){return this.readBits(8)},n.readUShort=function(){return this.readBits(16)},n.readUInt=function(){return this.readBits(32)},n.skipScalingList=function(e){for(var t=8,r=8,i=0;i<e;i++)r!==0&&(r=(t+this.readEG()+256)%256),t=r===0?t:r},n.readSPS=function(){var e,t,r,i=0,a=0,o=0,l=0,u=this.readUByte.bind(this),d=this.readBits.bind(this),h=this.readUEG.bind(this),f=this.readBoolean.bind(this),v=this.skipBits.bind(this),p=this.skipEG.bind(this),T=this.skipUEG.bind(this),S=this.skipScalingList.bind(this);u();var y=u();if(d(5),v(3),u(),T(),y===100||y===110||y===122||y===244||y===44||y===83||y===86||y===118||y===128){var b=h();if(b===3&&v(1),T(),T(),v(1),f())for(t=b!==3?8:12,r=0;r<t;r++)f()&&S(r<6?16:64)}T();var C=h();if(C===0)h();else if(C===1)for(v(1),p(),p(),e=h(),r=0;r<e;r++)p();T(),v(1);var D=h(),O=h(),N=d(1);N===0&&v(1),v(1),f()&&(i=h(),a=h(),o=h(),l=h());var G=[1,1];if(f()&&f())switch(u()){case 1:G=[1,1];break;case 2:G=[12,11];break;case 3:G=[10,11];break;case 4:G=[16,11];break;case 5:G=[40,33];break;case 6:G=[24,11];break;case 7:G=[20,11];break;case 8:G=[32,11];break;case 9:G=[80,33];break;case 10:G=[18,11];break;case 11:G=[15,11];break;case 12:G=[64,33];break;case 13:G=[160,99];break;case 14:G=[4,3];break;case 15:G=[3,2];break;case 16:G=[2,1];break;case 255:G=[u()<<8|u(),u()<<8|u()]}return{width:Math.ceil(16*(D+1)-2*i-2*a),height:(2-N)*(O+1)*16-(N?2:4)*(o+l),pixelRatio:G}},n.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},s}(),qo=function(){function s(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Ct(t,{removePKCS7Padding:!1})}var n=s.prototype;return n.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},n.decryptAacSample=function(e,t,r){var i=this,a=e[t].unit;if(!(a.length<=16)){var o=a.subarray(16,a.length-a.length%16),l=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(l).then(function(u){var d=new Uint8Array(u);a.set(d,16),i.decrypter.isSync()||i.decryptAacSamples(e,t+1,r)})}},n.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},n.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r},n.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)e.set(r.subarray(i,i+16),a);return e},n.decryptAvcSample=function(e,t,r,i,a){var o=this,l=sn(a.data),u=this.getAvcEncryptedData(l);this.decryptBuffer(u.buffer).then(function(d){a.data=o.getAvcDecryptedUnit(l,d),o.decrypter.isSync()||o.decryptAvcSamples(e,t,r+1,i)})},n.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var o=a[r];if(!(o.data.length<=48||o.type!==1&&o.type!==5||(this.decryptAvcSample(e,t,r,i,o),this.decrypter.isSync())))return}}},s}(),Et=188,jo=function(){function s(e,t,r){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=e,this.config=t,this.typeSupported=r}s.probe=function(e){var t=s.syncOffset(e);return t>0&&x.warn("MPEG2-TS detected but first sync word found @ offset "+t),t!==-1},s.syncOffset=function(e){for(var t=e.length,r=Math.min(940,e.length-Et)+1,i=0;i<r;){for(var a=!1,o=-1,l=0,u=i;u<t;u+=Et){if(e[u]!==71){if(l)return-1;break}if(l++,o===-1&&(o=u)!==0&&(r=Math.min(o+18612,e.length-Et)+1),a||(a=oa(e,u)===0),a&&l>1&&(o===0&&l>2||u+Et>r))return o}i++}return-1},s.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:en[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var n=s.prototype;return n.resetInitSegment=function(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=s.createTrack("video"),this._audioTrack=s.createTrack("audio",i),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=i},n.resetTimeStamp=function(){},n.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},n.demux=function(e,t,r,i){var a;r===void 0&&(r=!1),i===void 0&&(i=!1),r||(this.sampleAes=null);var o=this._avcTrack,l=this._audioTrack,u=this._id3Track,d=this._txtTrack,h=o.pid,f=o.pesData,v=l.pid,p=u.pid,T=l.pesData,S=u.pesData,y=null,b=this.pmtParsed,C=this._pmtId,D=e.length;if(this.remainderData&&(D=(e=Xt(this.remainderData,e)).length,this.remainderData=null),D<Et&&!i)return this.remainderData=e,{audioTrack:l,videoTrack:o,id3Track:u,textTrack:d};var O=Math.max(0,s.syncOffset(e));(D-=(D-O)%Et)<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,D,e.buffer.byteLength-D));for(var N=0,G=O;G<D;G+=Et)if(e[G]===71){var W=!!(64&e[G+1]),q=oa(e,G),V=void 0;if((48&e[G+3])>>4>1){if((V=G+5+e[G+4])===G+Et)continue}else V=G+4;switch(q){case h:W&&(f&&(a=Jr(f))&&this.parseAVCPES(o,d,a,!1),f={data:[],size:0}),f&&(f.data.push(e.subarray(V,G+Et)),f.size+=G+Et-V);break;case v:if(W){if(T&&(a=Jr(T)))switch(l.segmentCodec){case"aac":this.parseAACPES(l,a);break;case"mp3":this.parseMPEGPES(l,a)}T={data:[],size:0}}T&&(T.data.push(e.subarray(V,G+Et)),T.size+=G+Et-V);break;case p:W&&(S&&(a=Jr(S))&&this.parseID3PES(u,a),S={data:[],size:0}),S&&(S.data.push(e.subarray(V,G+Et)),S.size+=G+Et-V);break;case 0:W&&(V+=e[V]+1),C=this._pmtId=Vo(e,V);break;case C:W&&(V+=e[V]+1);var te=Yo(e,V,this.typeSupported,r);(h=te.avc)>0&&(o.pid=h),(v=te.audio)>0&&(l.pid=v,l.segmentCodec=te.segmentCodec),(p=te.id3)>0&&(u.pid=p),y===null||b||(x.warn("MPEG-TS PMT found at "+G+" after unknown PID '"+y+"'. Backtracking to sync byte @"+O+" to parse all TS packets."),y=null,G=O-188),b=this.pmtParsed=!0;break;case 17:case 8191:break;default:y=q}}else N++;if(N>0){var J=new Error("Found "+N+" TS packet/s that do not start with 0x47");this.observer.emit(E.ERROR,E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,fatal:!1,error:J,reason:J.message})}o.pesData=f,l.pesData=T,u.pesData=S;var oe={audioTrack:l,videoTrack:o,id3Track:u,textTrack:d};return i&&this.extractRemainingSamples(oe),oe},n.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},n.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,a=e.id3Track,o=e.textTrack,l=i.pesData,u=r.pesData,d=a.pesData;if(l&&(t=Jr(l))?(this.parseAVCPES(i,o,t,!0),i.pesData=null):i.pesData=l,u&&(t=Jr(u))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else u!=null&&u.size&&x.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=u;d&&(t=Jr(d))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=d},n.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),a=this.sampleAes=new qo(this.observer,this.config,t);return this.decrypt(i,a)},n.decrypt=function(e,t){return new Promise(function(r){var i=e.audioTrack,a=e.videoTrack;i.samples&&i.segmentCodec==="aac"?t.decryptAacSamples(i.samples,0,function(){a.samples?t.decryptAvcSamples(a.samples,0,0,function(){r(e)}):r(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,function(){r(e)})})},n.destroy=function(){this._duration=0},n.parseAVCPES=function(e,t,r,i){var a,o=this,l=this.parseAVCNALu(e,r.data),u=this.avcSample,d=!1;r.data=null,u&&l.length&&!e.audFound&&(la(u,e),u=this.avcSample=Rn(!1,r.pts,r.dts,"")),l.forEach(function(h){switch(h.type){case 1:a=!0,u||(u=o.avcSample=Rn(!0,r.pts,r.dts,"")),u.frame=!0;var f=h.data;if(d&&f.length>4){var v=new os(f).readSliceType();v!==2&&v!==4&&v!==7&&v!==9||(u.key=!0)}break;case 5:a=!0,u||(u=o.avcSample=Rn(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:a=!0,an(h.data,1,r.pts,t.samples);break;case 7:if(a=!0,d=!0,!e.sps){var p=h.data,T=new os(p).readSPS();e.width=T.width,e.height=T.height,e.pixelRatio=T.pixelRatio,e.sps=[p],e.duration=o._duration;for(var S=p.subarray(1,4),y="avc1.",b=0;b<3;b++){var C=S[b].toString(16);C.length<2&&(C="0"+C),y+=C}e.codec=y}break;case 8:a=!0,e.pps||(e.pps=[h.data]);break;case 9:a=!1,e.audFound=!0,u&&la(u,e),u=o.avcSample=Rn(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,u&&(u.debug+="unknown NAL "+h.type+" ")}u&&a&&u.units.push(h)}),i&&u&&(la(u,e),this.avcSample=null)},n.getLastNalUnit=function(e){var t,r,i=this.avcSample;if(i&&i.units.length!==0||(i=e[e.length-1]),(t=i)!=null&&t.units){var a=i.units;r=a[a.length-1]}return r},n.parseAVCNALu=function(e,t){var r,i,a=t.byteLength,o=e.naluState||0,l=o,u=[],d=0,h=-1,f=0;for(o===-1&&(h=0,f=31&t[0],o=0,d=1);d<a;)if(r=t[d++],o)if(o!==1)if(r)if(r===1){if(h>=0){var v={data:t.subarray(h,d-o-1),type:f};u.push(v)}else{var p=this.getLastNalUnit(e.samples);if(p&&(l&&d<=4-l&&p.state&&(p.data=p.data.subarray(0,p.data.byteLength-l)),(i=d-o-1)>0)){var T=new Uint8Array(p.data.byteLength+i);T.set(p.data,0),T.set(t.subarray(0,i),p.data.byteLength),p.data=T,p.state=0}}d<a?(h=d,f=31&t[d],o=0):o=-1}else o=0;else o=3;else o=r?0:2;else o=r?0:1;if(h>=0&&o>=0){var S={data:t.subarray(h,a),type:f,state:o};u.push(S)}if(u.length===0){var y=this.getLastNalUnit(e.samples);if(y){var b=new Uint8Array(y.data.byteLength+t.byteLength);b.set(y.data,0),b.set(t,y.data.byteLength),y.data=b}}return e.naluState=o,u},n.parseAACPES=function(e,t){var r,i,a,o=0,l=this.aacOverFlow,u=t.data;if(l){this.aacOverFlow=null;var d=l.missing,h=l.sample.unit.byteLength;if(d===-1){var f=new Uint8Array(h+u.byteLength);f.set(l.sample.unit,0),f.set(u,h),u=f}else{var v=h-d;l.sample.unit.set(u.subarray(0,d),v),e.samples.push(l.sample),o=l.missing}}for(r=o,i=u.length;r<i-1&&!kn(u,r);r++);if(r!==o){var p,T=r<i-1;p=T?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES";var S=new Error(p);if(x.warn("parsing error: "+p),this.observer.emit(E.ERROR,E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,fatal:!1,levelRetry:T,error:S,reason:p}),!T)return}if(ts(e,this.observer,u,r,this.audioCodec),t.pts!==void 0)a=t.pts;else{if(!l)return void x.warn("[tsdemuxer]: AAC PES unknown PTS");var y=rs(e.samplerate);a=l.sample.pts+y}for(var b,C=0;r<i;){if(r+=(b=is(e,u,r,a,C)).length,b.missing){this.aacOverFlow=b;break}for(C++;r<i-1&&!kn(u,r);r++);}},n.parseMPEGPES=function(e,t){var r=t.data,i=r.length,a=0,o=0,l=t.pts;if(l!==void 0)for(;o<i;)if(ss(r,o)){var u=ns(e,r,o,l,a);if(!u)break;o+=u.length,a++}else o++;else x.warn("[tsdemuxer]: MPEG PES unknown PTS")},n.parseID3PES=function(e,t){if(t.pts!==void 0){var r=X({},t,{type:this._avcTrack?$t:_r,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else x.warn("[tsdemuxer]: ID3 PES unknown PTS")},s}();function Rn(s,n,e,t){return{key:s,frame:!1,pts:n,dts:e,units:[],debug:t,length:0}}function oa(s,n){return((31&s[n+1])<<8)+s[n+2]}function Vo(s,n){return(31&s[n+10])<<8|s[n+11]}function Yo(s,n,e,t){var r={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},i=n+3+((15&s[n+1])<<8|s[n+2])-4;for(n+=12+((15&s[n+10])<<8|s[n+11]);n<i;){var a=oa(s,n);switch(s[n]){case 207:if(!t){x.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:r.audio===-1&&(r.audio=a);break;case 21:r.id3===-1&&(r.id3=a);break;case 219:if(!t){x.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:r.avc===-1&&(r.avc=a);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?x.log("MPEG audio found, not supported in this browser"):r.audio===-1&&(r.audio=a,r.segmentCodec="mp3");break;case 36:x.warn("Unsupported HEVC stream type found")}n+=5+((15&s[n+3])<<8|s[n+4])}return r}function Jr(s){var n,e,t,r,i,a=0,o=s.data;if(!s||s.size===0)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(((n=o[0])[0]<<16)+(n[1]<<8)+n[2]===1){if((e=(n[4]<<8)+n[5])&&e>s.size-6)return null;var u=n[7];192&u&&(r=536870912*(14&n[9])+4194304*(255&n[10])+16384*(254&n[11])+128*(255&n[12])+(254&n[13])/2,64&u?r-(i=536870912*(14&n[14])+4194304*(255&n[15])+16384*(254&n[16])+128*(255&n[17])+(254&n[18])/2)>54e5&&(x.warn(Math.round((r-i)/9e4)+"s delta between PTS and DTS, align them"),r=i):i=r);var d=(t=n[8])+9;if(s.size<=d)return null;s.size-=d;for(var h=new Uint8Array(s.size),f=0,v=o.length;f<v;f++){var p=(n=o[f]).byteLength;if(d){if(d>p){d-=p;continue}n=n.subarray(d),p-=d,d=0}h.set(n,a),a+=p}return e&&(e-=t+3),{data:h,pts:r,dts:i,len:e}}return null}function la(s,n){if(s.units.length&&s.frame){if(s.pts===void 0){var e=n.samples,t=e.length;if(!t)return void n.dropped++;var r=e[t-1];s.pts=r.pts,s.dts=r.dts}n.samples.push(s)}s.debug.length&&x.log(s.pts+"/"+s.dts+":"+s.debug)}var Wo=function(s){function n(){return s.apply(this,arguments)||this}ae(n,s);var e=n.prototype;return e.resetInitSegment=function(t,r,i,a){s.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var r=(mr(t,0)||[]).length,i=t.length;r<i;r++)if(Ko(t,r))return x.log("MPEG Audio sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return sa(i,a)&&4<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){if(this.basePTS!==null)return ns(t,r,i,this.basePTS,this.frameIndex)},n}($a),ls=function(){function s(){}return s.getSilentFrame=function(n,e){if(n==="mp4a.40.2"){if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===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(e===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])}else{if(e===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(e===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(e===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])}},s}(),cr=Math.pow(2,32)-1,lt=function(){function s(){}return s.init=function(){var n;for(n in s.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:[]},s.types)s.types.hasOwnProperty(n)&&(s.types[n]=[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]);var e=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]),t=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]);s.HDLR_TYPES={video:e,audio:t};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);s.STTS=s.STSC=s.STCO=i,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);s.FTYP=s.box(s.types.ftyp,a,l,a,o),s.DINF=s.box(s.types.dinf,s.box(s.types.dref,r))},s.box=function(n){for(var e=8,t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var a=r.length,o=a;a--;)e+=r[a].byteLength;var l=new Uint8Array(e);for(l[0]=e>>24&255,l[1]=e>>16&255,l[2]=e>>8&255,l[3]=255&e,l.set(n,4),a=0,e=8;a<o;a++)l.set(r[a],e),e+=r[a].byteLength;return l},s.hdlr=function(n){return s.box(s.types.hdlr,s.HDLR_TYPES[n])},s.mdat=function(n){return s.box(s.types.mdat,n)},s.mdhd=function(n,e){e*=n;var t=Math.floor(e/(cr+1)),r=Math.floor(e%(cr+1));return s.box(s.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,85,196,0,0]))},s.mdia=function(n){return s.box(s.types.mdia,s.mdhd(n.timescale,n.duration),s.hdlr(n.type),s.minf(n))},s.mfhd=function(n){return s.box(s.types.mfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n]))},s.minf=function(n){return n.type==="audio"?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(n)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(n))},s.moof=function(n,e,t){return s.box(s.types.moof,s.mfhd(n),s.traf(t,e))},s.moov=function(n){for(var e=n.length,t=[];e--;)t[e]=s.trak(n[e]);return s.box.apply(null,[s.types.moov,s.mvhd(n[0].timescale,n[0].duration)].concat(t).concat(s.mvex(n)))},s.mvex=function(n){for(var e=n.length,t=[];e--;)t[e]=s.trex(n[e]);return s.box.apply(null,[s.types.mvex].concat(t))},s.mvhd=function(n,e){e*=n;var t=Math.floor(e/(cr+1)),r=Math.floor(e%(cr+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,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 s.box(s.types.mvhd,i)},s.sdtp=function(n){var e,t,r=n.samples||[],i=new Uint8Array(4+r.length);for(e=0;e<r.length;e++)t=r[e].flags,i[e+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return s.box(s.types.sdtp,i)},s.stbl=function(n){return s.box(s.types.stbl,s.stsd(n),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))},s.avc1=function(n){var e,t,r,i=[],a=[];for(e=0;e<n.sps.length;e++)r=(t=n.sps[e]).byteLength,i.push(r>>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(e=0;e<n.pps.length;e++)r=(t=n.pps[e]).byteLength,a.push(r>>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(t));var o=s.box(s.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|n.sps.length].concat(i).concat([n.pps.length]).concat(a))),l=n.width,u=n.height,d=n.pixelRatio[0],h=n.pixelRatio[1];return s.box(s.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))},s.esds=function(n){var e=n.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(n.config).concat([6,1,2]))},s.mp4a=function(n){var e=n.samplerate;return s.box(s.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),s.box(s.types.esds,s.esds(n)))},s.mp3=function(n){var e=n.samplerate;return s.box(s.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))},s.stsd=function(n){return n.type==="audio"?n.segmentCodec==="mp3"&&n.codec==="mp3"?s.box(s.types.stsd,s.STSD,s.mp3(n)):s.box(s.types.stsd,s.STSD,s.mp4a(n)):s.box(s.types.stsd,s.STSD,s.avc1(n))},s.tkhd=function(n){var e=n.id,t=n.duration*n.timescale,r=n.width,i=n.height,a=Math.floor(t/(cr+1)),o=Math.floor(t%(cr+1));return s.box(s.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,255&r,0,0,i>>8&255,255&i,0,0]))},s.traf=function(n,e){var t=s.sdtp(n),r=n.id,i=Math.floor(e/(cr+1)),a=Math.floor(e%(cr+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a])),s.trun(n,t.length+16+20+8+16+8+8),t)},s.trak=function(n){return n.duration=n.duration||4294967295,s.box(s.types.trak,s.tkhd(n),s.mdia(n))},s.trex=function(n){var e=n.id;return s.box(s.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},s.trun=function(n,e){var t,r,i,a,o,l,u=n.samples||[],d=u.length,h=12+16*d,f=new Uint8Array(h);for(e+=8+h,f.set([n.type==="video"?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),t=0;t<d;t++)i=(r=u[t]).duration,a=r.size,o=r.flags,l=r.cts,f.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*t);return s.box(s.types.trun,f)},s.initSegment=function(n){s.types||s.init();var e=s.moov(n),t=new Uint8Array(s.FTYP.byteLength+e.byteLength);return t.set(s.FTYP),t.set(e,s.FTYP.byteLength),t},s}();function ua(s,n,e,t){e===void 0&&(e=1),t===void 0&&(t=!1);var r=s*n*e;return t?Math.round(r):r}function Oi(s,n){return n===void 0&&(n=!1),ua(s,1e3,1/9e4,n)}lt.types=void 0,lt.HDLR_TYPES=void 0,lt.STTS=void 0,lt.STSC=void 0,lt.STCO=void 0,lt.STSZ=void 0,lt.VMHD=void 0,lt.SMHD=void 0,lt.STSD=void 0,lt.FTYP=void 0,lt.DINF=void 0;var Dn=null,da=null,ha=function(){function s(e,t,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,Dn===null){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Dn=a?parseInt(a[1]):0}if(da===null){var o=navigator.userAgent.match(/Safari\/(\d+)/i);da=o?parseInt(o[1]):0}}var n=s.prototype;return n.destroy=function(){},n.resetTimeStamp=function(e){x.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},n.resetNextTimestamp=function(){x.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},n.resetInitSegment=function(){x.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},n.getVideoStartPts=function(e){var t=!1,r=e.reduce(function(i,a){var o=a.pts-i;return o<-4294967296?(t=!0,xt(i,a.pts)):o>0?i:a.pts},e[0].pts);return t&&x.debug("PTS rollover detected"),r},n.remux=function(e,t,r,i,a,o,l,u){var d,h,f,v,p,T,S=a,y=a,b=e.pid>-1,C=t.pid>-1,D=t.samples.length,O=e.samples.length>0,N=l&&D>0||D>1;if((!b||O)&&(!C||N)||this.ISGenerated||l){this.ISGenerated||(f=this.generateIS(e,t,a,o));var G,W=this.isVideoContiguous,q=-1;if(N&&(q=function(me){for(var ue=0;ue<me.length;ue++)if(me[ue].key)return ue;return-1}(t.samples),!W&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,q>0){x.warn("[mp4-remuxer]: Dropped "+q+" out of "+D+" video samples due to a missing keyframe");var V=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(q),t.dropped+=q,G=y+=(t.samples[0].pts-V)/t.inputTimeScale}else q===-1&&(x.warn("[mp4-remuxer]: No keyframe found out of "+D+" video samples"),T=!1);if(this.ISGenerated){if(O&&N){var te=this.getVideoStartPts(t.samples),J=(xt(e.samples[0].pts,te)-te)/t.inputTimeScale;S+=Math.max(0,J),y+=Math.max(0,-J)}if(O){if(e.samplerate||(x.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),f=this.generateIS(e,t,a,o)),h=this.remuxAudio(e,S,this.isAudioContiguous,o,C||N||u===kt?y:void 0),N){var oe=h?h.endPTS-h.startPTS:0;t.inputTimeScale||(x.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),f=this.generateIS(e,t,a,o)),d=this.remuxVideo(t,y,W,oe)}}else N&&(d=this.remuxVideo(t,y,W,0));d&&(d.firstKeyFrame=q,d.independent=q!==-1,d.firstKeyFramePTS=G)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(p=us(r,a,this._initPTS,this._initDTS)),i.samples.length&&(v=ds(i,a,this._initPTS))),{audio:h,video:d,initSegment:f,independent:T,text:v,id3:p}},n.generateIS=function(e,t,r,i){var a,o,l,u=e.samples,d=t.samples,h=this.typeSupported,f={},v=this._initPTS,p=!v||i,T="audio/mp4";if(p&&(a=o=1/0),e.config&&u.length&&(e.timescale=e.samplerate,e.segmentCodec==="mp3"&&(h.mpeg?(T="audio/mpeg",e.codec=""):h.mp3&&(e.codec="mp3")),f.audio={id:"audio",container:T,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&h.mpeg?new Uint8Array(0):lt.initSegment([e]),metadata:{channelCount:e.channelCount}},p&&(l=e.inputTimeScale,v&&l===v.timescale?p=!1:a=o=u[0].pts-Math.round(l*r))),t.sps&&t.pps&&d.length&&(t.timescale=t.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:lt.initSegment([t]),metadata:{width:t.width,height:t.height}},p))if(l=t.inputTimeScale,v&&l===v.timescale)p=!1;else{var S=this.getVideoStartPts(d),y=Math.round(l*r);o=Math.min(o,xt(d[0].dts,S)-y),a=Math.min(a,S-y)}if(Object.keys(f).length)return this.ISGenerated=!0,p?(this._initPTS={baseTime:a,timescale:l},this._initDTS={baseTime:o,timescale:l}):a=l=void 0,{tracks:f,initPTS:a,timescale:l}},n.remuxVideo=function(e,t,r,i){var a,o,l=e.inputTimeScale,u=e.samples,d=[],h=u.length,f=this._initPTS,v=this.nextAvcDts,p=8,T=this.videoSampleDuration,S=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,b=!1;r&&v!==null||(v=t*l-(u[0].pts-xt(u[0].dts,u[0].pts)));for(var C=f.baseTime*l/f.timescale,D=0;D<h;D++){var O=u[D];O.pts=xt(O.pts-C,v),O.dts=xt(O.dts-C,v),O.dts<u[D>0?D-1:D].dts&&(b=!0)}b&&u.sort(function(Fn,Ys){var Vl=Fn.dts-Ys.dts,Yl=Fn.pts-Ys.pts;return Vl||Yl}),a=u[0].dts;var N=(o=u[u.length-1].dts)-a,G=N?Math.round(N/(h-1)):T||e.inputTimeScale/30;if(r){var W=a-v,q=W>G,V=W<-1;if((q||V)&&(q?x.warn("AVC: "+Oi(W,!0)+" ms ("+W+"dts) hole between fragments detected, filling it"):x.warn("AVC: "+Oi(-W,!0)+" ms ("+W+"dts) overlapping between fragments detected"),!V||v>=u[0].pts)){a=v;var te=u[0].pts-W;u[0].dts=a,u[0].pts=te,x.log("Video: First PTS/DTS adjusted: "+Oi(te,!0)+"/"+Oi(a,!0)+", delta: "+Oi(W,!0)+" ms")}}a=Math.max(0,a);for(var J=0,oe=0,me=0;me<h;me++){for(var ue=u[me],ve=ue.units,Te=ve.length,ye=0,we=0;we<Te;we++)ye+=ve[we].data.length;oe+=ye,J+=Te,ue.length=ye,ue.dts=Math.max(ue.dts,a),S=Math.min(ue.pts,S),y=Math.max(ue.pts,y)}o=u[h-1].dts;var Ce,Oe=oe+4*J+8;try{Ce=new Uint8Array(Oe)}catch(Fn){return void this.observer.emit(E.ERROR,E.ERROR,{type:Q.MUX_ERROR,details:F.REMUX_ALLOC_ERROR,fatal:!1,error:Fn,bytes:Oe,reason:"fail allocating video mdat "+Oe})}var Ge=new DataView(Ce.buffer);Ge.setUint32(0,Oe),Ce.set(lt.types.mdat,4);for(var bt=!1,nt=Number.POSITIVE_INFINITY,Ht=Number.POSITIVE_INFINITY,Ot=Number.NEGATIVE_INFINITY,Mt=Number.NEGATIVE_INFINITY,at=0;at<h;at++){for(var ut=u[at],Vt=ut.units,fr=0,wt=0,Mi=Vt.length;wt<Mi;wt++){var Fi=Vt[wt],Mn=Fi.data,ei=Fi.data.byteLength;Ge.setUint32(p,ei),p+=4,Ce.set(Mn,p),p+=ei,fr+=4+ei}var Or=void 0;if(at<h-1)T=u[at+1].dts-ut.dts,Or=u[at+1].pts-ut.pts;else{var Ni=this.config,nr=at>0?ut.dts-u[at-1].dts:G;if(Or=at>0?ut.pts-u[at-1].pts:G,Ni.stretchShortVideoTrack&&this.nextAudioPts!==null){var Gl=Math.floor(Ni.maxBufferHole*l),Ca=(i?S+i*l:this.nextAudioPts)-ut.pts;Ca>Gl?((T=Ca-nr)<0?T=nr:bt=!0,x.log("[mp4-remuxer]: It is approximately "+Ca/90+" ms to the next segment; using duration "+T/90+" ms for the last video frame.")):T=nr}else T=nr}var Hl=Math.round(ut.pts-ut.dts);nt=Math.min(nt,T),Ot=Math.max(Ot,T),Ht=Math.min(Ht,Or),Mt=Math.max(Mt,Or),d.push(new hs(ut.key,T,fr,Hl))}if(d.length){if(Dn){if(Dn<70){var qs=d[0].flags;qs.dependsOn=2,qs.isNonSync=0}}else if(da&&Mt-Ht<Ot-nt&&G/Ot<.025&&d[0].cts===0){x.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var xa=a,Kt=0,js=d.length;Kt<js;Kt++){var Vs=xa+d[Kt].duration,Kl=xa+d[Kt].cts;if(Kt<js-1){var ql=Vs+d[Kt+1].cts;d[Kt].duration=ql-Kl}else d[Kt].duration=Kt?d[Kt-1].duration:G;d[Kt].cts=0,xa=Vs}}}T=bt||!T?G:T,this.nextAvcDts=v=o+T,this.videoSampleDuration=T,this.isVideoContiguous=!0;var jl={data1:lt.moof(e.sequenceNumber++,a,X({},e,{samples:d})),data2:Ce,startPTS:S/l,endPTS:(y+T)/l,startDTS:a/l,endDTS:v/l,type:"video",hasAudio:!1,hasVideo:!0,nb:d.length,dropped:e.dropped};return e.samples=[],e.dropped=0,jl},n.remuxAudio=function(e,t,r,i,a){var o=e.inputTimeScale,l=o/(e.samplerate?e.samplerate:o),u=e.segmentCodec==="aac"?1024:1152,d=u*l,h=this._initPTS,f=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,v=[],p=a!==void 0,T=e.samples,S=f?0:8,y=this.nextAudioPts||-1,b=t*o,C=h.baseTime*o/h.timescale;if(this.isAudioContiguous=r=r||T.length&&y>0&&(i&&Math.abs(b-y)<9e3||Math.abs(xt(T[0].pts-C,b)-y)<20*d),T.forEach(function(wt){wt.pts=xt(wt.pts-C,b)}),!r||y<0){if(T=T.filter(function(wt){return wt.pts>=0}),!T.length)return;y=a===0?0:i&&!p?Math.max(0,b):T[0].pts}if(e.segmentCodec==="aac")for(var D=this.config.maxAudioFramesDrift,O=0,N=y;O<T.length;O++){var G=T[O],W=G.pts,q=W-N,V=Math.abs(1e3*q/o);if(q<=-D*d&&p)O===0&&(x.warn("Audio frame @ "+(W/o).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*q/o)+" ms."),this.nextAudioPts=y=N=W);else if(q>=D*d&&V<1e4&&p){var te=Math.round(q/d);(N=W-te*d)<0&&(te--,N+=d),O===0&&(this.nextAudioPts=y=N),x.warn("[mp4-remuxer]: Injecting "+te+" audio frame @ "+(N/o).toFixed(3)+"s due to "+Math.round(1e3*q/o)+" ms gap.");for(var J=0;J<te;J++){var oe=Math.max(N,0),me=ls.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);me||(x.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),me=G.unit.subarray()),T.splice(O,0,{unit:me,pts:oe}),N+=d,O++}}G.pts=N,N+=d}for(var ue,ve=null,Te=null,ye=0,we=T.length;we--;)ye+=T[we].unit.byteLength;for(var Ce=0,Oe=T.length;Ce<Oe;Ce++){var Ge=T[Ce],bt=Ge.unit,nt=Ge.pts;if(Te!==null)v[Ce-1].duration=Math.round((nt-Te)/l);else{if(r&&e.segmentCodec==="aac"&&(nt=y),ve=nt,!(ye>0))return;ye+=S;try{ue=new Uint8Array(ye)}catch(wt){return void this.observer.emit(E.ERROR,E.ERROR,{type:Q.MUX_ERROR,details:F.REMUX_ALLOC_ERROR,fatal:!1,error:wt,bytes:ye,reason:"fail allocating audio mdat "+ye})}f||(new DataView(ue.buffer).setUint32(0,ye),ue.set(lt.types.mdat,4))}ue.set(bt,S);var Ht=bt.byteLength;S+=Ht,v.push(new hs(!0,u,Ht,0)),Te=nt}var Ot=v.length;if(Ot){var Mt=v[v.length-1];this.nextAudioPts=y=Te+l*Mt.duration;var at=f?new Uint8Array(0):lt.moof(e.sequenceNumber++,ve/l,X({},e,{samples:v}));e.samples=[];var ut=ve/o,Vt=y/o,fr={data1:at,data2:ue,startPTS:ut,endPTS:Vt,startDTS:ut,endDTS:Vt,type:"audio",hasAudio:!0,hasVideo:!1,nb:Ot};return this.isAudioContiguous=!0,fr}},n.remuxEmptyAudio=function(e,t,r,i){var a=e.inputTimeScale,o=a/(e.samplerate?e.samplerate:a),l=this.nextAudioPts,u=this._initDTS,d=9e4*u.baseTime/u.timescale,h=(l!==null?l:i.startDTS*a)+d,f=i.endDTS*a+d,v=1024*o,p=Math.ceil((f-h)/v),T=ls.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(x.warn("[mp4-remuxer]: remux empty Audio"),T){for(var S=[],y=0;y<p;y++){var b=h+y*v;S.push({unit:T,pts:b,dts:b})}return e.samples=S,this.remuxAudio(e,t,r,!1)}x.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},s}();function xt(s,n){var e;if(n===null)return s;for(e=n<s?-8589934592:8589934592;Math.abs(s-n)>4294967296;)s+=e;return s}function us(s,n,e,t){var r=s.samples.length;if(r){for(var i=s.inputTimeScale,a=0;a<r;a++){var o=s.samples[a];o.pts=xt(o.pts-e.baseTime*i/e.timescale,n*i)/i,o.dts=xt(o.dts-t.baseTime*i/t.timescale,n*i)/i}var l=s.samples;return s.samples=[],{samples:l}}}function ds(s,n,e){var t=s.samples.length;if(t){for(var r=s.inputTimeScale,i=0;i<t;i++){var a=s.samples[i];a.pts=xt(a.pts-9e4*e.baseTime/e.timescale,n*r)/r}s.samples.sort(function(l,u){return l.pts-u.pts});var o=s.samples;return s.samples=[],{samples:o}}}var rr,hs=function(s,n,e,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=n,this.size=e,this.cts=t,this.flags=new zo(s)},zo=function(s){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=s?2:1,this.isNonSync=s?0:1},Xo=function(){function s(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var n=s.prototype;return n.destroy=function(){},n.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},n.resetNextTimestamp=function(){this.lastEndTime=null},n.resetInitSegment=function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(a,o){if(!a||!o)return a;var l=o.keyId;return l&&o.isCommonEncryption&&Pe(a,["moov","trak"]).forEach(function(u){var d=Pe(u,["mdia","minf","stbl","stsd"])[0].subarray(8),h=Pe(d,["enca"]),f=h.length>0;f||(h=Pe(d,["encv"])),h.forEach(function(v){Pe(f?v.subarray(28):v.subarray(78),["sinf"]).forEach(function(p){var T=yi(p);if(T){var S=T.subarray(8,24);S.some(function(y){return y!==0})||(x.log("[eme] Patching keyId in 'enc"+(f?"a":"v")+">sinf>>tenc' box: "+Dt(S)+" -> "+Dt(l)),T.set(l,8))}})})}),a}(e,i)),this.emitInitSegment=!0},n.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(e==null||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=pi(e);t||(t=cs(i.audio,Xe)),r||(r=cs(i.video,mt));var a={};i.audio&&i.video?a.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?a.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?a.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:x.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},n.remux=function(e,t,r,i,a,o){var l,u,d=this.initPTS,h=this.lastEndTime,f={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};Z(h)||(h=this.lastEndTime=a||0);var v=t.samples;if(v==null||!v.length)return f;var p={initPTS:void 0,timescale:1},T=this.initData;if((l=T)!=null&&l.length||(this.generateInitSegment(v),T=this.initData),(u=T)==null||!u.length)return x.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),f;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1);var S=function(q,V){for(var te=0,J=0,oe=0,me=Pe(q,["moof","traf"]),ue=0;ue<me.length;ue++){var ve=me[ue],Te=Pe(ve,["tfhd"])[0],ye=V[Se(Te,4)];if(ye){var we=ye.default,Ce=Se(Te,0)|(we==null?void 0:we.flags),Oe=we==null?void 0:we.duration;8&Ce&&(Oe=Se(Te,2&Ce?12:8));for(var Ge=ye.timescale||9e4,bt=Pe(ve,["trun"]),nt=0;nt<bt.length;nt++)!(te=Xn(bt[nt]))&&Oe&&(te=Oe*Se(bt[nt],4)),ye.type===mt?J+=te/Ge:ye.type===Xe&&(oe+=te/Ge)}}if(J===0&&oe===0){for(var Ht=0,Ot=Pe(q,["sidx"]),Mt=0;Mt<Ot.length;Mt++){var at=rn(Ot[Mt]);at!=null&&at.references&&(Ht+=at.references.reduce(function(ut,Vt){return ut+Vt.info.duration||0},0))}return Ht}return J||oe}(v,T),y=function(q,V){return Pe(V,["moof","traf"]).reduce(function(te,J){var oe=Pe(J,["tfdt"])[0],me=oe[0],ue=Pe(J,["tfhd"]).reduce(function(ve,Te){var ye=Se(Te,4),we=q[ye];if(we){var Ce=Se(oe,4);if(me===1){if(Ce===pr)return x.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),ve;Ce*=pr+1,Ce+=Se(oe,8)}var Oe=Ce/(we.timescale||9e4);if(isFinite(Oe)&&(ve===null||Oe<ve))return Oe}return ve},null);return ue!==null&&isFinite(ue)&&(te===null||ue<te)?ue:te},null)}(T,v),b=y===null?a:y;(function(q,V,te,J){if(q===null)return!0;var oe=Math.max(J,1),me=V-q.baseTime/q.timescale;return Math.abs(me-te)>oe}(d,b,a,S)||p.timescale!==d.timescale&&o)&&(p.initPTS=b-a,d&&d.timescale===1&&x.warn("Adjusting initPTS by "+(p.initPTS-d.baseTime)),this.initPTS=d={baseTime:p.initPTS,timescale:1});var C=e?b-d.baseTime/d.timescale:h,D=C+S;(function(q,V,te){Pe(V,["moof","traf"]).forEach(function(J){Pe(J,["tfhd"]).forEach(function(oe){var me=Se(oe,4),ue=q[me];if(ue){var ve=ue.timescale||9e4;Pe(J,["tfdt"]).forEach(function(Te){var ye=Te[0],we=Se(Te,4);if(ye===0)we-=te*ve,mi(Te,4,we=Math.max(we,0));else{we*=Math.pow(2,32),we+=Se(Te,8),we-=te*ve,we=Math.max(we,0);var Ce=Math.floor(we/(pr+1)),Oe=Math.floor(we%(pr+1));mi(Te,4,Ce),mi(Te,8,Oe)}})}})})})(T,v,d.baseTime/d.timescale),S>0?this.lastEndTime=D:(x.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var O=!!T.audio,N=!!T.video,G="";O&&(G+="audio"),N&&(G+="video");var W={data1:v,startPTS:C,startDTS:C,endPTS:D,endDTS:D,type:G,hasAudio:O,hasVideo:N,nb:1,dropped:0};return f.audio=W.type==="audio"?W:void 0,f.video=W.type!=="audio"?W:void 0,f.initSegment=p,f.id3=us(r,a,d,d),i.samples.length&&(f.text=ds(i,a,d)),f},s}();function cs(s,n){var e=s==null?void 0:s.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||n===mt?"avc1.42e01e":"mp4a.40.5"}try{rr=self.performance.now.bind(self.performance)}catch{x.debug("Unable to use Performance API on this environment"),rr=typeof self!="undefined"&&self.Date.now}var ca=[{demux:No,remux:Xo},{demux:jo,remux:ha},{demux:Mo,remux:ha},{demux:Wo,remux:ha}],fa=function(){function s(e,t,r,i,a){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=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=a}var n=s.prototype;return n.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},n.push=function(e,t,r,i){var a=this,o=r.transmuxing;o.executeStart=rr();var l=new Uint8Array(e),u=this.currentTransmuxState,d=this.transmuxConfig;i&&(this.currentTransmuxState=i);var h=i||u,f=h.contiguous,v=h.discontinuity,p=h.trackSwitch,T=h.accurateTimeOffset,S=h.timeOffset,y=h.initSegmentChange,b=d.audioCodec,C=d.videoCodec,D=d.defaultInitPts,O=d.duration,N=d.initSegmentData,G=function(me,ue){var ve=null;return me.byteLength>0&&ue!=null&&ue.key!=null&&ue.iv!==null&&ue.method!=null&&(ve=ue),ve}(l,t);if(G&&G.method==="AES-128"){var W=this.getDecrypter();if(!W.isSync())return this.decryptionPromise=W.webCryptoDecrypt(l,G.key.buffer,G.iv.buffer).then(function(me){var ue=a.push(me,null,r);return a.decryptionPromise=null,ue}),this.decryptionPromise;var q=W.softwareDecrypt(l,G.key.buffer,G.iv.buffer);if(r.part>-1&&(q=W.flush()),!q)return o.executeEnd=rr(),va(r);l=new Uint8Array(q)}var V=this.needsProbing(v,p);if(V){var te=this.configureTransmuxer(l);if(te)return x.warn("[transmuxer] "+te.message),this.observer.emit(E.ERROR,E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,fatal:!1,error:te,reason:te.message}),o.executeEnd=rr(),va(r)}(v||p||y||V)&&this.resetInitSegment(N,b,C,O,t),(v||y||V)&&this.resetInitialTimestamp(D),f||this.resetContiguity();var J=this.transmux(l,G,S,T,r),oe=this.currentTransmuxState;return oe.contiguous=!0,oe.discontinuity=!1,oe.trackSwitch=!1,o.executeEnd=rr(),J},n.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=rr();var i=this.decrypter,a=this.currentTransmuxState,o=this.decryptionPromise;if(o)return o.then(function(){return t.flush(e)});var l=[],u=a.timeOffset;if(i){var d=i.flush();d&&l.push(this.push(d,null,e))}var h=this.demuxer,f=this.remuxer;if(!h||!f)return r.executeEnd=rr(),[va(e)];var v=h.flush(u);return Cr(v)?v.then(function(p){return t.flushRemux(l,p,e),l}):(this.flushRemux(l,v,e),l)},n.flushRemux=function(e,t,r){var i=t.audioTrack,a=t.videoTrack,o=t.id3Track,l=t.textTrack,u=this.currentTransmuxState,d=u.accurateTimeOffset,h=u.timeOffset;x.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var f=this.remuxer.remux(i,a,o,l,h,d,!0,this.id);e.push({remuxResult:f,chunkMeta:r}),r.transmuxing.executeEnd=rr()},n.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},n.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},n.resetInitSegment=function(e,t,r,i,a){var o=this.demuxer,l=this.remuxer;o&&l&&(o.resetInitSegment(e,t,r,i),l.resetInitSegment(e,t,r,a))},n.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},n.transmux=function(e,t,r,i,a){return t&&t.method==="SAMPLE-AES"?this.transmuxSampleAes(e,t,r,i,a):this.transmuxUnencrypted(e,r,i,a)},n.transmuxUnencrypted=function(e,t,r,i){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),o=a.audioTrack,l=a.videoTrack,u=a.id3Track,d=a.textTrack;return{remuxResult:this.remuxer.remux(o,l,u,d,t,r,!1,this.id),chunkMeta:i}},n.transmuxSampleAes=function(e,t,r,i,a){var o=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(l){return{remuxResult:o.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,r,i,!1,o.id),chunkMeta:a}})},n.configureTransmuxer=function(e){for(var t,r=this.config,i=this.observer,a=this.typeSupported,o=this.vendor,l=0,u=ca.length;l<u;l++)if(ca[l].demux.probe(e)){t=ca[l];break}if(!t)return new Error("Failed to find demuxer by probing fragment data");var d=this.demuxer,h=this.remuxer,f=t.remux,v=t.demux;h&&h instanceof f||(this.remuxer=new f(i,r,a,o)),d&&d instanceof v||(this.demuxer=new v(i,r,a),this.probe=v.probe)},n.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},n.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new Ct(this.config)),e},s}(),va=function(s){return{remuxResult:{},chunkMeta:s}};function Cr(s){return"then"in s&&s.then instanceof Function}var Qo=function(s,n,e,t,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=s,this.videoCodec=n,this.initSegmentData=e,this.duration=t,this.defaultInitPts=r||null},Jo=function(s,n,e,t,r,i){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=s,this.contiguous=n,this.accurateTimeOffset=e,this.trackSwitch=t,this.timeOffset=r,this.initSegmentChange=i},fs={exports:{}};(function(s){var n=Object.prototype.hasOwnProperty,e="~";function t(){}function r(l,u,d){this.fn=l,this.context=u,this.once=d||!1}function i(l,u,d,h,f){if(typeof d!="function")throw new TypeError("The listener must be a function");var v=new r(d,h||l,f),p=e?e+u:u;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],v]:l._events[p].push(v):(l._events[p]=v,l._eventsCount++),l}function a(l,u){--l._eventsCount==0?l._events=new t:delete l._events[u]}function o(){this._events=new t,this._eventsCount=0}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1)),o.prototype.eventNames=function(){var l,u,d=[];if(this._eventsCount===0)return d;for(u in l=this._events)n.call(l,u)&&d.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(l)):d},o.prototype.listeners=function(l){var u=e?e+l:l,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var h=0,f=d.length,v=new Array(f);h<f;h++)v[h]=d[h].fn;return v},o.prototype.listenerCount=function(l){var u=e?e+l:l,d=this._events[u];return d?d.fn?1:d.length:0},o.prototype.emit=function(l,u,d,h,f,v){var p=e?e+l:l;if(!this._events[p])return!1;var T,S,y=this._events[p],b=arguments.length;if(y.fn){switch(y.once&&this.removeListener(l,y.fn,void 0,!0),b){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,u),!0;case 3:return y.fn.call(y.context,u,d),!0;case 4:return y.fn.call(y.context,u,d,h),!0;case 5:return y.fn.call(y.context,u,d,h,f),!0;case 6:return y.fn.call(y.context,u,d,h,f,v),!0}for(S=1,T=new Array(b-1);S<b;S++)T[S-1]=arguments[S];y.fn.apply(y.context,T)}else{var C,D=y.length;for(S=0;S<D;S++)switch(y[S].once&&this.removeListener(l,y[S].fn,void 0,!0),b){case 1:y[S].fn.call(y[S].context);break;case 2:y[S].fn.call(y[S].context,u);break;case 3:y[S].fn.call(y[S].context,u,d);break;case 4:y[S].fn.call(y[S].context,u,d,h);break;default:if(!T)for(C=1,T=new Array(b-1);C<b;C++)T[C-1]=arguments[C];y[S].fn.apply(y[S].context,T)}}return!0},o.prototype.on=function(l,u,d){return i(this,l,u,d,!1)},o.prototype.once=function(l,u,d){return i(this,l,u,d,!0)},o.prototype.removeListener=function(l,u,d,h){var f=e?e+l:l;if(!this._events[f])return this;if(!u)return a(this,f),this;var v=this._events[f];if(v.fn)v.fn!==u||h&&!v.once||d&&v.context!==d||a(this,f);else{for(var p=0,T=[],S=v.length;p<S;p++)(v[p].fn!==u||h&&!v[p].once||d&&v[p].context!==d)&&T.push(v[p]);T.length?this._events[f]=T.length===1?T[0]:T:a(this,f)}return this},o.prototype.removeAllListeners=function(l){var u;return l?(u=e?e+l:l,this._events[u]&&a(this,u)):(this._events=new t,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,s.exports=o})(fs);var In=Ke(fs.exports);function ga(s,n){if(!((e=n.remuxResult).audio||e.video||e.text||e.id3||e.initSegment))return!1;var e,t=[],r=n.remuxResult,i=r.audio,a=r.video;return i&&vs(t,i),a&&vs(t,a),s.postMessage({event:"transmuxComplete",data:n},t),!0}function vs(s,n){n.data1&&s.push(n.data1.buffer),n.data2&&s.push(n.data2.buffer)}function gs(s,n,e){n.reduce(function(t,r){return ga(s,r)||t},!1)||s.postMessage({event:"transmuxComplete",data:n[0]}),s.postMessage({event:"flush",data:e})}w!==void 0&&w&&function(s){var n=new In,e=function(r,i){s.postMessage({event:r,data:i})};n.on(E.FRAG_DECRYPTED,e),n.on(E.ERROR,e);var t=function(){var r=function(a){var o=function(l){e("workerLog",{logType:a,message:l})};x[a]=o};for(var i in x)r(i)};s.addEventListener("message",function(r){var i=r.data;switch(i.cmd){case"init":var a=JSON.parse(i.config);s.transmuxer=new fa(n,i.typeSupported,a,i.vendor,i.id),qe(a.debug,i.id),t(),e("init",null);break;case"configure":s.transmuxer.configure(i.config);break;case"demux":var o=s.transmuxer.push(i.data,i.decryptdata,i.chunkMeta,i.state);Cr(o)?(s.transmuxer.async=!0,o.then(function(d){ga(s,d)}).catch(function(d){e(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:d,err:d,reason:"transmuxer-worker push error"})})):(s.transmuxer.async=!1,ga(s,o));break;case"flush":var l=i.chunkMeta,u=s.transmuxer.flush(l);Cr(u)||s.transmuxer.async?(Cr(u)||(u=Promise.resolve(u)),u.then(function(d){gs(s,d,l)}).catch(function(d){e(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:d,err:d,reason:"transmuxer-worker flush error"})})):gs(s,u,l)}})}(self);var ma=Kr()||{isTypeSupported:function(){return!1}},ms=function(){function s(e,t,r,i){var a=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var o=e.config;this.hls=e,this.id=t,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;var l=function(S,y){(y=y||{}).frag=a.frag,y.id=a.id,S===E.ERROR&&(a.error=y.error),a.hls.trigger(S,y)};this.observer=new In,this.observer.on(E.FRAG_DECRYPTED,l),this.observer.on(E.ERROR,l);var u,d,h,f,v={mp4:ma.isTypeSupported("video/mp4"),mpeg:ma.isTypeSupported("audio/mpeg"),mp3:ma.isTypeSupported('audio/mp4; codecs="mp3"')},p=navigator.vendor;if(!this.useWorker||typeof Worker=="undefined"||(o.workerPath,0))this.transmuxer=new fa(this.observer,v,o,p,t);else try{o.workerPath?(x.log("loading Web Worker "+o.workerPath+' for "'+t+'"'),this.workerContext=(h=o.workerPath,f=new self.URL(h,self.location.href).href,{worker:new self.Worker(f),scriptURL:f})):(x.log('injecting Web Worker for "'+t+'"'),this.workerContext=(u=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+L.toString()+")(true);"],{type:"text/javascript"}),d=self.URL.createObjectURL(u),{worker:new self.Worker(d),objectURL:d})),this.onwmsg=function(S){return a.onWorkerMessage(S)};var T=this.workerContext.worker;T.addEventListener("message",this.onwmsg),T.onerror=function(S){var y=new Error(S.message+" ("+S.filename+":"+S.lineno+")");o.enableWorker=!1,x.warn('Error in "'+t+'" Web Worker, fallback to inline'),a.hls.trigger(E.ERROR,{type:Q.OTHER_ERROR,details:F.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:y})},T.postMessage({cmd:"init",typeSupported:v,vendor:p,id:t,config:JSON.stringify(o)})}catch(S){x.warn('Error setting up "'+t+'" Web Worker, fallback to inline',S),this.resetWorker(),this.error=null,this.transmuxer=new fa(this.observer,v,o,p,t)}}var n=s.prototype;return n.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},n.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},n.push=function(e,t,r,i,a,o,l,u,d,h){var f,v,p=this;d.transmuxing.start=self.performance.now();var T=this.transmuxer,S=o?o.start:a.start,y=a.decryptdata,b=this.frag,C=!(b&&a.cc===b.cc),D=!(b&&d.level===b.level),O=b?d.sn-b.sn:-1,N=this.part?d.part-this.part.index:-1,G=O===0&&d.id>1&&d.id===(b==null?void 0:b.stats.chunkCount),W=!D&&(O===1||O===0&&(N===1||G&&N<=0)),q=self.performance.now();(D||O||a.stats.parsing.start===0)&&(a.stats.parsing.start=q),!o||!N&&W||(o.stats.parsing.start=q);var V=!(b&&((f=a.initSegment)==null?void 0:f.url)===((v=b.initSegment)==null?void 0:v.url)),te=new Jo(C,W,u,D,S,V);if(!W||C||V){x.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+d.sn+" p: "+d.part+" level: "+d.level+" id: "+d.id+`
|
|
21
|
+
discontinuity: `+C+`
|
|
22
|
+
trackSwitch: `+D+`
|
|
23
23
|
contiguous: `+W+`
|
|
24
|
-
accurateTimeOffset: `+
|
|
24
|
+
accurateTimeOffset: `+u+`
|
|
25
25
|
timeOffset: `+S+`
|
|
26
|
-
initSegmentChange: `+V);var J=new zo(r,i,t,l,c);this.configureTransmuxer(J)}if(this.frag=a,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:u,state:te},e instanceof ArrayBuffer?[e]:[]);else if(T){var oe=T.push(e,y,u,te);Cr(oe)?(T.async=!0,oe.then(function(me){p.handleTransmuxComplete(me)}).catch(function(me){p.transmuxerError(me,u,"transmuxer-interface push error")})):(T.async=!1,this.handleTransmuxComplete(oe))}},n.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var i=r.flush(e);Cr(i)||r.async?(Cr(i)||(i=Promise.resolve(i)),i.then(function(a){t.handleFlushResult(a,e)}).catch(function(a){t.transmuxerError(a,e,"transmuxer-interface flush error")})):this.handleFlushResult(i,e)}},n.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))},n.handleFlushResult=function(e,t){var r=this;e.forEach(function(i){r.handleTransmuxComplete(i)}),this.onFlush(t)},n.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":var i,a=(i=this.workerContext)==null?void 0:i.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":x[t.data.logType]&&x[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},n.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},n.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},s}(),Qo=function(){function s(e,t,r,i){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=t,this.fragmentTracker=r,this.hls=i}var n=s.prototype;return n.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},n.poll=function(e,t){var r=this.config,i=this.media,a=this.stalled;if(i!==null){var o=i.currentTime,l=i.seeking,d=this.seeking&&!l,u=!this.seeking&&l;if(this.seeking=l,o===e){if(u||d)this.stalled=null;else if(!(i.paused&&!l||i.ended||i.playbackRate===0)&&re.getBuffered(i).length){var c=re.bufferInfo(i,o,0),f=c.len>0,v=c.nextStart||0;if(f||v){if(l){var p=c.len>2,T=!v||t&&t.start<=o||v-o>2&&!this.fragmentTracker.getPartialFragment(o);if(p||T)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var S,y=Math.max(v,c.start||0)-o,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,D=!(b==null||(S=b.details)==null)&&S.live?2*b.details.targetduration:2,w=this.fragmentTracker.getPartialFragment(o);if(y>0&&(y<=D||w))return void this._trySkipBufferHole(w)}var O=self.performance.now();if(a!==null){var N=O-a;if(l||!(N>=250)||(this._reportStall(c),this.media)){var G=re.bufferInfo(i,o,r.maxBufferHole);this._tryFixBufferStall(G,N)}}else this.stalled=O}}}else if(this.moved=!0,a!==null){if(this.stallReported){var W=self.performance.now()-a;x.warn("playback not stuck anymore @"+o+", after "+Math.round(W)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},n._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,a=this.media;if(a!==null){var o=a.currentTime,l=i.getPartialFragment(o);if(l&&(this._trySkipBufferHole(l)||!this.media))return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-o<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(x.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},n._reportStall=function(e){var t=this.hls,r=this.media;if(!this.stallReported&&r){this.stallReported=!0;var i=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");x.warn(i.message),t.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}},n._trySkipBufferHole=function(e){var t=this.config,r=this.hls,i=this.media;if(i===null)return 0;var a=i.currentTime,o=re.bufferInfo(i,a,0),l=a<o.start?o.start:o.nextStart;if(l){var d=o.len<=t.maxBufferHole,u=o.len>0&&o.len<1&&i.readyState<3,c=l-a;if(c>0&&(d||u)){if(c>t.maxBufferHole){var f=this.fragmentTracker,v=!1;if(a===0){var p=f.getAppendedFrag(0,Ne);p&&l<p.end&&(v=!0)}if(!v){var T=e||f.getAppendedFrag(a,Ne);if(T){for(var S=!1,y=T.end;y<l;){var b=f.getPartialFragment(y);if(!b){S=!0;break}y+=b.duration}if(S)return 0}}}var D=Math.max(l+.05,a+.1);if(x.warn("skipping hole, adjusting currentTime from "+a+" to "+D),this.moved=!0,this.stalled=null,i.currentTime=D,e&&!e.gap){var w=new Error("fragment loaded with buffer holes, seeking from "+a+" to "+D);r.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:w,reason:w.message,frag:e})}return D}}return 0},n._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(r!==null){var a=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var o=a+(i+1)*e.nudgeOffset,l=new Error("Nudging 'currentTime' from "+a+" to "+o);x.warn(l.message),r.currentTime=o,t.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_NUDGE_ON_STALL,error:l,fatal:!1})}else{var d=new Error("Playhead still not moving while enough data buffered @"+a+" after "+e.nudgeMaxRetry+" nudges");x.error(d.message),t.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_STALLED_ERROR,error:d,fatal:!0})}}},s}(),Jo=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[stream-controller]",Ne)||this).audioCodecSwap=!1,a.gapController=null,a.level=-1,a._forceStartLoad=!1,a.altAudio=!1,a.audioOnly=!1,a.fragPlaying=null,a.onvplaying=null,a.onvseeked=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a._registerListeners(),a}ae(n,s);var e=n.prototype;return e._registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(E.ERROR,this.onError,this),t.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(E.BUFFER_CREATED,this.onBufferCreated,this),t.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(E.ERROR,this.onError,this),t.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(E.BUFFER_CREATED,this.onBufferCreated,this),t.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},e.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},e.startLoad=function(t){if(this.levels){var r=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var a=i.startLevel;a===-1&&(i.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=i.nextAutoLevel),this.level=i.nextLoadLevel=a,this.loadedmetadata=!1}r>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r),this.state=ce,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=rt},e.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},e.doTick=function(){switch(this.state){case Qr:var t,r=this.levels,i=this.level,a=r==null||(t=r[i])==null?void 0:t.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a))break;this.state=ce;break}break;case dr:var o,l=self.performance.now(),d=this.retryDate;(!d||l>=d||(o=this.media)!=null&&o.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=ce)}this.state===ce&&this.doTickIdle(),this.onTickEnd()},e.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},e.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,i=this.levels,a=this.media,o=t.config,l=t.nextLoadLevel;if(r!==null&&(a||!this.startFragRequested&&o.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&i!=null&&i[l]){var d=i[l],u=this.getMainFwdBufferInfo();if(u!==null){var c=this.getLevelDetails();if(c&&this._streamEnded(u,c)){var f={};return this.altAudio&&(f.type="video"),this.hls.trigger(E.BUFFER_EOS,f),void(this.state=xi)}t.loadLevel!==l&&t.manualLevel===-1&&this.log("Adapting to level "+l+" from level "+this.level),this.level=t.nextLoadLevel=l;var v=d.details;if(!v||this.state===Qr||v.live&&this.levelLastLoaded!==l)return this.level=l,void(this.state=Qr);var p=u.len,T=this.getMaxBufferLength(d.maxBitrate);if(!(p>=T)){this.backtrackFragment&&this.backtrackFragment.start>u.end&&(this.backtrackFragment=null);var S=this.backtrackFragment?this.backtrackFragment.start:u.end,y=this.getNextFragment(S,v);if(this.couldBacktrack&&!this.fragPrevious&&y&&y.sn!=="initSegment"&&this.fragmentTracker.getState(y)!==de){var b,D=((b=this.backtrackFragment)!=null?b:y).sn-v.startSN,w=v.fragments[D-1];w&&y.cc===w.cc&&(y=w,this.fragmentTracker.removeFragment(w))}else this.backtrackFragment&&u.len&&(this.backtrackFragment=null);if(y&&this.isLoopLoading(y,S)){if(!y.gap){var O=this.audioOnly&&!this.altAudio?Xe:mt,N=(O===mt?this.videoBuffer:this.mediaBuffer)||this.media;N&&this.afterBufferFlushed(N,O,Ne)}y=this.getNextFragmentLoopLoading(y,v,u,Ne,T)}y&&(!y.initSegment||y.initSegment.data||this.bitrateTest||(y=y.initSegment),this.loadFragment(y,d,S))}}}},e.loadFragment=function(t,r,i){var a=this.fragmentTracker.getState(t);this.fragCurrent=t,a===Y||a===se?t.sn==="initSegment"?this._loadInitSegment(t,r):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,r)):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,i)):this.clearTrackerIfNeeded(t)},e.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,Ne)},e.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},e.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},e.nextLevelSwitch=function(){var t=this.levels,r=this.media;if(r!=null&&r.readyState){var i,a=this.getAppendedFrag(r.currentTime);a&&a.start>1&&this.flushMainBuffer(0,a.start-1);var o=this.getLevelDetails();if(o!=null&&o.live){var l=this.getMainFwdBufferInfo();if(!l||l.len<2*o.targetduration)return}if(!r.paused&&t){var d=t[this.hls.nextLoadLevel],u=this.fragLastKbps;i=u&&this.fragCurrent?this.fragCurrent.duration*d.maxBitrate/(1e3*u)+1:0}else i=0;var c=this.getBufferedFrag(r.currentTime+i);if(c){var f=this.followingBufferedFrag(c);if(f){this.abortCurrentFrag();var v=f.maxStartPTS?f.maxStartPTS:f.start,p=f.duration,T=Math.max(c.end,v+Math.min(Math.max(p-this.config.maxFragLookUpTolerance,.5*p),.75*p));this.flushMainBuffer(T,Number.POSITIVE_INFINITY)}}}},e.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Zt:case ur:case dr:case er:case kn:this.state=ce}this.nextLoadPosition=this.getLoadPosition()},e.flushMainBuffer=function(t,r){s.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},e.onMediaAttached=function(t,r){s.prototype.onMediaAttached.call(this,t,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new Qo(this.config,i,this.fragmentTracker,this.hls)},e.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),s.prototype.onMediaDetaching.call(this)},e.onMediaPlaying=function(){this.tick()},e.onMediaSeeked=function(){var t=this.media,r=t?t.currentTime:null;Z(r)&&this.log("Media seeked to "+r.toFixed(3));var i=this.getMainFwdBufferInfo();i!==null&&i.len!==0?this.tick():this.warn('Main forward buffer length on "seeked" event '+(i?i.len:"empty")+")")},e.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1},e.onManifestParsed=function(t,r){var i,a,o,l=!1,d=!1;r.levels.forEach(function(u){(i=u.audioCodec)&&(i.indexOf("mp4a.40.2")!==-1&&(l=!0),i.indexOf("mp4a.40.5")!==-1&&(d=!0))}),this.audioCodecSwitch=l&&d&&typeof((o=Qa())==null||(a=o.prototype)==null?void 0:a.changeType)!="function",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},e.onLevelLoading=function(t,r){var i=this.levels;if(i&&this.state===ce){var a=i[r.level];(!a.details||a.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(a.details))&&(this.state=Qr)}},e.onLevelLoaded=function(t,r){var i,a=this.levels,o=r.level,l=r.details,d=l.totalduration;if(a){this.log("Level "+o+" loaded ["+l.startSN+","+l.endSN+"]"+(l.lastPartSn?"[part-"+l.lastPartSn+"-"+l.lastPartIndex+"]":"")+", cc ["+l.startCC+", "+l.endCC+"] duration:"+d);var u=a[o],c=this.fragCurrent;!c||this.state!==ur&&this.state!==dr||c.level===r.level&&c.urlId===u.urlId||!c.loader||this.abortCurrentFrag();var f=0;if(l.live||(i=u.details)!=null&&i.live){if(l.fragments[0]||(l.deltaUpdateFailed=!0),l.deltaUpdateFailed)return;f=this.alignPlaylists(l,u.details)}if(u.details=l,this.levelLastLoaded=o,this.hls.trigger(E.LEVEL_UPDATED,{details:l,level:o}),this.state===Qr){if(this.waitForCdnTuneIn(l))return;this.state=ce}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,f),this.tick()}else this.warn("Levels were reset while loading level "+o)},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.levels;if(l){var d=l[i.level],u=d.details;if(!u)return this.warn("Dropping fragment "+i.sn+" of level "+i.level+" after level details were reset"),void this.fragmentTracker.removeFragment(i);var c=d.videoCodec,f=u.PTSKnown||!u.live,v=(r=i.initSegment)==null?void 0:r.data,p=this._getAudioCodec(d),T=this.transmuxer=this.transmuxer||new gs(this.hls,Ne,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),S=a?a.index:-1,y=S!==-1,b=new ie(i.level,i.sn,i.stats.chunkCount,o.byteLength,S,y),D=this.initPTS[i.cc];T.push(o,v,p,c,i,a,u.totalduration,f,b,D)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},e.onAudioTrackSwitching=function(t,r){var i=this.altAudio;if(!r.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;i&&(o.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),o.trigger(E.AUDIO_TRACK_SWITCHED,r)}},e.onAudioTrackSwitched=function(t,r){var i=r.id,a=!!this.hls.audioTracks[i].url;if(a){var o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=a,this.tick()},e.onBufferCreated=function(t,r){var i,a,o=r.tracks,l=!1;for(var d in o){var u=o[d];if(u.id==="main"){if(a=d,i=u,d==="video"){var c=o[d];c&&(this.videoBuffer=c.buffer)}}else l=!0}l&&i?(this.log("Alternate track found, use "+a+".buffered to schedule main fragment loading"),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media},e.onFragBuffered=function(t,r){var i=r.frag,a=r.part;if(!i||i.type===Ne){if(this.fragContextChanged(i))return this.warn("Fragment "+i.sn+(a?" p: "+a.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===kn&&(this.state=ce));var o=a?a.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,a)}},e.onError=function(t,r){var i;if(r.fatal)this.state=Xr;else switch(r.details){case F.FRAG_GAP:case F.FRAG_PARSING_ERROR:case F.FRAG_DECRYPT_ERROR:case F.FRAG_LOAD_ERROR:case F.FRAG_LOAD_TIMEOUT:case F.KEY_LOAD_ERROR:case F.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Ne,r);break;case F.LEVEL_LOAD_ERROR:case F.LEVEL_LOAD_TIMEOUT:case F.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==Qr||((i=r.context)==null?void 0:i.type)!==Qt||(this.state=ce);break;case F.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case F.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.checkBuffer=function(){var t=this.media,r=this.gapController;if(t&&r&&t.readyState){if(this.loadedmetadata||!re.getBuffered(t).length){var i=this.state!==ce?this.fragCurrent:null;r.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}},e.onFragLoadEmergencyAborted=function(){this.state=ce,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},e.onBufferFlushed=function(t,r){var i=r.type;if(i!==Xe||this.audioOnly&&!this.altAudio){var a=(i===mt?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,i,Ne)}},e.onLevelsUpdated=function(t,r){this.levels=r.levels},e.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},e.seekToStartPos=function(){var t=this.media;if(t){var r=t.currentTime,i=this.startPosition;if(i>=0&&r<i){if(t.seeking)return void this.log("could not seek to "+i+", already seeking at "+r);var a=re.getBuffered(t),o=(a.length?a.start(0):0)-i;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+o+" to match buffer start"),i+=o,this.startPosition=i),this.log("seek to target start position "+i+" from current time "+r),t.currentTime=i}}},e._getAudioCodec=function(t){var r=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r=r.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),r},e._loadBitrateTestFrag=function(t,r){var i=this;t.bitrateTest=!0,this._doFragLoad(t,r).then(function(a){var o=i.hls;if(a&&!i.fragContextChanged(t)){r.fragmentError=0,i.state=ce,i.startFragRequested=!1,i.bitrateTest=!1;var l=t.stats;l.parsing.start=l.parsing.end=l.buffering.start=l.buffering.end=self.performance.now(),o.trigger(E.FRAG_LOADED,a),t.bitrateTest=!1}})},e._handleTransmuxComplete=function(t){var r,i="main",a=this.hls,o=t.remuxResult,l=t.chunkMeta,d=this.getCurrentContext(l);if(d){var u=d.frag,c=d.part,f=d.level,v=o.video,p=o.text,T=o.id3,S=o.initSegment,y=f.details,b=this.altAudio?void 0:o.audio;if(this.fragContextChanged(u))this.fragmentTracker.removeFragment(u);else{if(this.state=er,S){if(S!=null&&S.tracks){var D=u.initSegment||u;this._bufferInitSegment(f,S.tracks,D,l),a.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:D,id:i,tracks:S.tracks})}var w=S.initPTS,O=S.timescale;Z(w)&&(this.initPTS[u.cc]={baseTime:w,timescale:O},a.trigger(E.INIT_PTS_FOUND,{frag:u,id:i,initPTS:w,timescale:O}))}if(v&&o.independent!==!1){if(y){var N=v.startPTS,G=v.endPTS,W=v.startDTS,q=v.endDTS;if(c)c.elementaryStreams[v.type]={startPTS:N,endPTS:G,startDTS:W,endDTS:q};else if(v.firstKeyFrame&&v.independent&&l.id===1&&(this.couldBacktrack=!0),v.dropped&&v.independent){var V=this.getMainFwdBufferInfo();if((V?V.end:this.getLoadPosition())+this.config.maxBufferHole<(v.firstKeyFramePTS?v.firstKeyFramePTS:N)-this.config.maxBufferHole)return void this.backtrack(u);u.setElementaryStreamInfo(v.type,u.start,G,u.start,q,!0)}u.setElementaryStreamInfo(v.type,N,G,W,q),this.backtrackFragment&&(this.backtrackFragment=u),this.bufferFragmentData(v,u,c,l)}}else if(o.independent===!1)return void this.backtrack(u);if(b){var te=b.startPTS,J=b.endPTS,oe=b.startDTS,me=b.endDTS;c&&(c.elementaryStreams[Xe]={startPTS:te,endPTS:J,startDTS:oe,endDTS:me}),u.setElementaryStreamInfo(Xe,te,J,oe,me),this.bufferFragmentData(b,u,c,l)}if(y&&T!=null&&(r=T.samples)!=null&&r.length){var ue={id:i,frag:u,details:y,samples:T.samples};a.trigger(E.FRAG_PARSING_METADATA,ue)}if(y&&p){var ve={id:i,frag:u,details:y,samples:p.samples};a.trigger(E.FRAG_PARSING_USERDATA,ve)}}}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i,a){var o=this;if(this.state===er){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var l=r.audio,d=r.video,u=r.audiovideo;if(l){var c=t.audioCodec,f=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(c&&(c=c.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),l.metadata.channelCount!==1&&f.indexOf("firefox")===-1&&(c="mp4a.40.5")),f.indexOf("android")!==-1&&l.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log("Android: force audio codec to "+c)),t.audioCodec&&t.audioCodec!==c&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+c+'"'),l.levelCodec=c,l.id="main",this.log("Init audio buffer, container:"+l.container+", codecs[selected/level/parsed]=["+(c||"")+"/"+(t.audioCodec||"")+"/"+l.codec+"]")}d&&(d.levelCodec=t.videoCodec,d.id="main",this.log("Init video buffer, container:"+d.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+d.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(E.BUFFER_CODECS,r),Object.keys(r).forEach(function(v){var p=r[v].initSegment;p!=null&&p.byteLength&&o.hls.trigger(E.BUFFER_APPENDING,{type:v,data:p,frag:i,part:null,chunkMeta:a,parent:i.type})}),this.tick()}},e.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Ne)},e.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=ce},e.checkFragmentChanged=function(){var t=this.media,r=null;if(t&&t.readyState>1&&t.seeking===!1){var i=t.currentTime;if(re.isBuffered(t,i)?r=this.getAppendedFrag(i):re.isBuffered(t,i+.1)&&(r=this.getAppendedFrag(i+.1)),r){this.backtrackFragment=null;var a=this.fragPlaying,o=r.level;a&&r.sn===a.sn&&a.level===o&&r.urlId===a.urlId||(this.fragPlaying=r,this.hls.trigger(E.FRAG_CHANGED,{frag:r}),a&&a.level===o||this.hls.trigger(E.LEVEL_SWITCHED,{level:o}))}}},K(n,[{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 r=t.currentTime,i=this.currentFrag;if(i&&Z(r)&&Z(i.programDateTime)){var a=i.programDateTime+1e3*(r-i.start);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}}]),n}(na),$r=function(){function s(e,t,r){t===void 0&&(t=0),r===void 0&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var n=s.prototype;return n.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},n.getTotalWeight=function(){return this.totalWeight_},n.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},s}(),$o=function(){function s(e,t,r,i){i===void 0&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new $r(e),this.fast_=new $r(t),this.defaultTTFB_=i,this.ttfb_=new $r(e)}var n=s.prototype;return n.update=function(e,t){var r=this.slow_,i=this.fast_,a=this.ttfb_;r.halfLife!==e&&(this.slow_=new $r(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new $r(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new $r(e,a.getEstimate(),a.getTotalWeight()))},n.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},n.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},n.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},n.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},n.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},n.destroy=function(){},s}(),Zo=function(){function s(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;var t=e.config;this.bwEstimator=new $o(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this)},n.unregisterListeners=function(){var e=this.hls;e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this)},n.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},n.onFragLoading=function(e,t){var r,i=t.frag;this.ignoreFragment(i)||(this.fragCurrent=i,this.partCurrent=(r=t.part)!=null?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},n.onLevelSwitching=function(e,t){this.clearTimer()},n.getTimeToLoadFrag=function(e,t,r,i){return e+r/t+(i?this.lastLevelLoadSec:0)},n.onLevelLoaded=function(e,t){var r=this.hls.config,i=t.stats,a=i.total,o=i.bwEstimate;Z(a)&&Z(o)&&(this.lastLevelLoadSec=8*a/o),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},n._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.autoLevelEnabled,a=r.media;if(e&&a){var o=performance.now(),l=t?t.stats:e.stats,d=t?t.duration:e.duration,u=o-l.loading.start;if(l.aborted||l.loaded&&l.loaded===l.total||e.level===0)return this.clearTimer(),void(this._nextAutoLevel=-1);if(i&&!a.paused&&a.playbackRate&&a.readyState){var c=r.mainForwardBufferInfo;if(c!==null){var f=this.bwEstimator.getEstimateTTFB(),v=Math.abs(a.playbackRate);if(!(u<=Math.max(f,d/(2*v)*1e3))){var p=c.len/v;if(!(p>=2*d/v)){var T=l.loading.first?l.loading.first-l.loading.start:-1,S=l.loaded&&T>-1,y=this.bwEstimator.getEstimate(),b=r.levels,D=r.minAutoLevel,w=b[e.level],O=l.total||Math.max(l.loaded,Math.round(d*w.maxBitrate/8)),N=u-T;N<1&&S&&(N=Math.min(u,8*l.loaded/y));var G=S?1e3*l.loaded/N:0,W=G?(O-l.loaded)/G:8*O/y+f/1e3;if(!(W<=p)){var q,V=G?8*G:y,te=Number.POSITIVE_INFINITY;for(q=e.level-1;q>D;q--){var J=b[q].maxBitrate;if((te=this.getTimeToLoadFrag(f/1e3,V,d*J,!b[q].details))<p)break}te>=W||te>10*d||(r.nextLoadLevel=q,S?this.bwEstimator.sample(u-Math.min(f,T),l.loaded):this.bwEstimator.sampleTTFB(u),this.clearTimer(),x.warn("[abr] Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+` is loading too slowly;
|
|
26
|
+
initSegmentChange: `+V);var J=new Qo(r,i,t,l,h);this.configureTransmuxer(J)}if(this.frag=a,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:d,state:te},e instanceof ArrayBuffer?[e]:[]);else if(T){var oe=T.push(e,y,d,te);Cr(oe)?(T.async=!0,oe.then(function(me){p.handleTransmuxComplete(me)}).catch(function(me){p.transmuxerError(me,d,"transmuxer-interface push error")})):(T.async=!1,this.handleTransmuxComplete(oe))}},n.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var i=r.flush(e);Cr(i)||r.async?(Cr(i)||(i=Promise.resolve(i)),i.then(function(a){t.handleFlushResult(a,e)}).catch(function(a){t.transmuxerError(a,e,"transmuxer-interface flush error")})):this.handleFlushResult(i,e)}},n.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))},n.handleFlushResult=function(e,t){var r=this;e.forEach(function(i){r.handleTransmuxComplete(i)}),this.onFlush(t)},n.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":var i,a=(i=this.workerContext)==null?void 0:i.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":x[t.data.logType]&&x[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},n.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},n.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},s}(),$o=function(){function s(e,t,r,i){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=t,this.fragmentTracker=r,this.hls=i}var n=s.prototype;return n.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},n.poll=function(e,t){var r=this.config,i=this.media,a=this.stalled;if(i!==null){var o=i.currentTime,l=i.seeking,u=this.seeking&&!l,d=!this.seeking&&l;if(this.seeking=l,o===e){if(d||u)this.stalled=null;else if(!(i.paused&&!l||i.ended||i.playbackRate===0)&&re.getBuffered(i).length){var h=re.bufferInfo(i,o,0),f=h.len>0,v=h.nextStart||0;if(f||v){if(l){var p=h.len>2,T=!v||t&&t.start<=o||v-o>2&&!this.fragmentTracker.getPartialFragment(o);if(p||T)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var S,y=Math.max(v,h.start||0)-o,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,C=!(b==null||(S=b.details)==null)&&S.live?2*b.details.targetduration:2,D=this.fragmentTracker.getPartialFragment(o);if(y>0&&(y<=C||D))return void this._trySkipBufferHole(D)}var O=self.performance.now();if(a!==null){var N=O-a;if(l||!(N>=250)||(this._reportStall(h),this.media)){var G=re.bufferInfo(i,o,r.maxBufferHole);this._tryFixBufferStall(G,N)}}else this.stalled=O}}}else if(this.moved=!0,a!==null){if(this.stallReported){var W=self.performance.now()-a;x.warn("playback not stuck anymore @"+o+", after "+Math.round(W)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},n._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,a=this.media;if(a!==null){var o=a.currentTime,l=i.getPartialFragment(o);if(l&&(this._trySkipBufferHole(l)||!this.media))return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-o<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(x.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},n._reportStall=function(e){var t=this.hls,r=this.media;if(!this.stallReported&&r){this.stallReported=!0;var i=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");x.warn(i.message),t.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}},n._trySkipBufferHole=function(e){var t=this.config,r=this.hls,i=this.media;if(i===null)return 0;var a=i.currentTime,o=re.bufferInfo(i,a,0),l=a<o.start?o.start:o.nextStart;if(l){var u=o.len<=t.maxBufferHole,d=o.len>0&&o.len<1&&i.readyState<3,h=l-a;if(h>0&&(u||d)){if(h>t.maxBufferHole){var f=this.fragmentTracker,v=!1;if(a===0){var p=f.getAppendedFrag(0,Ne);p&&l<p.end&&(v=!0)}if(!v){var T=e||f.getAppendedFrag(a,Ne);if(T){for(var S=!1,y=T.end;y<l;){var b=f.getPartialFragment(y);if(!b){S=!0;break}y+=b.duration}if(S)return 0}}}var C=Math.max(l+.05,a+.1);if(x.warn("skipping hole, adjusting currentTime from "+a+" to "+C),this.moved=!0,this.stalled=null,i.currentTime=C,e&&!e.gap){var D=new Error("fragment loaded with buffer holes, seeking from "+a+" to "+C);r.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:D,reason:D.message,frag:e})}return C}}return 0},n._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(r!==null){var a=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var o=a+(i+1)*e.nudgeOffset,l=new Error("Nudging 'currentTime' from "+a+" to "+o);x.warn(l.message),r.currentTime=o,t.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_NUDGE_ON_STALL,error:l,fatal:!1})}else{var u=new Error("Playhead still not moving while enough data buffered @"+a+" after "+e.nudgeMaxRetry+" nudges");x.error(u.message),t.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_STALLED_ERROR,error:u,fatal:!0})}}},s}(),Zo=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[stream-controller]",Ne)||this).audioCodecSwap=!1,a.gapController=null,a.level=-1,a._forceStartLoad=!1,a.altAudio=!1,a.audioOnly=!1,a.fragPlaying=null,a.onvplaying=null,a.onvseeked=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a._registerListeners(),a}ae(n,s);var e=n.prototype;return e._registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(E.ERROR,this.onError,this),t.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(E.BUFFER_CREATED,this.onBufferCreated,this),t.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(E.ERROR,this.onError,this),t.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(E.BUFFER_CREATED,this.onBufferCreated,this),t.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},e.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},e.startLoad=function(t){if(this.levels){var r=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var a=i.startLevel;a===-1&&(i.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=i.nextAutoLevel),this.level=i.nextLoadLevel=a,this.loadedmetadata=!1}r>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r),this.state=he,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=rt},e.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},e.doTick=function(){switch(this.state){case Qr:var t,r=this.levels,i=this.level,a=r==null||(t=r[i])==null?void 0:t.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a))break;this.state=he;break}if(this.hls.nextLoadLevel!==this.level){this.state=he;break}break;case hr:var o,l=self.performance.now(),u=this.retryDate;(!u||l>=u||(o=this.media)!=null&&o.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=he)}this.state===he&&this.doTickIdle(),this.onTickEnd()},e.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},e.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,i=this.levels,a=this.media,o=t.config,l=t.nextLoadLevel;if(r!==null&&(a||!this.startFragRequested&&o.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&i!=null&&i[l]){var u=i[l],d=this.getMainFwdBufferInfo();if(d!==null){var h=this.getLevelDetails();if(h&&this._streamEnded(d,h)){var f={};return this.altAudio&&(f.type="video"),this.hls.trigger(E.BUFFER_EOS,f),void(this.state=xi)}t.loadLevel!==l&&t.manualLevel===-1&&this.log("Adapting to level "+l+" from level "+this.level),this.level=t.nextLoadLevel=l;var v=u.details;if(!v||this.state===Qr||v.live&&this.levelLastLoaded!==l)return this.level=l,void(this.state=Qr);var p=d.len,T=this.getMaxBufferLength(u.maxBitrate);if(!(p>=T)){this.backtrackFragment&&this.backtrackFragment.start>d.end&&(this.backtrackFragment=null);var S=this.backtrackFragment?this.backtrackFragment.start:d.end,y=this.getNextFragment(S,v);if(this.couldBacktrack&&!this.fragPrevious&&y&&y.sn!=="initSegment"&&this.fragmentTracker.getState(y)!==de){var b,C=((b=this.backtrackFragment)!=null?b:y).sn-v.startSN,D=v.fragments[C-1];D&&y.cc===D.cc&&(y=D,this.fragmentTracker.removeFragment(D))}else this.backtrackFragment&&d.len&&(this.backtrackFragment=null);if(y&&this.isLoopLoading(y,S)){if(!y.gap){var O=this.audioOnly&&!this.altAudio?Xe:mt,N=(O===mt?this.videoBuffer:this.mediaBuffer)||this.media;N&&this.afterBufferFlushed(N,O,Ne)}y=this.getNextFragmentLoopLoading(y,v,d,Ne,T)}y&&(!y.initSegment||y.initSegment.data||this.bitrateTest||(y=y.initSegment),this.loadFragment(y,u,S))}}}},e.loadFragment=function(t,r,i){var a=this.fragmentTracker.getState(t);this.fragCurrent=t,a===Y||a===se?t.sn==="initSegment"?this._loadInitSegment(t,r):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,r)):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,i)):this.clearTrackerIfNeeded(t)},e.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,Ne)},e.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},e.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},e.nextLevelSwitch=function(){var t=this.levels,r=this.media;if(r!=null&&r.readyState){var i,a=this.getAppendedFrag(r.currentTime);a&&a.start>1&&this.flushMainBuffer(0,a.start-1);var o=this.getLevelDetails();if(o!=null&&o.live){var l=this.getMainFwdBufferInfo();if(!l||l.len<2*o.targetduration)return}if(!r.paused&&t){var u=t[this.hls.nextLoadLevel],d=this.fragLastKbps;i=d&&this.fragCurrent?this.fragCurrent.duration*u.maxBitrate/(1e3*d)+1:0}else i=0;var h=this.getBufferedFrag(r.currentTime+i);if(h){var f=this.followingBufferedFrag(h);if(f){this.abortCurrentFrag();var v=f.maxStartPTS?f.maxStartPTS:f.start,p=f.duration,T=Math.max(h.end,v+Math.min(Math.max(p-this.config.maxFragLookUpTolerance,.5*p),.75*p));this.flushMainBuffer(T,Number.POSITIVE_INFINITY)}}}},e.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case er:case dr:case hr:case tr:case Ln:this.state=he}this.nextLoadPosition=this.getLoadPosition()},e.flushMainBuffer=function(t,r){s.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},e.onMediaAttached=function(t,r){s.prototype.onMediaAttached.call(this,t,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new $o(this.config,i,this.fragmentTracker,this.hls)},e.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),s.prototype.onMediaDetaching.call(this)},e.onMediaPlaying=function(){this.tick()},e.onMediaSeeked=function(){var t=this.media,r=t?t.currentTime:null;Z(r)&&this.log("Media seeked to "+r.toFixed(3));var i=this.getMainFwdBufferInfo();i!==null&&i.len!==0?this.tick():this.warn('Main forward buffer length on "seeked" event '+(i?i.len:"empty")+")")},e.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1},e.onManifestParsed=function(t,r){var i,a,o,l=!1,u=!1;r.levels.forEach(function(d){(i=d.audioCodec)&&(i.indexOf("mp4a.40.2")!==-1&&(l=!0),i.indexOf("mp4a.40.5")!==-1&&(u=!0))}),this.audioCodecSwitch=l&&u&&typeof((o=Ja())==null||(a=o.prototype)==null?void 0:a.changeType)!="function",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},e.onLevelLoading=function(t,r){var i=this.levels;if(i&&this.state===he){var a=i[r.level];(!a.details||a.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(a.details))&&(this.state=Qr)}},e.onLevelLoaded=function(t,r){var i,a=this.levels,o=r.level,l=r.details,u=l.totalduration;if(a){this.log("Level "+o+" loaded ["+l.startSN+","+l.endSN+"]"+(l.lastPartSn?"[part-"+l.lastPartSn+"-"+l.lastPartIndex+"]":"")+", cc ["+l.startCC+", "+l.endCC+"] duration:"+u);var d=a[o],h=this.fragCurrent;!h||this.state!==dr&&this.state!==hr||h.level===r.level&&h.urlId===d.urlId||!h.loader||this.abortCurrentFrag();var f=0;if(l.live||(i=d.details)!=null&&i.live){if(l.fragments[0]||(l.deltaUpdateFailed=!0),l.deltaUpdateFailed)return;f=this.alignPlaylists(l,d.details)}if(d.details=l,this.levelLastLoaded=o,this.hls.trigger(E.LEVEL_UPDATED,{details:l,level:o}),this.state===Qr){if(this.waitForCdnTuneIn(l))return;this.state=he}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,f),this.tick()}else this.warn("Levels were reset while loading level "+o)},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.levels;if(l){var u=l[i.level],d=u.details;if(!d)return this.warn("Dropping fragment "+i.sn+" of level "+i.level+" after level details were reset"),void this.fragmentTracker.removeFragment(i);var h=u.videoCodec,f=d.PTSKnown||!d.live,v=(r=i.initSegment)==null?void 0:r.data,p=this._getAudioCodec(u),T=this.transmuxer=this.transmuxer||new ms(this.hls,Ne,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),S=a?a.index:-1,y=S!==-1,b=new ie(i.level,i.sn,i.stats.chunkCount,o.byteLength,S,y),C=this.initPTS[i.cc];T.push(o,v,p,h,i,a,d.totalduration,f,b,C)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},e.onAudioTrackSwitching=function(t,r){var i=this.altAudio;if(!r.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;i&&(o.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),o.trigger(E.AUDIO_TRACK_SWITCHED,r)}},e.onAudioTrackSwitched=function(t,r){var i=r.id,a=!!this.hls.audioTracks[i].url;if(a){var o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=a,this.tick()},e.onBufferCreated=function(t,r){var i,a,o=r.tracks,l=!1;for(var u in o){var d=o[u];if(d.id==="main"){if(a=u,i=d,u==="video"){var h=o[u];h&&(this.videoBuffer=h.buffer)}}else l=!0}l&&i?(this.log("Alternate track found, use "+a+".buffered to schedule main fragment loading"),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media},e.onFragBuffered=function(t,r){var i=r.frag,a=r.part;if(!i||i.type===Ne){if(this.fragContextChanged(i))return this.warn("Fragment "+i.sn+(a?" p: "+a.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Ln&&(this.state=he));var o=a?a.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,a)}},e.onError=function(t,r){var i;if(r.fatal)this.state=Xr;else switch(r.details){case F.FRAG_GAP:case F.FRAG_PARSING_ERROR:case F.FRAG_DECRYPT_ERROR:case F.FRAG_LOAD_ERROR:case F.FRAG_LOAD_TIMEOUT:case F.KEY_LOAD_ERROR:case F.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Ne,r);break;case F.LEVEL_LOAD_ERROR:case F.LEVEL_LOAD_TIMEOUT:case F.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==Qr||((i=r.context)==null?void 0:i.type)!==Jt||(this.state=he);break;case F.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case F.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.checkBuffer=function(){var t=this.media,r=this.gapController;if(t&&r&&t.readyState){if(this.loadedmetadata||!re.getBuffered(t).length){var i=this.state!==he?this.fragCurrent:null;r.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}},e.onFragLoadEmergencyAborted=function(){this.state=he,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},e.onBufferFlushed=function(t,r){var i=r.type;if(i!==Xe||this.audioOnly&&!this.altAudio){var a=(i===mt?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,i,Ne)}},e.onLevelsUpdated=function(t,r){this.levels=r.levels},e.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},e.seekToStartPos=function(){var t=this.media;if(t){var r=t.currentTime,i=this.startPosition;if(i>=0&&r<i){if(t.seeking)return void this.log("could not seek to "+i+", already seeking at "+r);var a=re.getBuffered(t),o=(a.length?a.start(0):0)-i;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+o+" to match buffer start"),i+=o,this.startPosition=i),this.log("seek to target start position "+i+" from current time "+r),t.currentTime=i}}},e._getAudioCodec=function(t){var r=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r=r.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),r},e._loadBitrateTestFrag=function(t,r){var i=this;t.bitrateTest=!0,this._doFragLoad(t,r).then(function(a){var o=i.hls;if(a&&!i.fragContextChanged(t)){r.fragmentError=0,i.state=he,i.startFragRequested=!1,i.bitrateTest=!1;var l=t.stats;l.parsing.start=l.parsing.end=l.buffering.start=l.buffering.end=self.performance.now(),o.trigger(E.FRAG_LOADED,a),t.bitrateTest=!1}})},e._handleTransmuxComplete=function(t){var r,i="main",a=this.hls,o=t.remuxResult,l=t.chunkMeta,u=this.getCurrentContext(l);if(u){var d=u.frag,h=u.part,f=u.level,v=o.video,p=o.text,T=o.id3,S=o.initSegment,y=f.details,b=this.altAudio?void 0:o.audio;if(this.fragContextChanged(d))this.fragmentTracker.removeFragment(d);else{if(this.state=tr,S){if(S!=null&&S.tracks){var C=d.initSegment||d;this._bufferInitSegment(f,S.tracks,C,l),a.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:C,id:i,tracks:S.tracks})}var D=S.initPTS,O=S.timescale;Z(D)&&(this.initPTS[d.cc]={baseTime:D,timescale:O},a.trigger(E.INIT_PTS_FOUND,{frag:d,id:i,initPTS:D,timescale:O}))}if(v&&o.independent!==!1){if(y){var N=v.startPTS,G=v.endPTS,W=v.startDTS,q=v.endDTS;if(h)h.elementaryStreams[v.type]={startPTS:N,endPTS:G,startDTS:W,endDTS:q};else if(v.firstKeyFrame&&v.independent&&l.id===1&&(this.couldBacktrack=!0),v.dropped&&v.independent){var V=this.getMainFwdBufferInfo();if((V?V.end:this.getLoadPosition())+this.config.maxBufferHole<(v.firstKeyFramePTS?v.firstKeyFramePTS:N)-this.config.maxBufferHole)return void this.backtrack(d);d.setElementaryStreamInfo(v.type,d.start,G,d.start,q,!0)}d.setElementaryStreamInfo(v.type,N,G,W,q),this.backtrackFragment&&(this.backtrackFragment=d),this.bufferFragmentData(v,d,h,l)}}else if(o.independent===!1)return void this.backtrack(d);if(b){var te=b.startPTS,J=b.endPTS,oe=b.startDTS,me=b.endDTS;h&&(h.elementaryStreams[Xe]={startPTS:te,endPTS:J,startDTS:oe,endDTS:me}),d.setElementaryStreamInfo(Xe,te,J,oe,me),this.bufferFragmentData(b,d,h,l)}if(y&&T!=null&&(r=T.samples)!=null&&r.length){var ue={id:i,frag:d,details:y,samples:T.samples};a.trigger(E.FRAG_PARSING_METADATA,ue)}if(y&&p){var ve={id:i,frag:d,details:y,samples:p.samples};a.trigger(E.FRAG_PARSING_USERDATA,ve)}}}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i,a){var o=this;if(this.state===tr){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var l=r.audio,u=r.video,d=r.audiovideo;if(l){var h=t.audioCodec,f=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(h&&(h=h.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),l.metadata.channelCount!==1&&f.indexOf("firefox")===-1&&(h="mp4a.40.5")),f.indexOf("android")!==-1&&l.container!=="audio/mpeg"&&(h="mp4a.40.2",this.log("Android: force audio codec to "+h)),t.audioCodec&&t.audioCodec!==h&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+h+'"'),l.levelCodec=h,l.id="main",this.log("Init audio buffer, container:"+l.container+", codecs[selected/level/parsed]=["+(h||"")+"/"+(t.audioCodec||"")+"/"+l.codec+"]")}u&&(u.levelCodec=t.videoCodec,u.id="main",this.log("Init video buffer, container:"+u.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+u.codec+"]")),d&&this.log("Init audiovideo buffer, container:"+d.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+d.codec+"]"),this.hls.trigger(E.BUFFER_CODECS,r),Object.keys(r).forEach(function(v){var p=r[v].initSegment;p!=null&&p.byteLength&&o.hls.trigger(E.BUFFER_APPENDING,{type:v,data:p,frag:i,part:null,chunkMeta:a,parent:i.type})}),this.tick()}},e.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Ne)},e.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=he},e.checkFragmentChanged=function(){var t=this.media,r=null;if(t&&t.readyState>1&&t.seeking===!1){var i=t.currentTime;if(re.isBuffered(t,i)?r=this.getAppendedFrag(i):re.isBuffered(t,i+.1)&&(r=this.getAppendedFrag(i+.1)),r){this.backtrackFragment=null;var a=this.fragPlaying,o=r.level;a&&r.sn===a.sn&&a.level===o&&r.urlId===a.urlId||(this.fragPlaying=r,this.hls.trigger(E.FRAG_CHANGED,{frag:r}),a&&a.level===o||this.hls.trigger(E.LEVEL_SWITCHED,{level:o}))}}},K(n,[{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 r=t.currentTime,i=this.currentFrag;if(i&&Z(r)&&Z(i.programDateTime)){var a=i.programDateTime+1e3*(r-i.start);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}}]),n}(na),$r=function(){function s(e,t,r){t===void 0&&(t=0),r===void 0&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var n=s.prototype;return n.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},n.getTotalWeight=function(){return this.totalWeight_},n.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},s}(),el=function(){function s(e,t,r,i){i===void 0&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new $r(e),this.fast_=new $r(t),this.defaultTTFB_=i,this.ttfb_=new $r(e)}var n=s.prototype;return n.update=function(e,t){var r=this.slow_,i=this.fast_,a=this.ttfb_;r.halfLife!==e&&(this.slow_=new $r(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new $r(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new $r(e,a.getEstimate(),a.getTotalWeight()))},n.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},n.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},n.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},n.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},n.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},n.destroy=function(){},s}(),tl=function(){function s(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;var t=e.config;this.bwEstimator=new el(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this)},n.unregisterListeners=function(){var e=this.hls;e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this)},n.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},n.onFragLoading=function(e,t){var r,i=t.frag;this.ignoreFragment(i)||(this.fragCurrent=i,this.partCurrent=(r=t.part)!=null?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},n.onLevelSwitching=function(e,t){this.clearTimer()},n.getTimeToLoadFrag=function(e,t,r,i){return e+r/t+(i?this.lastLevelLoadSec:0)},n.onLevelLoaded=function(e,t){var r=this.hls.config,i=t.stats,a=i.total,o=i.bwEstimate;Z(a)&&Z(o)&&(this.lastLevelLoadSec=8*a/o),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},n._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.autoLevelEnabled,a=r.media;if(e&&a){var o=performance.now(),l=t?t.stats:e.stats,u=t?t.duration:e.duration,d=o-l.loading.start;if(l.aborted||l.loaded&&l.loaded===l.total||e.level===0)return this.clearTimer(),void(this._nextAutoLevel=-1);if(i&&!a.paused&&a.playbackRate&&a.readyState){var h=r.mainForwardBufferInfo;if(h!==null){var f=this.bwEstimator.getEstimateTTFB(),v=Math.abs(a.playbackRate);if(!(d<=Math.max(f,u/(2*v)*1e3))){var p=h.len/v;if(!(p>=2*u/v)){var T=l.loading.first?l.loading.first-l.loading.start:-1,S=l.loaded&&T>-1,y=this.bwEstimator.getEstimate(),b=r.levels,C=r.minAutoLevel,D=b[e.level],O=l.total||Math.max(l.loaded,Math.round(u*D.maxBitrate/8)),N=d-T;N<1&&S&&(N=Math.min(d,8*l.loaded/y));var G=S?1e3*l.loaded/N:0,W=G?(O-l.loaded)/G:8*O/y+f/1e3;if(!(W<=p)){var q,V=G?8*G:y,te=Number.POSITIVE_INFINITY;for(q=e.level-1;q>C;q--){var J=b[q].maxBitrate;if((te=this.getTimeToLoadFrag(f/1e3,V,u*J,!b[q].details))<p)break}te>=W||te>10*u||(r.nextLoadLevel=q,S?this.bwEstimator.sample(d-Math.min(f,T),l.loaded):this.bwEstimator.sampleTTFB(d),this.clearTimer(),x.warn("[abr] Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+` is loading too slowly;
|
|
27
27
|
Time to underbuffer: `+p.toFixed(3)+` s
|
|
28
28
|
Estimated load time for current fragment: `+W.toFixed(3)+` s
|
|
29
29
|
Estimated load time for down switch fragment: `+te.toFixed(3)+` s
|
|
30
30
|
TTFB estimate: `+T+`
|
|
31
31
|
Current BW estimate: `+(Z(y)?(y/1024).toFixed(3):"Unknown")+` Kb/s
|
|
32
32
|
New BW estimate: `+(this.bwEstimator.getEstimate()/1024).toFixed(3)+` Kb/s
|
|
33
|
-
Aborting and switching to level `+q),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),r.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:l}))}}}}}}},n.onFragLoaded=function(e,t){var r=t.frag,i=t.part,a=i?i.stats:r.stats;if(r.type===Ne&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var o=i?i.duration:r.duration,l=this.hls.levels[r.level],d=(l.loaded?l.loaded.bytes:0)+a.loaded,u=(l.loaded?l.loaded.duration:0)+o;l.loaded={bytes:d,duration:u},l.realBitrate=Math.round(8*d/u)}if(r.bitrateTest){var c={stats:a,frag:r,part:i,id:r.type};this.onFragBuffered(E.FRAG_BUFFERED,c),r.bitrateTest=!1}}},n.onFragBuffered=function(e,t){var r=t.frag,i=t.part,a=i!=null&&i.stats.loaded?i.stats:r.stats;if(!a.aborted&&!this.ignoreFragment(r)){var o=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,a.loaded),a.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}},n.ignoreFragment=function(e){return e.type!==Ne||e.sn==="initSegment"},n.clearTimer=function(){self.clearInterval(this.timer)},n.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.maxAutoLevel,a=r.config,o=r.minAutoLevel,l=r.media,d=t?t.duration:e?e.duration:0,u=l&&l.playbackRate!==0?Math.abs(l.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,f=r.mainForwardBufferInfo,v=(f?f.len:0)/u,p=this.findBestLevel(c,o,i,v,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(p>=0)return p;x.trace("[abr] "+(v?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var T=d?Math.min(d,a.maxStarvationDelay):a.maxStarvationDelay,S=a.abrBandWidthFactor,y=a.abrBandWidthUpFactor;if(!v){var b=this.bitrateTestDelay;b&&(T=(d?Math.min(d,a.maxLoadingDelay):a.maxLoadingDelay)-b,x.trace("[abr] bitrate test took "+Math.round(1e3*b)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*T)+" ms"),S=y=1)}return p=this.findBestLevel(c,o,i,v+T,S,y),Math.max(p,0)},n.findBestLevel=function(e,t,r,i,a,o){for(var l,d=this.fragCurrent,u=this.partCurrent,c=this.lastLoadedFragLevel,f=this.hls.levels,v=f[c],p=!(v==null||(l=v.details)==null||!l.live),T=v==null?void 0:v.codecSet,S=u?u.duration:d?d.duration:0,y=this.bwEstimator.getEstimateTTFB()/1e3,b=t,D=-1,w=r;w>=t;w--){var O=f[w];if(!O||T&&O.codecSet!==T)O&&(b=Math.min(w,b),D=Math.max(w,D));else{D!==-1&&x.trace("[abr] Skipped level(s) "+b+"-"+D+' with CODECS:"'+f[D].attrs.CODECS+'"; not compatible with "'+v.attrs.CODECS+'"');var N=O.details,G=(u?N==null?void 0:N.partTarget:N==null?void 0:N.averagetargetduration)||S,W=void 0;W=w<=c?a*e:o*e;var q=f[w].maxBitrate,V=this.getTimeToLoadFrag(y,W,q*G,N===void 0);if(x.trace("[abr] level:"+w+" adjustedbw-bitrate:"+Math.round(W-q)+" avgDuration:"+G.toFixed(1)+" maxFetchDuration:"+i.toFixed(1)+" fetchDuration:"+V.toFixed(1)),W>q&&(V===0||!Z(V)||p&&!this.bitrateTestDelay||V<i))return w}}return-1},K(s,[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this.bwEstimator;if(e!==-1&&!t.canEstimate())return e;var r=this.getNextABRAutoLevel();if(e!==-1){var i=this.hls.levels;if(i.length>Math.max(e,r)&&i[e].loadError<=i[r].loadError)return e}return e!==-1&&(r=Math.min(e,r)),r},set:function(e){this._nextAutoLevel=e}}]),s}(),ms=function(){function s(){this.chunks=[],this.dataLength=0}var n=s.prototype;return n.push=function(e){this.chunks.push(e),this.dataLength+=e.length},n.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=t.length===1?t[0]:function(i,a){for(var o=new Uint8Array(a),l=0,d=0;d<i.length;d++){var u=i[d];o.set(u,l),l+=u.length}return o}(t,r),this.reset(),e):new Uint8Array(0)},n.reset=function(){this.chunks.length=0,this.dataLength=0},s}(),el=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[audio-stream-controller]",kt)||this).videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.bufferedTrack=null,a.switchingTrack=null,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a.cachedTrackLoadedData=null,a._registerListeners(),a}ae(n,s);var e=n.prototype;return e.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null},e._registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(E.ERROR,this.onError,this),t.on(E.BUFFER_RESET,this.onBufferReset,this),t.on(E.BUFFER_CREATED,this.onBufferCreated,this),t.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(E.ERROR,this.onError,this),t.off(E.BUFFER_RESET,this.onBufferReset,this),t.off(E.BUFFER_CREATED,this.onBufferCreated,this),t.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},e.onInitPtsFound=function(t,r){var i=r.frag,a=r.id,o=r.initPTS,l=r.timescale;if(a==="main"){var d=i.cc;this.initPTS[i.cc]={baseTime:o,timescale:l},this.log("InitPTS for cc: "+d+" found from main: "+o),this.videoTrackCC=d,this.state===Pi&&this.tick()}},e.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=rt);var r=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),r>0&&t===-1?(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r,this.state=ce):(this.loadedmetadata=!1,this.state=Ir),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.doTick=function(){switch(this.state){case ce:this.doTickIdle();break;case Ir:var t,r=this.levels,i=this.trackId,a=r==null||(t=r[i])==null?void 0:t.details;if(a){if(this.waitForCdnTuneIn(a))break;this.state=Pi}break;case dr:var o,l=performance.now(),d=this.retryDate;(!d||l>=d||(o=this.media)!=null&&o.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=ce);break;case Pi:var u=this.waitingData;if(u){var c=u.frag,f=u.part,v=u.cache,p=u.complete;if(this.initPTS[c.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=ur;var T={frag:c,part:f,payload:v.flush(),networkDetails:null};this._handleFragmentLoadProgress(T),p&&s.prototype._handleFragmentLoadComplete.call(this,T)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var S=this.getLoadPosition(),y=re.bufferInfo(this.mediaBuffer,S,this.config.maxBufferHole);zr(y.end,this.config.maxFragLookUpTolerance,c)<0&&(this.log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+y.end+" is needed"),this.clearWaitingFragment())}}else this.state=ce}this.onTickEnd()},e.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=ce)},e.resetLoadingState=function(){this.clearWaitingFragment(),s.prototype.resetLoadingState.call(this)},e.onTickEnd=function(){var t=this.media;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)},e.doTickIdle=function(){var t=this.hls,r=this.levels,i=this.media,a=this.trackId,o=t.config;if(r!=null&&r[a]&&(i||!this.startFragRequested&&o.startFragPrefetch)){var l=r[a],d=l.details;if(!d||d.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(d))this.state=Ir;else{var u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,Xe,kt));var c=this.getFwdBufferInfo(u,kt);if(c!==null){var f=this.bufferedTrack,v=this.switchingTrack;if(!v&&this._streamEnded(c,d))return t.trigger(E.BUFFER_EOS,{type:"audio"}),void(this.state=xi);var p=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Ne),T=c.len,S=this.getMaxBufferLength(p==null?void 0:p.len);if(!(T>=S)||v){var y=d.fragments[0].start,b=c.end;if(v&&i){var D=this.getLoadPosition();f&&v.attrs!==f.attrs&&(b=D),d.PTSKnown&&D<y&&(c.end>y||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=y+.05)}var w=this.getNextFragment(b,d),O=!1;if(w&&this.isLoopLoading(w,b)&&(O=!!w.gap,w=this.getNextFragmentLoopLoading(w,d,c,Ne,S)),w){var N=p&&w.start>p.end+d.targetduration;if(N||(p==null||!p.len)&&c.len){var G=this.getAppendedFrag(w.start,Ne);if(G===null||(O||(O=!!G.gap||!!N&&p.len===0),N&&!O||O&&c.nextStart&&c.nextStart<G.end))return}this.loadFragment(w,l,b)}else this.bufferFlushed=!0}}}}},e.getMaxBufferLength=function(t){var r=s.prototype.getMaxBufferLength.call(this);return t?Math.min(Math.max(r,t),this.config.maxMaxBufferLength):r},e.onMediaDetaching=function(){this.videoBuffer=null,s.prototype.onMediaDetaching.call(this)},e.onAudioTracksUpdated=function(t,r){var i=r.audioTracks;this.resetTransmuxer(),this.levels=i.map(function(a){return new kr(a)})},e.onAudioTrackSwitching=function(t,r){var i=!!r.url;this.trackId=r.id;var a=this.fragCurrent;a&&(a.abortRequests(),this.removeUnbufferedFrags(a.start)),this.resetLoadingState(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.switchingTrack=r,this.state=ce):(this.switchingTrack=null,this.bufferedTrack=r,this.state=rt),this.tick()},e.onManifestLoading=function(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1},e.onLevelLoaded=function(t,r){this.mainDetails=r.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(E.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},e.onAudioTrackLoaded=function(t,r){var i;if(this.mainDetails!=null){var a=this.levels,o=r.details,l=r.id;if(a){this.log("Track "+l+" loaded ["+o.startSN+","+o.endSN+"]"+(o.lastPartSn?"[part-"+o.lastPartSn+"-"+o.lastPartIndex+"]":"")+",duration:"+o.totalduration);var d=a[l],u=0;if(o.live||(i=d.details)!=null&&i.live){var c=this.mainDetails;if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed||!c)return;!d.details&&o.hasProgramDateTime&&c.hasProgramDateTime?(Ze(o,c),u=o.fragments[0].start):u=this.alignPlaylists(o,d.details)}d.details=o,this.levelLastLoaded=l,this.startFragRequested||!this.mainDetails&&o.live||this.setStartPosition(d.details,u),this.state!==Ir||this.waitForCdnTuneIn(o)||(this.state=ce),this.tick()}else this.warn("Audio tracks were reset while loading level "+l)}else this.cachedTrackLoadedData=r},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.config,d=this.trackId,u=this.levels;if(u){var c=u[d];if(c){var f=c.details;if(!f)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);var v=l.defaultAudioCodec||c.audioCodec||"mp4a.40.2",p=this.transmuxer;p||(p=this.transmuxer=new gs(this.hls,kt,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var T=this.initPTS[i.cc],S=(r=i.initSegment)==null?void 0:r.data;if(T!==void 0){var y=a?a.index:-1,b=y!==-1,D=new ie(i.level,i.sn,i.stats.chunkCount,o.byteLength,y,b);p.push(o,S,v,"",i,a,f.totalduration,!1,D,T)}else this.log("Unknown video PTS for cc "+i.cc+", waiting for video PTS before demuxing audio frag "+i.sn+" of ["+f.startSN+" ,"+f.endSN+"],track "+d),(this.waitingData=this.waitingData||{frag:i,part:a,cache:new ms,complete:!1}).cache.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=Pi}else this.warn("Audio track is undefined on fragment load progress")}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},e._handleFragmentLoadComplete=function(t){this.waitingData?this.waitingData.complete=!0:s.prototype._handleFragmentLoadComplete.call(this,t)},e.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},e.onBufferCreated=function(t,r){var i=r.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),r.tracks.video&&(this.videoBuffer=r.tracks.video.buffer||null)},e.onFragBuffered=function(t,r){var i,a=r.frag,o=r.part;if(a.type===kt)if(this.fragContextChanged(a))this.warn("Fragment "+a.sn+(o?" p: "+o.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+(this.switchingTrack?this.switchingTrack.name:"false"));else{if(a.sn!=="initSegment"){this.fragPrevious=a;var l=this.switchingTrack;l&&(this.bufferedTrack=l,this.switchingTrack=null,this.hls.trigger(E.AUDIO_TRACK_SWITCHED,H({},l)))}this.fragBufferedComplete(a,o)}else this.loadedmetadata||a.type!==Ne||(i=this.videoBuffer||this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)},e.onError=function(t,r){var i;if(r.fatal)this.state=Xr;else switch(r.details){case F.FRAG_GAP:case F.FRAG_PARSING_ERROR:case F.FRAG_DECRYPT_ERROR:case F.FRAG_LOAD_ERROR:case F.FRAG_LOAD_TIMEOUT:case F.KEY_LOAD_ERROR:case F.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(kt,r);break;case F.AUDIO_TRACK_LOAD_ERROR:case F.AUDIO_TRACK_LOAD_TIMEOUT:case F.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==Ir||((i=r.context)==null?void 0:i.type)!==yt||(this.state=ce);break;case F.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="audio")return;this.reduceLengthAndFlushBuffer(r)&&(this.bufferedTrack=null,s.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case F.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.onBufferFlushed=function(t,r){r.type===Xe&&(this.bufferFlushed=!0,this.state===xi&&(this.state=ce))},e._handleTransmuxComplete=function(t){var r,i="audio",a=this.hls,o=t.remuxResult,l=t.chunkMeta,d=this.getCurrentContext(l);if(d){var u=d.frag,c=d.part,f=d.level.details,v=o.audio,p=o.text,T=o.id3,S=o.initSegment;if(!this.fragContextChanged(u)&&f){if(this.state=er,this.switchingTrack&&v&&this.completeAudioSwitch(this.switchingTrack),S!=null&&S.tracks){var y=u.initSegment||u;this._bufferInitSegment(S.tracks,y,l),a.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:i,tracks:S.tracks})}if(v){var b=v.startPTS,D=v.endPTS,w=v.startDTS,O=v.endDTS;c&&(c.elementaryStreams[Xe]={startPTS:b,endPTS:D,startDTS:w,endDTS:O}),u.setElementaryStreamInfo(Xe,b,D,w,O),this.bufferFragmentData(v,u,c,l)}if(T!=null&&(r=T.samples)!=null&&r.length){var N=X({id:i,frag:u,details:f},T);a.trigger(E.FRAG_PARSING_METADATA,N)}if(p){var G=X({id:i,frag:u,details:f},p);a.trigger(E.FRAG_PARSING_USERDATA,G)}}else this.fragmentTracker.removeFragment(u)}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i){if(this.state===er){t.video&&delete t.video;var a=t.audio;if(a){a.levelCodec=a.codec,a.id="audio",this.log("Init audio buffer, container:"+a.container+", codecs[parsed]=["+a.codec+"]"),this.hls.trigger(E.BUFFER_CODECS,t);var o=a.initSegment;if(o!=null&&o.byteLength){var l={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:o};this.hls.trigger(E.BUFFER_APPENDING,l)}this.tick()}}},e.loadFragment=function(t,r,i){var a,o=this.fragmentTracker.getState(t);this.fragCurrent=t,this.switchingTrack||o===Y||o===se?t.sn==="initSegment"?this._loadInitSegment(t,r):(a=r.details)!=null&&a.live&&!this.initPTS[t.cc]?(this.log("Waiting for video PTS in continuity counter "+t.cc+" of live stream before loading audio fragment "+t.sn+" of level "+this.trackId),this.state=Pi):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,i)):this.clearTrackerIfNeeded(t)},e.completeAudioSwitch=function(t){var r=this.hls,i=this.media,a=this.bufferedTrack,o=a==null?void 0:a.attrs,l=t.attrs;i&&o&&(o.CHANNELS!==l.CHANNELS||o.NAME!==l.NAME||o.LANGUAGE!==l.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),s.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,r.trigger(E.AUDIO_TRACK_SWITCHED,H({},t))},n}(na),tl=function(s){function n(t){var r;return(r=s.call(this,t,"[audio-track-controller]")||this).tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.currentTrack=null,r.selectDefaultTrack=!0,r.registerListeners(),r}ae(n,s);var e=n.prototype;return e.registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(E.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVEL_LOADING,this.onLevelLoading,this),t.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(E.ERROR,this.onError,this)},e.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,s.prototype.destroy.call(this)},e.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0},e.onManifestParsed=function(t,r){this.tracks=r.audioTracks||[]},e.onAudioTrackLoaded=function(t,r){var i=r.id,a=r.groupId,o=r.details,l=this.tracksInGroup[i];if(l&&l.groupId===a){var d=l.details;l.details=r.details,this.log("audio-track "+i+' "'+l.name+'" lang:'+l.lang+" group:"+a+" loaded ["+o.startSN+"-"+o.endSN+"]"),i===this.trackId&&this.playlistLoaded(i,r,d)}else this.warn("Track with id:"+i+" and group:"+a+" not found in active group "+l.groupId)},e.onLevelLoading=function(t,r){this.switchLevel(r.level)},e.onLevelSwitching=function(t,r){this.switchLevel(r.level)},e.switchLevel=function(t){var r=this.hls.levels[t];if(r!=null&&r.audioGroupIds){var i=r.audioGroupIds[r.urlId];if(this.groupId!==i){this.groupId=i||null;var a=this.tracks.filter(function(l){return!i||l.groupId===i});this.selectDefaultTrack&&!a.some(function(l){return l.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=a;var o={audioTracks:a};this.log("Updating audio tracks, "+a.length+" track(s) found in group:"+i),this.hls.trigger(E.AUDIO_TRACKS_UPDATED,o),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===yt&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(r))},e.setAudioTrack=function(t){var r=this.tracksInGroup;if(t<0||t>=r.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var i=this.currentTrack;r[this.trackId];var a=r[t],o=a.groupId,l=a.name;if(this.log("Switching to audio-track "+t+' "'+l+'" lang:'+a.lang+" group:"+o),this.trackId=t,this.currentTrack=a,this.selectDefaultTrack=!1,this.hls.trigger(E.AUDIO_TRACK_SWITCHING,H({},a)),!a.details||a.details.live){var d=this.switchParams(a.url,i==null?void 0:i.details);this.loadPlaylist(d)}}},e.selectInitialTrack=function(){var t=this.tracksInGroup,r=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(r!==-1)this.setAudioTrack(r);else{var i=new Error("No track found for running audio group-ID: "+this.groupId+" track count: "+t.length);this.warn(i.message),this.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}},e.findTrackId=function(t){for(var r=this.tracksInGroup,i=0;i<r.length;i++){var a=r[i];if((!this.selectDefaultTrack||a.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===a.attrs["STABLE-RENDITION-ID"]||t.name===a.name&&t.lang===a.lang))return a.id}return-1},e.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,a=r.groupId,o=r.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("loading audio-track playlist "+i+' "'+r.name+'" lang:'+r.lang+" group:"+a),this.clearTimer(),this.hls.trigger(E.AUDIO_TRACK_LOADING,{url:o,id:i,groupId:a,deliveryDirectives:t||null})}},K(n,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}}]),n}(k);function ps(s,n){if(s.length!==n.length)return!1;for(var e=0;e<s.length;e++)if(!rl(s[e].attrs,n[e].attrs))return!1;return!0}function rl(s,n){var e=s["STABLE-RENDITION-ID"];return e?e===n["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(function(t){return s[t]!==n[t]})}var il=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[subtitle-stream-controller]",It)||this).levels=[],a.currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a._registerListeners(),a}ae(n,s);var e=n.prototype;return e.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},e._registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.ERROR,this.onError,this),t.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.ERROR,this.onError,this),t.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},e.startLoad=function(t){this.stopLoad(),this.state=ce,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},e.onMediaDetaching=function(){this.tracksBuffered=[],s.prototype.onMediaDetaching.call(this)},e.onLevelLoaded=function(t,r){this.mainDetails=r.details},e.onSubtitleFragProcessed=function(t,r){var i=r.frag,a=r.success;if(this.fragPrevious=i,this.state=ce,a){var o=this.tracksBuffered[this.currentTrackId];if(o){for(var l,d=i.start,u=0;u<o.length;u++)if(d>=o[u].start&&d<=o[u].end){l=o[u];break}var c=i.start+i.duration;l?l.end=c:(l={start:d,end:c},o.push(l)),this.fragmentTracker.fragBuffered(i)}}},e.onBufferFlushing=function(t,r){var i=r.startOffset,a=r.endOffset;if(i===0&&a!==Number.POSITIVE_INFINITY){var o=this.currentTrackId,l=this.levels;if(!l.length||!l[o]||!l[o].details)return;var d=a-l[o].details.targetduration;if(d<=0)return;r.endOffsetSubtitles=Math.max(0,d),this.tracksBuffered.forEach(function(u){for(var c=0;c<u.length;)if(u[c].end<=d)u.shift();else{if(!(u[c].start<d))break;u[c].start=d,c++}}),this.fragmentTracker.removeFragmentsInRange(i,d,It)}},e.onFragBuffered=function(t,r){var i;this.loadedmetadata||r.frag.type!==Ne||(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)},e.onError=function(t,r){var i=r.frag;(i==null?void 0:i.type)===It&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==rt&&(this.state=ce))},e.onSubtitleTracksUpdated=function(t,r){var i=this,a=r.subtitleTracks;ps(this.levels,a)?this.levels=a.map(function(o){return new kr(o)}):(this.tracksBuffered=[],this.levels=a.map(function(o){var l=new kr(o);return i.tracksBuffered[l.id]=[],l}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,It),this.fragPrevious=null,this.mediaBuffer=null)},e.onSubtitleTrackSwitch=function(t,r){if(this.currentTrackId=r.id,this.levels.length&&this.currentTrackId!==-1){var i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(500)}else this.clearInterval()},e.onSubtitleTrackLoaded=function(t,r){var i,a=r.details,o=r.id,l=this.currentTrackId,d=this.levels;if(d.length){var u=d[l];if(!(o>=d.length||o!==l)&&u){this.mediaBuffer=this.mediaBufferTimeRanges;var c=0;if(a.live||(i=u.details)!=null&&i.live){var f=this.mainDetails;if(a.deltaUpdateFailed||!f)return;var v=f.fragments[0];u.details?(c=this.alignPlaylists(a,u.details))===0&&v&&wr(a,c=v.start):a.hasProgramDateTime&&f.hasProgramDateTime?(Ze(a,f),c=a.fragments[0].start):v&&wr(a,c=v.start)}u.details=a,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(u.details,c),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===ce&&(Rr(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),u.details=void 0))}}},e._handleFragmentLoadComplete=function(t){var r=this,i=t.frag,a=t.payload,o=i.decryptdata,l=this.hls;if(!this.fragContextChanged(i)&&a&&a.byteLength>0&&o&&o.key&&o.iv&&o.method==="AES-128"){var d=performance.now();this.decrypter.decrypt(new Uint8Array(a),o.key.buffer,o.iv.buffer).catch(function(u){throw l.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_DECRYPT_ERROR,fatal:!1,error:u,reason:u.message,frag:i}),u}).then(function(u){var c=performance.now();l.trigger(E.FRAG_DECRYPTED,{frag:i,payload:u,stats:{tstart:d,tdecrypt:c}})}).catch(function(u){r.warn(u.name+": "+u.message),r.state=ce})}},e.doTick=function(){if(this.media){if(this.state===ce){var t=this.currentTrackId,r=this.levels,i=r[t];if(!r.length||!i||!i.details)return;var a=i.details,o=a.targetduration,l=this.config,d=this.getLoadPosition(),u=re.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],d-o,l.maxBufferHole),c=u.end,f=u.len,v=this.getFwdBufferInfo(this.media,Ne);if(f>this.getMaxBufferLength(v==null?void 0:v.len)+o)return;var p=a.fragments,T=p.length,S=a.edge,y=null,b=this.fragPrevious;if(c<S){var D=l.maxFragLookUpTolerance;!(y=Rr(b,p,Math.max(p[0].start,c),D))&&b&&b.start<p[0].start&&(y=p[0])}else y=p[T-1];if(!y)return;y=this.mapToInitFragWhenRequired(y),this.fragmentTracker.getState(y)===Y&&this.loadFragment(y,i,c)}}else this.state=ce},e.getMaxBufferLength=function(t){var r=s.prototype.getMaxBufferLength.call(this);return t?Math.max(r,t):r},e.loadFragment=function(t,r,i){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t,r):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,i))},K(n,[{key:"mediaBufferTimeRanges",get:function(){return new nl(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(na),nl=function(s){this.buffered=void 0;var n=function(e,t,r){if((t>>>=0)>r-1)throw new DOMException("Failed to execute '"+e+"' on 'TimeRanges': The index provided ("+t+") is greater than the maximum bound ("+r+")");return s[t][e]};this.buffered={get length(){return s.length},end:function(e){return n("end",e,s.length)},start:function(e){return n("start",e,s.length)}}},al=function(s){function n(t){var r;return(r=s.call(this,t,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r._subtitleDisplay=!0,r.registerListeners(),r}ae(n,s);var e=n.prototype;return e.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,s.prototype.destroy.call(this)},e.registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(E.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVEL_LOADING,this.onLevelLoading,this),t.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(E.ERROR,this.onError,this)},e.onMediaAttached=function(t,r){this.media=r.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))},e.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},e.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),pa(this.media.textTracks).forEach(function(t){lr(t)}),this.subtitleTrack=-1,this.media=null)},e.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},e.onManifestParsed=function(t,r){this.tracks=r.subtitleTracks},e.onSubtitleTrackLoaded=function(t,r){var i=r.id,a=r.details,o=this.trackId,l=this.tracksInGroup[o];if(l){var d=l.details;l.details=r.details,this.log("subtitle track "+i+" loaded ["+a.startSN+"-"+a.endSN+"]"),i===this.trackId&&this.playlistLoaded(i,r,d)}else this.warn("Invalid subtitle track id "+i)},e.onLevelLoading=function(t,r){this.switchLevel(r.level)},e.onLevelSwitching=function(t,r){this.switchLevel(r.level)},e.switchLevel=function(t){var r=this.hls.levels[t];if(r!=null&&r.textGroupIds){var i=r.textGroupIds[r.urlId],a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){var o=this.tracks.filter(function(u){return!i||u.groupId===i});this.tracksInGroup=o;var l=this.findTrackId(a==null?void 0:a.name)||this.findTrackId();this.groupId=i||null;var d={subtitleTracks:o};this.log("Updating subtitle tracks, "+o.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(E.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.setSubtitleTrack(l,a)}else this.shouldReloadPlaylist(a)&&this.setSubtitleTrack(this.trackId,a)}},e.findTrackId=function(t){for(var r=this.tracksInGroup,i=0;i<r.length;i++){var a=r[i];if((!this.selectDefaultTrack||a.default)&&(!t||t===a.name))return a.id}return-1},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===Gt&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.checkRetry(r)},e.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,a=r.groupId,o=r.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(E.SUBTITLE_TRACK_LOADING,{url:o,id:i,groupId:a,deliveryDirectives:t||null})}},e.toggleTrackModes=function(t){var r=this,i=this.media,a=this.trackId;if(i){var o=pa(i.textTracks),l=o.filter(function(c){return c.groupId===r.groupId});if(t===-1)[].slice.call(o).forEach(function(c){c.mode="disabled"});else{var d=l[a];d&&(d.mode="disabled")}var u=l[t];u&&(u.mode=this.subtitleDisplay?"showing":"hidden")}},e.setSubtitleTrack=function(t,r){var i,a=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(t===-1||(i=a[t])!=null&&i.details)||t<-1||t>=a.length)){this.clearTimer();var o=a[t];if(this.log("Switching to subtitle-track "+t+(o?' "'+o.name+'" lang:'+o.lang+" group:"+o.groupId:"")),this.trackId=t,o){var l=o.id,d=o.groupId,u=d===void 0?"":d,c=o.name,f=o.type,v=o.url;this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:l,groupId:u,name:c,type:f,url:v});var p=this.switchParams(o.url,r==null?void 0:r.details);this.loadPlaylist(p)}else this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},e.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,r=pa(this.media.textTracks),i=0;i<r.length;i++)if(r[i].mode==="hidden")t=i;else if(r[i].mode==="showing"){t=i;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},K(n,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1;var r=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,r)}}]),n}(k);function pa(s){for(var n=[],e=0;e<s.length;e++){var t=s[e];t.kind!=="subtitles"&&t.kind!=="captions"||!t.label||n.push(s[e])}return n}var sl=function(){function s(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var n=s.prototype;return n.append=function(e,t){var r=this.queues[t];r.push(e),r.length===1&&this.buffers[t]&&this.executeNext(t)},n.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},n.appendBlocker=function(e){var t,r=new Promise(function(a){t=a}),i={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,e),r},n.executeNext=function(e){var t=this.buffers,r=this.queues,i=t[e],a=r[e];if(a.length){var o=a[0];try{o.execute()}catch(l){x.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),o.onError(l),i!=null&&i.updating||(a.shift(),this.executeNext(e))}}},n.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},n.current=function(e){return this.queues[e][0]},s}(),ys=Kr(),Ts=/([ha]vc.)(?:\.[^.,]+)+/,ol=function(){function s(e){var t=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 r=t.media,i=t.mediaSource;x.log("[buffer-controller]: Media source opened"),r&&(r.removeEventListener("emptied",t._onMediaEmptied),t.updateMediaElementDuration(),t.hls.trigger(E.MEDIA_ATTACHED,{media:r})),i&&i.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){x.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){x.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var r=t.media,i=t._objectUrl;r&&r.src!==i&&x.error("Media element src was set while attaching MediaSource ("+i+" > "+r.src+")")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var n=s.prototype;return n.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},n.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},n.registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.BUFFER_EOS,this.onBufferEos,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.FRAG_PARSED,this.onFragParsed,this),e.on(E.FRAG_CHANGED,this.onFragChanged,this)},n.unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_EOS,this.onBufferEos,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.FRAG_PARSED,this.onFragParsed,this),e.off(E.FRAG_CHANGED,this.onFragChanged,this)},n._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new sl(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},n.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},n.onManifestParsed=function(e,t){var r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,x.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},n.onMediaAttaching=function(e,t){var r=this.media=t.media;if(r&&ys){var i=this.mediaSource=new ys;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}},n.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(x.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(i){x.warn("[buffer-controller]: onMediaDetaching: "+i.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):x.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(E.MEDIA_DETACHED,void 0)},n.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){var r=e.sourceBuffer[t];try{r&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(r),e.sourceBuffer[t]=void 0)}catch(i){x.warn("[buffer-controller]: Failed to reset the "+t+" buffer",i)}}),this._initSourceBuffer()},n.onBufferCodecs=function(e,t){var r=this,i=this.getSourceBufferTypes().length;Object.keys(t).forEach(function(a){if(i){var o=r.tracks[a];if(o&&typeof o.buffer.changeType=="function"){var l=t[a],d=l.id,u=l.codec,c=l.levelCodec,f=l.container,v=l.metadata,p=(o.levelCodec||o.codec).replace(Ts,"$1"),T=(c||u).replace(Ts,"$1");if(p!==T){var S=f+";codecs="+(c||u);r.appendChangeType(a,S),x.log("[buffer-controller]: switching codec "+p+" to "+T),r.tracks[a]={buffer:o.buffer,codec:u,container:f,levelCodec:c,metadata:v,id:d}}}}else r.pendingTracks[a]=t[a]}),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},n.appendChangeType=function(e,t){var r=this,i=this.operationQueue,a={execute:function(){var o=r.sourceBuffer[e];o&&(x.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),o.changeType(t)),i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(o){x.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",o)}};i.append(a,e)},n.onBufferAppending=function(e,t){var r=this,i=this.hls,a=this.operationQueue,o=this.tracks,l=t.data,d=t.type,u=t.frag,c=t.part,f=t.chunkMeta,v=f.buffering[d],p=self.performance.now();v.start=p;var T=u.stats.buffering,S=c?c.stats.buffering:null;T.start===0&&(T.start=p),S&&S.start===0&&(S.start=p);var y=o.audio,b=!1;d==="audio"&&(y==null?void 0:y.container)==="audio/mpeg"&&(b=!this.lastMpegAudioChunk||f.id===1||this.lastMpegAudioChunk.sn!==f.sn,this.lastMpegAudioChunk=f);var D=u.start,w={execute:function(){if(v.executeStart=self.performance.now(),b){var O=r.sourceBuffer[d];if(O){var N=D-O.timestampOffset;Math.abs(N)>=.1&&(x.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+D+" (delta: "+N+") sn: "+u.sn+")"),O.timestampOffset=D)}}r.appendExecutor(l,d)},onStart:function(){},onComplete:function(){var O=self.performance.now();v.executeEnd=v.end=O,T.first===0&&(T.first=O),S&&S.first===0&&(S.first=O);var N=r.sourceBuffer,G={};for(var W in N)G[W]=re.getBuffered(N[W]);r.appendError=0,r.hls.trigger(E.BUFFER_APPENDED,{type:d,frag:u,part:c,chunkMeta:f,parent:u.type,timeRanges:G})},onError:function(O){x.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",O);var N={type:Q.MEDIA_ERROR,parent:u.type,details:F.BUFFER_APPEND_ERROR,frag:u,part:c,chunkMeta:f,error:O,err:O,fatal:!1};O.code===DOMException.QUOTA_EXCEEDED_ERR?N.details=F.BUFFER_FULL_ERROR:(r.appendError++,N.details=F.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(x.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),N.fatal=!0)),i.trigger(E.ERROR,N)}};a.append(w,d)},n.onBufferFlushing=function(e,t){var r=this,i=this.operationQueue,a=function(o){return{execute:r.removeExecutor.bind(r,o,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(E.BUFFER_FLUSHED,{type:o})},onError:function(l){x.warn("[buffer-controller]: Failed to remove from "+o+" SourceBuffer",l)}}};t.type?i.append(a(t.type),t.type):this.getSourceBufferTypes().forEach(function(o){i.append(a(o),o)})},n.onFragParsed=function(e,t){var r=this,i=t.frag,a=t.part,o=[],l=a?a.elementaryStreams:i.elementaryStreams;l[Nr]?o.push("audiovideo"):(l[Xe]&&o.push("audio"),l[mt]&&o.push("video")),o.length===0&&x.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers(function(){var d=self.performance.now();i.stats.buffering.end=d,a&&(a.stats.buffering.end=d);var u=a?a.stats:i.stats;r.hls.trigger(E.FRAG_BUFFERED,{frag:i,part:a,stats:u,id:i.type})},o)},n.onFragChanged=function(e,t){this.flushBackBuffer()},n.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce(function(i,a){var o=r.sourceBuffer[a];return!o||t.type&&t.type!==a||(o.ending=!0,o.ended||(o.ended=!0,x.log("[buffer-controller]: "+a+" sourceBuffer now EOS"))),i&&!(o&&!o.ended)},!0)&&(x.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){r.getSourceBufferTypes().forEach(function(a){var o=r.sourceBuffer[a];o&&(o.ending=!1)});var i=r.mediaSource;i&&i.readyState==="open"?(x.log("[buffer-controller]: Calling mediaSource.endOfStream()"),i.endOfStream()):i&&x.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+i.readyState)}))},n.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},n.flushBackBuffer=function(){var e=this.hls,t=this.details,r=this.media,i=this.sourceBuffer;if(r&&t!==null){var a=this.getSourceBufferTypes();if(a.length){var o=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(Z(o)&&!(o<0)){var l=r.currentTime,d=t.levelTargetDuration,u=Math.max(o,d),c=Math.floor(l/d)*d-u;a.forEach(function(f){var v=i[f];if(v){var p=re.getBuffered(v);if(p.length>0&&c>p.start(0)){if(e.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(v.ended&&p.end(p.length-1)-l<2*d)return void x.info("[buffer-controller]: Cannot flush "+f+" back buffer while SourceBuffer is in ended state");e.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:f})}}})}}}},n.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var e=this.details,t=this.hls,r=this.media,i=this.mediaSource,a=e.fragments[0].start+e.totalduration,o=r.duration,l=Z(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(x.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(e)):(a>l&&a>o||!Z(o))&&(x.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),i.duration=a)}},n.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){var i=Math.max(0,r[0].start),a=Math.max(i,i+e.totalduration);t.setLiveSeekableRange(i,a)}},n.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!e||i===2){this.createSourceBuffers(r),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length)this.hls.trigger(E.BUFFER_CREATED,{tracks:this.tracks}),a.forEach(function(l){t.executeNext(l)});else{var o=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:o,reason:o.message})}}},n.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(var i in e)if(!t[i]){var a=e[i];if(!a)throw Error("source buffer exists for track "+i+", however track does not");var o=a.levelCodec||a.codec,l=a.container+";codecs="+o;x.log("[buffer-controller]: creating sourceBuffer("+l+")");try{var d=t[i]=r.addSourceBuffer(l),u=i;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.tracks[i]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(c){x.error("[buffer-controller]: error while trying to add sourceBuffer: "+c.message),this.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:c,mimeType:l})}}},n._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},n._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},n._onSBUpdateError=function(e,t){var r=new Error(e+" SourceBuffer error");x.error("[buffer-controller]: "+r,t),this.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_APPENDING_ERROR,error:r,fatal:!1});var i=this.operationQueue.current(e);i&&i.onError(t)},n.removeExecutor=function(e,t,r){var i=this.media,a=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[e];if(!i||!a||!l)return x.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(e);var d=Z(i.duration)?i.duration:1/0,u=Z(a.duration)?a.duration:1/0,c=Math.max(0,t),f=Math.min(r,d,u);f>c&&!l.ending?(l.ended=!1,x.log("[buffer-controller]: Removing ["+c+","+f+"] from the "+e+" SourceBuffer"),l.remove(c,f)):o.shiftAndExecuteNext(e)},n.appendExecutor=function(e,t){var r=this.operationQueue,i=this.sourceBuffer[t];if(!i)return x.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(t);i.ended=!1,i.appendBuffer(e)},n.blockBuffers=function(e,t){var r=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length)return x.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var i=this.operationQueue,a=t.map(function(o){return i.appendBlocker(o)});Promise.all(a).then(function(){e(),t.forEach(function(o){var l=r.sourceBuffer[o];l!=null&&l.updating||i.shiftAndExecuteNext(o)})})},n.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},n.addBufferListener=function(e,t,r){var i=this.sourceBuffer[e];if(i){var a=r.bind(this,e);this.listeners[e].push({event:t,listener:a}),i.addEventListener(t,a)}},n.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(r){t.removeEventListener(r.event,r.listener)})},s}(),Es={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},bs=function(s){var n=s;return Es.hasOwnProperty(s)&&(n=Es[s]),String.fromCharCode(n)},xr=15,rr=100,ll={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},ul={17:2,18:4,21:6,22:8,23:10,19:13,20:15},dl={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},cl={25:2,26:4,29:6,30:8,31:10,27:13,28:15},hl=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],fl=function(){function s(){this.time=null,this.verboseLevel=0}return s.prototype.log=function(n,e){if(this.verboseLevel>=n){var t=typeof e=="function"?e():e;x.log(this.time+" ["+n+"] "+t)}},s}(),Pr=function(s){for(var n=[],e=0;e<s.length;e++)n.push(s[e].toString(16));return n},_s=function(){function s(e,t,r,i,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=a||!1}var n=s.prototype;return n.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},n.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}},n.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},n.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},n.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},n.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},s}(),vl=function(){function s(e,t,r,i,a,o){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new _s(t,r,i,a,o)}var n=s.prototype;return n.reset=function(){this.uchar=" ",this.penState.reset()},n.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},n.setPenState=function(e){this.penState.copy(e)},n.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},n.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},n.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},s}(),gl=function(){function s(e){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<rr;t++)this.chars.push(new vl);this.logger=e,this.pos=0,this.currPenState=new _s}var n=s.prototype;return n.equals=function(e){for(var t=!0,r=0;r<rr;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<rr;t++)this.chars[t].copy(e.chars[t])},n.isEmpty=function(){for(var e=!0,t=0;t<rr;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},n.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>rr&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=rr)},n.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)},n.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},n.insertChar=function(e){var t=this;e>=144&&this.backSpace();var r=bs(e);this.pos>=rr?this.logger.log(0,function(){return"Cannot insert "+e.toString(16)+" ("+r+") at position "+t.pos+". Skipping it!"}):(this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1))},n.clearFromPos=function(e){var t;for(t=e;t<rr;t++)this.chars[t].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 e=[],t=!0,r=0;r<rr;r++){var i=this.chars[r].uchar;i!==" "&&(t=!1),e.push(i)}return t?"":e.join("")},n.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},s}(),ya=function(){function s(e){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<xr;t++)this.rows.push(new gl(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var n=s.prototype;return n.reset=function(){for(var e=0;e<xr;e++)this.rows[e].clear();this.currRow=14},n.equals=function(e){for(var t=!0,r=0;r<xr;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<xr;t++)this.rows[t].copy(e.rows[t])},n.isEmpty=function(){for(var e=!0,t=0;t<xr;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},n.backSpace=function(){this.rows[this.currRow].backSpace()},n.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},n.insertChar=function(e){this.rows[this.currRow].insertChar(e)},n.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},n.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},n.setCursor=function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},n.setPAC=function(e){this.logger.log(2,function(){return"pacData = "+JSON.stringify(e)});var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<xr;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var o=a.rows[i].cueStartTime,l=this.logger.time;if(o&&l!==null&&o<l)for(var d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[i+d])}}this.currRow=t;var u=this.rows[this.currRow];if(e.indent!==null){var c=e.indent,f=Math.max(c-1,0);u.setCursor(e.indent),e.color=u.chars[f].penState.foreground}var v={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(v)},n.setBkgData=function(e){this.logger.log(2,function(){return"bkgData = "+JSON.stringify(e)}),this.backSpace(),this.setPen(e),this.insertChar(32)},n.setRollUpRows=function(e){this.nrRollUpRows=e},n.rollUp=function(){var e=this;if(this.nrRollUpRows!==null){this.logger.log(1,function(){return e.getDisplayText()});var t=this.currRow+1-this.nrRollUpRows,r=this.rows.splice(t,1)[0];r.clear(),this.rows.splice(this.currRow,0,r),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")},n.getDisplayText=function(e){e=e||!1;for(var t=[],r="",i=-1,a=0;a<xr;a++){var o=this.rows[a].getTextString();o&&(i=a+1,e?t.push("Row "+i+": '"+o+"'"):t.push(o.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join(`
|
|
34
|
-
`)),r},n.getTextAndFormat=function(){return this.rows},s}(),Ss=function(){function s(e,t,r){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=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new ya(r),this.nonDisplayedMemory=new ya(r),this.lastOutputScreen=new ya(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var n=s.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[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},n.getHandler=function(){return this.outputFilter},n.setHandler=function(e){this.outputFilter=e},n.setPAC=function(e){this.writeScreen.setPAC(e)},n.setBkgData=function(e){this.writeScreen.setBkgData(e)},n.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,function(){return"MODE="+e}),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=e)},n.insertChars=function(e){for(var t=this,r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,function(){return i+": "+t.writeScreen.getDisplayText(!0)}),this.mode!=="MODE_PAINT-ON"&&this.mode!=="MODE_ROLL-UP"||(this.logger.log(1,function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},n.ccRCL=function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},n.ccBS=function(){this.logger.log(2,"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(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},n.ccRU=function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},n.ccFON=function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},n.ccRDC=function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},n.ccTR=function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")},n.ccRTD=function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")},n.ccEDM=function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},n.ccCR=function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},n.ccENM=function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},n.ccEOC=function(){var e=this;if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,function(){return"DISP: "+e.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},n.ccTO=function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},n.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},n.outputDataUpdate=function(e){e===void 0&&(e=!1);var t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime!==null||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},n.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},s}(),As=function(){function s(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new fl;this.channels=[null,new Ss(e,t,i),new Ss(e+1,r,i)],this.cmdHistory={a:null,b:null},this.logger=i}var n=s.prototype;return n.getHandler=function(e){return this.channels[e].getHandler()},n.setHandler=function(e,t){this.channels[e].setHandler(t)},n.addData=function(e,t){var r,i,a,o=!1;this.logger.time=e;for(var l=0;l<t.length;l+=2)if(i=127&t[l],a=127&t[l+1],i!==0||a!==0){if(this.logger.log(3,"["+Pr([t[l],t[l+1]])+"] -> ("+Pr([i,a])+")"),(r=this.parseCmd(i,a))||(r=this.parseMidrow(i,a)),r||(r=this.parsePAC(i,a)),r||(r=this.parseBackgroundAttributes(i,a)),!r&&(o=this.parseChars(i,a))){var d=this.currentChannel;d&&d>0?this.channels[d].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}r||o||this.logger.log(2,"Couldn't parse cleaned data "+Pr([i,a])+" orig: "+Pr([t[l],t[l+1]]))}},n.parseCmd=function(e,t){var r=this.cmdHistory;if(!((e===20||e===28||e===21||e===29)&&t>=32&&t<=47||(e===23||e===31)&&t>=33&&t<=35))return!1;if(ks(e,t,r))return Zr(null,null,r),this.logger.log(3,"Repeated command ("+Pr([e,t])+") is dropped"),!0;var i=e===20||e===21||e===23?1:2,a=this.channels[i];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),Zr(e,t,r),this.currentChannel=i,!0},n.parseMidrow=function(e,t){var r=0;if((e===17||e===25)&&t>=32&&t<=47){if((r=e===17?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,"MIDROW ("+Pr([e,t])+")"),!0)}return!1},n.parsePAC=function(e,t){var r,i=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(e===16||e===24)&&t>=64&&t<=95))return!1;if(ks(e,t,i))return Zr(null,null,i),!0;var a=e<=23?1:2;r=t>=64&&t<=95?a===1?ll[e]:dl[e]:a===1?ul[e]:cl[e];var o=this.channels[a];return!!o&&(o.setPAC(this.interpretPAC(r,t)),Zr(e,t,i),this.currentChannel=a,!0)},n.interpretPAC=function(e,t){var r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=(1&r)==1,r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},n.parseChars=function(e,t){var r,i,a=null,o=null;if(e>=25?(r=2,o=e-8):(r=1,o=e),o>=17&&o<=19?(i=o===17?t+80:o===18?t+112:t+144,this.logger.log(2,"Special char '"+bs(i)+"' in channel "+r),a=[i]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var l=Pr(a);this.logger.log(3,"Char codes = "+l.join(",")),Zr(e,t,this.cmdHistory)}return a},n.parseBackgroundAttributes=function(e,t){var r;if(!((e===16||e===24)&&t>=32&&t<=47||(e===23||e===31)&&t>=45&&t<=47))return!1;var i={};e===16||e===24?(r=Math.floor((t-32)/2),i.background=hl[r],t%2==1&&(i.background=i.background+"_semi")):t===45?i.background="transparent":(i.foreground="black",t===47&&(i.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(i),Zr(e,t,this.cmdHistory),!0},n.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}},n.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}},s}();function Zr(s,n,e){e.a=s,e.b=n}function ks(s,n,e){return e.a===s&&e.b===n}var Cn=function(){function s(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}var n=s.prototype;return n.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},n.newCue=function(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},n.reset=function(){this.cueRanges=[],this.startTime=null},s}(),Ta=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var s=["","lr","rl"],n=["start","middle","end","left","right"];function e(a,o){if(typeof o!="string"||!Array.isArray(a))return!1;var l=o.toLowerCase();return!!~a.indexOf(l)&&l}function t(a){return e(n,a)}function r(a){for(var o=arguments.length,l=new Array(o>1?o-1:0),d=1;d<o;d++)l[d-1]=arguments[d];for(var u=1;u<arguments.length;u++){var c=arguments[u];for(var f in c)a[f]=c[f]}return a}function i(a,o,l){var d=this,u={enumerable:!0};d.hasBeenReset=!1;var c="",f=!1,v=a,p=o,T=l,S=null,y="",b=!0,D="auto",w="start",O=50,N="middle",G=50,W="middle";Object.defineProperty(d,"id",r({},u,{get:function(){return c},set:function(q){c=""+q}})),Object.defineProperty(d,"pauseOnExit",r({},u,{get:function(){return f},set:function(q){f=!!q}})),Object.defineProperty(d,"startTime",r({},u,{get:function(){return v},set:function(q){if(typeof q!="number")throw new TypeError("Start time must be set to a number.");v=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"endTime",r({},u,{get:function(){return p},set:function(q){if(typeof q!="number")throw new TypeError("End time must be set to a number.");p=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"text",r({},u,{get:function(){return T},set:function(q){T=""+q,this.hasBeenReset=!0}})),Object.defineProperty(d,"region",r({},u,{get:function(){return S},set:function(q){S=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"vertical",r({},u,{get:function(){return y},set:function(q){var V=function(te){return e(s,te)}(q);if(V===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=V,this.hasBeenReset=!0}})),Object.defineProperty(d,"snapToLines",r({},u,{get:function(){return b},set:function(q){b=!!q,this.hasBeenReset=!0}})),Object.defineProperty(d,"line",r({},u,{get:function(){return D},set:function(q){if(typeof q!="number"&&q!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");D=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"lineAlign",r({},u,{get:function(){return w},set:function(q){var V=t(q);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");w=V,this.hasBeenReset=!0}})),Object.defineProperty(d,"position",r({},u,{get:function(){return O},set:function(q){if(q<0||q>100)throw new Error("Position must be between 0 and 100.");O=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"positionAlign",r({},u,{get:function(){return N},set:function(q){var V=t(q);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");N=V,this.hasBeenReset=!0}})),Object.defineProperty(d,"size",r({},u,{get:function(){return G},set:function(q){if(q<0||q>100)throw new Error("Size must be between 0 and 100.");G=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"align",r({},u,{get:function(){return W},set:function(q){var V=t(q);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");W=V,this.hasBeenReset=!0}})),d.displayState=void 0}return i.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},i}(),ml=function(){function s(){}return s.prototype.decode=function(n,e){if(!n)return"";if(typeof n!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(n))},s}();function Ls(s){function n(t,r,i,a){return 3600*(0|t)+60*(0|r)+(0|i)+parseFloat(a||0)}var e=s.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?n(e[2],e[3],0,e[4]):n(e[1],e[2],e[3],e[4]):null}var pl=function(){function s(){this.values=Object.create(null)}var n=s.prototype;return n.set=function(e,t){this.get(e)||t===""||(this.values[e]=t)},n.get=function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},n.has=function(e){return e in this.values},n.alt=function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}},n.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},n.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1},s}();function ws(s,n,e,t){var r=t?s.split(t):[s];for(var i in r)if(typeof r[i]=="string"){var a=r[i].split(e);a.length===2&&n(a[0],a[1])}}var Ea=new Ta(0,0,""),xn=Ea.align==="middle"?"middle":"center";function yl(s,n,e){var t=s;function r(){var a=Ls(s);if(a===null)throw new Error("Malformed timestamp: "+t);return s=s.replace(/^[^\sa-zA-Z-]+/,""),a}function i(){s=s.replace(/^\s+/,"")}if(i(),n.startTime=r(),i(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+t);s=s.slice(3),i(),n.endTime=r(),i(),function(a,o){var l=new pl;ws(a,function(c,f){var v;switch(c){case"region":for(var p=e.length-1;p>=0;p--)if(e[p].id===f){l.set(c,e[p].region);break}break;case"vertical":l.alt(c,f,["rl","lr"]);break;case"line":v=f.split(","),l.integer(c,v[0]),l.percent(c,v[0])&&l.set("snapToLines",!1),l.alt(c,v[0],["auto"]),v.length===2&&l.alt("lineAlign",v[1],["start",xn,"end"]);break;case"position":v=f.split(","),l.percent(c,v[0]),v.length===2&&l.alt("positionAlign",v[1],["start",xn,"end","line-left","line-right","auto"]);break;case"size":l.percent(c,f);break;case"align":l.alt(c,f,["start",xn,"end","left","right"])}},/:/,/\s/),o.region=l.get("region",null),o.vertical=l.get("vertical","");var d=l.get("line","auto");d==="auto"&&Ea.line===-1&&(d=-1),o.line=d,o.lineAlign=l.get("lineAlign","start"),o.snapToLines=l.get("snapToLines",!0),o.size=l.get("size",100),o.align=l.get("align",xn);var u=l.get("position","auto");u==="auto"&&Ea.position===50&&(u=o.align==="start"||o.align==="left"?0:o.align==="end"||o.align==="right"?100:50),o.position=u}(s,n)}function Rs(s){return s.replace(/<br(?: \/)?>/gi,`
|
|
35
|
-
`)}var
|
|
36
|
-
`;)++
|
|
37
|
-
`&&++
|
|
33
|
+
Aborting and switching to level `+q),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),r.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:l}))}}}}}}},n.onFragLoaded=function(e,t){var r=t.frag,i=t.part,a=i?i.stats:r.stats;if(r.type===Ne&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var o=i?i.duration:r.duration,l=this.hls.levels[r.level],u=(l.loaded?l.loaded.bytes:0)+a.loaded,d=(l.loaded?l.loaded.duration:0)+o;l.loaded={bytes:u,duration:d},l.realBitrate=Math.round(8*u/d)}if(r.bitrateTest){var h={stats:a,frag:r,part:i,id:r.type};this.onFragBuffered(E.FRAG_BUFFERED,h),r.bitrateTest=!1}}},n.onFragBuffered=function(e,t){var r=t.frag,i=t.part,a=i!=null&&i.stats.loaded?i.stats:r.stats;if(!a.aborted&&!this.ignoreFragment(r)){var o=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,a.loaded),a.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}},n.ignoreFragment=function(e){return e.type!==Ne||e.sn==="initSegment"},n.clearTimer=function(){self.clearInterval(this.timer)},n.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.maxAutoLevel,a=r.config,o=r.minAutoLevel,l=r.media,u=t?t.duration:e?e.duration:0,d=l&&l.playbackRate!==0?Math.abs(l.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,f=r.mainForwardBufferInfo,v=(f?f.len:0)/d,p=this.findBestLevel(h,o,i,v,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(p>=0)return p;x.trace("[abr] "+(v?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var T=u?Math.min(u,a.maxStarvationDelay):a.maxStarvationDelay,S=a.abrBandWidthFactor,y=a.abrBandWidthUpFactor;if(!v){var b=this.bitrateTestDelay;b&&(T=(u?Math.min(u,a.maxLoadingDelay):a.maxLoadingDelay)-b,x.trace("[abr] bitrate test took "+Math.round(1e3*b)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*T)+" ms"),S=y=1)}return p=this.findBestLevel(h,o,i,v+T,S,y),Math.max(p,0)},n.findBestLevel=function(e,t,r,i,a,o){for(var l,u=this.fragCurrent,d=this.partCurrent,h=this.lastLoadedFragLevel,f=this.hls.levels,v=f[h],p=!(v==null||(l=v.details)==null||!l.live),T=v==null?void 0:v.codecSet,S=d?d.duration:u?u.duration:0,y=this.bwEstimator.getEstimateTTFB()/1e3,b=t,C=-1,D=r;D>=t;D--){var O=f[D];if(!O||T&&O.codecSet!==T)O&&(b=Math.min(D,b),C=Math.max(D,C));else{C!==-1&&x.trace("[abr] Skipped level(s) "+b+"-"+C+' with CODECS:"'+f[C].attrs.CODECS+'"; not compatible with "'+v.attrs.CODECS+'"');var N=O.details,G=(d?N==null?void 0:N.partTarget:N==null?void 0:N.averagetargetduration)||S,W=void 0;W=D<=h?a*e:o*e;var q=f[D].maxBitrate,V=this.getTimeToLoadFrag(y,W,q*G,N===void 0);if(x.trace("[abr] level:"+D+" adjustedbw-bitrate:"+Math.round(W-q)+" avgDuration:"+G.toFixed(1)+" maxFetchDuration:"+i.toFixed(1)+" fetchDuration:"+V.toFixed(1)),W>q&&(V===0||!Z(V)||p&&!this.bitrateTestDelay||V<i))return D}}return-1},K(s,[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this.bwEstimator;if(e!==-1&&!t.canEstimate())return e;var r=this.getNextABRAutoLevel();if(e!==-1){var i=this.hls.levels;if(i.length>Math.max(e,r)&&i[e].loadError<=i[r].loadError)return e}return e!==-1&&(r=Math.min(e,r)),r},set:function(e){this._nextAutoLevel=e}}]),s}(),ps=function(){function s(){this.chunks=[],this.dataLength=0}var n=s.prototype;return n.push=function(e){this.chunks.push(e),this.dataLength+=e.length},n.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=t.length===1?t[0]:function(i,a){for(var o=new Uint8Array(a),l=0,u=0;u<i.length;u++){var d=i[u];o.set(d,l),l+=d.length}return o}(t,r),this.reset(),e):new Uint8Array(0)},n.reset=function(){this.chunks.length=0,this.dataLength=0},s}(),rl=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[audio-stream-controller]",kt)||this).videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.bufferedTrack=null,a.switchingTrack=null,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a.cachedTrackLoadedData=null,a._registerListeners(),a}ae(n,s);var e=n.prototype;return e.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null},e._registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(E.ERROR,this.onError,this),t.on(E.BUFFER_RESET,this.onBufferReset,this),t.on(E.BUFFER_CREATED,this.onBufferCreated,this),t.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(E.ERROR,this.onError,this),t.off(E.BUFFER_RESET,this.onBufferReset,this),t.off(E.BUFFER_CREATED,this.onBufferCreated,this),t.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},e.onInitPtsFound=function(t,r){var i=r.frag,a=r.id,o=r.initPTS,l=r.timescale;if(a==="main"){var u=i.cc;this.initPTS[i.cc]={baseTime:o,timescale:l},this.log("InitPTS for cc: "+u+" found from main: "+o),this.videoTrackCC=u,this.state===Pi&&this.tick()}},e.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=rt);var r=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),r>0&&t===-1?(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r,this.state=he):(this.loadedmetadata=!1,this.state=Ir),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.doTick=function(){switch(this.state){case he:this.doTickIdle();break;case Ir:var t,r=this.levels,i=this.trackId,a=r==null||(t=r[i])==null?void 0:t.details;if(a){if(this.waitForCdnTuneIn(a))break;this.state=Pi}break;case hr:var o,l=performance.now(),u=this.retryDate;(!u||l>=u||(o=this.media)!=null&&o.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=he);break;case Pi:var d=this.waitingData;if(d){var h=d.frag,f=d.part,v=d.cache,p=d.complete;if(this.initPTS[h.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=dr;var T={frag:h,part:f,payload:v.flush(),networkDetails:null};this._handleFragmentLoadProgress(T),p&&s.prototype._handleFragmentLoadComplete.call(this,T)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+h.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var S=this.getLoadPosition(),y=re.bufferInfo(this.mediaBuffer,S,this.config.maxBufferHole);zr(y.end,this.config.maxFragLookUpTolerance,h)<0&&(this.log("Waiting fragment cc ("+h.cc+") @ "+h.start+" cancelled because another fragment at "+y.end+" is needed"),this.clearWaitingFragment())}}else this.state=he}this.onTickEnd()},e.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=he)},e.resetLoadingState=function(){this.clearWaitingFragment(),s.prototype.resetLoadingState.call(this)},e.onTickEnd=function(){var t=this.media;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)},e.doTickIdle=function(){var t=this.hls,r=this.levels,i=this.media,a=this.trackId,o=t.config;if(r!=null&&r[a]&&(i||!this.startFragRequested&&o.startFragPrefetch)){var l=r[a],u=l.details;if(!u||u.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(u))this.state=Ir;else{var d=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&d&&(this.bufferFlushed=!1,this.afterBufferFlushed(d,Xe,kt));var h=this.getFwdBufferInfo(d,kt);if(h!==null){var f=this.bufferedTrack,v=this.switchingTrack;if(!v&&this._streamEnded(h,u))return t.trigger(E.BUFFER_EOS,{type:"audio"}),void(this.state=xi);var p=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Ne),T=h.len,S=this.getMaxBufferLength(p==null?void 0:p.len);if(!(T>=S)||v){var y=u.fragments[0].start,b=h.end;if(v&&i){var C=this.getLoadPosition();f&&v.attrs!==f.attrs&&(b=C),u.PTSKnown&&C<y&&(h.end>y||h.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=y+.05)}var D=this.getNextFragment(b,u),O=!1;if(D&&this.isLoopLoading(D,b)&&(O=!!D.gap,D=this.getNextFragmentLoopLoading(D,u,h,Ne,S)),D){var N=p&&D.start>p.end+u.targetduration;if(N||(p==null||!p.len)&&h.len){var G=this.getAppendedFrag(D.start,Ne);if(G===null||(O||(O=!!G.gap||!!N&&p.len===0),N&&!O||O&&h.nextStart&&h.nextStart<G.end))return}this.loadFragment(D,l,b)}else this.bufferFlushed=!0}}}}},e.getMaxBufferLength=function(t){var r=s.prototype.getMaxBufferLength.call(this);return t?Math.min(Math.max(r,t),this.config.maxMaxBufferLength):r},e.onMediaDetaching=function(){this.videoBuffer=null,s.prototype.onMediaDetaching.call(this)},e.onAudioTracksUpdated=function(t,r){var i=r.audioTracks;this.resetTransmuxer(),this.levels=i.map(function(a){return new Lr(a)})},e.onAudioTrackSwitching=function(t,r){var i=!!r.url;this.trackId=r.id;var a=this.fragCurrent;a&&(a.abortRequests(),this.removeUnbufferedFrags(a.start)),this.resetLoadingState(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.switchingTrack=r,this.state=he):(this.switchingTrack=null,this.bufferedTrack=r,this.state=rt),this.tick()},e.onManifestLoading=function(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1},e.onLevelLoaded=function(t,r){this.mainDetails=r.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(E.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},e.onAudioTrackLoaded=function(t,r){var i;if(this.mainDetails!=null){var a=this.levels,o=r.details,l=r.id;if(a){this.log("Track "+l+" loaded ["+o.startSN+","+o.endSN+"]"+(o.lastPartSn?"[part-"+o.lastPartSn+"-"+o.lastPartIndex+"]":"")+",duration:"+o.totalduration);var u=a[l],d=0;if(o.live||(i=u.details)!=null&&i.live){var h=this.mainDetails;if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed||!h)return;!u.details&&o.hasProgramDateTime&&h.hasProgramDateTime?(Ze(o,h),d=o.fragments[0].start):d=this.alignPlaylists(o,u.details)}u.details=o,this.levelLastLoaded=l,this.startFragRequested||!this.mainDetails&&o.live||this.setStartPosition(u.details,d),this.state!==Ir||this.waitForCdnTuneIn(o)||(this.state=he),this.tick()}else this.warn("Audio tracks were reset while loading level "+l)}else this.cachedTrackLoadedData=r},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.config,u=this.trackId,d=this.levels;if(d){var h=d[u];if(h){var f=h.details;if(!f)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);var v=l.defaultAudioCodec||h.audioCodec||"mp4a.40.2",p=this.transmuxer;p||(p=this.transmuxer=new ms(this.hls,kt,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var T=this.initPTS[i.cc],S=(r=i.initSegment)==null?void 0:r.data;if(T!==void 0){var y=a?a.index:-1,b=y!==-1,C=new ie(i.level,i.sn,i.stats.chunkCount,o.byteLength,y,b);p.push(o,S,v,"",i,a,f.totalduration,!1,C,T)}else this.log("Unknown video PTS for cc "+i.cc+", waiting for video PTS before demuxing audio frag "+i.sn+" of ["+f.startSN+" ,"+f.endSN+"],track "+u),(this.waitingData=this.waitingData||{frag:i,part:a,cache:new ps,complete:!1}).cache.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=Pi}else this.warn("Audio track is undefined on fragment load progress")}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},e._handleFragmentLoadComplete=function(t){this.waitingData?this.waitingData.complete=!0:s.prototype._handleFragmentLoadComplete.call(this,t)},e.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},e.onBufferCreated=function(t,r){var i=r.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),r.tracks.video&&(this.videoBuffer=r.tracks.video.buffer||null)},e.onFragBuffered=function(t,r){var i=r.frag,a=r.part;if(i.type===kt)if(this.fragContextChanged(i))this.warn("Fragment "+i.sn+(a?" p: "+a.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+(this.switchingTrack?this.switchingTrack.name:"false"));else{if(i.sn!=="initSegment"){this.fragPrevious=i;var o=this.switchingTrack;o&&(this.bufferedTrack=o,this.switchingTrack=null,this.hls.trigger(E.AUDIO_TRACK_SWITCHED,H({},o)))}this.fragBufferedComplete(i,a)}else if(!this.loadedmetadata&&i.type===Ne){var l=this.videoBuffer||this.media;l&&re.getBuffered(l).length&&(this.loadedmetadata=!0)}},e.onError=function(t,r){var i;if(r.fatal)this.state=Xr;else switch(r.details){case F.FRAG_GAP:case F.FRAG_PARSING_ERROR:case F.FRAG_DECRYPT_ERROR:case F.FRAG_LOAD_ERROR:case F.FRAG_LOAD_TIMEOUT:case F.KEY_LOAD_ERROR:case F.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(kt,r);break;case F.AUDIO_TRACK_LOAD_ERROR:case F.AUDIO_TRACK_LOAD_TIMEOUT:case F.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==Ir||((i=r.context)==null?void 0:i.type)!==yt||(this.state=he);break;case F.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="audio")return;this.reduceLengthAndFlushBuffer(r)&&(this.bufferedTrack=null,s.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case F.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.onBufferFlushed=function(t,r){r.type===Xe&&(this.bufferFlushed=!0,this.state===xi&&(this.state=he))},e._handleTransmuxComplete=function(t){var r,i="audio",a=this.hls,o=t.remuxResult,l=t.chunkMeta,u=this.getCurrentContext(l);if(u){var d=u.frag,h=u.part,f=u.level.details,v=o.audio,p=o.text,T=o.id3,S=o.initSegment;if(!this.fragContextChanged(d)&&f){if(this.state=tr,this.switchingTrack&&v&&this.completeAudioSwitch(this.switchingTrack),S!=null&&S.tracks){var y=d.initSegment||d;this._bufferInitSegment(S.tracks,y,l),a.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:i,tracks:S.tracks})}if(v){var b=v.startPTS,C=v.endPTS,D=v.startDTS,O=v.endDTS;h&&(h.elementaryStreams[Xe]={startPTS:b,endPTS:C,startDTS:D,endDTS:O}),d.setElementaryStreamInfo(Xe,b,C,D,O),this.bufferFragmentData(v,d,h,l)}if(T!=null&&(r=T.samples)!=null&&r.length){var N=X({id:i,frag:d,details:f},T);a.trigger(E.FRAG_PARSING_METADATA,N)}if(p){var G=X({id:i,frag:d,details:f},p);a.trigger(E.FRAG_PARSING_USERDATA,G)}}else this.fragmentTracker.removeFragment(d)}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i){if(this.state===tr){t.video&&delete t.video;var a=t.audio;if(a){a.levelCodec=a.codec,a.id="audio",this.log("Init audio buffer, container:"+a.container+", codecs[parsed]=["+a.codec+"]"),this.hls.trigger(E.BUFFER_CODECS,t);var o=a.initSegment;if(o!=null&&o.byteLength){var l={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:o};this.hls.trigger(E.BUFFER_APPENDING,l)}this.tick()}}},e.loadFragment=function(t,r,i){var a,o=this.fragmentTracker.getState(t);this.fragCurrent=t,this.switchingTrack||o===Y||o===se?t.sn==="initSegment"?this._loadInitSegment(t,r):(a=r.details)!=null&&a.live&&!this.initPTS[t.cc]?(this.log("Waiting for video PTS in continuity counter "+t.cc+" of live stream before loading audio fragment "+t.sn+" of level "+this.trackId),this.state=Pi):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,i)):this.clearTrackerIfNeeded(t)},e.completeAudioSwitch=function(t){var r=this.hls,i=this.media,a=this.bufferedTrack,o=a==null?void 0:a.attrs,l=t.attrs;i&&o&&(o.CHANNELS!==l.CHANNELS||o.NAME!==l.NAME||o.LANGUAGE!==l.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),s.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,r.trigger(E.AUDIO_TRACK_SWITCHED,H({},t))},n}(na),il=function(s){function n(t){var r;return(r=s.call(this,t,"[audio-track-controller]")||this).tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.currentTrack=null,r.selectDefaultTrack=!0,r.registerListeners(),r}ae(n,s);var e=n.prototype;return e.registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(E.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVEL_LOADING,this.onLevelLoading,this),t.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(E.ERROR,this.onError,this)},e.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,s.prototype.destroy.call(this)},e.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0},e.onManifestParsed=function(t,r){this.tracks=r.audioTracks||[]},e.onAudioTrackLoaded=function(t,r){var i=r.id,a=r.groupId,o=r.details,l=this.tracksInGroup[i];if(l&&l.groupId===a){var u=l.details;l.details=r.details,this.log("audio-track "+i+' "'+l.name+'" lang:'+l.lang+" group:"+a+" loaded ["+o.startSN+"-"+o.endSN+"]"),i===this.trackId&&this.playlistLoaded(i,r,u)}else this.warn("Track with id:"+i+" and group:"+a+" not found in active group "+l.groupId)},e.onLevelLoading=function(t,r){this.switchLevel(r.level)},e.onLevelSwitching=function(t,r){this.switchLevel(r.level)},e.switchLevel=function(t){var r=this.hls.levels[t];if(r!=null&&r.audioGroupIds){var i=r.audioGroupIds[r.urlId];if(this.groupId!==i){this.groupId=i||null;var a=this.tracks.filter(function(l){return!i||l.groupId===i});this.selectDefaultTrack&&!a.some(function(l){return l.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=a;var o={audioTracks:a};this.log("Updating audio tracks, "+a.length+" track(s) found in group:"+i),this.hls.trigger(E.AUDIO_TRACKS_UPDATED,o),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===yt&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(r))},e.setAudioTrack=function(t){var r=this.tracksInGroup;if(t<0||t>=r.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var i=this.currentTrack;r[this.trackId];var a=r[t],o=a.groupId,l=a.name;if(this.log("Switching to audio-track "+t+' "'+l+'" lang:'+a.lang+" group:"+o),this.trackId=t,this.currentTrack=a,this.selectDefaultTrack=!1,this.hls.trigger(E.AUDIO_TRACK_SWITCHING,H({},a)),!a.details||a.details.live){var u=this.switchParams(a.url,i==null?void 0:i.details);this.loadPlaylist(u)}}},e.selectInitialTrack=function(){var t=this.tracksInGroup,r=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(r!==-1)this.setAudioTrack(r);else{var i=new Error("No track found for running audio group-ID: "+this.groupId+" track count: "+t.length);this.warn(i.message),this.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}},e.findTrackId=function(t){for(var r=this.tracksInGroup,i=0;i<r.length;i++){var a=r[i];if((!this.selectDefaultTrack||a.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===a.attrs["STABLE-RENDITION-ID"]||t.name===a.name&&t.lang===a.lang))return a.id}return-1},e.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,a=r.groupId,o=r.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("loading audio-track playlist "+i+' "'+r.name+'" lang:'+r.lang+" group:"+a),this.clearTimer(),this.hls.trigger(E.AUDIO_TRACK_LOADING,{url:o,id:i,groupId:a,deliveryDirectives:t||null})}},K(n,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}}]),n}(k);function ys(s,n){if(s.length!==n.length)return!1;for(var e=0;e<s.length;e++)if(!nl(s[e].attrs,n[e].attrs))return!1;return!0}function nl(s,n){var e=s["STABLE-RENDITION-ID"];return e?e===n["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(function(t){return s[t]!==n[t]})}var al=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[subtitle-stream-controller]",It)||this).levels=[],a.currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a._registerListeners(),a}ae(n,s);var e=n.prototype;return e.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},e._registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.ERROR,this.onError,this),t.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.ERROR,this.onError,this),t.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},e.startLoad=function(t){this.stopLoad(),this.state=he,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},e.onMediaDetaching=function(){this.tracksBuffered=[],s.prototype.onMediaDetaching.call(this)},e.onLevelLoaded=function(t,r){this.mainDetails=r.details},e.onSubtitleFragProcessed=function(t,r){var i=r.frag,a=r.success;if(this.fragPrevious=i,this.state=he,a){var o=this.tracksBuffered[this.currentTrackId];if(o){for(var l,u=i.start,d=0;d<o.length;d++)if(u>=o[d].start&&u<=o[d].end){l=o[d];break}var h=i.start+i.duration;l?l.end=h:(l={start:u,end:h},o.push(l)),this.fragmentTracker.fragBuffered(i)}}},e.onBufferFlushing=function(t,r){var i=r.startOffset,a=r.endOffset;if(i===0&&a!==Number.POSITIVE_INFINITY){var o=this.currentTrackId,l=this.levels;if(!l.length||!l[o]||!l[o].details)return;var u=a-l[o].details.targetduration;if(u<=0)return;r.endOffsetSubtitles=Math.max(0,u),this.tracksBuffered.forEach(function(d){for(var h=0;h<d.length;)if(d[h].end<=u)d.shift();else{if(!(d[h].start<u))break;d[h].start=u,h++}}),this.fragmentTracker.removeFragmentsInRange(i,u,It)}},e.onFragBuffered=function(t,r){var i;this.loadedmetadata||r.frag.type!==Ne||(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)},e.onError=function(t,r){var i=r.frag;(i==null?void 0:i.type)===It&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==rt&&(this.state=he))},e.onSubtitleTracksUpdated=function(t,r){var i=this,a=r.subtitleTracks;ys(this.levels,a)?this.levels=a.map(function(o){return new Lr(o)}):(this.tracksBuffered=[],this.levels=a.map(function(o){var l=new Lr(o);return i.tracksBuffered[l.id]=[],l}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,It),this.fragPrevious=null,this.mediaBuffer=null)},e.onSubtitleTrackSwitch=function(t,r){if(this.currentTrackId=r.id,this.levels.length&&this.currentTrackId!==-1){var i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(500)}else this.clearInterval()},e.onSubtitleTrackLoaded=function(t,r){var i,a=r.details,o=r.id,l=this.currentTrackId,u=this.levels;if(u.length){var d=u[l];if(!(o>=u.length||o!==l)&&d){this.mediaBuffer=this.mediaBufferTimeRanges;var h=0;if(a.live||(i=d.details)!=null&&i.live){var f=this.mainDetails;if(a.deltaUpdateFailed||!f)return;var v=f.fragments[0];d.details?(h=this.alignPlaylists(a,d.details))===0&&v&&wr(a,h=v.start):a.hasProgramDateTime&&f.hasProgramDateTime?(Ze(a,f),h=a.fragments[0].start):v&&wr(a,h=v.start)}d.details=a,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(d.details,h),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===he&&(Rr(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),d.details=void 0))}}},e._handleFragmentLoadComplete=function(t){var r=this,i=t.frag,a=t.payload,o=i.decryptdata,l=this.hls;if(!this.fragContextChanged(i)&&a&&a.byteLength>0&&o&&o.key&&o.iv&&o.method==="AES-128"){var u=performance.now();this.decrypter.decrypt(new Uint8Array(a),o.key.buffer,o.iv.buffer).catch(function(d){throw l.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:i}),d}).then(function(d){var h=performance.now();l.trigger(E.FRAG_DECRYPTED,{frag:i,payload:d,stats:{tstart:u,tdecrypt:h}})}).catch(function(d){r.warn(d.name+": "+d.message),r.state=he})}},e.doTick=function(){if(this.media){if(this.state===he){var t=this.currentTrackId,r=this.levels,i=r[t];if(!r.length||!i||!i.details)return;var a=i.details,o=a.targetduration,l=this.config,u=this.getLoadPosition(),d=re.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],u-o,l.maxBufferHole),h=d.end,f=d.len,v=this.getFwdBufferInfo(this.media,Ne);if(f>this.getMaxBufferLength(v==null?void 0:v.len)+o)return;var p=a.fragments,T=p.length,S=a.edge,y=null,b=this.fragPrevious;if(h<S){var C=l.maxFragLookUpTolerance;!(y=Rr(b,p,Math.max(p[0].start,h),C))&&b&&b.start<p[0].start&&(y=p[0])}else y=p[T-1];if(!y)return;y=this.mapToInitFragWhenRequired(y),this.fragmentTracker.getState(y)===Y&&this.loadFragment(y,i,h)}}else this.state=he},e.getMaxBufferLength=function(t){var r=s.prototype.getMaxBufferLength.call(this);return t?Math.max(r,t):r},e.loadFragment=function(t,r,i){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t,r):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,i))},K(n,[{key:"mediaBufferTimeRanges",get:function(){return new sl(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(na),sl=function(s){this.buffered=void 0;var n=function(e,t,r){if((t>>>=0)>r-1)throw new DOMException("Failed to execute '"+e+"' on 'TimeRanges': The index provided ("+t+") is greater than the maximum bound ("+r+")");return s[t][e]};this.buffered={get length(){return s.length},end:function(e){return n("end",e,s.length)},start:function(e){return n("start",e,s.length)}}},ol=function(s){function n(t){var r;return(r=s.call(this,t,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r._subtitleDisplay=!0,r.registerListeners(),r}ae(n,s);var e=n.prototype;return e.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,s.prototype.destroy.call(this)},e.registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(E.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVEL_LOADING,this.onLevelLoading,this),t.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(E.ERROR,this.onError,this)},e.onMediaAttached=function(t,r){this.media=r.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))},e.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},e.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),pa(this.media.textTracks).forEach(function(t){ur(t)}),this.subtitleTrack=-1,this.media=null)},e.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},e.onManifestParsed=function(t,r){this.tracks=r.subtitleTracks},e.onSubtitleTrackLoaded=function(t,r){var i=r.id,a=r.details,o=this.trackId,l=this.tracksInGroup[o];if(l){var u=l.details;l.details=r.details,this.log("subtitle track "+i+" loaded ["+a.startSN+"-"+a.endSN+"]"),i===this.trackId&&this.playlistLoaded(i,r,u)}else this.warn("Invalid subtitle track id "+i)},e.onLevelLoading=function(t,r){this.switchLevel(r.level)},e.onLevelSwitching=function(t,r){this.switchLevel(r.level)},e.switchLevel=function(t){var r=this.hls.levels[t];if(r!=null&&r.textGroupIds){var i=r.textGroupIds[r.urlId],a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){var o=this.tracks.filter(function(d){return!i||d.groupId===i});this.tracksInGroup=o;var l=this.findTrackId(a==null?void 0:a.name)||this.findTrackId();this.groupId=i||null;var u={subtitleTracks:o};this.log("Updating subtitle tracks, "+o.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(E.SUBTITLE_TRACKS_UPDATED,u),l!==-1&&this.setSubtitleTrack(l,a)}else this.shouldReloadPlaylist(a)&&this.setSubtitleTrack(this.trackId,a)}},e.findTrackId=function(t){for(var r=this.tracksInGroup,i=0;i<r.length;i++){var a=r[i];if((!this.selectDefaultTrack||a.default)&&(!t||t===a.name))return a.id}return-1},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===Gt&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.checkRetry(r)},e.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,a=r.groupId,o=r.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(E.SUBTITLE_TRACK_LOADING,{url:o,id:i,groupId:a,deliveryDirectives:t||null})}},e.toggleTrackModes=function(t){var r=this,i=this.media,a=this.trackId;if(i){var o=pa(i.textTracks),l=o.filter(function(h){return h.groupId===r.groupId});if(t===-1)[].slice.call(o).forEach(function(h){h.mode="disabled"});else{var u=l[a];u&&(u.mode="disabled")}var d=l[t];d&&(d.mode=this.subtitleDisplay?"showing":"hidden")}},e.setSubtitleTrack=function(t,r){var i,a=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(t===-1||(i=a[t])!=null&&i.details)||t<-1||t>=a.length)){this.clearTimer();var o=a[t];if(this.log("Switching to subtitle-track "+t+(o?' "'+o.name+'" lang:'+o.lang+" group:"+o.groupId:"")),this.trackId=t,o){var l=o.id,u=o.groupId,d=u===void 0?"":u,h=o.name,f=o.type,v=o.url;this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:l,groupId:d,name:h,type:f,url:v});var p=this.switchParams(o.url,r==null?void 0:r.details);this.loadPlaylist(p)}else this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},e.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,r=pa(this.media.textTracks),i=0;i<r.length;i++)if(r[i].mode==="hidden")t=i;else if(r[i].mode==="showing"){t=i;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},K(n,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1;var r=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,r)}}]),n}(k);function pa(s){for(var n=[],e=0;e<s.length;e++){var t=s[e];t.kind!=="subtitles"&&t.kind!=="captions"||!t.label||n.push(s[e])}return n}var ll=function(){function s(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var n=s.prototype;return n.append=function(e,t){var r=this.queues[t];r.push(e),r.length===1&&this.buffers[t]&&this.executeNext(t)},n.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},n.appendBlocker=function(e){var t,r=new Promise(function(a){t=a}),i={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,e),r},n.executeNext=function(e){var t=this.buffers,r=this.queues,i=t[e],a=r[e];if(a.length){var o=a[0];try{o.execute()}catch(l){x.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),o.onError(l),i!=null&&i.updating||(a.shift(),this.executeNext(e))}}},n.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},n.current=function(e){return this.queues[e][0]},s}(),Ts=Kr(),Es=/([ha]vc.)(?:\.[^.,]+)+/,ul=function(){function s(e){var t=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 r=t.media,i=t.mediaSource;x.log("[buffer-controller]: Media source opened"),r&&(r.removeEventListener("emptied",t._onMediaEmptied),t.updateMediaElementDuration(),t.hls.trigger(E.MEDIA_ATTACHED,{media:r})),i&&i.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){x.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){x.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var r=t.media,i=t._objectUrl;r&&r.src!==i&&x.error("Media element src was set while attaching MediaSource ("+i+" > "+r.src+")")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var n=s.prototype;return n.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},n.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},n.registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.BUFFER_EOS,this.onBufferEos,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.FRAG_PARSED,this.onFragParsed,this),e.on(E.FRAG_CHANGED,this.onFragChanged,this)},n.unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_EOS,this.onBufferEos,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.FRAG_PARSED,this.onFragParsed,this),e.off(E.FRAG_CHANGED,this.onFragChanged,this)},n._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new ll(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},n.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},n.onManifestParsed=function(e,t){var r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,x.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},n.onMediaAttaching=function(e,t){var r=this.media=t.media;if(r&&Ts){var i=this.mediaSource=new Ts;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}},n.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(x.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(i){x.warn("[buffer-controller]: onMediaDetaching: "+i.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):x.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(E.MEDIA_DETACHED,void 0)},n.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){var r=e.sourceBuffer[t];try{r&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(r),e.sourceBuffer[t]=void 0)}catch(i){x.warn("[buffer-controller]: Failed to reset the "+t+" buffer",i)}}),this._initSourceBuffer()},n.onBufferCodecs=function(e,t){var r=this,i=this.getSourceBufferTypes().length;Object.keys(t).forEach(function(a){if(i){var o=r.tracks[a];if(o&&typeof o.buffer.changeType=="function"){var l=t[a],u=l.id,d=l.codec,h=l.levelCodec,f=l.container,v=l.metadata,p=(o.levelCodec||o.codec).replace(Es,"$1"),T=(h||d).replace(Es,"$1");if(p!==T){var S=f+";codecs="+(h||d);r.appendChangeType(a,S),x.log("[buffer-controller]: switching codec "+p+" to "+T),r.tracks[a]={buffer:o.buffer,codec:d,container:f,levelCodec:h,metadata:v,id:u}}}}else r.pendingTracks[a]=t[a]}),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},n.appendChangeType=function(e,t){var r=this,i=this.operationQueue,a={execute:function(){var o=r.sourceBuffer[e];o&&(x.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),o.changeType(t)),i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(o){x.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",o)}};i.append(a,e)},n.onBufferAppending=function(e,t){var r=this,i=this.hls,a=this.operationQueue,o=this.tracks,l=t.data,u=t.type,d=t.frag,h=t.part,f=t.chunkMeta,v=f.buffering[u],p=self.performance.now();v.start=p;var T=d.stats.buffering,S=h?h.stats.buffering:null;T.start===0&&(T.start=p),S&&S.start===0&&(S.start=p);var y=o.audio,b=!1;u==="audio"&&(y==null?void 0:y.container)==="audio/mpeg"&&(b=!this.lastMpegAudioChunk||f.id===1||this.lastMpegAudioChunk.sn!==f.sn,this.lastMpegAudioChunk=f);var C=d.start,D={execute:function(){if(v.executeStart=self.performance.now(),b){var O=r.sourceBuffer[u];if(O){var N=C-O.timestampOffset;Math.abs(N)>=.1&&(x.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+C+" (delta: "+N+") sn: "+d.sn+")"),O.timestampOffset=C)}}r.appendExecutor(l,u)},onStart:function(){},onComplete:function(){var O=self.performance.now();v.executeEnd=v.end=O,T.first===0&&(T.first=O),S&&S.first===0&&(S.first=O);var N=r.sourceBuffer,G={};for(var W in N)G[W]=re.getBuffered(N[W]);r.appendError=0,r.hls.trigger(E.BUFFER_APPENDED,{type:u,frag:d,part:h,chunkMeta:f,parent:d.type,timeRanges:G})},onError:function(O){x.error("[buffer-controller]: Error encountered while trying to append to the "+u+" SourceBuffer",O);var N={type:Q.MEDIA_ERROR,parent:d.type,details:F.BUFFER_APPEND_ERROR,frag:d,part:h,chunkMeta:f,error:O,err:O,fatal:!1};O.code===DOMException.QUOTA_EXCEEDED_ERR?N.details=F.BUFFER_FULL_ERROR:(r.appendError++,N.details=F.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(x.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),N.fatal=!0)),i.trigger(E.ERROR,N)}};a.append(D,u)},n.onBufferFlushing=function(e,t){var r=this,i=this.operationQueue,a=function(o){return{execute:r.removeExecutor.bind(r,o,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(E.BUFFER_FLUSHED,{type:o})},onError:function(l){x.warn("[buffer-controller]: Failed to remove from "+o+" SourceBuffer",l)}}};t.type?i.append(a(t.type),t.type):this.getSourceBufferTypes().forEach(function(o){i.append(a(o),o)})},n.onFragParsed=function(e,t){var r=this,i=t.frag,a=t.part,o=[],l=a?a.elementaryStreams:i.elementaryStreams;l[Nr]?o.push("audiovideo"):(l[Xe]&&o.push("audio"),l[mt]&&o.push("video")),o.length===0&&x.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers(function(){var u=self.performance.now();i.stats.buffering.end=u,a&&(a.stats.buffering.end=u);var d=a?a.stats:i.stats;r.hls.trigger(E.FRAG_BUFFERED,{frag:i,part:a,stats:d,id:i.type})},o)},n.onFragChanged=function(e,t){this.flushBackBuffer()},n.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce(function(i,a){var o=r.sourceBuffer[a];return!o||t.type&&t.type!==a||(o.ending=!0,o.ended||(o.ended=!0,x.log("[buffer-controller]: "+a+" sourceBuffer now EOS"))),i&&!(o&&!o.ended)},!0)&&(x.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){r.getSourceBufferTypes().forEach(function(a){var o=r.sourceBuffer[a];o&&(o.ending=!1)});var i=r.mediaSource;i&&i.readyState==="open"?(x.log("[buffer-controller]: Calling mediaSource.endOfStream()"),i.endOfStream()):i&&x.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+i.readyState)}))},n.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},n.flushBackBuffer=function(){var e=this.hls,t=this.details,r=this.media,i=this.sourceBuffer;if(r&&t!==null){var a=this.getSourceBufferTypes();if(a.length){var o=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(Z(o)&&!(o<0)){var l=r.currentTime,u=t.levelTargetDuration,d=Math.max(o,u),h=Math.floor(l/u)*u-d;a.forEach(function(f){var v=i[f];if(v){var p=re.getBuffered(v);if(p.length>0&&h>p.start(0)){if(e.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:h}),t.live)e.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h});else if(v.ended&&p.end(p.length-1)-l<2*u)return void x.info("[buffer-controller]: Cannot flush "+f+" back buffer while SourceBuffer is in ended state");e.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:f})}}})}}}},n.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var e=this.details,t=this.hls,r=this.media,i=this.mediaSource,a=e.fragments[0].start+e.totalduration,o=r.duration,l=Z(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(x.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(e)):(a>l&&a>o||!Z(o))&&(x.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),i.duration=a)}},n.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){var i=Math.max(0,r[0].start),a=Math.max(i,i+e.totalduration);t.setLiveSeekableRange(i,a)}},n.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!e||i===2){this.createSourceBuffers(r),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length)this.hls.trigger(E.BUFFER_CREATED,{tracks:this.tracks}),a.forEach(function(l){t.executeNext(l)});else{var o=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:o,reason:o.message})}}},n.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(var i in e)if(!t[i]){var a=e[i];if(!a)throw Error("source buffer exists for track "+i+", however track does not");var o=a.levelCodec||a.codec,l=a.container+";codecs="+o;x.log("[buffer-controller]: creating sourceBuffer("+l+")");try{var u=t[i]=r.addSourceBuffer(l),d=i;this.addBufferListener(d,"updatestart",this._onSBUpdateStart),this.addBufferListener(d,"updateend",this._onSBUpdateEnd),this.addBufferListener(d,"error",this._onSBUpdateError),this.tracks[i]={buffer:u,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(h){x.error("[buffer-controller]: error while trying to add sourceBuffer: "+h.message),this.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:h,mimeType:l})}}},n._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},n._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},n._onSBUpdateError=function(e,t){var r=new Error(e+" SourceBuffer error");x.error("[buffer-controller]: "+r,t),this.hls.trigger(E.ERROR,{type:Q.MEDIA_ERROR,details:F.BUFFER_APPENDING_ERROR,error:r,fatal:!1});var i=this.operationQueue.current(e);i&&i.onError(t)},n.removeExecutor=function(e,t,r){var i=this.media,a=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[e];if(!i||!a||!l)return x.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(e);var u=Z(i.duration)?i.duration:1/0,d=Z(a.duration)?a.duration:1/0,h=Math.max(0,t),f=Math.min(r,u,d);f>h&&!l.ending?(l.ended=!1,x.log("[buffer-controller]: Removing ["+h+","+f+"] from the "+e+" SourceBuffer"),l.remove(h,f)):o.shiftAndExecuteNext(e)},n.appendExecutor=function(e,t){var r=this.operationQueue,i=this.sourceBuffer[t];if(!i)return x.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(t);i.ended=!1,i.appendBuffer(e)},n.blockBuffers=function(e,t){var r=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length)return x.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var i=this.operationQueue,a=t.map(function(o){return i.appendBlocker(o)});Promise.all(a).then(function(){e(),t.forEach(function(o){var l=r.sourceBuffer[o];l!=null&&l.updating||i.shiftAndExecuteNext(o)})})},n.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},n.addBufferListener=function(e,t,r){var i=this.sourceBuffer[e];if(i){var a=r.bind(this,e);this.listeners[e].push({event:t,listener:a}),i.addEventListener(t,a)}},n.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(r){t.removeEventListener(r.event,r.listener)})},s}(),bs={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},_s=function(s){var n=s;return bs.hasOwnProperty(s)&&(n=bs[s]),String.fromCharCode(n)},xr=15,ir=100,dl={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},hl={17:2,18:4,21:6,22:8,23:10,19:13,20:15},cl={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},fl={25:2,26:4,29:6,30:8,31:10,27:13,28:15},vl=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],gl=function(){function s(){this.time=null,this.verboseLevel=0}return s.prototype.log=function(n,e){if(this.verboseLevel>=n){var t=typeof e=="function"?e():e;x.log(this.time+" ["+n+"] "+t)}},s}(),Pr=function(s){for(var n=[],e=0;e<s.length;e++)n.push(s[e].toString(16));return n},Ss=function(){function s(e,t,r,i,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=a||!1}var n=s.prototype;return n.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},n.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}},n.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},n.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},n.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},n.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},s}(),ml=function(){function s(e,t,r,i,a,o){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new Ss(t,r,i,a,o)}var n=s.prototype;return n.reset=function(){this.uchar=" ",this.penState.reset()},n.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},n.setPenState=function(e){this.penState.copy(e)},n.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},n.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},n.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},s}(),pl=function(){function s(e){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<ir;t++)this.chars.push(new ml);this.logger=e,this.pos=0,this.currPenState=new Ss}var n=s.prototype;return n.equals=function(e){for(var t=!0,r=0;r<ir;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<ir;t++)this.chars[t].copy(e.chars[t])},n.isEmpty=function(){for(var e=!0,t=0;t<ir;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},n.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>ir&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ir)},n.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)},n.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},n.insertChar=function(e){var t=this;e>=144&&this.backSpace();var r=_s(e);this.pos>=ir?this.logger.log(0,function(){return"Cannot insert "+e.toString(16)+" ("+r+") at position "+t.pos+". Skipping it!"}):(this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1))},n.clearFromPos=function(e){var t;for(t=e;t<ir;t++)this.chars[t].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 e=[],t=!0,r=0;r<ir;r++){var i=this.chars[r].uchar;i!==" "&&(t=!1),e.push(i)}return t?"":e.join("")},n.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},s}(),ya=function(){function s(e){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<xr;t++)this.rows.push(new pl(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var n=s.prototype;return n.reset=function(){for(var e=0;e<xr;e++)this.rows[e].clear();this.currRow=14},n.equals=function(e){for(var t=!0,r=0;r<xr;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<xr;t++)this.rows[t].copy(e.rows[t])},n.isEmpty=function(){for(var e=!0,t=0;t<xr;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},n.backSpace=function(){this.rows[this.currRow].backSpace()},n.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},n.insertChar=function(e){this.rows[this.currRow].insertChar(e)},n.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},n.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},n.setCursor=function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},n.setPAC=function(e){this.logger.log(2,function(){return"pacData = "+JSON.stringify(e)});var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<xr;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var o=a.rows[i].cueStartTime,l=this.logger.time;if(o&&l!==null&&o<l)for(var u=0;u<this.nrRollUpRows;u++)this.rows[t-this.nrRollUpRows+u+1].copy(a.rows[i+u])}}this.currRow=t;var d=this.rows[this.currRow];if(e.indent!==null){var h=e.indent,f=Math.max(h-1,0);d.setCursor(e.indent),e.color=d.chars[f].penState.foreground}var v={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(v)},n.setBkgData=function(e){this.logger.log(2,function(){return"bkgData = "+JSON.stringify(e)}),this.backSpace(),this.setPen(e),this.insertChar(32)},n.setRollUpRows=function(e){this.nrRollUpRows=e},n.rollUp=function(){var e=this;if(this.nrRollUpRows!==null){this.logger.log(1,function(){return e.getDisplayText()});var t=this.currRow+1-this.nrRollUpRows,r=this.rows.splice(t,1)[0];r.clear(),this.rows.splice(this.currRow,0,r),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")},n.getDisplayText=function(e){e=e||!1;for(var t=[],r="",i=-1,a=0;a<xr;a++){var o=this.rows[a].getTextString();o&&(i=a+1,e?t.push("Row "+i+": '"+o+"'"):t.push(o.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join(`
|
|
34
|
+
`)),r},n.getTextAndFormat=function(){return this.rows},s}(),As=function(){function s(e,t,r){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=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new ya(r),this.nonDisplayedMemory=new ya(r),this.lastOutputScreen=new ya(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var n=s.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[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},n.getHandler=function(){return this.outputFilter},n.setHandler=function(e){this.outputFilter=e},n.setPAC=function(e){this.writeScreen.setPAC(e)},n.setBkgData=function(e){this.writeScreen.setBkgData(e)},n.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,function(){return"MODE="+e}),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=e)},n.insertChars=function(e){for(var t=this,r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,function(){return i+": "+t.writeScreen.getDisplayText(!0)}),this.mode!=="MODE_PAINT-ON"&&this.mode!=="MODE_ROLL-UP"||(this.logger.log(1,function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},n.ccRCL=function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},n.ccBS=function(){this.logger.log(2,"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(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},n.ccRU=function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},n.ccFON=function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},n.ccRDC=function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},n.ccTR=function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")},n.ccRTD=function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")},n.ccEDM=function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},n.ccCR=function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},n.ccENM=function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},n.ccEOC=function(){var e=this;if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,function(){return"DISP: "+e.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},n.ccTO=function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},n.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},n.outputDataUpdate=function(e){e===void 0&&(e=!1);var t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime!==null||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},n.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},s}(),Ls=function(){function s(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new gl;this.channels=[null,new As(e,t,i),new As(e+1,r,i)],this.cmdHistory={a:null,b:null},this.logger=i}var n=s.prototype;return n.getHandler=function(e){return this.channels[e].getHandler()},n.setHandler=function(e,t){this.channels[e].setHandler(t)},n.addData=function(e,t){var r,i,a,o=!1;this.logger.time=e;for(var l=0;l<t.length;l+=2)if(i=127&t[l],a=127&t[l+1],i!==0||a!==0){if(this.logger.log(3,"["+Pr([t[l],t[l+1]])+"] -> ("+Pr([i,a])+")"),(r=this.parseCmd(i,a))||(r=this.parseMidrow(i,a)),r||(r=this.parsePAC(i,a)),r||(r=this.parseBackgroundAttributes(i,a)),!r&&(o=this.parseChars(i,a))){var u=this.currentChannel;u&&u>0?this.channels[u].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}r||o||this.logger.log(2,"Couldn't parse cleaned data "+Pr([i,a])+" orig: "+Pr([t[l],t[l+1]]))}},n.parseCmd=function(e,t){var r=this.cmdHistory;if(!((e===20||e===28||e===21||e===29)&&t>=32&&t<=47||(e===23||e===31)&&t>=33&&t<=35))return!1;if(ks(e,t,r))return Zr(null,null,r),this.logger.log(3,"Repeated command ("+Pr([e,t])+") is dropped"),!0;var i=e===20||e===21||e===23?1:2,a=this.channels[i];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),Zr(e,t,r),this.currentChannel=i,!0},n.parseMidrow=function(e,t){var r=0;if((e===17||e===25)&&t>=32&&t<=47){if((r=e===17?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,"MIDROW ("+Pr([e,t])+")"),!0)}return!1},n.parsePAC=function(e,t){var r,i=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(e===16||e===24)&&t>=64&&t<=95))return!1;if(ks(e,t,i))return Zr(null,null,i),!0;var a=e<=23?1:2;r=t>=64&&t<=95?a===1?dl[e]:cl[e]:a===1?hl[e]:fl[e];var o=this.channels[a];return!!o&&(o.setPAC(this.interpretPAC(r,t)),Zr(e,t,i),this.currentChannel=a,!0)},n.interpretPAC=function(e,t){var r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=(1&r)==1,r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},n.parseChars=function(e,t){var r,i,a=null,o=null;if(e>=25?(r=2,o=e-8):(r=1,o=e),o>=17&&o<=19?(i=o===17?t+80:o===18?t+112:t+144,this.logger.log(2,"Special char '"+_s(i)+"' in channel "+r),a=[i]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var l=Pr(a);this.logger.log(3,"Char codes = "+l.join(",")),Zr(e,t,this.cmdHistory)}return a},n.parseBackgroundAttributes=function(e,t){var r;if(!((e===16||e===24)&&t>=32&&t<=47||(e===23||e===31)&&t>=45&&t<=47))return!1;var i={};e===16||e===24?(r=Math.floor((t-32)/2),i.background=vl[r],t%2==1&&(i.background=i.background+"_semi")):t===45?i.background="transparent":(i.foreground="black",t===47&&(i.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(i),Zr(e,t,this.cmdHistory),!0},n.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}},n.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}},s}();function Zr(s,n,e){e.a=s,e.b=n}function ks(s,n,e){return e.a===s&&e.b===n}var Cn=function(){function s(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}var n=s.prototype;return n.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},n.newCue=function(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},n.reset=function(){this.cueRanges=[],this.startTime=null},s}(),Ta=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var s=["","lr","rl"],n=["start","middle","end","left","right"];function e(a,o){if(typeof o!="string"||!Array.isArray(a))return!1;var l=o.toLowerCase();return!!~a.indexOf(l)&&l}function t(a){return e(n,a)}function r(a){for(var o=arguments.length,l=new Array(o>1?o-1:0),u=1;u<o;u++)l[u-1]=arguments[u];for(var d=1;d<arguments.length;d++){var h=arguments[d];for(var f in h)a[f]=h[f]}return a}function i(a,o,l){var u=this,d={enumerable:!0};u.hasBeenReset=!1;var h="",f=!1,v=a,p=o,T=l,S=null,y="",b=!0,C="auto",D="start",O=50,N="middle",G=50,W="middle";Object.defineProperty(u,"id",r({},d,{get:function(){return h},set:function(q){h=""+q}})),Object.defineProperty(u,"pauseOnExit",r({},d,{get:function(){return f},set:function(q){f=!!q}})),Object.defineProperty(u,"startTime",r({},d,{get:function(){return v},set:function(q){if(typeof q!="number")throw new TypeError("Start time must be set to a number.");v=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",r({},d,{get:function(){return p},set:function(q){if(typeof q!="number")throw new TypeError("End time must be set to a number.");p=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",r({},d,{get:function(){return T},set:function(q){T=""+q,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",r({},d,{get:function(){return S},set:function(q){S=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",r({},d,{get:function(){return y},set:function(q){var V=function(te){return e(s,te)}(q);if(V===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=V,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",r({},d,{get:function(){return b},set:function(q){b=!!q,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",r({},d,{get:function(){return C},set:function(q){if(typeof q!="number"&&q!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");C=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",r({},d,{get:function(){return D},set:function(q){var V=t(q);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");D=V,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",r({},d,{get:function(){return O},set:function(q){if(q<0||q>100)throw new Error("Position must be between 0 and 100.");O=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",r({},d,{get:function(){return N},set:function(q){var V=t(q);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");N=V,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",r({},d,{get:function(){return G},set:function(q){if(q<0||q>100)throw new Error("Size must be between 0 and 100.");G=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",r({},d,{get:function(){return W},set:function(q){var V=t(q);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");W=V,this.hasBeenReset=!0}})),u.displayState=void 0}return i.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},i}(),yl=function(){function s(){}return s.prototype.decode=function(n,e){if(!n)return"";if(typeof n!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(n))},s}();function ws(s){function n(t,r,i,a){return 3600*(0|t)+60*(0|r)+(0|i)+parseFloat(a||0)}var e=s.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?n(e[2],e[3],0,e[4]):n(e[1],e[2],e[3],e[4]):null}var Tl=function(){function s(){this.values=Object.create(null)}var n=s.prototype;return n.set=function(e,t){this.get(e)||t===""||(this.values[e]=t)},n.get=function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},n.has=function(e){return e in this.values},n.alt=function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}},n.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},n.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1},s}();function Rs(s,n,e,t){var r=t?s.split(t):[s];for(var i in r)if(typeof r[i]=="string"){var a=r[i].split(e);a.length===2&&n(a[0],a[1])}}var Ea=new Ta(0,0,""),xn=Ea.align==="middle"?"middle":"center";function El(s,n,e){var t=s;function r(){var a=ws(s);if(a===null)throw new Error("Malformed timestamp: "+t);return s=s.replace(/^[^\sa-zA-Z-]+/,""),a}function i(){s=s.replace(/^\s+/,"")}if(i(),n.startTime=r(),i(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+t);s=s.slice(3),i(),n.endTime=r(),i(),function(a,o){var l=new Tl;Rs(a,function(h,f){var v;switch(h){case"region":for(var p=e.length-1;p>=0;p--)if(e[p].id===f){l.set(h,e[p].region);break}break;case"vertical":l.alt(h,f,["rl","lr"]);break;case"line":v=f.split(","),l.integer(h,v[0]),l.percent(h,v[0])&&l.set("snapToLines",!1),l.alt(h,v[0],["auto"]),v.length===2&&l.alt("lineAlign",v[1],["start",xn,"end"]);break;case"position":v=f.split(","),l.percent(h,v[0]),v.length===2&&l.alt("positionAlign",v[1],["start",xn,"end","line-left","line-right","auto"]);break;case"size":l.percent(h,f);break;case"align":l.alt(h,f,["start",xn,"end","left","right"])}},/:/,/\s/),o.region=l.get("region",null),o.vertical=l.get("vertical","");var u=l.get("line","auto");u==="auto"&&Ea.line===-1&&(u=-1),o.line=u,o.lineAlign=l.get("lineAlign","start"),o.snapToLines=l.get("snapToLines",!0),o.size=l.get("size",100),o.align=l.get("align",xn);var d=l.get("position","auto");d==="auto"&&Ea.position===50&&(d=o.align==="start"||o.align==="left"?0:o.align==="end"||o.align==="right"?100:50),o.position=d}(s,n)}function Ds(s){return s.replace(/<br(?: \/)?>/gi,`
|
|
35
|
+
`)}var bl=function(){function s(){this.state="INITIAL",this.buffer="",this.decoder=new yl,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var n=s.prototype;return n.parse=function(e){var t=this;function r(){var u=t.buffer,d=0;for(u=Ds(u);d<u.length&&u[d]!=="\r"&&u[d]!==`
|
|
36
|
+
`;)++d;var h=u.slice(0,d);return u[d]==="\r"&&++d,u[d]===`
|
|
37
|
+
`&&++d,t.buffer=u.slice(d),h}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var i="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;var a=(i=r()).match(/^()?WEBVTT([ \t].*)?$/);if(a==null||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var o=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!1:i=r(),t.state){case"HEADER":/:/.test(i)?Rs(i,function(u,d){},/:/):i||(t.state="ID");continue;case"NOTE":i||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){t.state="NOTE";break}if(!i)continue;if(t.cue=new Ta(0,0,""),t.state="CUE",i.indexOf("-->")===-1){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{El(i,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var l=i.indexOf("-->")!==-1;if(!i||l&&(o=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
|
|
38
38
|
`),t.cue.text+=i;continue;case"BADCUE":i||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},n.flush=function(){var e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
|
|
39
39
|
|
|
40
|
-
`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this},s}(),
|
|
40
|
+
`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this},s}(),_l=/\r\n|\n\r|\n|\r/g,ba=function(s,n,e){return e===void 0&&(e=0),s.slice(e,e+n.length)===n},_a=function(s){for(var n=5381,e=s.length;e;)n=33*n^s.charCodeAt(--e);return(n>>>0).toString()};function Sa(s,n,e){return _a(s.toString())+_a(n.toString())+_a(e)}function Sl(s,n,e,t,r,i,a){var o,l,u,d=new bl,h=At(new Uint8Array(s)).trim().replace(_l,`
|
|
41
41
|
`).split(`
|
|
42
|
-
`),f=[],v=(o=n.baseTime,(l=n.timescale)===void 0&&(l=1),ua(o,9e4,1/l)),p="00:00.000",T=0,S=0,y=!0;
|
|
43
|
-
`)}),
|
|
44
|
-
`:(i=t.childNodes)!=null&&i.length?Ps(t,n):n?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function La(s,n,e){return s&&s.hasAttributeNS(n,e)?s.getAttributeNS(n,e):null}function Os(s){return new Error("Could not parse ttml timestamp "+s)}function wa(s,n){if(!s)return null;var e=Ls(s);return e===null&&(Ds.test(s)?e=function(t,r){var i=Ds.exec(t),a=(0|i[4])+(0|i[5])/r.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+a/r.frameRate}(s,n):Is.test(s)&&(e=function(t,r){var i=Is.exec(t),a=Number(i[1]);switch(i[2]){case"h":return 3600*a;case"m":return 60*a;case"ms":return 1e3*a;case"f":return a/r.frameRate;case"t":return a/r.tickRate}return a}(s,n))),e}var Sl=function(){function s(e){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.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.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 t=new Cn(this,"textTrack1"),r=new Cn(this,"textTrack2"),i=new Cn(this,"textTrack3"),a=new Cn(this,"textTrack4");this.cea608Parser1=new As(1,t,r),this.cea608Parser2=new As(3,i,a)}e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}var n=s.prototype;return n.destroy=function(){var e=this.hls;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},n.addCues=function(e,t,r,i,a){for(var o,l,d,u,c=!1,f=a.length;f--;){var v=a[f],p=(o=v[0],l=v[1],d=t,u=r,Math.min(l,u)-Math.max(o,d));if(p>=0&&(v[0]=Math.min(v[0],t),v[1]=Math.max(v[1],r),c=!0,p/(r-t)>.5))return}if(c||a.push([t,r]),this.config.renderTextTracksNatively){var T=this.captionsTracks[e];this.Cues.newCue(T,t,r,i)}else{var S=this.Cues.newCue(null,t,r,i);this.hls.trigger(E.CUES_PARSED,{type:"captions",cues:S,track:e})}},n.onInitPtsFound=function(e,t){var r=this,i=t.frag,a=t.id,o=t.initPTS,l=t.timescale,d=this.unparsedVttFrags;a==="main"&&(this.initPTS[i.cc]={baseTime:o,timescale:l}),d.length&&(this.unparsedVttFrags=[],d.forEach(function(u){r.onFragLoaded(E.FRAG_LOADED,u)}))},n.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r<t.textTracks.length;r++){var i=t.textTracks[r];if(i[e])return i}return null},n.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},n.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,r=this.captionsTracks,i=this.media,a=t[e],o=a.label,l=a.languageCode,d=this.getExistingTrack(e);if(d)r[e]=d,lr(r[e]),br(r[e],i);else{var u=this.createTextTrack("captions",o,l);u&&(u[e]=!0,r[e]=u)}}},n.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},n.createTextTrack=function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)},n.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},n.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach(function(t){lr(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}},n.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},n._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)lr(t[r])}},n.onSubtitleTracksUpdated=function(e,t){var r=this,i=t.subtitleTracks||[],a=i.some(function(d){return d.textCodec===Aa});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){if(ps(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:null;this.tracks.forEach(function(d,u){var c;if(o&&u<o.length){for(var f=null,v=0;v<o.length;v++)if(Al(o[v],d)){f=o[v];break}f&&(c=f)}if(c)lr(c);else{var p=r._captionsOrSubtitlesFromCharacteristics(d);(c=r.createTextTrack(p,d.name,d.lang))&&(c.mode="disabled")}c&&(c.groupId=d.groupId,r.textTracks.push(c))})}else if(this.tracks.length){var l=this.tracks.map(function(d){return{label:d.name,kind:d.type.toLowerCase(),default:d.default,subtitleTrack:d}});this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}},n._captionsOrSubtitlesFromCharacteristics=function(e){if(e.attrs.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),r=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&r)return"captions"}return"subtitles"},n.onManifestLoaded=function(e,t){var r=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(function(i){var a=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(a){var o="textTrack"+a[1],l=r.captionsProperties[o];l&&(l.label=i.name,i.lang&&(l.languageCode=i.lang),l.media=i)}})},n.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]},n.onFragLoading=function(e,t){var r=this.cea608Parser1,i=this.cea608Parser2,a=this.lastSn,o=this.lastPartIndex;if(this.enabled&&r&&i&&t.frag.type===Ne){var l,d,u=t.frag.sn,c=(l=t==null||(d=t.part)==null?void 0:d.index)!=null?l:-1;u===a+1||u===a&&c===o+1||(r.reset(),i.reset()),this.lastSn=u,this.lastPartIndex=c}},n.onFragLoaded=function(e,t){var r=t.frag,i=t.payload,a=this.initPTS,o=this.unparsedVttFrags;if(r.type===It)if(i.byteLength){if(!a[r.cc])return o.push(t),void(a.length&&this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")}));var l=r.decryptdata,d="stats"in t;if(l==null||!l.encrypted||d){var u=this.tracks[r.level],c=this.vttCCs;c[r.cc]||(c[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),u&&u.textCodec===Aa?this._parseIMSC1(r,i):this._parseVTTs(r,i,c)}}else this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},n._parseIMSC1=function(e,t){var r=this,i=this.hls;Cs(t,this.initPTS[e.cc],function(a){r._appendCues(a,e.level),i.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(a){x.log("Failed to parse IMSC1: "+a),i.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:a})})},n._parseVTTs=function(e,t,r){var i,a=this,o=this.hls;bl((i=e.initSegment)!=null&&i.data?zt(e.initSegment.data,new Uint8Array(t)):t,this.initPTS[e.cc],r,e.cc,e.start,function(l){a._appendCues(l,e.level),o.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(l){a._fallbackToIMSC1(e,t),x.log("Failed to parse VTT cue: "+l),o.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:l})})},n._fallbackToIMSC1=function(e,t){var r=this,i=this.tracks[e.level];i.textCodec||Cs(t,this.initPTS[e.cc],function(){i.textCodec=Aa,r._parseIMSC1(e,t)},function(){i.textCodec="wvtt"})},n._appendCues=function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[t];if(!i||i.mode==="disabled")return;e.forEach(function(l){return pn(i,l)})}else{var a=this.tracks[t];if(!a)return;var o=a.default?"default":"subtitles"+t;r.trigger(E.CUES_PARSED,{type:"subtitles",cues:e,track:o})}},n.onFragDecrypted=function(e,t){var r=t.frag;if(r.type===It){if(!this.initPTS[r.cc])return void this.unparsedVttFrags.push(t);this.onFragLoaded(E.FRAG_LOADED,t)}},n.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},n.onFragParsingUserdata=function(e,t){var r=this.cea608Parser1,i=this.cea608Parser2;if(this.enabled&&r&&i){var a=t.frag,o=t.samples;if(a.type!==Ne||this.closedCaptionsForLevel(a)!=="NONE")for(var l=0;l<o.length;l++){var d=o[l].bytes;if(d){var u=this.extractCea608Data(d);r.addData(o[l].pts,u[0]),i.addData(o[l].pts,u[1])}}}},n.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.endOffsetSubtitles,o=t.type,l=this.media;if(l&&!(l.currentTime<i)){if(!o||o==="video"){var d=this.captionsTracks;Object.keys(d).forEach(function(c){return ki(d[c],r,i)})}if(this.config.renderTextTracksNatively&&r===0&&a!==void 0){var u=this.textTracks;Object.keys(u).forEach(function(c){return ki(u[c],r,a)})}}},n.extractCea608Data=function(e){for(var t=[[],[]],r=31&e[0],i=2,a=0;a<r;a++){var o=e[i++],l=127&e[i++],d=127&e[i++];if((l!==0||d!==0)&&(4&o)!=0){var u=3&o;u!==0&&u!==1||(t[u].push(l),t[u].push(d))}}return t},s}();function Al(s,n){return!!s&&s.label===n.name&&!(s.textTrack1||s.textTrack2)}var kl=function(){function s(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var n=s.prototype;return n.setStreamController=function(e){this.streamController=e},n.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},n.registerListeners=function(){var e=this.hls;e.on(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)},n.unregisterListener=function(){var e=this.hls;e.off(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)},n.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},n.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null},n.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onMediaDetaching=function(){this.stopCapping()},n.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var e=this.hls.levels;if(e.length){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},n.getMaxLevel=function(e){var t=this,r=this.hls.levels;if(!r.length)return-1;var i=r.filter(function(a,o){return t.isLevelAllowed(a)&&o<=e});return this.clientRect=null,s.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},n.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())},n.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},n.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},n.isLevelAllowed=function(e){return!this.restrictedLevels.some(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height})},s.getMaxLevelByMediaSize=function(e,t,r){if(e==null||!e.length)return-1;for(var i,a,o=e.length-1,l=0;l<e.length;l+=1){var d=e[l];if((d.width>=t||d.height>=r)&&(i=d,!(a=e[l+1])||i.width!==a.width||i.height!==a.height)){o=l;break}}return o},K(s,[{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 e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}}]),s}(),Ll=function(){function s(e){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=e,this.registerListeners()}var n=s.prototype;return n.setStreamController=function(e){this.streamController=e},n.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},n.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&typeof i.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},n.checkFPS=function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var a=i-this.lastTime,o=r-this.lastDroppedFrames,l=t-this.lastDecodedFrames,d=1e3*o/a,u=this.hls;if(u.trigger(E.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),d>0&&o>u.config.fpsDroppedMonitoringThreshold*l){var c=u.currentLevel;x.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(u.autoLevelCapping===-1||u.autoLevelCapping>=c)&&(c-=1,u.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:u.currentLevel}),u.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},n.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},s}(),Pn="[eme]",Ms=function(){function s(e){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=s.CDMCleanupPromise?[s.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=x.debug.bind(x,Pn),this.log=x.log.bind(x,Pn),this.warn=x.warn.bind(x,Pn),this.error=x.error.bind(x,Pn),this.hls=e,this.config=e.config,this.registerListeners()}var n=s.prototype;return n.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null},n.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.MANIFEST_LOADED,this.onManifestLoaded,this)},n.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this)},n.getLicenseServerUrl=function(e){var t=this.config,r=t.drmSystems,i=t.widevineLicenseUrl,a=r[e];if(a)return a.licenseUrl;if(e===Ye.WIDEVINE&&i)return i;throw new Error('no license server URL configured for key-system "'+e+'"')},n.getServerCertificateUrl=function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},n.attemptKeySystemAccess=function(e){var t=this,r=this.hls.levels,i=function(l,d,u){return!!l&&u.indexOf(l)===d},a=r.map(function(l){return l.audioCodec}).filter(i),o=r.map(function(l){return l.videoCodec}).filter(i);return a.length+o.length===0&&o.push("avc1.42e01e"),new Promise(function(l,d){(function u(c){var f=c.shift();t.getMediaKeysPromise(f,a,o).then(function(v){return l({keySystem:f,mediaKeys:v})}).catch(function(v){c.length?u(c):d(v instanceof Pt?v:new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_NO_ACCESS,error:v,fatal:!0},v.message))})})(e)})},n.requestMediaKeySystemAccess=function(e,t){var r=this.config.requestMediaKeySystemAccessFunc;if(typeof r!="function"){var i="Configured requestMediaKeySystemAccess is not a function "+r;return hi===null&&self.location.protocol==="http:"&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(i))}return r(e,t)},n.getMediaKeysPromise=function(e,t,r){var i=this,a=function(u,c,f,v){var p;switch(u){case Ye.FAIRPLAY:p=["cenc","sinf"];break;case Ye.WIDEVINE:case Ye.PLAYREADY:p=["cenc"];break;case Ye.CLEARKEY:p=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+u)}return function(T,S,y,b){return[{initDataTypes:T,persistentState:b.persistentState||"not-allowed",distinctiveIdentifier:b.distinctiveIdentifier||"not-allowed",sessionTypes:b.sessionTypes||[b.sessionType||"temporary"],audioCapabilities:S.map(function(D){return{contentType:'audio/mp4; codecs="'+D+'"',robustness:b.audioRobustness||"",encryptionScheme:b.audioEncryptionScheme||null}}),videoCapabilities:y.map(function(D){return{contentType:'video/mp4; codecs="'+D+'"',robustness:b.videoRobustness||"",encryptionScheme:b.videoEncryptionScheme||null}})}]}(p,c,f,v)}(e,t,r,this.config.drmSystemOptions),o=this.keySystemAccessPromises[e],l=o==null?void 0:o.keySystemAccess;if(!l){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(a)),l=this.requestMediaKeySystemAccess(e,a);var d=this.keySystemAccessPromises[e]={keySystemAccess:l};return l.catch(function(u){i.log('Failed to obtain access to key-system "'+e+'": '+u)}),l.then(function(u){i.log('Access for key-system "'+u.keySystem+'" obtained');var c=i.fetchServerCertificate(e);return i.log('Create media-keys for "'+e+'"'),d.mediaKeys=u.createMediaKeys().then(function(f){return i.log('Media-keys created for "'+e+'"'),c.then(function(v){return v?i.setMediaKeysServerCertificate(f,e,v):f})}),d.mediaKeys.catch(function(f){i.error('Failed to create media-keys for "'+e+'"}: '+f)}),d.mediaKeys})}return l.then(function(){return o.mediaKeys})},n.createMediaKeySessionContext=function(e){var t=e.decryptdata,r=e.keySystem,i=e.mediaKeys;this.log('Creating key-system session "'+r+'" keyId: '+Dt(t.keyId||[]));var a=i.createSession(),o={decryptdata:t,keySystem:r,mediaKeys:i,mediaKeysSession:a,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o},n.renewKeySession=function(e){var t=e.decryptdata;if(t.pssh){var r=this.createMediaKeySessionContext(e),i=this.getKeyIdString(t);this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,"cenc",t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},n.getKeyIdString=function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Dt(e.keyId)},n.updateKeySession=function(e,t){var r,i=e.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+Dt(((r=e.decryptdata)==null?void 0:r.keyId)||[])+`
|
|
45
|
-
} (data length: `+(t&&t.byteLength)+")"),i.update(t)},n.selectKeySystemFormat=function(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+e.sn+" "+e.type+": "+e.level+") key formats "+t.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise},n.getKeyFormatPromise=function(e){var t=this;return new Promise(function(r,i){var a=ci(t.config),o=e.map(ui).filter(function(l){return!!l&&a.indexOf(l)!==-1});return t.getKeySystemSelectionPromise(o).then(function(l){var d=l.keySystem,u=di(d);u?r(u):i(new Error('Unable to find format for key-system "'+d+'"'))}).catch(i)})},n.loadKey=function(e){var t=this,r=e.keyInfo.decryptdata,i=this.getKeyIdString(r),a="(keyId: "+i+' format: "'+r.keyFormat+'" method: '+r.method+" uri: "+r.uri+")";this.log("Starting session for key "+a);var o=this.keyIdToKeySessionPromise[i];return o||(o=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(r).then(function(l){var d=l.keySystem,u=l.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+a),t.attemptSetMediaKeys(d,u).then(function(){t.throwIfDestroyed();var c=t.createMediaKeySessionContext({keySystem:d,mediaKeys:u,decryptdata:r});return t.generateRequestWithPreferredKeySession(c,"cenc",r.pssh,"playlist-key")})})).catch(function(l){return t.handleError(l)}),o},n.throwIfDestroyed=function(e){if(!this.hls)throw new Error("invalid state")},n.handleError=function(e){this.hls&&(this.error(e.message),e instanceof Pt?this.hls.trigger(E.ERROR,e.data):this.hls.trigger(E.ERROR,{type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},n.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){var i=ui(e.keyFormat),a=i?[i]:ci(this.config);return this.attemptKeySystemAccess(a)}return r},n.getKeySystemSelectionPromise=function(e){if(e.length||(e=ci(this.config)),e.length===0)throw new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},n._onMediaEncrypted=function(e){var t=this,r=e.initDataType,i=e.initData;if(this.debug('"'+e.type+'" event: init data type: "'+r+'"'),i!==null){var a,o;if(r==="sinf"&&this.config.drmSystems[Ye.FAIRPLAY]){var l=Qe(new Uint8Array(i));try{var d=oi(JSON.parse(l).sinf),u=yi(new Uint8Array(d));if(!u)return;a=u.subarray(8,24),o=Ye.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var c=function(D){if(!(D instanceof ArrayBuffer)||D.byteLength<32)return null;var w={version:0,systemId:"",kids:null,data:null},O=new DataView(D),N=O.getUint32(0);if(D.byteLength!==N&&N>44||O.getUint32(4)!==1886614376||(w.version=O.getUint32(8)>>>24,w.version>1))return null;w.systemId=Dt(new Uint8Array(D,12,16));var G=O.getUint32(28);if(w.version===0){if(N-32<G)return null;w.data=new Uint8Array(D,32,G)}else if(w.version===1){w.kids=[];for(var W=0;W<G;W++)w.kids.push(new Uint8Array(D,32+16*W,16))}return w}(i);if(c===null)return;c.version===0&&c.systemId===Wi&&c.data&&(a=c.data.subarray(8,24)),o=function(D){if(D===Wi)return Ye.WIDEVINE}(c.systemId)}if(o&&a){for(var f=Dt(a),v=this.keyIdToKeySessionPromise,p=this.mediaKeySessions,T=v[f],S=function(){var D=p[y],w=D.decryptdata;if(w.pssh||!w.keyId)return"continue";var O=Dt(w.keyId);return f===O||w.uri.replace(/-/g,"").indexOf(f)!==-1?(T=v[O],delete v[O],w.pssh=new Uint8Array(i),w.keyId=a,T=v[f]=T.then(function(){return t.generateRequestWithPreferredKeySession(D,r,i,"encrypted-event-key-match")}),"break"):void 0},y=0;y<p.length;y++){var b=S();if(b!=="continue"&&b==="break")break}T||(T=v[f]=this.getKeySystemSelectionPromise([o]).then(function(D){var w,O=D.keySystem,N=D.mediaKeys;t.throwIfDestroyed();var G=new Tr("ISO-23001-7",f,(w=di(O))!=null?w:"");return G.pssh=new Uint8Array(i),G.keyId=a,t.attemptSetMediaKeys(O,N).then(function(){t.throwIfDestroyed();var W=t.createMediaKeySessionContext({decryptdata:G,keySystem:O,mediaKeys:N});return t.generateRequestWithPreferredKeySession(W,r,i,"encrypted-event-no-match")})})),T.catch(function(D){return t.handleError(D)})}}},n._onWaitingForKey=function(e){this.log('"'+e.type+'" event')},n.attemptSetMediaKeys=function(e,t){var r=this,i=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var a=Promise.all(i).then(function(){if(!r.media)throw new Error("Attempted to set mediaKeys without media element attached");return r.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(a),a.then(function(){r.log('Media-keys set for "'+e+'"'),i.push(a),r.setMediaKeysQueue=r.setMediaKeysQueue.filter(function(o){return i.indexOf(o)===-1})})},n.generateRequestWithPreferredKeySession=function(e,t,r,i){var a,o,l=this,d=(a=this.config.drmSystems)==null||(o=a[e.keySystem])==null?void 0:o.generateRequest;if(d)try{var u=d.call(this.hls,t,r,e);if(!u)throw new Error("Invalid response from configured generateRequest filter");t=u.initDataType,r=e.decryptdata.pssh=u.initData?new Uint8Array(u.initData):null}catch(T){var c;if(this.warn(T.message),(c=this.hls)!=null&&c.config.debug)throw T}if(r===null)return this.log('Skipping key-session request for "'+i+'" (no initData)'),Promise.resolve(e);var f=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'+i+'": '+f+" (init data type: "+t+" length: "+(r?r.byteLength:null)+")");var v=new In;e.mediaKeysSession.onmessage=function(T){var S=e.mediaKeysSession;if(S){var y=T.messageType,b=T.message;l.log('"'+y+'" message event for session "'+S.sessionId+'" message size: '+b.byteLength),y==="license-request"||y==="license-renewal"?l.renewLicense(e,b).catch(function(D){l.handleError(D),v.emit("error",D)}):y==="license-release"?e.keySystem===Ye.FAIRPLAY&&(l.updateKeySession(e,Yi("acknowledged")),l.removeSession(e)):l.warn('unhandled media key message type "'+y+'"')}else v.emit("error",new Error("invalid state"))},e.mediaKeysSession.onkeystatuseschange=function(T){if(e.mediaKeysSession){l.onKeyStatusChange(e);var S=e.keyStatus;v.emit("keyStatus",S),S==="expired"&&(l.warn(e.keySystem+" expired for key "+f),l.renewKeySession(e))}else v.emit("error",new Error("invalid state"))};var p=new Promise(function(T,S){v.on("error",S),v.on("keyStatus",function(y){y.startsWith("usable")?T():y==="output-restricted"?S(new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):y==="internal-error"?S(new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+y+'"')):y==="expired"?S(new Error("key expired while generating request")):l.warn('unhandled key status change "'+y+'"')})});return e.mediaKeysSession.generateRequest(t,r).then(function(){var T;l.log('Request generated for key-session "'+((T=e.mediaKeysSession)==null?void 0:T.sessionId)+'" keyId: '+f)}).catch(function(T){throw new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_NO_SESSION,error:T,fatal:!1},"Error generating key-session request: "+T)}).then(function(){return p}).catch(function(T){throw v.removeAllListeners(),l.removeSession(e),T}).then(function(){return v.removeAllListeners(),e})},n.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach(function(r,i){t.log('key status change "'+r+'" for keyStatuses keyId: '+Dt("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))+" session keyId: "+Dt(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=r})},n.fetchServerCertificate=function(e){var t=this.config,r=new t.loader(t),i=this.getServerCertificateUrl(e);return i?(this.log('Fetching serverCertificate for "'+e+'"'),new Promise(function(a,o){var l={responseType:"arraybuffer",url:i},d=t.certLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:function(f,v,p,T){a(f.data)},onError:function(f,v,p,T){o(new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:p,response:H({url:l.url,data:void 0},f)},'"'+e+'" certificate request failed ('+i+"). Status: "+f.code+" ("+f.text+")"))},onTimeout:function(f,v,p){o(new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:p,response:{url:l.url,data:void 0}},'"'+e+'" certificate request timed out ('+i+")"))},onAbort:function(f,v,p){o(new Error("aborted"))}};r.load(l,u,c)})):Promise.resolve()},n.setMediaKeysServerCertificate=function(e,t,r){var i=this;return new Promise(function(a,o){e.setServerCertificate(r).then(function(l){i.log("setServerCertificate "+(l?"success":"not supported by CDM")+" ("+(r==null?void 0:r.byteLength)+') on "'+t+'"'),a(e)}).catch(function(l){o(new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:l,fatal:!0},l.message))})})},n.renewLicense=function(e,t){var r=this;return this.requestLicense(e,new Uint8Array(t)).then(function(i){return r.updateKeySession(e,new Uint8Array(i)).catch(function(a){throw new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:a,fatal:!0},a.message)})})},n.setupLicenseXHR=function(e,t,r,i){var a=this,o=this.config.licenseXhrSetup;return o?Promise.resolve().then(function(){if(!r.decryptdata)throw new Error("Key removed");return o.call(a.hls,e,t,r,i)}).catch(function(l){if(!r.decryptdata)throw l;return e.open("POST",t,!0),o.call(a.hls,e,t,r,i)}).then(function(l){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:l||i}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))},n.requestLicense=function(e,t){var r=this,i=this.config.keyLoadPolicy.default;return new Promise(function(a,o){var l=r.getLicenseServerUrl(e.keySystem);r.log("Sending license request to URL: "+l);var d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=function(){if(!r.hls||!e.mediaKeysSession)return o(new Error("invalid state"));if(d.readyState===4)if(d.status===200){r._requestLicenseFailureCount=0;var u=d.response;r.log("License received "+(u instanceof ArrayBuffer?u.byteLength:u));var c=r.config.licenseResponseCallback;if(c)try{u=c.call(r.hls,d,l,e)}catch(T){r.error(T)}a(u)}else{var f=i.errorRetry,v=f?f.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>v||d.status>=400&&d.status<500)o(new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:l,data:void 0,code:d.status,text:d.statusText}},"License Request XHR failed ("+l+"). Status: "+d.status+" ("+d.statusText+")"));else{var p=v-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+p+" attempts left"),r.requestLicense(e,t).then(a,o)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=d,r.setupLicenseXHR(d,l,e,t).then(function(u){var c=u.xhr,f=u.licenseChallenge;c.send(f)})})},n.onMediaAttached=function(e,t){if(this.config.emeEnabled){var r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}},n.onMediaDetached=function(){var e=this,t=this.media,r=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Tr.clearKeyUriToKeyIdMap();var i=r.length;s.CDMCleanupPromise=Promise.all(r.map(function(a){return e.removeSession(a)}).concat(t==null?void 0:t.setMediaKeys(null).catch(function(a){e.log("Could not clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))}))).then(function(){i&&(e.log("finished closing key sessions and clearing media keys"),r.length=0)}).catch(function(a){e.log("Could not close sessions and clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))})},n.onManifestLoading=function(){this.keyFormatPromise=null},n.onManifestLoaded=function(e,t){var r=t.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var i=r.reduce(function(a,o){return a.indexOf(o.keyFormat)===-1&&a.push(o.keyFormat),a},[]);this.log("Selecting key-system from session-keys "+i.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(i)}},n.removeSession=function(e){var t=this,r=e.mediaKeysSession,i=e.licenseXhr;if(r){this.log("Remove licenses and keys and close session "+r.sessionId),r.onmessage=null,r.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);return a>-1&&this.mediaKeySessions.splice(a,1),r.remove().catch(function(o){t.log("Could not remove session: "+o)}).then(function(){return r.close()}).catch(function(o){t.log("Could not close session: "+o)})}},s}();Ms.CDMCleanupPromise=void 0;var Pt=function(s){function n(e,t){var r;return(r=s.call(this,t)||this).data=void 0,e.error||(e.error=new Error(t)),r.data=e,e.err=e.error,r}return ae(n,s),n}(xe(Error)),wl="m",On="a",Ra="v",Da="av",Fs="i",Rl="tt",Dl=function(){function s(e){var t=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(){t.initialized&&(t.starved=!0),t.buffering=!0},this.onPlaying=function(){t.initialized||(t.initialized=!0),t.buffering=!1},this.applyPlaylistData=function(a){try{t.apply(a,{ot:wl,su:!t.initialized})}catch(o){x.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=function(a){try{var o=a.frag,l=t.hls.levels[o.level],d=t.getObjectType(o),u={d:1e3*o.duration,ot:d};d!==Ra&&d!==On&&d!=Da||(u.br=l.bitrate/1e3,u.tb=t.getTopBandwidth(d)/1e3,u.bl=t.getBufferLength(d)),t.apply(a,u)}catch(c){x.warn("Could not generate segment CMCD data.",c)}},this.hls=e;var r=this.config=e.config,i=r.cmcd;i!=null&&(r.pLoader=this.createPlaylistLoader(),r.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||s.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHED,this.onMediaDetached,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this)},n.unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHED,this.onMediaDetached,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this)},n.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},n.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},n.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},n.onBufferCreated=function(e,t){var r,i;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(i=t.tracks.video)==null?void 0:i.buffer},n.createData=function(){var e;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},n.apply=function(e,t){t===void 0&&(t={}),X(t,this.createData());var r=t.ot===Fs||t.ot===Ra||t.ot===Da;if(this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){var i=s.toHeaders(t);if(!Object.keys(i).length)return;e.headers||(e.headers={}),X(e.headers,i)}else{var a=s.toQuery(t);if(!a)return;e.url=s.appendQueryToUri(e.url,a)}},n.getObjectType=function(e){var t=e.type;return t==="subtitle"?Rl:e.sn==="initSegment"?Fs:t==="audio"?On:t==="main"?this.hls.audioTracks.length?Ra:Da:void 0},n.getTopBandwidth=function(e){var t,r=0,i=this.hls;if(e===On)t=i.audioTracks;else{var a=i.maxAutoLevel,o=a>-1?a+1:i.levels.length;t=i.levels.slice(0,o)}for(var l,d=Re(t);!(l=d()).done;){var u=l.value;u.bitrate>r&&(r=u.bitrate)}return r>0?r:NaN},n.getBufferLength=function(e){var t=this.hls.media,r=e===On?this.audioBuffer:this.videoBuffer;return r&&t?1e3*re.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN},n.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function i(o){this.loader=void 0,this.loader=new r(o)}var a=i.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(o,l,d){t(o),this.loader.load(o,l,d)},K(i,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),i}()},n.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,r=e||this.config.loader;return function(){function i(o){this.loader=void 0,this.loader=new r(o)}var a=i.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(o,l,d){t(o),this.loader.load(o,l,d)},K(i,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),i}()},s.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)},s.serialize=function(e){for(var t,r=[],i=function(T){return!Number.isNaN(T)&&T!=null&&T!==""&&T!==!1},a=function(T){return Math.round(T)},o=function(T){return 100*a(T/100)},l={br:a,d:a,bl:o,dl:o,mtp:o,nor:function(T){return encodeURIComponent(T)},rtp:o,tb:a},d=Re(Object.keys(e||{}).sort());!(t=d()).done;){var u=t.value,c=e[u];if(i(c)&&!(u==="v"&&c===1||u=="pr"&&c===1)){var f=l[u];f&&(c=f(c));var v=typeof c,p=void 0;p=u==="ot"||u==="sf"||u==="st"?u+"="+c:v==="boolean"?u:v==="number"?u+"="+c:u+"="+JSON.stringify(c),r.push(p)}}return r.join(",")},s.toHeaders=function(e){for(var t={},r=["Object","Request","Session","Status"],i=[{},{},{},{}],a={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,l=Object.keys(e);o<l.length;o++){var d=l[o];i[a[d]!=null?a[d]:1][d]=e[d]}for(var u=0;u<i.length;u++){var c=s.serialize(i[u]);c&&(t["CMCD-"+r[u]]=c)}return t},s.toQuery=function(e){return"CMCD="+encodeURIComponent(s.serialize(e))},s.appendQueryToUri=function(e,t){if(!t)return e;var r=e.includes("?")?"&":"?";return""+e+r+t},s}(),Il=function(){function s(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=x.log.bind(x,"[content-steering]:"),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.ERROR,this.onError,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.ERROR,this.onError,this))},n.startLoad=function(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){var e=Math.max(1e3*this.timeToLoad-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else this.loadSteeringManifest(this.uri)},n.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)},n.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},n.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter(function(r){return r!==e}))},n.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},n.onManifestLoaded=function(e,t){var r=t.contentSteering;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},n.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},n.onError=function(e,t){var r=t.errorAction;if((r==null?void 0:r.action)===m&&r.flags===_){var i=this.pathwayPriority,a=this.pathwayId;this.penalizedPathways[a]||(this.penalizedPathways[a]=performance.now()),!i&&this.levels&&(i=this.levels.reduce(function(o,l){return o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o},[])),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==a)}},n.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t):e},n.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(t){return e===t.pathwayId})},n.updatePathwayPriority=function(e){var t;this.pathwayPriority=e;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(function(c){i-r[c]>3e5&&delete r[c]});for(var a=0;a<e.length;a++){var o=e[a];if(!r[o]){if(o===this.pathwayId)return;var l=this.hls.nextLoadLevel,d=this.hls.levels[l];if((t=this.getLevelsForPathway(o)).length>0){this.log('Setting Pathway to "'+o+'"'),this.pathwayId=o,this.hls.trigger(E.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[l];d&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==d.bitrate&&this.log("Unstable Pathways change from bitrate "+d.bitrate+" to "+u.bitrate),this.hls.nextLoadLevel=l);break}}}},n.clonePathways=function(e){var t=this,r=this.levels;if(r){var i={},a={};e.forEach(function(o){var l=o.ID,d=o["BASE-ID"],u=o["URI-REPLACEMENT"];if(!r.some(function(f){return f.pathwayId===l})){var c=t.getLevelsForPathway(d).map(function(f){var v=X({},f);v.details=void 0,v.url=Us(f.uri,f.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",u);var p=new Ve(f.attrs);p["PATHWAY-ID"]=l;var T=p.AUDIO&&p.AUDIO+"_clone_"+l,S=p.SUBTITLES&&p.SUBTITLES+"_clone_"+l;T&&(i[p.AUDIO]=T,p.AUDIO=T),S&&(a[p.SUBTITLES]=S,p.SUBTITLES=S),v.attrs=p;var y=new kr(v);return U(y,"audio",T),U(y,"text",S),y});r.push.apply(r,c),Ns(t.audioTracks,i,u,l),Ns(t.subtitleTracks,a,u,l)}})}},n.loadSteeringManifest=function(e){var t,r=this,i=this.hls.config,a=i.loader;this.loader&&this.loader.destroy(),this.loader=new a(i);try{t=new self.URL(e)}catch{return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if(t.protocol!=="data:"){var o=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+o)}var l={responseType:"json",url:t.href},d=i.steeringManifestLoadPolicy.default,u=d.errorRetry||d.timeoutRetry||{},c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},f={onSuccess:function(v,p,T,S){r.log('Loaded steering manifest: "'+t+'"');var y=v.data;if(y.VERSION===1){r.updated=performance.now(),r.timeToLoad=y.TTL;var b=y["RELOAD-URI"],D=y["PATHWAY-CLONES"],w=y["PATHWAY-PRIORITY"];if(b)try{r.uri=new self.URL(b,t).href}catch{return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+b)}r.scheduleRefresh(r.uri||T.url),D&&r.clonePathways(D),w&&r.updatePathwayPriority(w)}else r.log("Steering VERSION "+y.VERSION+" not supported!")},onError:function(v,p,T,S){if(r.log("Error loading steering manifest: "+v.code+" "+v.text+" ("+p.url+")"),r.stopLoad(),v.code===410)return r.enabled=!1,void r.log("Steering manifest "+p.url+" no longer available");var y=1e3*r.timeToLoad;if(v.code!==429)r.scheduleRefresh(r.uri||p.url,y);else{var b=r.loader;if(typeof(b==null?void 0:b.getResponseHeader)=="function"){var D=b.getResponseHeader("Retry-After");D&&(y=1e3*parseFloat(D))}r.log("Steering manifest "+p.url+" rate limited")}},onTimeout:function(v,p,T){r.log("Timeout loading steering manifest ("+p.url+")"),r.scheduleRefresh(r.uri||p.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(l,c,f)},n.scheduleRefresh=function(e,t){var r=this;t===void 0&&(t=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(function(){r.loadSteeringManifest(e)},t)},s}();function Ns(s,n,e,t){s&&Object.keys(n).forEach(function(r){var i=s.filter(function(a){return a.groupId===r}).map(function(a){var o=X({},a);return o.details=void 0,o.attrs=new Ve(o.attrs),o.url=o.attrs.URI=Us(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),o.groupId=o.attrs["GROUP-ID"]=n[r],o.attrs["PATHWAY-ID"]=t,o});s.push.apply(s,i)})}function Us(s,n,e,t){var r,i=t.HOST,a=t.PARAMS,o=t[e];n&&(r=o==null?void 0:o[n])&&(s=r);var l=new self.URL(s);return i&&!r&&(l.host=i),a&&Object.keys(a).sort().forEach(function(d){d&&l.searchParams.set(d,a[d])}),l.href}var Cl=/^age:\s*[\d.]+\s*$/im,Bs=function(){function s(e){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=e&&e.xhrSetup||null,this.stats=new gt,this.retryDelay=0}var n=s.prototype;return n.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},n.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},n.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},n.loadInternal=function(){var e=this,t=this.config,r=this.context;if(t){var i=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0;var o=this.xhrSetup;o?Promise.resolve().then(function(){if(!e.stats.aborted)return o(i,r.url)}).catch(function(l){return i.open("GET",r.url,!0),o(i,r.url)}).then(function(){e.stats.aborted||e.openAndSendXhr(i,r,t)}).catch(function(l){e.callbacks.onError({code:i.status,text:l.message},r,i,a)}):this.openAndSendXhr(i,r,t)}},n.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var i=this.context.headers,a=r.loadPolicy,o=a.maxTimeToFirstByteMs,l=a.maxLoadTimeMs;if(i)for(var d in i)e.setRequestHeader(d,i[d]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=o&&Z(o)?o:l,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},n.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,a=this.config;if(!r.aborted&&i>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),i===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var o=t.status,l=t.responseType!=="text";if(o>=200&&o<300&&(l&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var d=l?t.response:t.responseText,u=t.responseType==="arraybuffer"?d.byteLength:d.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(r,e,d,t),!this.callbacks)return;var f={url:t.responseURL,data:d,code:o};this.callbacks.onSuccess(f,r,e,t)}else{var v=a.loadPolicy.errorRetry;Wr(v,r.retry,!1,o)?this.retry(v):(x.error(o+" while loading "+e.url),this.callbacks.onError({code:o,text:t.statusText},e,t,r))}}}},n.loadtimeout=function(){var e,t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry;if(Wr(t,this.stats.retry,!0))this.retry(t);else{x.warn("timeout while loading "+this.context.url);var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}},n.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=Ci(e,r.retry),r.retry++,x.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+t.url+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},n.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},n.getCacheAge=function(){var e=null;if(this.loader&&Cl.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},s}(),xl=/(\d+)-(\d+)\/(\d+)/,Gs=function(){function s(e){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=e.fetchSetup||Pl,this.controller=new self.AbortController,this.stats=new gt}var n=s.prototype;return n.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},n.abortInternal=function(){var e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},n.load=function(e,t,r){var i=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var o=function(p,T){var S={method:"GET",mode:"cors",credentials:"same-origin",signal:T,headers:new self.Headers(X({},p.headers))};return p.rangeEnd&&S.headers.set("Range","bytes="+p.rangeStart+"-"+String(p.rangeEnd-1)),S}(e,this.controller.signal),l=r.onProgress,d=e.responseType==="arraybuffer",u=d?"byteLength":"length",c=t.loadPolicy,f=c.maxTimeToFirstByteMs,v=c.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,o),self.clearTimeout(this.requestTimeout),t.timeout=f&&Z(f)?f:v,this.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(a,e,i.response)},t.timeout),self.fetch(this.request).then(function(p){i.response=i.loader=p;var T=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=v,i.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(a,e,i.response)},v-(T-a.loading.start)),!p.ok){var S=p.status,y=p.statusText;throw new Ol(y||"fetch, bad network response",S,p)}return a.loading.first=T,a.total=function(b){var D=b.get("Content-Range");if(D){var w=function(N){var G=xl.exec(N);if(G)return parseInt(G[2])-parseInt(G[1])+1}(D);if(Z(w))return w}var O=b.get("Content-Length");if(O)return parseInt(O)}(p.headers)||a.total,l&&Z(t.highWaterMark)?i.loadProgressively(p,a,e,t.highWaterMark,l):d?p.arrayBuffer():e.responseType==="json"?p.json():p.text()}).then(function(p){var T=i.response;self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var S=p[u];S&&(a.loaded=a.total=S);var y={url:T.url,data:p,code:T.status};l&&!Z(t.highWaterMark)&&l(a,e,p,T),r.onSuccess(y,a,e,T)}).catch(function(p){if(self.clearTimeout(i.requestTimeout),!a.aborted){var T=p&&p.code||0,S=p?p.message:null;r.onError({code:T,text:S},e,p?p.details:null,a)}})},n.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},n.loadProgressively=function(e,t,r,i,a){i===void 0&&(i=0);var o=new ms,l=e.body.getReader();return function d(){return l.read().then(function(u){if(u.done)return o.dataLength&&a(t,r,o.flush(),e),Promise.resolve(new ArrayBuffer(0));var c=u.value,f=c.length;return t.loaded+=f,f<i||o.dataLength?(o.push(c),o.dataLength>=i&&a(t,r,o.flush(),e)):a(t,r,c,e),d()}).catch(function(){return Promise.reject()})}()},s}();function Pl(s,n){return new self.Request(s.url,n)}var Ol=function(s){function n(e,t,r){var i;return(i=s.call(this,e)||this).code=void 0,i.details=void 0,i.code=t,i.details=r,i}return ae(n,s),n}(xe(Error)),Ml=/\s/,Fl=H(H({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,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,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Bs,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Zo,bufferController:ol,capLevelController:kl,errorController:R,fpsController:Ll,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:hi,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:{newCue:function(s,n,e,t){for(var r,i,a,o,l,d=[],u=self.VTTCue||self.TextTrackCue,c=0;c<t.rows.length;c++)if(a=!0,o=0,l="",!(r=t.rows[c]).isEmpty()){for(var f,v=0;v<r.chars.length;v++)Ml.test(r.chars[v].uchar)&&a?o++:(l+=r.chars[v].uchar,a=!1);r.cueStartTime=n,n===e&&(e+=1e-4),o>=16?o--:o++;var p=Rs(l.trim()),T=Sa(n,e,p);s!=null&&(f=s.cues)!=null&&f.getCueById(T)||((i=new u(n,e,p)).id=T,i.line=c+1,i.align="left",i.position=10+Math.min(80,10*Math.floor(8*o/32)),d.push(i))}return s&&d.length&&(d.sort(function(S,y){return S.line==="auto"||y.line==="auto"?0:S.line>8&&y.line>8?y.line-S.line:S.line-y.line}),d.forEach(function(S){return pn(s,S)})),d}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:il,subtitleTrackController:al,timelineController:Sl,audioStreamController:el,audioTrackController:tl,emeController:Ms,cmcdController:Dl,contentSteeringController:Il});function Ia(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Ia):Object.keys(s).reduce(function(n,e){return n[e]=Ia(s[e]),n},{}):s}function Nl(s){var n=s.loader;n!==Gs&&n!==Bs?(x.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}()&&(s.loader=Gs,s.progressive=!0,s.enableSoftwareAES=!0,x.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Hs=function(){function s(e){e===void 0&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new In,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,qe(e.debug||!1,"Hls instance");var t=this.config=function(te,J){if((J.liveSyncDurationCount||J.liveMaxLatencyDurationCount)&&(J.liveSyncDuration||J.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(J.liveMaxLatencyDurationCount!==void 0&&(J.liveSyncDurationCount===void 0||J.liveMaxLatencyDurationCount<=J.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(J.liveMaxLatencyDuration!==void 0&&(J.liveSyncDuration===void 0||J.liveMaxLatencyDuration<=J.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var oe=Ia(te),me=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(ue){var ve=(ue==="level"?"playlist":ue)+"LoadPolicy",Te=J[ve]===void 0,ye=[];me.forEach(function(we){var Ce=ue+"Loading"+we,Oe=J[Ce];if(Oe!==void 0&&Te){ye.push(Ce);var Ge=oe[ve].default;switch(J[ve]={default:Ge},we){case"TimeOut":Ge.maxLoadTimeMs=Oe,Ge.maxTimeToFirstByteMs=Oe;break;case"MaxRetry":Ge.errorRetry.maxNumRetry=Oe,Ge.timeoutRetry.maxNumRetry=Oe;break;case"RetryDelay":Ge.errorRetry.retryDelayMs=Oe,Ge.timeoutRetry.retryDelayMs=Oe;break;case"MaxRetryTimeout":Ge.errorRetry.maxRetryDelayMs=Oe,Ge.timeoutRetry.maxRetryDelayMs=Oe}}}),ye.length&&x.warn('hls.js config: "'+ye.join('", "')+'" setting(s) are deprecated, use "'+ve+'": '+JSON.stringify(J[ve]))}),H(H({},oe),J)}(s.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&Nl(t);var r=t.abrController,i=t.bufferController,a=t.capLevelController,o=t.errorController,l=t.fpsController,d=new o(this),u=this.abrController=new r(this),c=this.bufferController=new i(this),f=this.capLevelController=new a(this),v=new l(this),p=new Je(this),T=new Zn(this),S=t.contentSteeringController,y=S?new S(this):null,b=this.levelController=new P(this,y),D=new le(this),w=new ze(this.config),O=this.streamController=new Jo(this,D,w);f.setStreamController(O),v.setStreamController(O);var N=[p,b,O];y&&N.splice(1,0,y),this.networkControllers=N;var G=[u,c,f,v,T,D];this.audioTrackController=this.createController(t.audioTrackController,N);var W=t.audioStreamController;W&&N.push(new W(this,D,w)),this.subtitleTrackController=this.createController(t.subtitleTrackController,N);var q=t.subtitleStreamController;q&&N.push(new q(this,D,w)),this.createController(t.timelineController,G),w.emeController=this.emeController=this.createController(t.emeController,G),this.cmcdController=this.createController(t.cmcdController,G),this.latencyController=this.createController(ea,G),this.coreComponents=G,N.push(d);var V=d.onErrorOut;typeof V=="function"&&this.on(E.ERROR,V,d)}s.isSupported=function(){return function(){var e=Kr();if(!e)return!1;var t=Qa(),r=e&&typeof e.isTypeSupported=="function"&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!r&&!!i}()};var n=s.prototype;return n.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},n.on=function(e,t,r){r===void 0&&(r=this),this._emitter.on(e,t,r)},n.once=function(e,t,r){r===void 0&&(r=this),this._emitter.once(e,t,r)},n.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},n.off=function(e,t,r,i){r===void 0&&(r=this),this._emitter.off(e,t,r,i)},n.listeners=function(e){return this._emitter.listeners(e)},n.emit=function(e,t,r){return this._emitter.emit(e,t,r)},n.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){x.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(E.ERROR,{type:Q.OTHER_ERROR,details:F.INTERNAL_EXCEPTION,fatal:!1,event:e,error:r})}return!1},n.listenerCount=function(e){return this._emitter.listenerCount(e)},n.destroy=function(){x.log("destroy"),this.trigger(E.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;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},n.attachMedia=function(e){x.log("attachMedia"),this._media=e,this.trigger(E.MEDIA_ATTACHING,{media:e})},n.detachMedia=function(){x.log("detachMedia"),this.trigger(E.MEDIA_DETACHING,void 0),this._media=null},n.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=be.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});x.log("loadSource:"+i),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(E.MANIFEST_LOADING,{url:e})},n.startLoad=function(e){e===void 0&&(e=-1),x.log("startLoad("+e+")"),this.networkControllers.forEach(function(t){t.startLoad(e)})},n.stopLoad=function(){x.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})},n.swapAudioCodec=function(){x.log("swapAudioCodec"),this.streamController.swapAudioCodec()},n.recoverMediaError=function(){x.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},n.removeLevel=function(e,t){t===void 0&&(t=0),this.levelController.removeLevel(e,t)},K(s,[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){x.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){x.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){x.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){x.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){x.log("set startLevel:"+e),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(x.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){Li.indexOf(e)>-1&&(this._maxHdcpLevel=e)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=r===-1&&t&&t.length?t.length-1:r,i)for(var a=e;a--;){var o=t[a].attrs["HDCP-LEVEL"];if(o&&o<=i)return a}return e}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{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.4.3"}},{key:"Events",get:function(){return E}},{key:"ErrorTypes",get:function(){return Q}},{key:"ErrorDetails",get:function(){return F}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:Fl},set:function(e){s.defaultConfig=e}}]),s}();return Hs.defaultConfig=void 0,Hs},typeof Js=="object"&&typeof Ba!="undefined"?Ba.exports=B():typeof define=="function"&&define.amd?define(B):(L=typeof globalThis!="undefined"?globalThis:L||self).Hls=B()})(!1)});var ti=class{addEventListener(){}removeEventListener(){}dispatchEvent(C){return!0}};if(typeof DocumentFragment=="undefined"){class I extends ti{}globalThis.DocumentFragment=I}var Ui=class extends ti{},Fa=class extends ti{},$l={get(I){},define(I,C,L){},upgrade(I){},whenDefined(I){return Promise.resolve(Ui)}},Bi,Na=class{constructor(C,L={}){vt(this,Bi,void 0);Rt(this,Bi,L==null?void 0:L.detail)}get detail(){return ft(this,Bi)}initCustomEvent(){}};Bi=new WeakMap;function Zl(I,C){return new Ui}var zs={document:{createElement:Zl},DocumentFragment,customElements:$l,CustomEvent:Na,EventTarget:ti,HTMLElement:Ui,HTMLVideoElement:Fa},Xs=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Nn=Xs?zs:globalThis,Fu=Xs?zs.document:globalThis.document;var Bn=Ws(Qs(),1),ao=Ws($s(),1),eu=ao.default,_t=eu,Gi=class extends Error{constructor(I,C=Gi.MEDIA_ERR_CUSTOM,L,B){var j;super(I),this.name="MediaError",this.code=C,this.context=B,this.fatal=L!=null?L:C>=Gi.MEDIA_ERR_NETWORK&&C<=Gi.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(j=Gi.defaultMessages[this.code])!=null?j:"")}},bt=Gi;bt.MEDIA_ERR_ABORTED=1,bt.MEDIA_ERR_NETWORK=2,bt.MEDIA_ERR_DECODE=3,bt.MEDIA_ERR_SRC_NOT_SUPPORTED=4,bt.MEDIA_ERR_ENCRYPTED=5,bt.MEDIA_ERR_CUSTOM=100,bt.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 tu=I=>I==null,so=(I,C)=>tu(C)?!1:I in C,Ha={ANY:"any",MUTED:"muted"},Mr={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},Fr={MSE:"mse",NATIVE:"native"},Ka={HEADER:"header",QUERY:"query",NONE:"none"},Bu=Object.values(Ka),vr={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},qa={HLS:vr.M3U8},Gu=Object.keys(qa),Hu=[...Object.values(vr),"hls","HLS"],fr=(I,C,L,B,j=I)=>{j.addEventListener(C,L,B),I.addEventListener("teardown",()=>{j.removeEventListener(C,L)},{once:!0})};function ru(I,C,L){C&&L>C&&(L=C);for(let B=0;B<I.length;B++)if(I.start(B)<=L&&I.end(B)>=L)return!0;return!1}var iu=I=>{let C=I.indexOf("?");if(C<0)return[I];let L=I.slice(0,C),B=I.slice(C);return[L,B]},Gn=I=>{let C=I.type;if(C){let B=C.toUpperCase();return so(B,qa)?qa[B]:C}let{src:L}=I;return L?nu(L):""},oo=I=>I==="VOD"?Mr.ON_DEMAND:Mr.LIVE,lo=I=>I==="EVENT"?Number.POSITIVE_INFINITY:I==="VOD"?Number.NaN:0,nu=I=>{let C="";try{C=new URL(I).pathname}catch{console.error("invalid url")}let L=C.lastIndexOf(".");if(L<0)return"";let B=C.slice(L+1).toUpperCase();return so(B,vr)?vr[B]:""},au=Object.values(Ha),Zs=I=>typeof I=="boolean"||typeof I=="string"&&au.includes(I),su=({autoplay:I},C,L)=>{let B=!1,j=!1,H=Zs(I)?I:!!I,z=()=>{B||fr(C,"playing",()=>{B=!0},{once:!0})};if(z(),fr(C,"loadstart",()=>{B=!1,z(),Ga(C,H)},{once:!0}),fr(C,"loadstart",()=>{L||(j=!Number.isFinite(C.duration)),Ga(C,H)},{once:!0}),L&&L.once(_t.Events.LEVEL_LOADED,(K,ee)=>{var X;j=(X=ee.details.live)!=null?X:!1}),!H){let K=()=>{!j||(L!=null&&L.liveSyncPosition?C.currentTime=L.liveSyncPosition:Number.isFinite(C.seekable.end(0))&&(C.currentTime=C.seekable.end(0)))};L&&fr(C,"play",()=>{C.preload==="metadata"?L.once(_t.Events.LEVEL_UPDATED,K):K()},{once:!0})}return K=>{B||(H=Zs(K)?K:!!K,Ga(C,H))}},Ga=(I,C)=>{if(!C)return;let L=I.muted,B=()=>I.muted=L;switch(C){case Ha.ANY:I.play().catch(()=>{I.muted=!0,I.play().catch(B)});break;case Ha.MUTED:I.muted=!0,I.play().catch(B);break;default:I.play().catch(()=>{});break}},ou=({preload:I,src:C},L,B)=>{let j=ge=>{ge!=null&&["","none","metadata","auto"].includes(ge)?L.setAttribute("preload",ge):L.removeAttribute("preload")};if(!B)return j(I),j;let H=!1,z=!1,K=B.config.maxBufferLength,ee=B.config.maxBufferSize,X=ge=>{j(ge);let ne=ge!=null?ge:L.preload;z||ne==="none"||(ne==="metadata"?(B.config.maxBufferLength=1,B.config.maxBufferSize=1):(B.config.maxBufferLength=K,B.config.maxBufferSize=ee),ae())},ae=()=>{!H&&C&&(H=!0,B.loadSource(C))};return fr(L,"play",()=>{z=!0,B.config.maxBufferLength=K,B.config.maxBufferSize=ee,ae()},{once:!0}),X(I),X};function lu(I,C){C.on(_t.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(j,{tracks:H})=>{H.forEach(z=>{var K;let ee=(K=z.subtitleTrack)!=null?K:z.closedCaptions,X=C.subtitleTracks.findIndex(({lang:ae,name:ge,type:ne})=>ae==(ee==null?void 0:ee.lang)&&ge===z.label&&ne.toLowerCase()===z.kind);uo(I,z.kind,z.label,ee==null?void 0:ee.lang,`${z.kind}${X}`)})});let L=()=>{var j;if(!C.subtitleTracks.length)return;let H=Array.from(I.textTracks).find(K=>K.id&&K.mode==="showing"&&["subtitles","captions"].includes(K.kind)),z=`${(j=C.subtitleTracks[C.subtitleTrack])==null?void 0:j.type.toLowerCase()}${C.subtitleTrack}`;if(H&&(C.subtitleTrack<0||(H==null?void 0:H.id)!==z)){let K=C.subtitleTracks.findIndex(({lang:ee,name:X,type:ae})=>ee==H.language&&X===H.label&&ae.toLowerCase()===H.kind);C.subtitleTrack=K}H&&(H==null?void 0:H.id)===z&&H.cues&&Array.from(H.cues).forEach(K=>{H.addCue(K)})};I.textTracks.addEventListener("change",L),C.on(_t.Events.CUES_PARSED,(j,{track:H,cues:z})=>{let K=I.textTracks.getTrackById(H);if(!K)return;let ee=K.mode==="disabled";ee&&(K.mode="hidden"),z.forEach(X=>{var ae;(ae=K.cues)!=null&&ae.getCueById(X.id)||K.addCue(X)}),ee&&(K.mode="disabled")}),C.once(_t.Events.DESTROYING,()=>{I.textTracks.removeEventListener("change",L),I.querySelectorAll("track[data-removeondestroy]").forEach(j=>{j.remove()})});let B=()=>{Array.from(I.textTracks).forEach(j=>{var H,z;if(!["subtitles","caption"].includes(j.kind)&&j.label==="thumbnails"){if(!((H=j.cues)!=null&&H.length)){let K=I.querySelector('track[label="thumbnails"]'),ee=(z=K==null?void 0:K.getAttribute("src"))!=null?z:"";K==null||K.removeAttribute("src"),setTimeout(()=>{K==null||K.setAttribute("src",ee)},0)}j.mode!=="hidden"&&(j.mode="hidden")}})};C.once(_t.Events.MANIFEST_LOADED,B),C.once(_t.Events.MEDIA_ATTACHED,B)}function uo(I,C,L,B,j){let H=document.createElement("track");return H.kind=C,H.label=L,B&&(H.srclang=B),j&&(H.id=j),H.track.mode=["subtitles","captions"].includes(C)?"disabled":"hidden",H.setAttribute("data-removeondestroy",""),I.append(H),H.track}var Hn="cuepoints",Va=Object.freeze({label:Hn}),co=(I,{label:C=Hn}=Va)=>{var L;return(L=Array.from(I.querySelectorAll("track")).find(B=>B.track.label===C&&B.track.kind==="metadata"))==null?void 0:L.track};async function uu(I,C,L=Va){let B=co(I,L);if(!B){let{label:j=Hn}=L;B=uo(I,"metadata",j),B.mode="hidden",await new Promise(H=>setTimeout(()=>H(void 0),0))}return B.mode!=="hidden"&&(B.mode="hidden"),[...C].sort(({time:j},{time:H})=>H-j).forEach(({time:j,value:H})=>{var z,K;let ee=Array.prototype.findIndex.call(B==null?void 0:B.cues,Ae=>Ae.startTime>=j),X=(z=B==null?void 0:B.cues)==null?void 0:z[ee],ae=X?X.startTime:Number.isFinite(I.duration)?I.duration:Number.MAX_SAFE_INTEGER,ge=(K=B==null?void 0:B.cues)==null?void 0:K[ee-1];ge&&(ge.endTime=j);let ne=new VTTCue(j,ae,JSON.stringify(H!=null?H:null));B.addCue(ne)}),B}var du=I=>({time:I.startTime,value:JSON.parse(I.text)});function cu(I,C={label:Hn}){var L,B;let j=co(I,C);if(!((L=j==null?void 0:j.activeCues)!=null&&L.length))return;let{currentTime:H}=I,z=Array.prototype.find.call((B=j.activeCues)!=null?B:[],({startTime:K,endTime:ee})=>K<=H&&ee>H);return du(z)}async function hu(I,C=Va){return new Promise(L=>{fr(I,"loadstart",async()=>{let B=await uu(I,[],C);fr(I,"cuechange",()=>{let j=cu(I);if(j){let H=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:j});I.dispatchEvent(H)}},{},B),L(B)})})}function ho(I,C){if(C){let L=C.playingDate;if(L!=null)return new Date(L.getTime()-I.currentTime*1e3)}return typeof I.getStartDate=="function"?I.getStartDate():new Date(NaN)}function fo(I,C){if(C&&C.playingDate)return C.playingDate;if(typeof I.getStartDate=="function"){let L=I.getStartDate();return new Date(L.getTime()+I.currentTime*1e3)}return new Date(NaN)}var fu=async I=>fetch(I).then(C=>C.text()).then(C=>{let L=C.split(`
|
|
46
|
-
`).find((B,j,H)=>j&&H[j-1].startsWith("#EXT-X-STREAM-INF"));return fetch(
|
|
47
|
-
`))}),
|
|
42
|
+
`),f=[],v=(o=n.baseTime,(l=n.timescale)===void 0&&(l=1),ua(o,9e4,1/l)),p="00:00.000",T=0,S=0,y=!0;d.oncue=function(b){var C=e[t],D=e.ccOffset,O=(T-v)/9e4;C!=null&&C.new&&(S!==void 0?D=e.ccOffset=C.start:function(q,V,te){var J=q[V],oe=q[J.prevCC];if(!oe||!oe.new&&J.new)return q.ccOffset=q.presentationOffset=J.start,void(J.new=!1);for(;(me=oe)!=null&&me.new;){var me;q.ccOffset+=J.start-oe.start,J.new=!1,oe=q[(J=oe).prevCC]}q.presentationOffset=te}(e,t,O)),O&&(D=O-e.presentationOffset);var N=b.endTime-b.startTime,G=xt(9e4*(b.startTime+D-S),9e4*r)/9e4;b.startTime=Math.max(G,0),b.endTime=Math.max(G+N,0);var W=b.text.trim();b.text=decodeURIComponent(encodeURIComponent(W)),b.id||(b.id=Sa(b.startTime,b.endTime,W)),b.endTime>0&&f.push(b)},d.onparsingerror=function(b){u=b},d.onflush=function(){u?a(u):i(f)},h.forEach(function(b){if(y){if(ba(b,"X-TIMESTAMP-MAP=")){y=!1,b.slice(16).split(",").forEach(function(C){ba(C,"LOCAL:")?p=C.slice(6):ba(C,"MPEGTS:")&&(T=parseInt(C.slice(7)))});try{S=function(C){var D=parseInt(C.slice(-3)),O=parseInt(C.slice(-6,-4)),N=parseInt(C.slice(-9,-7)),G=C.length>9?parseInt(C.substring(0,C.indexOf(":"))):0;if(!(Z(D)&&Z(O)&&Z(N)&&Z(G)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+C);return D+=1e3*O,(D+=6e4*N)+36e5*G}(p)/1e3}catch(C){u=C}return}b===""&&(y=!1)}d.parse(b+`
|
|
43
|
+
`)}),d.flush()}var Aa="stpp.ttml.im1t",Is=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Cs=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Al={left:"start",center:"center",right:"end",start:"start",end:"end"};function xs(s,n,e,t){var r=Pe(new Uint8Array(s),["mdat"]);if(r.length!==0){var i,a,o,l,u=r.map(function(h){return At(h)}),d=(i=n.baseTime,a=1,(o=n.timescale)===void 0&&(o=1),l===void 0&&(l=!1),ua(i,a,1/o,l));try{u.forEach(function(h){return e(function(f,v){var p=new DOMParser().parseFromString(f,"text/xml").getElementsByTagName("tt")[0];if(!p)throw new Error("Invalid ttml");var T={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(T).reduce(function(O,N){return O[N]=p.getAttribute("ttp:"+N)||T[N],O},{}),y=p.getAttribute("xml:space")!=="preserve",b=Ps(La(p,"styling","style")),C=Ps(La(p,"layout","region")),D=La(p,"body","[begin]");return[].map.call(D,function(O){var N=Os(O,y);if(!N||!O.hasAttribute("begin"))return null;var G=wa(O.getAttribute("begin"),S),W=wa(O.getAttribute("dur"),S),q=wa(O.getAttribute("end"),S);if(G===null)throw Ms(O);if(q===null){if(W===null)throw Ms(O);q=G+W}var V=new Ta(G-v,q-v,N);V.id=Sa(V.startTime,V.endTime,V.text);var te=function(me,ue,ve){var Te="http://www.w3.org/ns/ttml#styling",ye=null,we=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],Ce=me!=null&&me.hasAttribute("style")?me.getAttribute("style"):null;return Ce&&ve.hasOwnProperty(Ce)&&(ye=ve[Ce]),we.reduce(function(Oe,Ge){var bt=ka(ue,Te,Ge)||ka(me,Te,Ge)||ka(ye,Te,Ge);return bt&&(Oe[Ge]=bt),Oe},{})}(C[O.getAttribute("region")],b[O.getAttribute("style")],b),J=te.textAlign;if(J){var oe=Al[J];oe&&(V.lineAlign=oe),V.align=J}return X(V,te),V}).filter(function(O){return O!==null})}(h,d))})}catch(h){t(h)}}else t(new Error("Could not parse IMSC1 mdat"))}function La(s,n,e){var t=s.getElementsByTagName(n)[0];return t?[].slice.call(t.querySelectorAll(e)):[]}function Ps(s){return s.reduce(function(n,e){var t=e.getAttribute("xml:id");return t&&(n[t]=e),n},{})}function Os(s,n){return[].slice.call(s.childNodes).reduce(function(e,t,r){var i;return t.nodeName==="br"&&r?e+`
|
|
44
|
+
`:(i=t.childNodes)!=null&&i.length?Os(t,n):n?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function ka(s,n,e){return s&&s.hasAttributeNS(n,e)?s.getAttributeNS(n,e):null}function Ms(s){return new Error("Could not parse ttml timestamp "+s)}function wa(s,n){if(!s)return null;var e=ws(s);return e===null&&(Is.test(s)?e=function(t,r){var i=Is.exec(t),a=(0|i[4])+(0|i[5])/r.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+a/r.frameRate}(s,n):Cs.test(s)&&(e=function(t,r){var i=Cs.exec(t),a=Number(i[1]);switch(i[2]){case"h":return 3600*a;case"m":return 60*a;case"ms":return 1e3*a;case"f":return a/r.frameRate;case"t":return a/r.tickRate}return a}(s,n))),e}var Ll=function(){function s(e){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.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.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 t=new Cn(this,"textTrack1"),r=new Cn(this,"textTrack2"),i=new Cn(this,"textTrack3"),a=new Cn(this,"textTrack4");this.cea608Parser1=new Ls(1,t,r),this.cea608Parser2=new Ls(3,i,a)}e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}var n=s.prototype;return n.destroy=function(){var e=this.hls;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},n.addCues=function(e,t,r,i,a){for(var o,l,u,d,h=!1,f=a.length;f--;){var v=a[f],p=(o=v[0],l=v[1],u=t,d=r,Math.min(l,d)-Math.max(o,u));if(p>=0&&(v[0]=Math.min(v[0],t),v[1]=Math.max(v[1],r),h=!0,p/(r-t)>.5))return}if(h||a.push([t,r]),this.config.renderTextTracksNatively){var T=this.captionsTracks[e];this.Cues.newCue(T,t,r,i)}else{var S=this.Cues.newCue(null,t,r,i);this.hls.trigger(E.CUES_PARSED,{type:"captions",cues:S,track:e})}},n.onInitPtsFound=function(e,t){var r=this,i=t.frag,a=t.id,o=t.initPTS,l=t.timescale,u=this.unparsedVttFrags;a==="main"&&(this.initPTS[i.cc]={baseTime:o,timescale:l}),u.length&&(this.unparsedVttFrags=[],u.forEach(function(d){r.onFragLoaded(E.FRAG_LOADED,d)}))},n.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r<t.textTracks.length;r++){var i=t.textTracks[r];if(i[e])return i}return null},n.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},n.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,r=this.captionsTracks,i=this.media,a=t[e],o=a.label,l=a.languageCode,u=this.getExistingTrack(e);if(u)r[e]=u,ur(r[e]),br(r[e],i);else{var d=this.createTextTrack("captions",o,l);d&&(d[e]=!0,r[e]=d)}}},n.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},n.createTextTrack=function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)},n.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},n.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach(function(t){ur(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}},n.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},n._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)ur(t[r])}},n.onSubtitleTracksUpdated=function(e,t){var r=this,i=t.subtitleTracks||[],a=i.some(function(u){return u.textCodec===Aa});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){if(ys(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:null;this.tracks.forEach(function(u,d){var h;if(o&&d<o.length){for(var f=null,v=0;v<o.length;v++)if(kl(o[v],u)){f=o[v];break}f&&(h=f)}if(h)ur(h);else{var p=r._captionsOrSubtitlesFromCharacteristics(u);(h=r.createTextTrack(p,u.name,u.lang))&&(h.mode="disabled")}h&&(h.groupId=u.groupId,r.textTracks.push(h))})}else if(this.tracks.length){var l=this.tracks.map(function(u){return{label:u.name,kind:u.type.toLowerCase(),default:u.default,subtitleTrack:u}});this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}},n._captionsOrSubtitlesFromCharacteristics=function(e){if(e.attrs.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),r=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&r)return"captions"}return"subtitles"},n.onManifestLoaded=function(e,t){var r=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(function(i){var a=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(a){var o="textTrack"+a[1],l=r.captionsProperties[o];l&&(l.label=i.name,i.lang&&(l.languageCode=i.lang),l.media=i)}})},n.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]},n.onFragLoading=function(e,t){var r=this.cea608Parser1,i=this.cea608Parser2,a=this.lastSn,o=this.lastPartIndex;if(this.enabled&&r&&i&&t.frag.type===Ne){var l,u,d=t.frag.sn,h=(l=t==null||(u=t.part)==null?void 0:u.index)!=null?l:-1;d===a+1||d===a&&h===o+1||(r.reset(),i.reset()),this.lastSn=d,this.lastPartIndex=h}},n.onFragLoaded=function(e,t){var r=t.frag,i=t.payload,a=this.initPTS,o=this.unparsedVttFrags;if(r.type===It)if(i.byteLength){if(!a[r.cc])return o.push(t),void(a.length&&this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")}));var l=r.decryptdata,u="stats"in t;if(l==null||!l.encrypted||u){var d=this.tracks[r.level],h=this.vttCCs;h[r.cc]||(h[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),d&&d.textCodec===Aa?this._parseIMSC1(r,i):this._parseVTTs(r,i,h)}}else this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},n._parseIMSC1=function(e,t){var r=this,i=this.hls;xs(t,this.initPTS[e.cc],function(a){r._appendCues(a,e.level),i.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(a){x.log("Failed to parse IMSC1: "+a),i.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:a})})},n._parseVTTs=function(e,t,r){var i,a=this,o=this.hls;Sl((i=e.initSegment)!=null&&i.data?Xt(e.initSegment.data,new Uint8Array(t)):t,this.initPTS[e.cc],r,e.cc,e.start,function(l){a._appendCues(l,e.level),o.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(l){a._fallbackToIMSC1(e,t),x.log("Failed to parse VTT cue: "+l),o.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:l})})},n._fallbackToIMSC1=function(e,t){var r=this,i=this.tracks[e.level];i.textCodec||xs(t,this.initPTS[e.cc],function(){i.textCodec=Aa,r._parseIMSC1(e,t)},function(){i.textCodec="wvtt"})},n._appendCues=function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[t];if(!i||i.mode==="disabled")return;e.forEach(function(l){return pn(i,l)})}else{var a=this.tracks[t];if(!a)return;var o=a.default?"default":"subtitles"+t;r.trigger(E.CUES_PARSED,{type:"subtitles",cues:e,track:o})}},n.onFragDecrypted=function(e,t){var r=t.frag;if(r.type===It){if(!this.initPTS[r.cc])return void this.unparsedVttFrags.push(t);this.onFragLoaded(E.FRAG_LOADED,t)}},n.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},n.onFragParsingUserdata=function(e,t){var r=this.cea608Parser1,i=this.cea608Parser2;if(this.enabled&&r&&i){var a=t.frag,o=t.samples;if(a.type!==Ne||this.closedCaptionsForLevel(a)!=="NONE")for(var l=0;l<o.length;l++){var u=o[l].bytes;if(u){var d=this.extractCea608Data(u);r.addData(o[l].pts,d[0]),i.addData(o[l].pts,d[1])}}}},n.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.endOffsetSubtitles,o=t.type,l=this.media;if(l&&!(l.currentTime<i)){if(!o||o==="video"){var u=this.captionsTracks;Object.keys(u).forEach(function(h){return Li(u[h],r,i)})}if(this.config.renderTextTracksNatively&&r===0&&a!==void 0){var d=this.textTracks;Object.keys(d).forEach(function(h){return Li(d[h],r,a)})}}},n.extractCea608Data=function(e){for(var t=[[],[]],r=31&e[0],i=2,a=0;a<r;a++){var o=e[i++],l=127&e[i++],u=127&e[i++];if((l!==0||u!==0)&&(4&o)!=0){var d=3&o;d!==0&&d!==1||(t[d].push(l),t[d].push(u))}}return t},s}();function kl(s,n){return!!s&&s.label===n.name&&!(s.textTrack1||s.textTrack2)}var wl=function(){function s(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var n=s.prototype;return n.setStreamController=function(e){this.streamController=e},n.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},n.registerListeners=function(){var e=this.hls;e.on(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)},n.unregisterListener=function(){var e=this.hls;e.off(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)},n.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},n.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null},n.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onMediaDetaching=function(){this.stopCapping()},n.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var e=this.hls.levels;if(e.length){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},n.getMaxLevel=function(e){var t=this,r=this.hls.levels;if(!r.length)return-1;var i=r.filter(function(a,o){return t.isLevelAllowed(a)&&o<=e});return this.clientRect=null,s.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},n.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())},n.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},n.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},n.isLevelAllowed=function(e){return!this.restrictedLevels.some(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height})},s.getMaxLevelByMediaSize=function(e,t,r){if(e==null||!e.length)return-1;for(var i,a,o=e.length-1,l=0;l<e.length;l+=1){var u=e[l];if((u.width>=t||u.height>=r)&&(i=u,!(a=e[l+1])||i.width!==a.width||i.height!==a.height)){o=l;break}}return o},K(s,[{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 e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}}]),s}(),Rl=function(){function s(e){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=e,this.registerListeners()}var n=s.prototype;return n.setStreamController=function(e){this.streamController=e},n.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},n.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&typeof i.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},n.checkFPS=function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var a=i-this.lastTime,o=r-this.lastDroppedFrames,l=t-this.lastDecodedFrames,u=1e3*o/a,d=this.hls;if(d.trigger(E.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),u>0&&o>d.config.fpsDroppedMonitoringThreshold*l){var h=d.currentLevel;x.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=h)&&(h-=1,d.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:d.currentLevel}),d.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},n.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},s}(),Pn="[eme]",Fs=function(){function s(e){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=s.CDMCleanupPromise?[s.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=x.debug.bind(x,Pn),this.log=x.log.bind(x,Pn),this.warn=x.warn.bind(x,Pn),this.error=x.error.bind(x,Pn),this.hls=e,this.config=e.config,this.registerListeners()}var n=s.prototype;return n.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null},n.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.MANIFEST_LOADED,this.onManifestLoaded,this)},n.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this)},n.getLicenseServerUrl=function(e){var t=this.config,r=t.drmSystems,i=t.widevineLicenseUrl,a=r[e];if(a)return a.licenseUrl;if(e===Ye.WIDEVINE&&i)return i;throw new Error('no license server URL configured for key-system "'+e+'"')},n.getServerCertificateUrl=function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},n.attemptKeySystemAccess=function(e){var t=this,r=this.hls.levels,i=function(l,u,d){return!!l&&d.indexOf(l)===u},a=r.map(function(l){return l.audioCodec}).filter(i),o=r.map(function(l){return l.videoCodec}).filter(i);return a.length+o.length===0&&o.push("avc1.42e01e"),new Promise(function(l,u){(function d(h){var f=h.shift();t.getMediaKeysPromise(f,a,o).then(function(v){return l({keySystem:f,mediaKeys:v})}).catch(function(v){h.length?d(h):u(v instanceof Pt?v:new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_NO_ACCESS,error:v,fatal:!0},v.message))})})(e)})},n.requestMediaKeySystemAccess=function(e,t){var r=this.config.requestMediaKeySystemAccessFunc;if(typeof r!="function"){var i="Configured requestMediaKeySystemAccess is not a function "+r;return ci===null&&self.location.protocol==="http:"&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(i))}return r(e,t)},n.getMediaKeysPromise=function(e,t,r){var i=this,a=function(d,h,f,v){var p;switch(d){case Ye.FAIRPLAY:p=["cenc","sinf"];break;case Ye.WIDEVINE:case Ye.PLAYREADY:p=["cenc"];break;case Ye.CLEARKEY:p=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+d)}return function(T,S,y,b){return[{initDataTypes:T,persistentState:b.persistentState||"not-allowed",distinctiveIdentifier:b.distinctiveIdentifier||"not-allowed",sessionTypes:b.sessionTypes||[b.sessionType||"temporary"],audioCapabilities:S.map(function(C){return{contentType:'audio/mp4; codecs="'+C+'"',robustness:b.audioRobustness||"",encryptionScheme:b.audioEncryptionScheme||null}}),videoCapabilities:y.map(function(C){return{contentType:'video/mp4; codecs="'+C+'"',robustness:b.videoRobustness||"",encryptionScheme:b.videoEncryptionScheme||null}})}]}(p,h,f,v)}(e,t,r,this.config.drmSystemOptions),o=this.keySystemAccessPromises[e],l=o==null?void 0:o.keySystemAccess;if(!l){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(a)),l=this.requestMediaKeySystemAccess(e,a);var u=this.keySystemAccessPromises[e]={keySystemAccess:l};return l.catch(function(d){i.log('Failed to obtain access to key-system "'+e+'": '+d)}),l.then(function(d){i.log('Access for key-system "'+d.keySystem+'" obtained');var h=i.fetchServerCertificate(e);return i.log('Create media-keys for "'+e+'"'),u.mediaKeys=d.createMediaKeys().then(function(f){return i.log('Media-keys created for "'+e+'"'),h.then(function(v){return v?i.setMediaKeysServerCertificate(f,e,v):f})}),u.mediaKeys.catch(function(f){i.error('Failed to create media-keys for "'+e+'"}: '+f)}),u.mediaKeys})}return l.then(function(){return o.mediaKeys})},n.createMediaKeySessionContext=function(e){var t=e.decryptdata,r=e.keySystem,i=e.mediaKeys;this.log('Creating key-system session "'+r+'" keyId: '+Dt(t.keyId||[]));var a=i.createSession(),o={decryptdata:t,keySystem:r,mediaKeys:i,mediaKeysSession:a,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o},n.renewKeySession=function(e){var t=e.decryptdata;if(t.pssh){var r=this.createMediaKeySessionContext(e),i=this.getKeyIdString(t);this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,"cenc",t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},n.getKeyIdString=function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Dt(e.keyId)},n.updateKeySession=function(e,t){var r,i=e.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+Dt(((r=e.decryptdata)==null?void 0:r.keyId)||[])+`
|
|
45
|
+
} (data length: `+(t&&t.byteLength)+")"),i.update(t)},n.selectKeySystemFormat=function(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+e.sn+" "+e.type+": "+e.level+") key formats "+t.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise},n.getKeyFormatPromise=function(e){var t=this;return new Promise(function(r,i){var a=hi(t.config),o=e.map(ui).filter(function(l){return!!l&&a.indexOf(l)!==-1});return t.getKeySystemSelectionPromise(o).then(function(l){var u=l.keySystem,d=di(u);d?r(d):i(new Error('Unable to find format for key-system "'+u+'"'))}).catch(i)})},n.loadKey=function(e){var t=this,r=e.keyInfo.decryptdata,i=this.getKeyIdString(r),a="(keyId: "+i+' format: "'+r.keyFormat+'" method: '+r.method+" uri: "+r.uri+")";this.log("Starting session for key "+a);var o=this.keyIdToKeySessionPromise[i];return o||(o=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(r).then(function(l){var u=l.keySystem,d=l.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+a),t.attemptSetMediaKeys(u,d).then(function(){t.throwIfDestroyed();var h=t.createMediaKeySessionContext({keySystem:u,mediaKeys:d,decryptdata:r});return t.generateRequestWithPreferredKeySession(h,"cenc",r.pssh,"playlist-key")})})).catch(function(l){return t.handleError(l)}),o},n.throwIfDestroyed=function(e){if(!this.hls)throw new Error("invalid state")},n.handleError=function(e){this.hls&&(this.error(e.message),e instanceof Pt?this.hls.trigger(E.ERROR,e.data):this.hls.trigger(E.ERROR,{type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},n.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){var i=ui(e.keyFormat),a=i?[i]:hi(this.config);return this.attemptKeySystemAccess(a)}return r},n.getKeySystemSelectionPromise=function(e){if(e.length||(e=hi(this.config)),e.length===0)throw new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},n._onMediaEncrypted=function(e){var t=this,r=e.initDataType,i=e.initData;if(this.debug('"'+e.type+'" event: init data type: "'+r+'"'),i!==null){var a,o;if(r==="sinf"&&this.config.drmSystems[Ye.FAIRPLAY]){var l=Qe(new Uint8Array(i));try{var u=oi(JSON.parse(l).sinf),d=yi(new Uint8Array(u));if(!d)return;a=d.subarray(8,24),o=Ye.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var h=function(C){if(!(C instanceof ArrayBuffer)||C.byteLength<32)return null;var D={version:0,systemId:"",kids:null,data:null},O=new DataView(C),N=O.getUint32(0);if(C.byteLength!==N&&N>44||O.getUint32(4)!==1886614376||(D.version=O.getUint32(8)>>>24,D.version>1))return null;D.systemId=Dt(new Uint8Array(C,12,16));var G=O.getUint32(28);if(D.version===0){if(N-32<G)return null;D.data=new Uint8Array(C,32,G)}else if(D.version===1){D.kids=[];for(var W=0;W<G;W++)D.kids.push(new Uint8Array(C,32+16*W,16))}return D}(i);if(h===null)return;h.version===0&&h.systemId===Wi&&h.data&&(a=h.data.subarray(8,24)),o=function(C){if(C===Wi)return Ye.WIDEVINE}(h.systemId)}if(o&&a){for(var f=Dt(a),v=this.keyIdToKeySessionPromise,p=this.mediaKeySessions,T=v[f],S=function(){var C=p[y],D=C.decryptdata;if(D.pssh||!D.keyId)return"continue";var O=Dt(D.keyId);return f===O||D.uri.replace(/-/g,"").indexOf(f)!==-1?(T=v[O],delete v[O],D.pssh=new Uint8Array(i),D.keyId=a,T=v[f]=T.then(function(){return t.generateRequestWithPreferredKeySession(C,r,i,"encrypted-event-key-match")}),"break"):void 0},y=0;y<p.length;y++){var b=S();if(b!=="continue"&&b==="break")break}T||(T=v[f]=this.getKeySystemSelectionPromise([o]).then(function(C){var D,O=C.keySystem,N=C.mediaKeys;t.throwIfDestroyed();var G=new Tr("ISO-23001-7",f,(D=di(O))!=null?D:"");return G.pssh=new Uint8Array(i),G.keyId=a,t.attemptSetMediaKeys(O,N).then(function(){t.throwIfDestroyed();var W=t.createMediaKeySessionContext({decryptdata:G,keySystem:O,mediaKeys:N});return t.generateRequestWithPreferredKeySession(W,r,i,"encrypted-event-no-match")})})),T.catch(function(C){return t.handleError(C)})}}},n._onWaitingForKey=function(e){this.log('"'+e.type+'" event')},n.attemptSetMediaKeys=function(e,t){var r=this,i=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var a=Promise.all(i).then(function(){if(!r.media)throw new Error("Attempted to set mediaKeys without media element attached");return r.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(a),a.then(function(){r.log('Media-keys set for "'+e+'"'),i.push(a),r.setMediaKeysQueue=r.setMediaKeysQueue.filter(function(o){return i.indexOf(o)===-1})})},n.generateRequestWithPreferredKeySession=function(e,t,r,i){var a,o,l=this,u=(a=this.config.drmSystems)==null||(o=a[e.keySystem])==null?void 0:o.generateRequest;if(u)try{var d=u.call(this.hls,t,r,e);if(!d)throw new Error("Invalid response from configured generateRequest filter");t=d.initDataType,r=e.decryptdata.pssh=d.initData?new Uint8Array(d.initData):null}catch(T){var h;if(this.warn(T.message),(h=this.hls)!=null&&h.config.debug)throw T}if(r===null)return this.log('Skipping key-session request for "'+i+'" (no initData)'),Promise.resolve(e);var f=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'+i+'": '+f+" (init data type: "+t+" length: "+(r?r.byteLength:null)+")");var v=new In;e.mediaKeysSession.onmessage=function(T){var S=e.mediaKeysSession;if(S){var y=T.messageType,b=T.message;l.log('"'+y+'" message event for session "'+S.sessionId+'" message size: '+b.byteLength),y==="license-request"||y==="license-renewal"?l.renewLicense(e,b).catch(function(C){l.handleError(C),v.emit("error",C)}):y==="license-release"?e.keySystem===Ye.FAIRPLAY&&(l.updateKeySession(e,Yi("acknowledged")),l.removeSession(e)):l.warn('unhandled media key message type "'+y+'"')}else v.emit("error",new Error("invalid state"))},e.mediaKeysSession.onkeystatuseschange=function(T){if(e.mediaKeysSession){l.onKeyStatusChange(e);var S=e.keyStatus;v.emit("keyStatus",S),S==="expired"&&(l.warn(e.keySystem+" expired for key "+f),l.renewKeySession(e))}else v.emit("error",new Error("invalid state"))};var p=new Promise(function(T,S){v.on("error",S),v.on("keyStatus",function(y){y.startsWith("usable")?T():y==="output-restricted"?S(new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):y==="internal-error"?S(new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+y+'"')):y==="expired"?S(new Error("key expired while generating request")):l.warn('unhandled key status change "'+y+'"')})});return e.mediaKeysSession.generateRequest(t,r).then(function(){var T;l.log('Request generated for key-session "'+((T=e.mediaKeysSession)==null?void 0:T.sessionId)+'" keyId: '+f)}).catch(function(T){throw new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_NO_SESSION,error:T,fatal:!1},"Error generating key-session request: "+T)}).then(function(){return p}).catch(function(T){throw v.removeAllListeners(),l.removeSession(e),T}).then(function(){return v.removeAllListeners(),e})},n.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach(function(r,i){t.log('key status change "'+r+'" for keyStatuses keyId: '+Dt("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))+" session keyId: "+Dt(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=r})},n.fetchServerCertificate=function(e){var t=this.config,r=new t.loader(t),i=this.getServerCertificateUrl(e);return i?(this.log('Fetching serverCertificate for "'+e+'"'),new Promise(function(a,o){var l={responseType:"arraybuffer",url:i},u=t.certLoadPolicy.default,d={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:function(f,v,p,T){a(f.data)},onError:function(f,v,p,T){o(new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:p,response:H({url:l.url,data:void 0},f)},'"'+e+'" certificate request failed ('+i+"). Status: "+f.code+" ("+f.text+")"))},onTimeout:function(f,v,p){o(new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:p,response:{url:l.url,data:void 0}},'"'+e+'" certificate request timed out ('+i+")"))},onAbort:function(f,v,p){o(new Error("aborted"))}};r.load(l,d,h)})):Promise.resolve()},n.setMediaKeysServerCertificate=function(e,t,r){var i=this;return new Promise(function(a,o){e.setServerCertificate(r).then(function(l){i.log("setServerCertificate "+(l?"success":"not supported by CDM")+" ("+(r==null?void 0:r.byteLength)+') on "'+t+'"'),a(e)}).catch(function(l){o(new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:l,fatal:!0},l.message))})})},n.renewLicense=function(e,t){var r=this;return this.requestLicense(e,new Uint8Array(t)).then(function(i){return r.updateKeySession(e,new Uint8Array(i)).catch(function(a){throw new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:a,fatal:!0},a.message)})})},n.setupLicenseXHR=function(e,t,r,i){var a=this,o=this.config.licenseXhrSetup;return o?Promise.resolve().then(function(){if(!r.decryptdata)throw new Error("Key removed");return o.call(a.hls,e,t,r,i)}).catch(function(l){if(!r.decryptdata)throw l;return e.open("POST",t,!0),o.call(a.hls,e,t,r,i)}).then(function(l){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:l||i}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))},n.requestLicense=function(e,t){var r=this,i=this.config.keyLoadPolicy.default;return new Promise(function(a,o){var l=r.getLicenseServerUrl(e.keySystem);r.log("Sending license request to URL: "+l);var u=new XMLHttpRequest;u.responseType="arraybuffer",u.onreadystatechange=function(){if(!r.hls||!e.mediaKeysSession)return o(new Error("invalid state"));if(u.readyState===4)if(u.status===200){r._requestLicenseFailureCount=0;var d=u.response;r.log("License received "+(d instanceof ArrayBuffer?d.byteLength:d));var h=r.config.licenseResponseCallback;if(h)try{d=h.call(r.hls,u,l,e)}catch(T){r.error(T)}a(d)}else{var f=i.errorRetry,v=f?f.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>v||u.status>=400&&u.status<500)o(new Pt({type:Q.KEY_SYSTEM_ERROR,details:F.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:u,response:{url:l,data:void 0,code:u.status,text:u.statusText}},"License Request XHR failed ("+l+"). Status: "+u.status+" ("+u.statusText+")"));else{var p=v-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+p+" attempts left"),r.requestLicense(e,t).then(a,o)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=u,r.setupLicenseXHR(u,l,e,t).then(function(d){var h=d.xhr,f=d.licenseChallenge;h.send(f)})})},n.onMediaAttached=function(e,t){if(this.config.emeEnabled){var r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}},n.onMediaDetached=function(){var e=this,t=this.media,r=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Tr.clearKeyUriToKeyIdMap();var i=r.length;s.CDMCleanupPromise=Promise.all(r.map(function(a){return e.removeSession(a)}).concat(t==null?void 0:t.setMediaKeys(null).catch(function(a){e.log("Could not clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))}))).then(function(){i&&(e.log("finished closing key sessions and clearing media keys"),r.length=0)}).catch(function(a){e.log("Could not close sessions and clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))})},n.onManifestLoading=function(){this.keyFormatPromise=null},n.onManifestLoaded=function(e,t){var r=t.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var i=r.reduce(function(a,o){return a.indexOf(o.keyFormat)===-1&&a.push(o.keyFormat),a},[]);this.log("Selecting key-system from session-keys "+i.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(i)}},n.removeSession=function(e){var t=this,r=e.mediaKeysSession,i=e.licenseXhr;if(r){this.log("Remove licenses and keys and close session "+r.sessionId),r.onmessage=null,r.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);return a>-1&&this.mediaKeySessions.splice(a,1),r.remove().catch(function(o){t.log("Could not remove session: "+o)}).then(function(){return r.close()}).catch(function(o){t.log("Could not close session: "+o)})}},s}();Fs.CDMCleanupPromise=void 0;var Pt=function(s){function n(e,t){var r;return(r=s.call(this,t)||this).data=void 0,e.error||(e.error=new Error(t)),r.data=e,e.err=e.error,r}return ae(n,s),n}(xe(Error)),Dl="m",On="a",Ra="v",Da="av",Ns="i",Il="tt",Cl=function(){function s(e){var t=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(){t.initialized&&(t.starved=!0),t.buffering=!0},this.onPlaying=function(){t.initialized||(t.initialized=!0),t.buffering=!1},this.applyPlaylistData=function(a){try{t.apply(a,{ot:Dl,su:!t.initialized})}catch(o){x.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=function(a){try{var o=a.frag,l=t.hls.levels[o.level],u=t.getObjectType(o),d={d:1e3*o.duration,ot:u};u!==Ra&&u!==On&&u!=Da||(d.br=l.bitrate/1e3,d.tb=t.getTopBandwidth(u)/1e3,d.bl=t.getBufferLength(u)),t.apply(a,d)}catch(h){x.warn("Could not generate segment CMCD data.",h)}},this.hls=e;var r=this.config=e.config,i=r.cmcd;i!=null&&(r.pLoader=this.createPlaylistLoader(),r.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||s.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHED,this.onMediaDetached,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this)},n.unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHED,this.onMediaDetached,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this)},n.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},n.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},n.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},n.onBufferCreated=function(e,t){var r,i;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(i=t.tracks.video)==null?void 0:i.buffer},n.createData=function(){var e;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},n.apply=function(e,t){t===void 0&&(t={}),X(t,this.createData());var r=t.ot===Ns||t.ot===Ra||t.ot===Da;if(this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){var i=s.toHeaders(t);if(!Object.keys(i).length)return;e.headers||(e.headers={}),X(e.headers,i)}else{var a=s.toQuery(t);if(!a)return;e.url=s.appendQueryToUri(e.url,a)}},n.getObjectType=function(e){var t=e.type;return t==="subtitle"?Il:e.sn==="initSegment"?Ns:t==="audio"?On:t==="main"?this.hls.audioTracks.length?Ra:Da:void 0},n.getTopBandwidth=function(e){var t,r=0,i=this.hls;if(e===On)t=i.audioTracks;else{var a=i.maxAutoLevel,o=a>-1?a+1:i.levels.length;t=i.levels.slice(0,o)}for(var l,u=Re(t);!(l=u()).done;){var d=l.value;d.bitrate>r&&(r=d.bitrate)}return r>0?r:NaN},n.getBufferLength=function(e){var t=this.hls.media,r=e===On?this.audioBuffer:this.videoBuffer;return r&&t?1e3*re.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN},n.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function i(o){this.loader=void 0,this.loader=new r(o)}var a=i.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(o,l,u){t(o),this.loader.load(o,l,u)},K(i,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),i}()},n.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,r=e||this.config.loader;return function(){function i(o){this.loader=void 0,this.loader=new r(o)}var a=i.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(o,l,u){t(o),this.loader.load(o,l,u)},K(i,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),i}()},s.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)},s.serialize=function(e){for(var t,r=[],i=function(T){return!Number.isNaN(T)&&T!=null&&T!==""&&T!==!1},a=function(T){return Math.round(T)},o=function(T){return 100*a(T/100)},l={br:a,d:a,bl:o,dl:o,mtp:o,nor:function(T){return encodeURIComponent(T)},rtp:o,tb:a},u=Re(Object.keys(e||{}).sort());!(t=u()).done;){var d=t.value,h=e[d];if(i(h)&&!(d==="v"&&h===1||d=="pr"&&h===1)){var f=l[d];f&&(h=f(h));var v=typeof h,p=void 0;p=d==="ot"||d==="sf"||d==="st"?d+"="+h:v==="boolean"?d:v==="number"?d+"="+h:d+"="+JSON.stringify(h),r.push(p)}}return r.join(",")},s.toHeaders=function(e){for(var t={},r=["Object","Request","Session","Status"],i=[{},{},{},{}],a={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,l=Object.keys(e);o<l.length;o++){var u=l[o];i[a[u]!=null?a[u]:1][u]=e[u]}for(var d=0;d<i.length;d++){var h=s.serialize(i[d]);h&&(t["CMCD-"+r[d]]=h)}return t},s.toQuery=function(e){return"CMCD="+encodeURIComponent(s.serialize(e))},s.appendQueryToUri=function(e,t){if(!t)return e;var r=e.includes("?")?"&":"?";return""+e+r+t},s}(),xl=function(){function s(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=x.log.bind(x,"[content-steering]:"),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.ERROR,this.onError,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.ERROR,this.onError,this))},n.startLoad=function(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){var e=Math.max(1e3*this.timeToLoad-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else this.loadSteeringManifest(this.uri)},n.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)},n.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},n.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter(function(r){return r!==e}))},n.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},n.onManifestLoaded=function(e,t){var r=t.contentSteering;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},n.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},n.onError=function(e,t){var r=t.errorAction;if((r==null?void 0:r.action)===m&&r.flags===_){var i=this.pathwayPriority,a=this.pathwayId;this.penalizedPathways[a]||(this.penalizedPathways[a]=performance.now()),!i&&this.levels&&(i=this.levels.reduce(function(o,l){return o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o},[])),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==a)}},n.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t):e},n.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(t){return e===t.pathwayId})},n.updatePathwayPriority=function(e){var t;this.pathwayPriority=e;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(function(h){i-r[h]>3e5&&delete r[h]});for(var a=0;a<e.length;a++){var o=e[a];if(!r[o]){if(o===this.pathwayId)return;var l=this.hls.nextLoadLevel,u=this.hls.levels[l];if((t=this.getLevelsForPathway(o)).length>0){this.log('Setting Pathway to "'+o+'"'),this.pathwayId=o,this.hls.trigger(E.LEVELS_UPDATED,{levels:t});var d=this.hls.levels[l];u&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==u.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==u.bitrate&&this.log("Unstable Pathways change from bitrate "+u.bitrate+" to "+d.bitrate),this.hls.nextLoadLevel=l);break}}}},n.clonePathways=function(e){var t=this,r=this.levels;if(r){var i={},a={};e.forEach(function(o){var l=o.ID,u=o["BASE-ID"],d=o["URI-REPLACEMENT"];if(!r.some(function(f){return f.pathwayId===l})){var h=t.getLevelsForPathway(u).map(function(f){var v=X({},f);v.details=void 0,v.url=Bs(f.uri,f.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",d);var p=new Ve(f.attrs);p["PATHWAY-ID"]=l;var T=p.AUDIO&&p.AUDIO+"_clone_"+l,S=p.SUBTITLES&&p.SUBTITLES+"_clone_"+l;T&&(i[p.AUDIO]=T,p.AUDIO=T),S&&(a[p.SUBTITLES]=S,p.SUBTITLES=S),v.attrs=p;var y=new Lr(v);return U(y,"audio",T),U(y,"text",S),y});r.push.apply(r,h),Us(t.audioTracks,i,d,l),Us(t.subtitleTracks,a,d,l)}})}},n.loadSteeringManifest=function(e){var t,r=this,i=this.hls.config,a=i.loader;this.loader&&this.loader.destroy(),this.loader=new a(i);try{t=new self.URL(e)}catch{return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if(t.protocol!=="data:"){var o=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+o)}var l={responseType:"json",url:t.href},u=i.steeringManifestLoadPolicy.default,d=u.errorRetry||u.timeoutRetry||{},h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:d.maxNumRetry||0,retryDelay:d.retryDelayMs||0,maxRetryDelay:d.maxRetryDelayMs||0},f={onSuccess:function(v,p,T,S){r.log('Loaded steering manifest: "'+t+'"');var y=v.data;if(y.VERSION===1){r.updated=performance.now(),r.timeToLoad=y.TTL;var b=y["RELOAD-URI"],C=y["PATHWAY-CLONES"],D=y["PATHWAY-PRIORITY"];if(b)try{r.uri=new self.URL(b,t).href}catch{return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+b)}r.scheduleRefresh(r.uri||T.url),C&&r.clonePathways(C),D&&r.updatePathwayPriority(D)}else r.log("Steering VERSION "+y.VERSION+" not supported!")},onError:function(v,p,T,S){if(r.log("Error loading steering manifest: "+v.code+" "+v.text+" ("+p.url+")"),r.stopLoad(),v.code===410)return r.enabled=!1,void r.log("Steering manifest "+p.url+" no longer available");var y=1e3*r.timeToLoad;if(v.code!==429)r.scheduleRefresh(r.uri||p.url,y);else{var b=r.loader;if(typeof(b==null?void 0:b.getResponseHeader)=="function"){var C=b.getResponseHeader("Retry-After");C&&(y=1e3*parseFloat(C))}r.log("Steering manifest "+p.url+" rate limited")}},onTimeout:function(v,p,T){r.log("Timeout loading steering manifest ("+p.url+")"),r.scheduleRefresh(r.uri||p.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(l,h,f)},n.scheduleRefresh=function(e,t){var r=this;t===void 0&&(t=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(function(){r.loadSteeringManifest(e)},t)},s}();function Us(s,n,e,t){s&&Object.keys(n).forEach(function(r){var i=s.filter(function(a){return a.groupId===r}).map(function(a){var o=X({},a);return o.details=void 0,o.attrs=new Ve(o.attrs),o.url=o.attrs.URI=Bs(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),o.groupId=o.attrs["GROUP-ID"]=n[r],o.attrs["PATHWAY-ID"]=t,o});s.push.apply(s,i)})}function Bs(s,n,e,t){var r,i=t.HOST,a=t.PARAMS,o=t[e];n&&(r=o==null?void 0:o[n])&&(s=r);var l=new self.URL(s);return i&&!r&&(l.host=i),a&&Object.keys(a).sort().forEach(function(u){u&&l.searchParams.set(u,a[u])}),l.href}var Pl=/^age:\s*[\d.]+\s*$/im,Gs=function(){function s(e){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=e&&e.xhrSetup||null,this.stats=new gt,this.retryDelay=0}var n=s.prototype;return n.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},n.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},n.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},n.loadInternal=function(){var e=this,t=this.config,r=this.context;if(t){var i=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0;var o=this.xhrSetup;o?Promise.resolve().then(function(){if(!e.stats.aborted)return o(i,r.url)}).catch(function(l){return i.open("GET",r.url,!0),o(i,r.url)}).then(function(){e.stats.aborted||e.openAndSendXhr(i,r,t)}).catch(function(l){e.callbacks.onError({code:i.status,text:l.message},r,i,a)}):this.openAndSendXhr(i,r,t)}},n.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var i=this.context.headers,a=r.loadPolicy,o=a.maxTimeToFirstByteMs,l=a.maxLoadTimeMs;if(i)for(var u in i)e.setRequestHeader(u,i[u]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=o&&Z(o)?o:l,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},n.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,a=this.config;if(!r.aborted&&i>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),i===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var o=t.status,l=t.responseType!=="text";if(o>=200&&o<300&&(l&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var u=l?t.response:t.responseText,d=t.responseType==="arraybuffer"?u.byteLength:u.length;if(r.loaded=r.total=d,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var h=this.callbacks.onProgress;if(h&&h(r,e,u,t),!this.callbacks)return;var f={url:t.responseURL,data:u,code:o};this.callbacks.onSuccess(f,r,e,t)}else{var v=a.loadPolicy.errorRetry;Wr(v,r.retry,!1,o)?this.retry(v):(x.error(o+" while loading "+e.url),this.callbacks.onError({code:o,text:t.statusText},e,t,r))}}}},n.loadtimeout=function(){var e,t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry;if(Wr(t,this.stats.retry,!0))this.retry(t);else{x.warn("timeout while loading "+this.context.url);var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}},n.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=Ci(e,r.retry),r.retry++,x.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+t.url+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},n.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},n.getCacheAge=function(){var e=null;if(this.loader&&Pl.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},s}(),Ol=/(\d+)-(\d+)\/(\d+)/,Hs=function(){function s(e){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=e.fetchSetup||Ml,this.controller=new self.AbortController,this.stats=new gt}var n=s.prototype;return n.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},n.abortInternal=function(){var e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},n.load=function(e,t,r){var i=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var o=function(p,T){var S={method:"GET",mode:"cors",credentials:"same-origin",signal:T,headers:new self.Headers(X({},p.headers))};return p.rangeEnd&&S.headers.set("Range","bytes="+p.rangeStart+"-"+String(p.rangeEnd-1)),S}(e,this.controller.signal),l=r.onProgress,u=e.responseType==="arraybuffer",d=u?"byteLength":"length",h=t.loadPolicy,f=h.maxTimeToFirstByteMs,v=h.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,o),self.clearTimeout(this.requestTimeout),t.timeout=f&&Z(f)?f:v,this.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(a,e,i.response)},t.timeout),self.fetch(this.request).then(function(p){i.response=i.loader=p;var T=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=v,i.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(a,e,i.response)},v-(T-a.loading.start)),!p.ok){var S=p.status,y=p.statusText;throw new Fl(y||"fetch, bad network response",S,p)}return a.loading.first=T,a.total=function(b){var C=b.get("Content-Range");if(C){var D=function(N){var G=Ol.exec(N);if(G)return parseInt(G[2])-parseInt(G[1])+1}(C);if(Z(D))return D}var O=b.get("Content-Length");if(O)return parseInt(O)}(p.headers)||a.total,l&&Z(t.highWaterMark)?i.loadProgressively(p,a,e,t.highWaterMark,l):u?p.arrayBuffer():e.responseType==="json"?p.json():p.text()}).then(function(p){var T=i.response;self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var S=p[d];S&&(a.loaded=a.total=S);var y={url:T.url,data:p,code:T.status};l&&!Z(t.highWaterMark)&&l(a,e,p,T),r.onSuccess(y,a,e,T)}).catch(function(p){if(self.clearTimeout(i.requestTimeout),!a.aborted){var T=p&&p.code||0,S=p?p.message:null;r.onError({code:T,text:S},e,p?p.details:null,a)}})},n.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},n.loadProgressively=function(e,t,r,i,a){i===void 0&&(i=0);var o=new ps,l=e.body.getReader();return function u(){return l.read().then(function(d){if(d.done)return o.dataLength&&a(t,r,o.flush(),e),Promise.resolve(new ArrayBuffer(0));var h=d.value,f=h.length;return t.loaded+=f,f<i||o.dataLength?(o.push(h),o.dataLength>=i&&a(t,r,o.flush(),e)):a(t,r,h,e),u()}).catch(function(){return Promise.reject()})}()},s}();function Ml(s,n){return new self.Request(s.url,n)}var Fl=function(s){function n(e,t,r){var i;return(i=s.call(this,e)||this).code=void 0,i.details=void 0,i.code=t,i.details=r,i}return ae(n,s),n}(xe(Error)),Nl=/\s/,Ul=H(H({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,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,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Gs,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:tl,bufferController:ul,capLevelController:wl,errorController:I,fpsController:Rl,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:ci,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:{newCue:function(s,n,e,t){for(var r,i,a,o,l,u=[],d=self.VTTCue||self.TextTrackCue,h=0;h<t.rows.length;h++)if(a=!0,o=0,l="",!(r=t.rows[h]).isEmpty()){for(var f,v=0;v<r.chars.length;v++)Nl.test(r.chars[v].uchar)&&a?o++:(l+=r.chars[v].uchar,a=!1);r.cueStartTime=n,n===e&&(e+=1e-4),o>=16?o--:o++;var p=Ds(l.trim()),T=Sa(n,e,p);s!=null&&(f=s.cues)!=null&&f.getCueById(T)||((i=new d(n,e,p)).id=T,i.line=h+1,i.align="left",i.position=10+Math.min(80,10*Math.floor(8*o/32)),u.push(i))}return s&&u.length&&(u.sort(function(S,y){return S.line==="auto"||y.line==="auto"?0:S.line>8&&y.line>8?y.line-S.line:S.line-y.line}),u.forEach(function(S){return pn(s,S)})),u}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:al,subtitleTrackController:ol,timelineController:Ll,audioStreamController:rl,audioTrackController:il,emeController:Fs,cmcdController:Cl,contentSteeringController:xl});function Ia(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Ia):Object.keys(s).reduce(function(n,e){return n[e]=Ia(s[e]),n},{}):s}function Bl(s){var n=s.loader;n!==Hs&&n!==Gs?(x.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}()&&(s.loader=Hs,s.progressive=!0,s.enableSoftwareAES=!0,x.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Ks=function(){function s(e){e===void 0&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new In,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,qe(e.debug||!1,"Hls instance");var t=this.config=function(te,J){if((J.liveSyncDurationCount||J.liveMaxLatencyDurationCount)&&(J.liveSyncDuration||J.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(J.liveMaxLatencyDurationCount!==void 0&&(J.liveSyncDurationCount===void 0||J.liveMaxLatencyDurationCount<=J.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(J.liveMaxLatencyDuration!==void 0&&(J.liveSyncDuration===void 0||J.liveMaxLatencyDuration<=J.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var oe=Ia(te),me=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(ue){var ve=(ue==="level"?"playlist":ue)+"LoadPolicy",Te=J[ve]===void 0,ye=[];me.forEach(function(we){var Ce=ue+"Loading"+we,Oe=J[Ce];if(Oe!==void 0&&Te){ye.push(Ce);var Ge=oe[ve].default;switch(J[ve]={default:Ge},we){case"TimeOut":Ge.maxLoadTimeMs=Oe,Ge.maxTimeToFirstByteMs=Oe;break;case"MaxRetry":Ge.errorRetry.maxNumRetry=Oe,Ge.timeoutRetry.maxNumRetry=Oe;break;case"RetryDelay":Ge.errorRetry.retryDelayMs=Oe,Ge.timeoutRetry.retryDelayMs=Oe;break;case"MaxRetryTimeout":Ge.errorRetry.maxRetryDelayMs=Oe,Ge.timeoutRetry.maxRetryDelayMs=Oe}}}),ye.length&&x.warn('hls.js config: "'+ye.join('", "')+'" setting(s) are deprecated, use "'+ve+'": '+JSON.stringify(J[ve]))}),H(H({},oe),J)}(s.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&Bl(t);var r=t.abrController,i=t.bufferController,a=t.capLevelController,o=t.errorController,l=t.fpsController,u=new o(this),d=this.abrController=new r(this),h=this.bufferController=new i(this),f=this.capLevelController=new a(this),v=new l(this),p=new Je(this),T=new Zn(this),S=t.contentSteeringController,y=S?new S(this):null,b=this.levelController=new P(this,y),C=new le(this),D=new ze(this.config),O=this.streamController=new Zo(this,C,D);f.setStreamController(O),v.setStreamController(O);var N=[p,b,O];y&&N.splice(1,0,y),this.networkControllers=N;var G=[d,h,f,v,T,C];this.audioTrackController=this.createController(t.audioTrackController,N);var W=t.audioStreamController;W&&N.push(new W(this,C,D)),this.subtitleTrackController=this.createController(t.subtitleTrackController,N);var q=t.subtitleStreamController;q&&N.push(new q(this,C,D)),this.createController(t.timelineController,G),D.emeController=this.emeController=this.createController(t.emeController,G),this.cmcdController=this.createController(t.cmcdController,G),this.latencyController=this.createController(ea,G),this.coreComponents=G,N.push(u);var V=u.onErrorOut;typeof V=="function"&&this.on(E.ERROR,V,u)}s.isSupported=function(){return function(){var e=Kr();if(!e)return!1;var t=Ja(),r=e&&typeof e.isTypeSupported=="function"&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!r&&!!i}()};var n=s.prototype;return n.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},n.on=function(e,t,r){r===void 0&&(r=this),this._emitter.on(e,t,r)},n.once=function(e,t,r){r===void 0&&(r=this),this._emitter.once(e,t,r)},n.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},n.off=function(e,t,r,i){r===void 0&&(r=this),this._emitter.off(e,t,r,i)},n.listeners=function(e){return this._emitter.listeners(e)},n.emit=function(e,t,r){return this._emitter.emit(e,t,r)},n.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){x.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(E.ERROR,{type:Q.OTHER_ERROR,details:F.INTERNAL_EXCEPTION,fatal:!1,event:e,error:r})}return!1},n.listenerCount=function(e){return this._emitter.listenerCount(e)},n.destroy=function(){x.log("destroy"),this.trigger(E.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;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},n.attachMedia=function(e){x.log("attachMedia"),this._media=e,this.trigger(E.MEDIA_ATTACHING,{media:e})},n.detachMedia=function(){x.log("detachMedia"),this.trigger(E.MEDIA_DETACHING,void 0),this._media=null},n.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=be.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});x.log("loadSource:"+i),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(E.MANIFEST_LOADING,{url:e})},n.startLoad=function(e){e===void 0&&(e=-1),x.log("startLoad("+e+")"),this.networkControllers.forEach(function(t){t.startLoad(e)})},n.stopLoad=function(){x.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})},n.swapAudioCodec=function(){x.log("swapAudioCodec"),this.streamController.swapAudioCodec()},n.recoverMediaError=function(){x.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},n.removeLevel=function(e,t){t===void 0&&(t=0),this.levelController.removeLevel(e,t)},K(s,[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){x.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){x.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){x.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){x.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){x.log("set startLevel:"+e),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(x.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){ki.indexOf(e)>-1&&(this._maxHdcpLevel=e)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=r===-1&&t&&t.length?t.length-1:r,i)for(var a=e;a--;){var o=t[a].attrs["HDCP-LEVEL"];if(o&&o<=i)return a}return e}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{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.4.5"}},{key:"Events",get:function(){return E}},{key:"ErrorTypes",get:function(){return Q}},{key:"ErrorDetails",get:function(){return F}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:Ul},set:function(e){s.defaultConfig=e}}]),s}();return Ks.defaultConfig=void 0,Ks},typeof $s=="object"&&typeof Ba!="undefined"?Ba.exports=B():typeof define=="function"&&define.amd?define(B):(R=typeof globalThis!="undefined"?globalThis:R||self).Hls=B()})(!1)});var ti=class{addEventListener(){}removeEventListener(){}dispatchEvent(w){return!0}};if(typeof DocumentFragment=="undefined"){class L extends ti{}globalThis.DocumentFragment=L}var Ui=class extends ti{},Fa=class extends ti{},eu={get(L){},define(L,w,R){},upgrade(L){},whenDefined(L){return Promise.resolve(Ui)}},Bi,Na=class{constructor(w,R={}){vt(this,Bi,void 0);Rt(this,Bi,R==null?void 0:R.detail)}get detail(){return ft(this,Bi)}initCustomEvent(){}};Bi=new WeakMap;function tu(L,w){return new Ui}var Xs={document:{createElement:tu},DocumentFragment,customElements:eu,CustomEvent:Na,EventTarget:ti,HTMLElement:Ui,HTMLVideoElement:Fa},Qs=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Nn=Qs?Xs:globalThis,Gu=Qs?Xs.document:globalThis.document;var Bn=zs(Js(),1),so=zs(Zs(),1),ru=so.default,St=ru,Gi=class extends Error{constructor(L,w=Gi.MEDIA_ERR_CUSTOM,R,B){var j;super(L),this.name="MediaError",this.code=w,this.context=B,this.fatal=R!=null?R:w>=Gi.MEDIA_ERR_NETWORK&&w<=Gi.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(j=Gi.defaultMessages[this.code])!=null?j:"")}},_t=Gi;_t.MEDIA_ERR_ABORTED=1,_t.MEDIA_ERR_NETWORK=2,_t.MEDIA_ERR_DECODE=3,_t.MEDIA_ERR_SRC_NOT_SUPPORTED=4,_t.MEDIA_ERR_ENCRYPTED=5,_t.MEDIA_ERR_CUSTOM=100,_t.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 iu=L=>L==null,oo=(L,w)=>iu(w)?!1:L in w,Ha={ANY:"any",MUTED:"muted"},Mr={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},Fr={MSE:"mse",NATIVE:"native"},Ka={HEADER:"header",QUERY:"query",NONE:"none"},qu=Object.values(Ka),vr={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},qa={HLS:vr.M3U8},ju=Object.keys(qa),Vu=[...Object.values(vr),"hls","HLS"],Yt=(L,w,R,B,j=L)=>{j.addEventListener(w,R,B),L.addEventListener("teardown",()=>{j.removeEventListener(w,R)},{once:!0})};function nu(L,w,R){w&&R>w&&(R=w);for(let B=0;B<L.length;B++)if(L.start(B)<=R&&L.end(B)>=R)return!0;return!1}var au=L=>{let w=L.indexOf("?");if(w<0)return[L];let R=L.slice(0,w),B=L.slice(w);return[R,B]},Gn=L=>{let w=L.type;if(w){let B=w.toUpperCase();return oo(B,qa)?qa[B]:w}let{src:R}=L;return R?su(R):""},lo=L=>L==="VOD"?Mr.ON_DEMAND:Mr.LIVE,uo=L=>L==="EVENT"?Number.POSITIVE_INFINITY:L==="VOD"?Number.NaN:0,su=L=>{let w="";try{w=new URL(L).pathname}catch{console.error("invalid url")}let R=w.lastIndexOf(".");if(R<0)return"";let B=w.slice(R+1).toUpperCase();return oo(B,vr)?vr[B]:""},ou=Object.values(Ha),eo=L=>typeof L=="boolean"||typeof L=="string"&&ou.includes(L),lu=({autoplay:L},w,R)=>{let B=!1,j=!1,H=eo(L)?L:!!L,z=()=>{B||Yt(w,"playing",()=>{B=!0},{once:!0})};if(z(),Yt(w,"loadstart",()=>{B=!1,z(),Ga(w,H)},{once:!0}),Yt(w,"loadstart",()=>{R||(j=!Number.isFinite(w.duration)),Ga(w,H)},{once:!0}),R&&R.once(St.Events.LEVEL_LOADED,(K,ee)=>{var X;j=(X=ee.details.live)!=null?X:!1}),!H){let K=()=>{!j||(R!=null&&R.liveSyncPosition?w.currentTime=R.liveSyncPosition:Number.isFinite(w.seekable.end(0))&&(w.currentTime=w.seekable.end(0)))};R&&Yt(w,"play",()=>{w.preload==="metadata"?R.once(St.Events.LEVEL_UPDATED,K):K()},{once:!0})}return K=>{B||(H=eo(K)?K:!!K,Ga(w,H))}},Ga=(L,w)=>{if(!w)return;let R=L.muted,B=()=>L.muted=R;switch(w){case Ha.ANY:L.play().catch(()=>{L.muted=!0,L.play().catch(B)});break;case Ha.MUTED:L.muted=!0,L.play().catch(B);break;default:L.play().catch(()=>{});break}},uu=({preload:L,src:w},R,B)=>{let j=ge=>{ge!=null&&["","none","metadata","auto"].includes(ge)?R.setAttribute("preload",ge):R.removeAttribute("preload")};if(!B)return j(L),j;let H=!1,z=!1,K=B.config.maxBufferLength,ee=B.config.maxBufferSize,X=ge=>{j(ge);let ne=ge!=null?ge:R.preload;z||ne==="none"||(ne==="metadata"?(B.config.maxBufferLength=1,B.config.maxBufferSize=1):(B.config.maxBufferLength=K,B.config.maxBufferSize=ee),ae())},ae=()=>{!H&&w&&(H=!0,B.loadSource(w))};return Yt(R,"play",()=>{z=!0,B.config.maxBufferLength=K,B.config.maxBufferSize=ee,ae()},{once:!0}),X(L),X};function du(L,w){w.on(St.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(j,{tracks:H})=>{H.forEach(z=>{var K;let ee=(K=z.subtitleTrack)!=null?K:z.closedCaptions,X=w.subtitleTracks.findIndex(({lang:ae,name:ge,type:ne})=>ae==(ee==null?void 0:ee.lang)&&ge===z.label&&ne.toLowerCase()===z.kind);ho(L,z.kind,z.label,ee==null?void 0:ee.lang,`${z.kind}${X}`)})});let R=()=>{var j;if(!w.subtitleTracks.length)return;let H=Array.from(L.textTracks).find(K=>K.id&&K.mode==="showing"&&["subtitles","captions"].includes(K.kind)),z=`${(j=w.subtitleTracks[w.subtitleTrack])==null?void 0:j.type.toLowerCase()}${w.subtitleTrack}`;if(H&&(w.subtitleTrack<0||(H==null?void 0:H.id)!==z)){let K=w.subtitleTracks.findIndex(({lang:ee,name:X,type:ae})=>ee==H.language&&X===H.label&&ae.toLowerCase()===H.kind);w.subtitleTrack=K}H&&(H==null?void 0:H.id)===z&&H.cues&&Array.from(H.cues).forEach(K=>{H.addCue(K)})};L.textTracks.addEventListener("change",R),w.on(St.Events.CUES_PARSED,(j,{track:H,cues:z})=>{let K=L.textTracks.getTrackById(H);if(!K)return;let ee=K.mode==="disabled";ee&&(K.mode="hidden"),z.forEach(X=>{var ae;(ae=K.cues)!=null&&ae.getCueById(X.id)||K.addCue(X)}),ee&&(K.mode="disabled")}),w.once(St.Events.DESTROYING,()=>{L.textTracks.removeEventListener("change",R),L.querySelectorAll("track[data-removeondestroy]").forEach(j=>{j.remove()})});let B=()=>{Array.from(L.textTracks).forEach(j=>{var H,z;if(!["subtitles","caption"].includes(j.kind)&&j.label==="thumbnails"){if(!((H=j.cues)!=null&&H.length)){let K=L.querySelector('track[label="thumbnails"]'),ee=(z=K==null?void 0:K.getAttribute("src"))!=null?z:"";K==null||K.removeAttribute("src"),setTimeout(()=>{K==null||K.setAttribute("src",ee)},0)}j.mode!=="hidden"&&(j.mode="hidden")}})};w.once(St.Events.MANIFEST_LOADED,B),w.once(St.Events.MEDIA_ATTACHED,B)}function ho(L,w,R,B,j){let H=document.createElement("track");return H.kind=w,H.label=R,B&&(H.srclang=B),j&&(H.id=j),H.track.mode=["subtitles","captions"].includes(w)?"disabled":"hidden",H.setAttribute("data-removeondestroy",""),L.append(H),H.track}var Hn="cuepoints",Va=Object.freeze({label:Hn}),co=(L,{label:w=Hn}=Va)=>{var R;return(R=Array.from(L.querySelectorAll("track")).find(B=>B.track.label===w&&B.track.kind==="metadata"))==null?void 0:R.track};async function hu(L,w,R=Va){let B=co(L,R);if(!B){let{label:j=Hn}=R;B=ho(L,"metadata",j),B.mode="hidden",await new Promise(H=>setTimeout(()=>H(void 0),0))}return B.mode!=="hidden"&&(B.mode="hidden"),[...w].sort(({time:j},{time:H})=>H-j).forEach(({time:j,value:H})=>{var z,K;let ee=Array.prototype.findIndex.call(B==null?void 0:B.cues,Ae=>Ae.startTime>=j),X=(z=B==null?void 0:B.cues)==null?void 0:z[ee],ae=X?X.startTime:Number.isFinite(L.duration)?L.duration:Number.MAX_SAFE_INTEGER,ge=(K=B==null?void 0:B.cues)==null?void 0:K[ee-1];ge&&(ge.endTime=j);let ne=new VTTCue(j,ae,JSON.stringify(H!=null?H:null));B.addCue(ne)}),B}var cu=L=>({time:L.startTime,value:JSON.parse(L.text)});function fu(L,w={label:Hn}){var R,B;let j=co(L,w);if(!((R=j==null?void 0:j.activeCues)!=null&&R.length))return;let{currentTime:H}=L,z=Array.prototype.find.call((B=j.activeCues)!=null?B:[],({startTime:K,endTime:ee})=>K<=H&&ee>H);return cu(z)}async function vu(L,w=Va){return new Promise(R=>{Yt(L,"loadstart",async()=>{let B=await hu(L,[],w);Yt(L,"cuechange",()=>{let j=fu(L);if(j){let H=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:j});L.dispatchEvent(H)}},{},B),R(B)})})}function fo(L,w){if(w){let R=w.playingDate;if(R!=null)return new Date(R.getTime()-L.currentTime*1e3)}return typeof L.getStartDate=="function"?L.getStartDate():new Date(NaN)}function vo(L,w){if(w&&w.playingDate)return w.playingDate;if(typeof L.getStartDate=="function"){let R=L.getStartDate();return new Date(R.getTime()+L.currentTime*1e3)}return new Date(NaN)}var gu=async L=>fetch(L).then(w=>w.text()).then(w=>{let R=w.split(`
|
|
46
|
+
`).find((B,j,H)=>j&&H[j-1].startsWith("#EXT-X-STREAM-INF"));return fetch(R).then(B=>B.text()).then(B=>B.split(`
|
|
47
|
+
`))}),mu=L=>{var w,R;let B=(R=((w=L.find(K=>K.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?w:"").split(":")[1])==null?void 0:R.trim(),j=lo(B),H=uo(B),z;if(j===Mr.LIVE){let K=L.find(ee=>ee.startsWith("#EXT-X-PART-INF"));K?z=+K.split(":")[1].split("=")[1]*2:z=+L.find(ee=>ee.startsWith("#EXT-X-TARGETDURATION")).split(":")[1]*3}return{streamType:j,targetLiveWindow:H,liveEdgeStartOffset:z}},pu=async(L,w)=>{if(w===vr.MP4)return{streamType:Mr.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(w===vr.M3U8){let R=await gu(L);return mu(R)}return console.error(`Media type ${w} is an unrecognized or unsupported type for src ${L}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},to=async(L,w,R=Gn({src:L}))=>{var B,j,H;let{streamType:z,targetLiveWindow:K,liveEdgeStartOffset:ee}=await pu(L,R);((B=Nt.get(w))!=null?B:{}).liveEdgeStartOffset=ee,((j=Nt.get(w))!=null?j:{}).targetLiveWindow=K,w.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((H=Nt.get(w))!=null?H:{}).streamType=z,w.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},yu=L=>{var w;let R=L.type,B=lo(R),j=uo(R),H,z=!!((w=L.partList)!=null&&w.length);return B===Mr.LIVE&&(H=z?L.partTarget*2:L.targetduration*3),{streamType:B,targetLiveWindow:j,liveEdgeStartOffset:H,lowLatency:z}},Tu=(L,w,R)=>{var B,j,H,z,K,ee,X,ae;let{streamType:ge,targetLiveWindow:ne,liveEdgeStartOffset:Ae,lowLatency:Le}=yu(L);if(ge===Mr.LIVE){Le?(R.config.backBufferLength=(B=R.userConfig.backBufferLength)!=null?B:4,R.config.maxFragLookUpTolerance=(j=R.userConfig.maxFragLookUpTolerance)!=null?j:.001,R.config.abrBandWidthUpFactor=(H=R.userConfig.abrBandWidthUpFactor)!=null?H:R.config.abrBandWidthFactor):R.config.backBufferLength=(z=R.userConfig.backBufferLength)!=null?z:8;let xe=Object.freeze({get length(){return w.seekable.length},start(je){return w.seekable.start(je)},end(je){var Re;return je>this.length?w.seekable.end(je):(Re=R.liveSyncPosition)!=null?Re:w.seekable.end(je)}});((K=Nt.get(w))!=null?K:{}).seekable=xe}((ee=Nt.get(w))!=null?ee:{}).liveEdgeStartOffset=Ae,((X=Nt.get(w))!=null?X:{}).targetLiveWindow=ne,w.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((ae=Nt.get(w))!=null?ae:{}).streamType=ge,w.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},ro,io,Eu=(io=(ro=globalThis==null?void 0:globalThis.navigator)==null?void 0:ro.userAgent)!=null?io:"",bu=Eu.toLowerCase().indexOf("android")!==-1,Nt=new WeakMap,go="mux.com",no,ao,mo=(ao=(no=St).isSupported)==null?void 0:ao.call(no),_u=bu,po=()=>Bn.default.utils.now(),Su=Bn.default.utils.generateUUID,yo=(L,{domain:w=go,maxResolution:R=""}={})=>{if(!L)return;let[B,j=""]=au(L),H=new URL(`https://stream.${w}/${B}.m3u8${j}`);return R&&H.searchParams.set("max_resolution",R),H.toString()},Au=L=>{if(!L)return;let[w]=L.split("?");return w||void 0},Lu=L=>{if(!L||!L.startsWith("https://stream."))return;let[w]=new URL(L).pathname.slice(1).split(".m3u8");return w||void 0},ku=L=>{var w,R,B;return(w=L==null?void 0:L.metadata)!=null&&w.video_id?L.metadata.video_id:_o(L)&&(B=(R=Au(L.playbackId))!=null?R:Lu(L.src))!=null?B:L.src};var wu=(L,w,R=.001)=>Math.abs(L-w)<=R,To=(L,w,R=.001)=>L>w||wu(L,w,R),Ru=L=>L.paused&&To(L.currentTime,L.duration),Ya=(L,w)=>w?L.ended:L.ended||Ru(L),Eo=(L,w,R)=>{Wa(w,R);let{metadata:B={}}=L,{view_session_id:j=Su()}=B,H=ku(L);B.view_session_id=j,B.video_id=H,L.metadata=B,Nt.set(w,{});let z=Du(L,w);Cu(L,w,z),xu(L,w,z),vu(w);let K=lu(L,w,z),ee=uu(L,w,z);return{engine:z,setAutoplay:K,setPreload:ee}},Wa=(L,w)=>{let R=w==null?void 0:w.engine;R&&(R.detachMedia(),R.destroy()),(L==null?void 0:L.mux)&&!L.mux.deleted&&(L.mux.destroy(),delete L.mux),L&&(L.removeAttribute("src"),L.load(),L.removeEventListener("error",Ao),L.removeEventListener("error",ja),L.removeEventListener("durationchange",So),Nt.delete(L),L.dispatchEvent(new Event("teardown")))};function bo(L,w){var R;let B=Gn(L);if(B!==vr.M3U8)return!0;let j=!B||((R=w.canPlayType(B))!=null?R:!0),{preferPlayback:H}=L,z=H===Fr.MSE,K=H===Fr.NATIVE;return j&&(K||!(mo&&(z||_u)))}var Du=(L,w)=>{let{debug:R,streamType:B,startTime:j=-1,metadata:H,preferCmcd:z}=L,K=Gn(L)===vr.M3U8,ee=bo(L,w);if(K&&!ee&&mo){let X={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},ae=Iu(B),ge=z!==Ka.NONE?{useHeaders:z===Ka.HEADER,sessionId:H==null?void 0:H.view_session_id,contentId:H==null?void 0:H.video_id}:void 0;return new St({debug:R,startPosition:j,cmcd:ge,...X,...ae})}},Iu=L=>L===Mr.LIVE?{backBufferLength:8}:{},_o=({playbackId:L,src:w,customDomain:R})=>{if(L)return!0;if(typeof w!="string")return!1;let B=window==null?void 0:window.location.href,j=new URL(w,B).hostname.toLocaleLowerCase();return j.includes(go)||!!R&&j.includes(R.toLocaleLowerCase())},Cu=(L,w,R)=>{var B;let{envKey:j}=L,H=_o(L);if(j||H){let{playerInitTime:z,playerSoftwareName:K,playerSoftwareVersion:ee,beaconCollectionDomain:X,debug:ae,disableCookies:ge}=L,ne={...L.metadata,video_title:((B=L==null?void 0:L.metadata)==null?void 0:B.video_title)||void 0},Ae=Le=>typeof Le.player_error_code=="string"?!1:typeof L.errorTranslator=="function"?L.errorTranslator(Le):Le;Bn.default.monitor(w,{debug:ae,beaconCollectionDomain:X,hlsjs:R,Hls:R?St:void 0,automaticErrorTracking:!1,errorTranslator:Ae,disableCookies:ge,data:{...j?{env_key:j}:{},player_software_name:K,player_software:K,player_software_version:ee,player_init_time:z,...ne}})}},xu=(L,w,R)=>{var B;let j=bo(L,w),{src:H}=L;if(w&&j){let z=Gn(L);typeof H=="string"?(w.preload==="none"?Yt(w,"loadstart",()=>to(H,w,z)):to(H,w,z),w.setAttribute("src",H),L.startTime&&(((B=Nt.get(w))!=null?B:{}).startTime=L.startTime,w.addEventListener("durationchange",So,{once:!0}))):w.removeAttribute("src"),w.addEventListener("error",Ao),w.addEventListener("error",ja),w.addEventListener("emptied",()=>{w.querySelectorAll("track[data-removeondestroy]").forEach(K=>{K.remove()})},{once:!0}),Yt(w,"pause",()=>{!Ya(w)||w.ended||w.dispatchEvent(new Event("ended"))}),Yt(w,"play",()=>{w.ended||!To(w.currentTime,w.duration)||(w.currentTime=w.seekable.start(0))})}else R&&H?(R.once(St.Events.LEVEL_LOADED,(z,K)=>{Tu(K.details,w,R)}),R.on(St.Events.ERROR,(z,K)=>{let ee={[St.ErrorTypes.NETWORK_ERROR]:_t.MEDIA_ERR_NETWORK,[St.ErrorTypes.MEDIA_ERROR]:_t.MEDIA_ERR_DECODE},X=new _t("",ee[K.type]);X.fatal=K.fatal,X.data=K,w.dispatchEvent(new CustomEvent("error",{detail:X}))}),w.addEventListener("error",ja),du(w,R),R.attachMedia(w)):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 So(L){var w;let R=L.target,B=(w=Nt.get(R))==null?void 0:w.startTime;if(!!B&&nu(R.seekable,R.duration,B)){let j=R.preload==="auto";j&&(R.preload="none"),R.currentTime=B,j&&(R.preload="auto")}}async function Ao(L){if(!L.isTrusted)return;L.stopImmediatePropagation();let w=L.target;if(!(w!=null&&w.error))return;let{message:R,code:B}=w.error,j=new _t(R,B);if(w.src&&(B!==_t.MEDIA_ERR_DECODE||B!==void 0))try{let{status:H}=await fetch(w.src);j.data={response:{code:H}}}catch{}w.dispatchEvent(new CustomEvent("error",{detail:j}))}function ja(L){var w,R;if(!(L instanceof CustomEvent)||!(L.detail instanceof _t))return;let B=L.target,j=L.detail;!j||!j.fatal||(((w=Nt.get(B))!=null?w:{}).error=j,(R=B.mux)==null||R.emit("error",{player_error_code:j.code,player_error_message:j.message,player_error_context:j.context}))}var Pu=()=>{try{return"0.10.3"}catch{}return"UNKNOWN"},Ou=Pu(),Lo=()=>Ou;var Ro=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],ko,za=(ko=globalThis.document)==null?void 0:ko.createElement("template");za&&(za.innerHTML=`
|
|
48
48
|
<style>
|
|
49
49
|
:host {
|
|
50
50
|
display: inline-block;
|
|
@@ -59,7 +59,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
59
59
|
}
|
|
60
60
|
</style>
|
|
61
61
|
<slot></slot>
|
|
62
|
-
`);var
|
|
62
|
+
`);var wo,Xa=(wo=globalThis.document)==null?void 0:wo.createElement("template");Xa&&(Xa.innerHTML=`
|
|
63
63
|
<style>
|
|
64
64
|
:host {
|
|
65
65
|
display: inline-block;
|
|
@@ -81,7 +81,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
81
81
|
}
|
|
82
82
|
</style>
|
|
83
83
|
<slot></slot>
|
|
84
|
-
`);var
|
|
84
|
+
`);var Do=(L,{tag:w,is:R})=>{var H,z,K,ee,Io,ae,ge,ne,ri,Le,Co,je,xo;let B=(H=globalThis.document)==null?void 0:H.createElement(w,{is:R}),j=B?Mu(B):[];return z=class extends L{constructor(){super();vt(this,ne);vt(this,Le);vt(this,je);vt(this,ae,void 0);vt(this,ge,void 0);this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var be,Z,E;return Ft(be=z,ee,Io).call(be),[...(E=(Z=B==null?void 0:B.constructor)==null?void 0:Z.observedAttributes)!=null?E:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var pe,be;return(be=(pe=ft(this,ge))!=null?pe:this.shadowRoot.querySelector(w))!=null?be:this.querySelector(w)}set nativeEl(pe){Rt(this,ge,pe)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(pe){this.toggleAttribute("muted",Boolean(pe))}get src(){return this.getAttribute("src")}set src(pe){this.setAttribute("src",`${pe}`)}get preload(){var pe,be;return(be=this.getAttribute("preload"))!=null?be:(pe=this.nativeEl)==null?void 0:pe.preload}set preload(pe){this.setAttribute("preload",`${pe}`)}attributeChangedCallback(pe,be,Z){Ft(this,ne,ri).call(this),Ft(this,je,xo).call(this,pe,be,Z)}connectedCallback(){Ft(this,ne,ri).call(this)}},K=new WeakMap,ee=new WeakSet,Io=function(){if(ft(this,K))return;Rt(this,K,!0);let pe=new Set(this.observedAttributes);pe.delete("muted");for(let be of j){if(be in this.prototype)continue;if(typeof B[be]=="function")this.prototype[be]=function(...E){return Ft(this,ne,ri).call(this),(()=>this.call?this.call(be,...E):this.nativeEl[be].apply(this.nativeEl,E))()};else{let E={get(){var F,ce,Ue;Ft(this,ne,ri).call(this);let Q=be.toLowerCase();if(pe.has(Q)){let Be=this.getAttribute(Q);return Be===null?!1:Be===""?!0:Be}return(Ue=(F=this.get)==null?void 0:F.call(this,be))!=null?Ue:(ce=this.nativeEl)==null?void 0:ce[be]}};be!==be.toUpperCase()&&(E.set=function(Q){Ft(this,ne,ri).call(this);let F=be.toLowerCase();if(pe.has(F)){Q===!0||Q===!1||Q==null?this.toggleAttribute(F,Boolean(Q)):this.setAttribute(F,Q);return}if(this.set){this.set(be,Q);return}this.nativeEl[be]=Q}),Object.defineProperty(this.prototype,be,E)}}},ae=new WeakMap,ge=new WeakMap,ne=new WeakSet,ri=function(){var Z,E;if(ft(this,ae))return;if(Rt(this,ae,!0),!this.nativeEl){let Q=document.createElement(w,{is:R});Q.part=w,this.shadowRoot.append(Q)}this.nativeEl.muted=this.hasAttribute("muted");for(let Q of j)Ft(this,Le,Co).call(this,Q);let pe=new Map,be=this.shadowRoot.querySelector("slot:not([name])");be==null||be.addEventListener("slotchange",()=>{let Q=new Map(pe);be.assignedElements().filter(F=>["track","source"].includes(F.localName)).forEach(F=>{var Ue,Be;Q.delete(F);let ce=pe.get(F);ce||(ce=F.cloneNode(),pe.set(F,ce)),(Be=(Ue=this.nativeEl).append)==null||Be.call(Ue,ce)}),Q.forEach(F=>F.remove())});for(let Q of this.constructor.Events)(E=(Z=this.shadowRoot).addEventListener)==null||E.call(Z,Q,F=>{F.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(F.type,{detail:F.detail}))},!0)},Le=new WeakSet,Co=function(pe){if(Object.prototype.hasOwnProperty.call(this,pe)){let be=this[pe];delete this[pe],this[pe]=be}},je=new WeakSet,xo=function(pe,be,Z){var E,Q,F,ce;["id","class"].includes(pe)||(Z===null?(Q=(E=this.nativeEl).removeAttribute)==null||Q.call(E,pe):(ce=(F=this.nativeEl).setAttribute)==null||ce.call(F,pe,Z))},vt(z,ee),Oa(z,"Events",Ro),Oa(z,"template",w.endsWith("audio")?za:Xa),vt(z,K,void 0),z};function Mu(L){let w=[];for(let R=Object.getPrototypeOf(L);R&&R!==HTMLElement.prototype;R=Object.getPrototypeOf(R))w.push(...Object.getOwnPropertyNames(R));return w}var Xu=globalThis.document?Do(HTMLElement,{tag:"video"}):class{},Kn=globalThis.document?Do(HTMLElement,{tag:"audio"}):class{};var He={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_PLAYBACK:"prefer-playback",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",DISABLE_COOKIES:"disable-cookies",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},Fu=Object.values(He),Nu=Lo(),Uu="mux-audio",Wt,ii,Ki,ni,qi,Qa,Hi=class extends Kn{constructor(){super();vt(this,qi);vt(this,Wt,void 0);vt(this,ii,void 0);vt(this,Ki,void 0);vt(this,ni,{});Rt(this,Ki,po())}static get observedAttributes(){var R;return[...Fu,...(R=Kn.observedAttributes)!=null?R:[]]}get playerInitTime(){return ft(this,Ki)}get playerSoftwareName(){return Uu}get playerSoftwareVersion(){return Nu}get _hls(){var R;return(R=ft(this,Wt))==null?void 0:R.engine}get mux(){return this.nativeEl.mux}get src(){return this.getAttribute("src")}set src(R){R!==this.src&&(R==null?this.removeAttribute("src"):this.setAttribute("src",R))}get preload(){let R=this.getAttribute("preload");return R===""?"auto":["none","metadata","auto"].includes(R)?R:super.preload}set preload(R){R!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(R)?this.setAttribute("preload",R):this.removeAttribute("preload"))}get debug(){return this.getAttribute(He.DEBUG)!=null}set debug(R){R!==this.debug&&(R?this.setAttribute(He.DEBUG,""):this.removeAttribute(He.DEBUG))}get disableCookies(){return this.hasAttribute(He.DISABLE_COOKIES)}set disableCookies(R){R!==this.disableCookies&&(R?this.setAttribute(He.DISABLE_COOKIES,""):this.removeAttribute(He.DISABLE_COOKIES))}get startTime(){let R=this.getAttribute(He.START_TIME);if(R==null)return;let B=+R;return Number.isNaN(B)?void 0:B}set startTime(R){R!==this.startTime&&(R==null?this.removeAttribute(He.START_TIME):this.setAttribute(He.START_TIME,`${R}`))}get playbackId(){var R;return(R=this.getAttribute(He.PLAYBACK_ID))!=null?R:void 0}set playbackId(R){R!==this.playbackId&&(R?this.setAttribute(He.PLAYBACK_ID,R):this.removeAttribute(He.PLAYBACK_ID))}get ended(){return Ya(this.nativeEl,this._hls)}get envKey(){var R;return(R=this.getAttribute(He.ENV_KEY))!=null?R:void 0}set envKey(R){R!==this.envKey&&(R?this.setAttribute(He.ENV_KEY,R):this.removeAttribute(He.ENV_KEY))}get beaconCollectionDomain(){var R;return(R=this.getAttribute(He.BEACON_COLLECTION_DOMAIN))!=null?R:void 0}set beaconCollectionDomain(R){R!==this.beaconCollectionDomain&&(R?this.setAttribute(He.BEACON_COLLECTION_DOMAIN,R):this.removeAttribute(He.BEACON_COLLECTION_DOMAIN))}get streamType(){var R;return(R=this.getAttribute(He.STREAM_TYPE))!=null?R:void 0}set streamType(R){R!==this.streamType&&(R?this.setAttribute(He.STREAM_TYPE,R):this.removeAttribute(He.STREAM_TYPE))}getStartDate(){return fo(this.nativeEl,this._hls)}get currentPdt(){return vo(this.nativeEl,this._hls)}get preferPlayback(){let R=this.getAttribute(He.PREFER_PLAYBACK);if(R===Fr.MSE||R===Fr.NATIVE)return R}set preferPlayback(R){R!==this.preferPlayback&&(R===Fr.MSE||R===Fr.NATIVE?this.setAttribute(He.PREFER_PLAYBACK,R):this.removeAttribute(He.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(B=>B.startsWith("metadata-")&&![He.METADATA_URL].includes(B)).reduce((B,j)=>{let H=this.getAttribute(j);return H!=null&&(B[j.replace(/^metadata-/,"").replace(/-/g,"_")]=H),B},{}),...ft(this,ni)}}set metadata(R){Rt(this,ni,R!=null?R:{}),this.mux&&(console.info("Some metadata values may not be overridable at this time. Make sure you set all metadata to override before setting the src."),this.mux.emit("hb",ft(this,ni)))}load(){Rt(this,Wt,Eo(this,this.nativeEl,ft(this,Wt)))}unload(){Wa(this.nativeEl,ft(this,Wt)),Rt(this,Wt,void 0)}attributeChangedCallback(R,B,j){var z,K;switch(Kn.observedAttributes.includes(R)&&!["src","autoplay","preload"].includes(R)&&super.attributeChangedCallback(R,B,j),R){case"src":{let ee=!!B,X=!!j;!ee&&X?Ft(this,qi,Qa).call(this):ee&&!X?this.unload():ee&&X&&(this.unload(),Ft(this,qi,Qa).call(this));break}case"autoplay":if(j===B)break;(z=ft(this,Wt))==null||z.setAutoplay(this.autoplay);break;case"preload":if(j===B)break;(K=ft(this,Wt))==null||K.setPreload(j);break;case He.PLAYBACK_ID:this.src=yo(j!=null?j:void 0);break;case He.DEBUG:{let ee=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=ee);break}case He.METADATA_URL:j&&fetch(j).then(ee=>ee.json()).then(ee=>this.metadata=ee).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${j}!`));break;default:break}}disconnectedCallback(){this.unload()}};Wt=new WeakMap,ii=new WeakMap,Ki=new WeakMap,ni=new WeakMap,qi=new WeakSet,Qa=async function(){ft(this,ii)||(await Rt(this,ii,Promise.resolve()),Rt(this,ii,null),this.load())};Nn.customElements.get("mux-audio")||(Nn.customElements.define("mux-audio",Hi),Nn.MuxAudioElement=Hi);var ld=Hi;export{Ro as AudioEvents,_t as MediaError,ld as default};
|
|
85
85
|
/*!
|
|
86
86
|
* JavaScript Cookie v2.1.3
|
|
87
87
|
* https://github.com/js-cookie/js-cookie
|