@mux/playback-core 0.18.2 → 0.18.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 +3 -3
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +3 -3
- package/dist/playback-core.js +20 -20
- package/dist/playback-core.js.map +3 -3
- package/dist/playback-core.mjs +20 -20
- package/dist/playback-core.mjs.map +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types-ts3.4/index.d.ts +2 -0
- package/package.json +3 -3
package/dist/playback-core.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var vl=Object.create;var ks=Object.defineProperty;var gl=Object.getOwnPropertyDescriptor;var pl=Object.getOwnPropertyNames;var ml=Object.getPrototypeOf,yl=Object.prototype.hasOwnProperty;var ws=(D,I)=>()=>(I||D((I={exports:{}}).exports,I),I.exports);var Tl=(D,I,M,H)=>{if(I&&typeof I=="object"||typeof I=="function")for(let j of pl(I))!yl.call(D,j)&&j!==M&&ks(D,j,{get:()=>I[j],enumerable:!(H=gl(I,j))||H.enumerable});return D};var As=(D,I,M)=>(M=D!=null?vl(ml(D)):{},Tl(I||!D||!D.__esModule?ks(M,"default",{value:D,enumerable:!0}):M,D));var Rs=ws((Sn,Ta)=>{(function(){var D,I;D=this,I=function(){return function(){var M={80:function(K,Q,V){K.exports=V(728).default},728:function(K,Q,V){"use strict";V.d(Q,{default:function(){return dn}});var re=V(48),z=V.n(re),ne=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(p){var h=16*Math.random()|0;return(p==="x"?h:3&h|8).toString(16)})},ye=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},oe=function(p){return p&&p.nodeName!==void 0?(p.muxId||(p.muxId=p.id||ye()),p.muxId):p},Te=function(p){var h;p&&p.nodeName!==void 0?p=oe(h=p):h=document.querySelector(p);var g=h&&h.nodeName?h.nodeName.toLowerCase():"";return[h,p,g]},we=V(640),Ie=V.n(we),je=Ie().methodFactory;Ie().methodFactory=function(p,h,g){var b=je(p,h,g);return function(){for(var L=["[mux]"],A=0;A<arguments.length;A++)L.push(arguments[A]);b.apply(void 0,L)}},Ie().setLevel(Ie().getLevel());var ke=Ie();function dt(){return(z().doNotTrack||z().navigator&&z().navigator.doNotTrack)==="1"}var Ue={now:function(){var p=z().performance,h=p&&p.timing,g=h&&h.navigationStart,b=typeof g=="number"&&typeof p.now=="function"?g+p.now():Date.now();return Math.round(b)}},et=function(p){return mt(p)[0]},mt=function(p){if(typeof p!="string"||p==="")return["localhost"];var h,g=(p.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return g&&(h=(g.match(/[^\.]+\.[^\.]+$/)||[])[0]),[g,h]},ie={exists:function(){var p=z().performance;return(p&&p.timing)!==void 0},domContentLoadedEventEnd:function(){var p=z().performance,h=p&&p.timing;return h&&h.domContentLoadedEventEnd},navigationStart:function(){var p=z().performance,h=p&&p.timing;return h&&h.navigationStart}};function E(p,h,g){g=g===void 0?1:g,p[h]=p[h]||0,p[h]+=g}var te=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],B=["x-cdn","content-type"].concat(te);function be(p){var h={};return(p=p||"").trim().split(/[\r\n]+/).forEach(function(g){if(g){var b=g.split(": "),L=b.shift();L&&(B.indexOf(L.toLowerCase())>=0||L.toLowerCase().indexOf("x-litix-")===0)&&(h[L]=b.join(": "))}}),h}function Be(p){if(p){var h=te.find(function(g){return p[g]!==void 0});return h?p[h]:void 0}}var qe=function(p){var h={};for(var g in p){var b=p[g];b["DATA-ID"].search("io.litix.data.")!==-1&&(h[b["DATA-ID"].replace("io.litix.data.","")]=b.VALUE)}return h};function Ot(p,h){var g=Object.keys(p);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(p);h&&(b=b.filter(function(L){return Object.getOwnPropertyDescriptor(p,L).enumerable})),g.push.apply(g,b)}return g}function Ne(p){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?Ot(Object(g),!0).forEach(function(b){x(p,b,g[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(g)):Ot(Object(g)).forEach(function(b){Object.defineProperty(p,b,Object.getOwnPropertyDescriptor(g,b))})}return p}function x(p,h,g){return h in p?Object.defineProperty(p,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):p[h]=g,p}var tr=function(p){if(!p)return{};var h=ie.navigationStart(),g=p.loading,b=g?g.start:p.trequest,L=g?g.first:p.tfirst,A=g?g.end:p.tload;return{bytesLoaded:p.total,requestStart:Math.round(h+b),responseStart:Math.round(h+L),responseEnd:Math.round(h+A)}},Mt=function(p){if(p&&typeof p.getAllResponseHeaders=="function")return be(p.getAllResponseHeaders())};function He(p,h){var g=Object.keys(p);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(p);h&&(b=b.filter(function(L){return Object.getOwnPropertyDescriptor(p,L).enumerable})),g.push.apply(g,b)}return g}function rr(p){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?He(Object(g),!0).forEach(function(b){Pe(p,b,g[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(g)):He(Object(g)).forEach(function(b){Object.defineProperty(p,b,Object.getOwnPropertyDescriptor(g,b))})}return p}function Pe(p,h,g){return h in p?Object.defineProperty(p,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):p[h]=g,p}var vt=function(p,h){if(!p||typeof p.getRequests!="function")return{};var g=p.getRequests({state:"executed"});if(g.length===0)return{};var b,L=g[g.length-1],A=et(L.url),k=L.url,C=L.bytesLoaded,N=new Date(L.requestStartDate).getTime(),O=new Date(L.firstByteDate).getTime(),W=new Date(L.requestEndDate).getTime(),me=isNaN(L.duration)?0:L.duration,ae=typeof h.getMetricsFor=="function"?h.getMetricsFor(L.mediaType).HttpList:h.getDashMetrics().getHttpRequests(L.mediaType);return ae.length>0&&(b=be(ae[ae.length-1]._responseHeaders||"")),{requestStart:N,requestResponseStart:O,requestResponseEnd:W,requestBytesLoaded:C,requestResponseHeaders:b,requestMediaDuration:me,requestHostname:A,requestUrl:k,requestId:b?Be(b):void 0}},We=function(p,h){var g=h.getQualityFor(p),b=h.getCurrentTrackFor(p).bitrateList;return b?{currentLevel:g,renditionWidth:b[g].width||null,renditionHeight:b[g].height||null,renditionBitrate:b[g].bandwidth}:{}},gt=function(p){var h;return(h=p.match(/.*codecs\*?="(.*)"/))===null||h===void 0?void 0:h[1]};function Ir(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Xr=0,Qr=function(){function p(){(function(L,A){if(!(L instanceof A))throw new TypeError("Cannot call a class as a function")})(this,p)}var h,g,b;return h=p,g=[{key:"on",value:function(L,A,k){return A._eventEmitterGuid=A._eventEmitterGuid||++Xr,this._listeners=this._listeners||{},this._listeners[L]=this._listeners[L]||[],k&&(A=A.bind(k)),this._listeners[L].push(A),A}},{key:"off",value:function(L,A){var k=this._listeners&&this._listeners[L];k&&k.forEach(function(C,N){C._eventEmitterGuid===A._eventEmitterGuid&&k.splice(N,1)})}},{key:"one",value:function(L,A,k){var C=this;A._eventEmitterGuid=A._eventEmitterGuid||++Xr;var N=function O(){C.off(L,O),A.apply(k||this,arguments)};N._eventEmitterGuid=A._eventEmitterGuid,this.on(L,N)}},{key:"emit",value:function(L,A){var k=this;if(this._listeners){A=A||{};var C=this._listeners["before*"]||[],N=this._listeners[L]||[],O=this._listeners["after"+L]||[],W=function(me,ae){(me=me.slice()).forEach(function(de){de.call(k,{type:L},ae)})};W(C,A),W(N,A),W(O,A)}}}],g&&Ir(h.prototype,g),b&&Ir(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}(),Dn=Qr;function Ii(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Jr=function(){function p(L){var A=this;(function(k,C){if(!(k instanceof C))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,L.on("playing",function(){A._playheadShouldBeProgressing=!0}),L.on("play",this._startPlaybackHeartbeatInterval.bind(this)),L.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),L.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),L.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),L.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),L.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),L.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),L.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),L.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),L.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("seeked",function(){L.data.player_is_paused?A._stopPlaybackHeartbeatInterval():A._startPlaybackHeartbeatInterval()}),L.on("timeupdate",function(){A._playbackHeartbeatInterval!==null&&L.emit("playbackheartbeat")}),L.on("devicesleep",function(k,C){A._playbackHeartbeatInterval!==null&&(z().clearInterval(A._playbackHeartbeatInterval),L.emit("playbackheartbeatend",{viewer_time:C.viewer_time}),A._playbackHeartbeatInterval=null)})}var h,g,b;return h=p,(g=[{key:"_startPlaybackHeartbeatInterval",value:function(){var L=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=z().setInterval(function(){L.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(z().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Ii(h.prototype,g),b&&Ii(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function xi(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Ci(p,h,g){return h&&xi(p.prototype,h),g&&xi(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Ge=Ci(function p(h){var g=this;(function(b,L){if(!(b instanceof L))throw new TypeError("Cannot call a class as a function")})(this,p),h.on("viewinit",function(){g.viewErrored=!1}),h.on("error",function(b,L){try{var A=h.errorTranslator({player_error_code:L.player_error_code,player_error_message:L.player_error_message,player_error_context:L.player_error_context});A?(h.data.player_error_code=A.player_error_code||L.player_error_code,h.data.player_error_message=A.player_error_message||L.player_error_message,h.data.player_error_context=A.player_error_context||L.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 xr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var $r=function(){function p(L){(function(A,k){if(!(A instanceof k))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,this._watchTimeTrackerLastCheckedTime=null,L.on("playbackheartbeat",this._updateWatchTime.bind(this)),L.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var h,g,b;return h=p,(g=[{key:"_updateWatchTime",value:function(L,A){var k=A.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(L,A){this._updateWatchTime(L,A),this._watchTimeTrackerLastCheckedTime=null}}])&&xr(h.prototype,g),b&&xr(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function dr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Cr=function(){function p(L){(function(A,k){if(!(A instanceof k))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,this._playbackTimeTrackerLastPlayheadPosition=-1,L.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),L.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),L.on("seeking",this._clearPlaybackTimeState.bind(this))}var h,g,b;return h=p,(g=[{key:"_updatePlaybackTime",value:function(){var L=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&L>this._playbackTimeTrackerLastPlayheadPosition){var A=L-this._playbackTimeTrackerLastPlayheadPosition;A<=1e3&&E(this.pm.data,"view_content_playback_time",A)}this._playbackTimeTrackerLastPlayheadPosition=L}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&dr(h.prototype,g),b&&dr(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Zr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Pi=function(){function p(L){(function(k,C){if(!(k instanceof C))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L;var A=this._updatePlayheadTime.bind(this);L.on("playbackheartbeat",A),L.on("playbackheartbeatend",A),L.on("timeupdate",A),L.on("destroy",function(){L.off("timeupdate",A)})}var h,g,b;return h=p,(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(L,A){var k=this,C=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(A&&A.player_playhead_time)this.pm.data.player_playhead_time=A.player_playhead_time,C(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var N=this.pm.getPlayheadTime();N!==void 0&&(this.pm.data.player_playhead_time=N,C(),this._updateMaxPlayheadPosition())}}}])&&Zr(h.prototype,g),b&&Zr(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function ei(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function ti(p,h,g){return h&&ei(p.prototype,h),g&&ei(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var ri=3e5,Vt=ti(function p(h){if(function(A,k){if(!(A instanceof k))throw new TypeError("Cannot call a class as a function")}(this,p),!h.disableRebufferTracking){var g,b=function(A,k){L(k),g=void 0},L=function(A){if(g){var k=A.viewer_time-g;E(h.data,"view_rebuffer_duration",k),g=A.viewer_time,h.data.view_rebuffer_duration>ri&&(h.emit("viewend"),h.send("viewend"),h.mux.log.warn("Ending view after rebuffering for longer than ".concat(ri,"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(A,k){return L(k)}),h.on("rebufferstart",function(A,k){g||(E(h.data,"view_rebuffer_count",1),g=k.viewer_time,h.one("rebufferend",b))}),h.on("viewinit",function(){g=void 0,h.off("rebufferend",b)})}});function Pr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var ii=function(){function p(L){var A=this;(function(k,C){if(!(k instanceof C))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,L.disableRebufferTracking||L.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,L.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),L.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),L.on("seeking",function(){A._cleanupRebufferTracker(null,{viewer_time:Ue.now()})}))}var h,g,b;return h=p,g=[{key:"_checkIfRebuffering",value:function(L,A){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(L,A);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var k=A.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=A.viewer_time}else this._cleanupRebufferTracker(L,A,!0);else this._prepareRebufferTrackerState(A.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(L){this._lastCheckedTime=L,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=L}},{key:"_cleanupRebufferTracker",value:function(L,A){var k=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:A.viewer_time});else{if(this._lastCheckedTime===null)return;var C=this.pm.data.player_playhead_time-this._lastPlayheadTime,N=A.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&C>0&&N-C>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+N-C}))}k?this._prepareRebufferTrackerState(A.viewer_time):this._clearRebufferTrackerState()}}],g&&Pr(h.prototype,g),b&&Pr(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}(),Oi=ii;function cr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Or=function(){function p(L){var A=this;(function(k,C){if(!(k instanceof C))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,L.on("viewinit",function(){var k=L.data,C=k.view_id;if(!k.view_program_changed){var N=function(O,W){var me=W.viewer_time;O.type==="playing"&&L.data.view_time_to_first_frame===void 0?A.calculateTimeToFirstFrame(me||Ue.now(),C):O.type!=="adplaying"||L.data.view_time_to_first_frame!==void 0&&!A._inPrerollPosition()||A.calculateTimeToFirstFrame(me||Ue.now(),C)};L.one("playing",N),L.one("adplaying",N),L.one("viewend",function(){L.off("playing",N),L.off("adplaying",N)})}})}var h,g,b;return h=p,(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(L,A){A===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:L}),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))}}])&&cr(h.prototype,g),b&&cr(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Mi(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Fi(p,h,g){return h&&Mi(p.prototype,h),g&&Mi(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var In=Fi(function p(h){var g=this;(function(b,L){if(!(b instanceof L))throw new TypeError("Cannot call a class as a function")})(this,p),h.on("viewinit",function(){g._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(b){h.on(b,function(){if(g._lastPlayheadPosition>=0&&h.data.player_playhead_time>=0&&g._lastPlayerWidth>=0&&g._lastSourceWidth>0&&g._lastPlayerHeight>=0&&g._lastSourceHeight>0){var L=h.data.player_playhead_time-g._lastPlayheadPosition;if(L<0)return void(g._lastPlayheadPosition=-1);var A=Math.min(g._lastPlayerWidth/g._lastSourceWidth,g._lastPlayerHeight/g._lastSourceHeight),k=Math.max(0,A-1),C=Math.max(0,1-A);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,C),E(h.data,"view_total_content_playback_time",L),E(h.data,"view_total_upscaling",k*L),E(h.data,"view_total_downscaling",C*L)}g._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(b){h.on(b,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 ni(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function xn(p,h,g){return h&&ni(p.prototype,h),g&&ni(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Cn=xn(function p(h){var g=this;(function(b,L){if(!(b instanceof L))throw new TypeError("Cannot call a class as a function")})(this,p),this.isSeeking=!1,h.on("seeking",function(b,L){Object.assign(h.data,L),g._lastSeekingTime=Ue.now(),g.isSeeking===!1&&(g.isSeeking=!0,h.send("seeking"))}),h.on("seeked",function(){g.isSeeking=!1;var b=g._lastSeekingTime||Ue.now(),L=Ue.now()-b;E(h.data,"view_seek_count",1),E(h.data,"view_seek_duration",L);var A=h.data.view_max_seek_time||0;h.data.view_max_seek_time=Math.max(A,L)}),h.on("viewend",function(){g.isSeeking=!1})});function Ni(p,h){return function(g){if(Array.isArray(g))return g}(p)||function(g,b){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var A,k,C=[],N=!0,O=!1;try{for(L=L.call(g);!(N=(A=L.next()).done)&&(C.push(A.value),!b||C.length!==b);N=!0);}catch(W){O=!0,k=W}finally{try{N||L.return==null||L.return()}finally{if(O)throw k}}return C}}(p,h)||function(g,b){if(g){if(typeof g=="string")return Ui(g,b);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?Ui(g,b):void 0}}(p,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 Ui(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}function Bi(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var _t=function(p,h){p.push(h),p.sort(function(g,b){return g.viewer_time-b.viewer_time})},Pn=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],wt=function(){function p(L){var A=this;(function(C,N){if(!(C instanceof N))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,L.on("viewinit",function(){A.isAdBreak=!1,A._currentAdRequestNumber=0,A._currentAdResponseNumber=0,A._adRequests=[],A._adResponses=[],A._adHasPlayed=!1,A._wouldBeNewAdPlay=!0,A._prerollPlayTime=void 0}),Pn.forEach(function(C){return L.on(C,A._updateAdData.bind(A))});var k=function(){A.isAdBreak=!1};L.on("adbreakstart",function(){A.isAdBreak=!0}),L.on("play",k),L.on("playing",k),L.on("viewend",k),L.on("adrequest",function(C,N){N=Object.assign({ad_request_id:"generatedAdRequestId"+A._currentAdRequestNumber++},N),_t(A._adRequests,N),E(L.data,"view_ad_request_count"),A.inPrerollPosition()&&(L.data.view_preroll_requested=!0,A._adHasPlayed||E(L.data,"view_preroll_request_count"))}),L.on("adresponse",function(C,N){N=Object.assign({ad_request_id:"generatedAdRequestId"+A._currentAdResponseNumber++},N),_t(A._adResponses,N);var O=A.findAdRequest(N.ad_request_id);O&&E(L.data,"view_ad_request_time",Math.max(0,N.viewer_time-O.viewer_time))}),L.on("adplay",function(C,N){A._adHasPlayed=!0,A._wouldBeNewAdPlay&&(A._wouldBeNewAdPlay=!1,E(L.data,"view_ad_played_count")),A.inPrerollPosition()&&!L.data.view_preroll_played&&(L.data.view_preroll_played=!0,A._adRequests.length>0&&(L.data.view_preroll_request_time=Math.max(0,N.viewer_time-A._adRequests[0].viewer_time)),L.data.view_start&&(L.data.view_startup_preroll_request_time=Math.max(0,N.viewer_time-L.data.view_start)),A._prerollPlayTime=N.viewer_time)}),L.on("adplaying",function(C,N){A.inPrerollPosition()&&L.data.view_preroll_load_time===void 0&&A._prerollPlayTime!==void 0&&(L.data.view_preroll_load_time=N.viewer_time-A._prerollPlayTime,L.data.view_startup_preroll_load_time=N.viewer_time-A._prerollPlayTime)}),L.on("adended",function(){A._wouldBeNewAdPlay=!0}),L.on("aderror",function(){A._wouldBeNewAdPlay=!0})}var h,g,b;return h=p,(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(L){for(var A=0;A<this._adRequests.length;A++)if(this._adRequests[A].ad_request_id===L)return this._adRequests[A]}},{key:"_updateAdData",value:function(L,A){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&A.ad_tag_url){var k=Ni(mt(A.ad_tag_url),2),C=k[0],N=k[1];this.pm.data.view_preroll_ad_tag_domain=N,this.pm.data.view_preroll_ad_tag_hostname=C}if(!this.pm.data.view_preroll_ad_asset_hostname&&A.ad_asset_url){var O=Ni(mt(A.ad_asset_url),2),W=O[0],me=O[1];this.pm.data.view_preroll_ad_asset_domain=me,this.pm.data.view_preroll_ad_asset_hostname=W}}this.pm.data.ad_asset_url=A==null?void 0:A.ad_asset_url,this.pm.data.ad_tag_url=A==null?void 0:A.ad_tag_url,this.pm.data.ad_creative_id=A==null?void 0:A.ad_creative_id,this.pm.data.ad_id=A==null?void 0:A.ad_id,this.pm.data.ad_universal_id=A==null?void 0:A.ad_universal_id}}])&&Bi(h.prototype,g),b&&Bi(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function hr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function On(p,h,g){return h&&hr(p.prototype,h),g&&hr(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Hi=On(function p(h){var g,b;(function(C,N){if(!(C instanceof N))throw new TypeError("Cannot call a class as a function")})(this,p);var L=function(){h.disableRebufferTracking||g&&(E(h.data,"view_waiting_rebuffer_duration",Ue.now()-g),g=!1,z().clearInterval(b))},A=!1,k=function(){A=!1,L()};h.on("waiting",function(){A&&(h.disableRebufferTracking||(E(h.data,"view_waiting_rebuffer_count",1),g=Ue.now(),b=z().setInterval(function(){if(g){var C=Ue.now();E(h.data,"view_waiting_rebuffer_duration",C-g),g=C}},250)))}),h.on("playing",function(){L(),A=!0}),h.on("pause",k),h.on("seeking",k)});function Ye(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Gi(p,h,g){return h&&Ye(p.prototype,h),g&&Ye(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var _e=Gi(function p(h){var g=this;(function(A,k){if(!(A instanceof k))throw new TypeError("Cannot call a class as a function")})(this,p);var b=function(){g.lastWallClockTime=Ue.now(),h.on("before*",L)},L=function(A){var k=Ue.now(),C=g.lastWallClockTime;g.lastWallClockTime=k,k-C>3e4&&(h.emit("devicesleep",{viewer_time:C}),Object.assign(h.data,{viewer_time:C}),h.send("devicesleep"),h.emit("devicewake",{viewer_time:k}),Object.assign(h.data,{viewer_time:k}),h.send("devicewake"))};h.one("playbackheartbeat",b),h.on("playbackheartbeatend",function(){h.off("before*",L),h.one("playbackheartbeat",b)})}),ai=V(375),si=V(655),xe=V.n(si),Ki="muxData",oi=function(){var p;try{p=ai.parse(xe().get(Ki)||"")}catch{p={}}return p},li=function(p){try{xe().set(Ki,ai.stringify(p),{expires:7300})}catch{}},Mn=function(){var p=oi();return p.mux_viewer_id=p.mux_viewer_id||ne(),p.msn=p.msn||Math.random(),li(p),{mux_viewer_id:p.mux_viewer_id,mux_sample_number:p.msn}};function jt(p,h){var g=h.beaconCollectionDomain,b=h.beaconDomain;if(g)return"https://"+g;var L=b||"litix.io";return(p=p||"inferred").match(/^[a-z0-9]+$/)?"https://"+p+"."+L:"https://img.litix.io/a.gif"}var ui=function(){var p;switch(qi()){case"cellular":p="cellular";break;case"ethernet":p="wired";break;case"wifi":p="wifi";break;case void 0:break;default:p="other"}return p},qi=function(){var p=z().navigator,h=p&&(p.connection||p.mozConnection||p.webkitConnection);return h&&h.type};ui.getConnectionFromAPI=qi;var Vi=ui,ji=fr({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"}),Wi=fr({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 fr(p){var h={};for(var g in p)p.hasOwnProperty(g)&&(h[p[g]]=g);return h}function vr(p){var h={},g={};return Object.keys(p).forEach(function(b){var L=!1;if(p.hasOwnProperty(b)&&p[b]!==void 0){var A=b.split("_"),k=A[0],C=ji[k];C||(ke.info("Data key word `"+A[0]+"` not expected in "+b),C=k+"_"),A.splice(1).forEach(function(N){N==="url"&&(L=!0),Wi[N]?C+=Wi[N]:Number(N)&&Math.floor(Number(N))===Number(N)?C+=N:(ke.info("Data key word `"+N+"` not expected in "+b),C+="_"+N+"_")}),L?g[C]=p[b]:h[C]=p[b]}}),Object.assign(h,g)}var Yi={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},zi=["hb","requestcompleted","requestfailed","requestcanceled"],ct="https://img.litix.io",bt=function(p){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=p||ct,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},Yi,h)};bt.prototype.queueEvent=function(p,h){var g=Object.assign({},h);return(this._eventQueue.length<=this._options.maxQueueLength||p==="eventrateexceeded")&&(this._eventQueue.push(g),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},bt.prototype.flushEvents=function(){var p=arguments.length>0&&arguments[0]!==void 0&&arguments[0];p&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},bt.prototype.destroy=function(){var p=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,p?this._clearBeaconQueue():this.flushEvents(),z().clearTimeout(this._sendTimeout)},bt.prototype._clearBeaconQueue=function(){var p=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,h=this._eventQueue.slice(p);p>0&&Object.assign(h[h.length-1],vr({mux_view_message:"event queue truncated"}));var g=this._createPayload(h);Qi(this._beaconUrl,g,!0,function(){})},bt.prototype._sendBeaconQueue=function(){var p=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),b=Ue.now();Qi(this._beaconUrl,g,!1,function(L,A){A?(p._eventQueue=h.concat(p._eventQueue),p._failureCount+=1,ke.info("Error sending beacon: "+A)):p._failureCount=0,p._roundTripTime=Ue.now()-b,p._postInFlight=!1})}},bt.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var p=Math.pow(2,this._failureCount-1);return(1+(p*=Math.random()))*this._options.baseTimeBetweenBeacons},bt.prototype._startBeaconSending=function(){var p=this;z().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=z().setTimeout(function(){p._eventQueue.length&&p._sendBeaconQueue(),p._startBeaconSending()},this._getNextBeaconTime()))},bt.prototype._createPayload=function(p){var h,g,b,L=this,A={transmission_timestamp:Math.round(Ue.now())};this._roundTripTime&&(A.rtt_ms=Math.round(this._roundTripTime));var k=function(){h=JSON.stringify({metadata:A,events:g||p}),b=h.length/1024},C=function(){return b<=L._options.maxPayloadKBSize};return k(),C()||(ke.info("Payload size is too big ("+b+" kb). Removing unnecessary events."),g=p.filter(function(N){return zi.indexOf(N.e)===-1}),k()),C()||(ke.info("Payload size still too big ("+b+" kb). Cropping fields.."),g.forEach(function(N){for(var O in N){var W=N[O];typeof W=="string"&&W.length>51200&&(N[O]=W.substring(0,51200))}}),k()),h};var Xi=function(p){return p.length<=57344},Qi=function(p,h,g,b){if(g&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(p,h))b();else if(z().fetch)z().fetch(p,{method:"POST",body:h,headers:{"Content-Type":"text/plain"},keepalive:Xi(h)}).then(function(A){return b(null,A.ok?null:"Error")}).catch(function(A){return b(null,A)});else{if(z().XMLHttpRequest){var L=new(z()).XMLHttpRequest;return L.onreadystatechange=function(){if(L.readyState===4)return b(null,L.status!==200?"error":void 0)},L.open("POST",p),L.setRequestHeader("Content-Type","text/plain"),void L.send(h)}b()}},Mr=bt;function Fn(p,h){return function(g){if(Array.isArray(g))return g}(p)||function(g,b){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var A,k,C=[],N=!0,O=!1;try{for(L=L.call(g);!(N=(A=L.next()).done)&&(C.push(A.value),!b||C.length!==b);N=!0);}catch(W){O=!0,k=W}finally{try{N||L.return==null||L.return()}finally{if(O)throw k}}return C}}(p,h)||function(g,b){if(g){if(typeof g=="string")return di(g,b);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?di(g,b):void 0}}(p,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
1
|
+
var gl=Object.create;var ks=Object.defineProperty;var pl=Object.getOwnPropertyDescriptor;var ml=Object.getOwnPropertyNames;var yl=Object.getPrototypeOf,Tl=Object.prototype.hasOwnProperty;var ws=(I,D)=>()=>(D||I((D={exports:{}}).exports,D),D.exports);var El=(I,D,M,H)=>{if(D&&typeof D=="object"||typeof D=="function")for(let j of ml(D))!Tl.call(I,j)&&j!==M&&ks(I,j,{get:()=>D[j],enumerable:!(H=pl(D,j))||H.enumerable});return I};var As=(I,D,M)=>(M=I!=null?gl(yl(I)):{},El(D||!I||!I.__esModule?ks(M,"default",{value:I,enumerable:!0}):M,I));var Rs=ws((Sn,Ta)=>{(function(){var I,D;I=this,D=function(){return function(){var M={80:function(K,Q,V){K.exports=V(728).default},728:function(K,Q,V){"use strict";V.d(Q,{default:function(){return dn}});var re=V(48),z=V.n(re),ne=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(p){var h=16*Math.random()|0;return(p==="x"?h:3&h|8).toString(16)})},ye=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},oe=function(p){return p&&p.nodeName!==void 0?(p.muxId||(p.muxId=p.id||ye()),p.muxId):p},Te=function(p){var h;p&&p.nodeName!==void 0?p=oe(h=p):h=document.querySelector(p);var g=h&&h.nodeName?h.nodeName.toLowerCase():"";return[h,p,g]},we=V(640),Ie=V.n(we),je=Ie().methodFactory;Ie().methodFactory=function(p,h,g){var b=je(p,h,g);return function(){for(var L=["[mux]"],A=0;A<arguments.length;A++)L.push(arguments[A]);b.apply(void 0,L)}},Ie().setLevel(Ie().getLevel());var ke=Ie();function dt(){return(z().doNotTrack||z().navigator&&z().navigator.doNotTrack)==="1"}var Ue={now:function(){var p=z().performance,h=p&&p.timing,g=h&&h.navigationStart,b=typeof g=="number"&&typeof p.now=="function"?g+p.now():Date.now();return Math.round(b)}},et=function(p){return mt(p)[0]},mt=function(p){if(typeof p!="string"||p==="")return["localhost"];var h,g=(p.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return g&&(h=(g.match(/[^\.]+\.[^\.]+$/)||[])[0]),[g,h]},ie={exists:function(){var p=z().performance;return(p&&p.timing)!==void 0},domContentLoadedEventEnd:function(){var p=z().performance,h=p&&p.timing;return h&&h.domContentLoadedEventEnd},navigationStart:function(){var p=z().performance,h=p&&p.timing;return h&&h.navigationStart}};function E(p,h,g){g=g===void 0?1:g,p[h]=p[h]||0,p[h]+=g}var te=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],B=["x-cdn","content-type"].concat(te);function be(p){var h={};return(p=p||"").trim().split(/[\r\n]+/).forEach(function(g){if(g){var b=g.split(": "),L=b.shift();L&&(B.indexOf(L.toLowerCase())>=0||L.toLowerCase().indexOf("x-litix-")===0)&&(h[L]=b.join(": "))}}),h}function Be(p){if(p){var h=te.find(function(g){return p[g]!==void 0});return h?p[h]:void 0}}var qe=function(p){var h={};for(var g in p){var b=p[g];b["DATA-ID"].search("io.litix.data.")!==-1&&(h[b["DATA-ID"].replace("io.litix.data.","")]=b.VALUE)}return h};function Ot(p,h){var g=Object.keys(p);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(p);h&&(b=b.filter(function(L){return Object.getOwnPropertyDescriptor(p,L).enumerable})),g.push.apply(g,b)}return g}function Ne(p){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?Ot(Object(g),!0).forEach(function(b){x(p,b,g[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(g)):Ot(Object(g)).forEach(function(b){Object.defineProperty(p,b,Object.getOwnPropertyDescriptor(g,b))})}return p}function x(p,h,g){return h in p?Object.defineProperty(p,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):p[h]=g,p}var tr=function(p){if(!p)return{};var h=ie.navigationStart(),g=p.loading,b=g?g.start:p.trequest,L=g?g.first:p.tfirst,A=g?g.end:p.tload;return{bytesLoaded:p.total,requestStart:Math.round(h+b),responseStart:Math.round(h+L),responseEnd:Math.round(h+A)}},Mt=function(p){if(p&&typeof p.getAllResponseHeaders=="function")return be(p.getAllResponseHeaders())};function He(p,h){var g=Object.keys(p);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(p);h&&(b=b.filter(function(L){return Object.getOwnPropertyDescriptor(p,L).enumerable})),g.push.apply(g,b)}return g}function rr(p){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?He(Object(g),!0).forEach(function(b){Pe(p,b,g[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(g)):He(Object(g)).forEach(function(b){Object.defineProperty(p,b,Object.getOwnPropertyDescriptor(g,b))})}return p}function Pe(p,h,g){return h in p?Object.defineProperty(p,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):p[h]=g,p}var vt=function(p,h){if(!p||typeof p.getRequests!="function")return{};var g=p.getRequests({state:"executed"});if(g.length===0)return{};var b,L=g[g.length-1],A=et(L.url),k=L.url,C=L.bytesLoaded,N=new Date(L.requestStartDate).getTime(),O=new Date(L.firstByteDate).getTime(),W=new Date(L.requestEndDate).getTime(),me=isNaN(L.duration)?0:L.duration,ae=typeof h.getMetricsFor=="function"?h.getMetricsFor(L.mediaType).HttpList:h.getDashMetrics().getHttpRequests(L.mediaType);return ae.length>0&&(b=be(ae[ae.length-1]._responseHeaders||"")),{requestStart:N,requestResponseStart:O,requestResponseEnd:W,requestBytesLoaded:C,requestResponseHeaders:b,requestMediaDuration:me,requestHostname:A,requestUrl:k,requestId:b?Be(b):void 0}},We=function(p,h){var g=h.getQualityFor(p),b=h.getCurrentTrackFor(p).bitrateList;return b?{currentLevel:g,renditionWidth:b[g].width||null,renditionHeight:b[g].height||null,renditionBitrate:b[g].bandwidth}:{}},gt=function(p){var h;return(h=p.match(/.*codecs\*?="(.*)"/))===null||h===void 0?void 0:h[1]};function Ir(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Xr=0,Qr=function(){function p(){(function(L,A){if(!(L instanceof A))throw new TypeError("Cannot call a class as a function")})(this,p)}var h,g,b;return h=p,g=[{key:"on",value:function(L,A,k){return A._eventEmitterGuid=A._eventEmitterGuid||++Xr,this._listeners=this._listeners||{},this._listeners[L]=this._listeners[L]||[],k&&(A=A.bind(k)),this._listeners[L].push(A),A}},{key:"off",value:function(L,A){var k=this._listeners&&this._listeners[L];k&&k.forEach(function(C,N){C._eventEmitterGuid===A._eventEmitterGuid&&k.splice(N,1)})}},{key:"one",value:function(L,A,k){var C=this;A._eventEmitterGuid=A._eventEmitterGuid||++Xr;var N=function O(){C.off(L,O),A.apply(k||this,arguments)};N._eventEmitterGuid=A._eventEmitterGuid,this.on(L,N)}},{key:"emit",value:function(L,A){var k=this;if(this._listeners){A=A||{};var C=this._listeners["before*"]||[],N=this._listeners[L]||[],O=this._listeners["after"+L]||[],W=function(me,ae){(me=me.slice()).forEach(function(de){de.call(k,{type:L},ae)})};W(C,A),W(N,A),W(O,A)}}}],g&&Ir(h.prototype,g),b&&Ir(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}(),Dn=Qr;function Ii(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Jr=function(){function p(L){var A=this;(function(k,C){if(!(k instanceof C))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,L.on("playing",function(){A._playheadShouldBeProgressing=!0}),L.on("play",this._startPlaybackHeartbeatInterval.bind(this)),L.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),L.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),L.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),L.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),L.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),L.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),L.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),L.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),L.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("seeked",function(){L.data.player_is_paused?A._stopPlaybackHeartbeatInterval():A._startPlaybackHeartbeatInterval()}),L.on("timeupdate",function(){A._playbackHeartbeatInterval!==null&&L.emit("playbackheartbeat")}),L.on("devicesleep",function(k,C){A._playbackHeartbeatInterval!==null&&(z().clearInterval(A._playbackHeartbeatInterval),L.emit("playbackheartbeatend",{viewer_time:C.viewer_time}),A._playbackHeartbeatInterval=null)})}var h,g,b;return h=p,(g=[{key:"_startPlaybackHeartbeatInterval",value:function(){var L=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=z().setInterval(function(){L.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(z().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Ii(h.prototype,g),b&&Ii(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function xi(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Ci(p,h,g){return h&&xi(p.prototype,h),g&&xi(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Ge=Ci(function p(h){var g=this;(function(b,L){if(!(b instanceof L))throw new TypeError("Cannot call a class as a function")})(this,p),h.on("viewinit",function(){g.viewErrored=!1}),h.on("error",function(b,L){try{var A=h.errorTranslator({player_error_code:L.player_error_code,player_error_message:L.player_error_message,player_error_context:L.player_error_context});A?(h.data.player_error_code=A.player_error_code||L.player_error_code,h.data.player_error_message=A.player_error_message||L.player_error_message,h.data.player_error_context=A.player_error_context||L.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 xr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var $r=function(){function p(L){(function(A,k){if(!(A instanceof k))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,this._watchTimeTrackerLastCheckedTime=null,L.on("playbackheartbeat",this._updateWatchTime.bind(this)),L.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var h,g,b;return h=p,(g=[{key:"_updateWatchTime",value:function(L,A){var k=A.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(L,A){this._updateWatchTime(L,A),this._watchTimeTrackerLastCheckedTime=null}}])&&xr(h.prototype,g),b&&xr(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function dr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Cr=function(){function p(L){(function(A,k){if(!(A instanceof k))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,this._playbackTimeTrackerLastPlayheadPosition=-1,L.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),L.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),L.on("seeking",this._clearPlaybackTimeState.bind(this))}var h,g,b;return h=p,(g=[{key:"_updatePlaybackTime",value:function(){var L=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&L>this._playbackTimeTrackerLastPlayheadPosition){var A=L-this._playbackTimeTrackerLastPlayheadPosition;A<=1e3&&E(this.pm.data,"view_content_playback_time",A)}this._playbackTimeTrackerLastPlayheadPosition=L}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&dr(h.prototype,g),b&&dr(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Zr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Pi=function(){function p(L){(function(k,C){if(!(k instanceof C))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L;var A=this._updatePlayheadTime.bind(this);L.on("playbackheartbeat",A),L.on("playbackheartbeatend",A),L.on("timeupdate",A),L.on("destroy",function(){L.off("timeupdate",A)})}var h,g,b;return h=p,(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(L,A){var k=this,C=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(A&&A.player_playhead_time)this.pm.data.player_playhead_time=A.player_playhead_time,C(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var N=this.pm.getPlayheadTime();N!==void 0&&(this.pm.data.player_playhead_time=N,C(),this._updateMaxPlayheadPosition())}}}])&&Zr(h.prototype,g),b&&Zr(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function ei(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function ti(p,h,g){return h&&ei(p.prototype,h),g&&ei(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var ri=3e5,Vt=ti(function p(h){if(function(A,k){if(!(A instanceof k))throw new TypeError("Cannot call a class as a function")}(this,p),!h.disableRebufferTracking){var g,b=function(A,k){L(k),g=void 0},L=function(A){if(g){var k=A.viewer_time-g;E(h.data,"view_rebuffer_duration",k),g=A.viewer_time,h.data.view_rebuffer_duration>ri&&(h.emit("viewend"),h.send("viewend"),h.mux.log.warn("Ending view after rebuffering for longer than ".concat(ri,"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(A,k){return L(k)}),h.on("rebufferstart",function(A,k){g||(E(h.data,"view_rebuffer_count",1),g=k.viewer_time,h.one("rebufferend",b))}),h.on("viewinit",function(){g=void 0,h.off("rebufferend",b)})}});function Pr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var ii=function(){function p(L){var A=this;(function(k,C){if(!(k instanceof C))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,L.disableRebufferTracking||L.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,L.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),L.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),L.on("seeking",function(){A._cleanupRebufferTracker(null,{viewer_time:Ue.now()})}))}var h,g,b;return h=p,g=[{key:"_checkIfRebuffering",value:function(L,A){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(L,A);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var k=A.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=A.viewer_time}else this._cleanupRebufferTracker(L,A,!0);else this._prepareRebufferTrackerState(A.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(L){this._lastCheckedTime=L,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=L}},{key:"_cleanupRebufferTracker",value:function(L,A){var k=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:A.viewer_time});else{if(this._lastCheckedTime===null)return;var C=this.pm.data.player_playhead_time-this._lastPlayheadTime,N=A.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&C>0&&N-C>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+N-C}))}k?this._prepareRebufferTrackerState(A.viewer_time):this._clearRebufferTrackerState()}}],g&&Pr(h.prototype,g),b&&Pr(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}(),Oi=ii;function cr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Or=function(){function p(L){var A=this;(function(k,C){if(!(k instanceof C))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,L.on("viewinit",function(){var k=L.data,C=k.view_id;if(!k.view_program_changed){var N=function(O,W){var me=W.viewer_time;O.type==="playing"&&L.data.view_time_to_first_frame===void 0?A.calculateTimeToFirstFrame(me||Ue.now(),C):O.type!=="adplaying"||L.data.view_time_to_first_frame!==void 0&&!A._inPrerollPosition()||A.calculateTimeToFirstFrame(me||Ue.now(),C)};L.one("playing",N),L.one("adplaying",N),L.one("viewend",function(){L.off("playing",N),L.off("adplaying",N)})}})}var h,g,b;return h=p,(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(L,A){A===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:L}),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))}}])&&cr(h.prototype,g),b&&cr(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Mi(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Fi(p,h,g){return h&&Mi(p.prototype,h),g&&Mi(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var In=Fi(function p(h){var g=this;(function(b,L){if(!(b instanceof L))throw new TypeError("Cannot call a class as a function")})(this,p),h.on("viewinit",function(){g._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(b){h.on(b,function(){if(g._lastPlayheadPosition>=0&&h.data.player_playhead_time>=0&&g._lastPlayerWidth>=0&&g._lastSourceWidth>0&&g._lastPlayerHeight>=0&&g._lastSourceHeight>0){var L=h.data.player_playhead_time-g._lastPlayheadPosition;if(L<0)return void(g._lastPlayheadPosition=-1);var A=Math.min(g._lastPlayerWidth/g._lastSourceWidth,g._lastPlayerHeight/g._lastSourceHeight),k=Math.max(0,A-1),C=Math.max(0,1-A);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,C),E(h.data,"view_total_content_playback_time",L),E(h.data,"view_total_upscaling",k*L),E(h.data,"view_total_downscaling",C*L)}g._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(b){h.on(b,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 ni(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function xn(p,h,g){return h&&ni(p.prototype,h),g&&ni(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Cn=xn(function p(h){var g=this;(function(b,L){if(!(b instanceof L))throw new TypeError("Cannot call a class as a function")})(this,p),this.isSeeking=!1,h.on("seeking",function(b,L){Object.assign(h.data,L),g._lastSeekingTime=Ue.now(),g.isSeeking===!1&&(g.isSeeking=!0,h.send("seeking"))}),h.on("seeked",function(){g.isSeeking=!1;var b=g._lastSeekingTime||Ue.now(),L=Ue.now()-b;E(h.data,"view_seek_count",1),E(h.data,"view_seek_duration",L);var A=h.data.view_max_seek_time||0;h.data.view_max_seek_time=Math.max(A,L)}),h.on("viewend",function(){g.isSeeking=!1})});function Ni(p,h){return function(g){if(Array.isArray(g))return g}(p)||function(g,b){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var A,k,C=[],N=!0,O=!1;try{for(L=L.call(g);!(N=(A=L.next()).done)&&(C.push(A.value),!b||C.length!==b);N=!0);}catch(W){O=!0,k=W}finally{try{N||L.return==null||L.return()}finally{if(O)throw k}}return C}}(p,h)||function(g,b){if(g){if(typeof g=="string")return Ui(g,b);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?Ui(g,b):void 0}}(p,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 Ui(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}function Bi(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var St=function(p,h){p.push(h),p.sort(function(g,b){return g.viewer_time-b.viewer_time})},Pn=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],At=function(){function p(L){var A=this;(function(C,N){if(!(C instanceof N))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,L.on("viewinit",function(){A.isAdBreak=!1,A._currentAdRequestNumber=0,A._currentAdResponseNumber=0,A._adRequests=[],A._adResponses=[],A._adHasPlayed=!1,A._wouldBeNewAdPlay=!0,A._prerollPlayTime=void 0}),Pn.forEach(function(C){return L.on(C,A._updateAdData.bind(A))});var k=function(){A.isAdBreak=!1};L.on("adbreakstart",function(){A.isAdBreak=!0}),L.on("play",k),L.on("playing",k),L.on("viewend",k),L.on("adrequest",function(C,N){N=Object.assign({ad_request_id:"generatedAdRequestId"+A._currentAdRequestNumber++},N),St(A._adRequests,N),E(L.data,"view_ad_request_count"),A.inPrerollPosition()&&(L.data.view_preroll_requested=!0,A._adHasPlayed||E(L.data,"view_preroll_request_count"))}),L.on("adresponse",function(C,N){N=Object.assign({ad_request_id:"generatedAdRequestId"+A._currentAdResponseNumber++},N),St(A._adResponses,N);var O=A.findAdRequest(N.ad_request_id);O&&E(L.data,"view_ad_request_time",Math.max(0,N.viewer_time-O.viewer_time))}),L.on("adplay",function(C,N){A._adHasPlayed=!0,A._wouldBeNewAdPlay&&(A._wouldBeNewAdPlay=!1,E(L.data,"view_ad_played_count")),A.inPrerollPosition()&&!L.data.view_preroll_played&&(L.data.view_preroll_played=!0,A._adRequests.length>0&&(L.data.view_preroll_request_time=Math.max(0,N.viewer_time-A._adRequests[0].viewer_time)),L.data.view_start&&(L.data.view_startup_preroll_request_time=Math.max(0,N.viewer_time-L.data.view_start)),A._prerollPlayTime=N.viewer_time)}),L.on("adplaying",function(C,N){A.inPrerollPosition()&&L.data.view_preroll_load_time===void 0&&A._prerollPlayTime!==void 0&&(L.data.view_preroll_load_time=N.viewer_time-A._prerollPlayTime,L.data.view_startup_preroll_load_time=N.viewer_time-A._prerollPlayTime)}),L.on("adended",function(){A._wouldBeNewAdPlay=!0}),L.on("aderror",function(){A._wouldBeNewAdPlay=!0})}var h,g,b;return h=p,(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(L){for(var A=0;A<this._adRequests.length;A++)if(this._adRequests[A].ad_request_id===L)return this._adRequests[A]}},{key:"_updateAdData",value:function(L,A){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&A.ad_tag_url){var k=Ni(mt(A.ad_tag_url),2),C=k[0],N=k[1];this.pm.data.view_preroll_ad_tag_domain=N,this.pm.data.view_preroll_ad_tag_hostname=C}if(!this.pm.data.view_preroll_ad_asset_hostname&&A.ad_asset_url){var O=Ni(mt(A.ad_asset_url),2),W=O[0],me=O[1];this.pm.data.view_preroll_ad_asset_domain=me,this.pm.data.view_preroll_ad_asset_hostname=W}}this.pm.data.ad_asset_url=A==null?void 0:A.ad_asset_url,this.pm.data.ad_tag_url=A==null?void 0:A.ad_tag_url,this.pm.data.ad_creative_id=A==null?void 0:A.ad_creative_id,this.pm.data.ad_id=A==null?void 0:A.ad_id,this.pm.data.ad_universal_id=A==null?void 0:A.ad_universal_id}}])&&Bi(h.prototype,g),b&&Bi(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function hr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function On(p,h,g){return h&&hr(p.prototype,h),g&&hr(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Hi=On(function p(h){var g,b;(function(C,N){if(!(C instanceof N))throw new TypeError("Cannot call a class as a function")})(this,p);var L=function(){h.disableRebufferTracking||g&&(E(h.data,"view_waiting_rebuffer_duration",Ue.now()-g),g=!1,z().clearInterval(b))},A=!1,k=function(){A=!1,L()};h.on("waiting",function(){A&&(h.disableRebufferTracking||(E(h.data,"view_waiting_rebuffer_count",1),g=Ue.now(),b=z().setInterval(function(){if(g){var C=Ue.now();E(h.data,"view_waiting_rebuffer_duration",C-g),g=C}},250)))}),h.on("playing",function(){L(),A=!0}),h.on("pause",k),h.on("seeking",k)});function Ye(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Gi(p,h,g){return h&&Ye(p.prototype,h),g&&Ye(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var _e=Gi(function p(h){var g=this;(function(A,k){if(!(A instanceof k))throw new TypeError("Cannot call a class as a function")})(this,p);var b=function(){g.lastWallClockTime=Ue.now(),h.on("before*",L)},L=function(A){var k=Ue.now(),C=g.lastWallClockTime;g.lastWallClockTime=k,k-C>3e4&&(h.emit("devicesleep",{viewer_time:C}),Object.assign(h.data,{viewer_time:C}),h.send("devicesleep"),h.emit("devicewake",{viewer_time:k}),Object.assign(h.data,{viewer_time:k}),h.send("devicewake"))};h.one("playbackheartbeat",b),h.on("playbackheartbeatend",function(){h.off("before*",L),h.one("playbackheartbeat",b)})}),ai=V(375),si=V(655),xe=V.n(si),Ki="muxData",oi=function(){var p;try{p=ai.parse(xe().get(Ki)||"")}catch{p={}}return p},li=function(p){try{xe().set(Ki,ai.stringify(p),{expires:7300})}catch{}},Mn=function(){var p=oi();return p.mux_viewer_id=p.mux_viewer_id||ne(),p.msn=p.msn||Math.random(),li(p),{mux_viewer_id:p.mux_viewer_id,mux_sample_number:p.msn}};function jt(p,h){var g=h.beaconCollectionDomain,b=h.beaconDomain;if(g)return"https://"+g;var L=b||"litix.io";return(p=p||"inferred").match(/^[a-z0-9]+$/)?"https://"+p+"."+L:"https://img.litix.io/a.gif"}var ui=function(){var p;switch(qi()){case"cellular":p="cellular";break;case"ethernet":p="wired";break;case"wifi":p="wifi";break;case void 0:break;default:p="other"}return p},qi=function(){var p=z().navigator,h=p&&(p.connection||p.mozConnection||p.webkitConnection);return h&&h.type};ui.getConnectionFromAPI=qi;var Vi=ui,ji=fr({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"}),Wi=fr({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 fr(p){var h={};for(var g in p)p.hasOwnProperty(g)&&(h[p[g]]=g);return h}function vr(p){var h={},g={};return Object.keys(p).forEach(function(b){var L=!1;if(p.hasOwnProperty(b)&&p[b]!==void 0){var A=b.split("_"),k=A[0],C=ji[k];C||(ke.info("Data key word `"+A[0]+"` not expected in "+b),C=k+"_"),A.splice(1).forEach(function(N){N==="url"&&(L=!0),Wi[N]?C+=Wi[N]:Number(N)&&Math.floor(Number(N))===Number(N)?C+=N:(ke.info("Data key word `"+N+"` not expected in "+b),C+="_"+N+"_")}),L?g[C]=p[b]:h[C]=p[b]}}),Object.assign(h,g)}var Yi={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},zi=["hb","requestcompleted","requestfailed","requestcanceled"],ct="https://img.litix.io",Lt=function(p){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=p||ct,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},Yi,h)};Lt.prototype.queueEvent=function(p,h){var g=Object.assign({},h);return(this._eventQueue.length<=this._options.maxQueueLength||p==="eventrateexceeded")&&(this._eventQueue.push(g),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},Lt.prototype.flushEvents=function(){var p=arguments.length>0&&arguments[0]!==void 0&&arguments[0];p&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},Lt.prototype.destroy=function(){var p=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,p?this._clearBeaconQueue():this.flushEvents(),z().clearTimeout(this._sendTimeout)},Lt.prototype._clearBeaconQueue=function(){var p=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,h=this._eventQueue.slice(p);p>0&&Object.assign(h[h.length-1],vr({mux_view_message:"event queue truncated"}));var g=this._createPayload(h);Qi(this._beaconUrl,g,!0,function(){})},Lt.prototype._sendBeaconQueue=function(){var p=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),b=Ue.now();Qi(this._beaconUrl,g,!1,function(L,A){A?(p._eventQueue=h.concat(p._eventQueue),p._failureCount+=1,ke.info("Error sending beacon: "+A)):p._failureCount=0,p._roundTripTime=Ue.now()-b,p._postInFlight=!1})}},Lt.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var p=Math.pow(2,this._failureCount-1);return(1+(p*=Math.random()))*this._options.baseTimeBetweenBeacons},Lt.prototype._startBeaconSending=function(){var p=this;z().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=z().setTimeout(function(){p._eventQueue.length&&p._sendBeaconQueue(),p._startBeaconSending()},this._getNextBeaconTime()))},Lt.prototype._createPayload=function(p){var h,g,b,L=this,A={transmission_timestamp:Math.round(Ue.now())};this._roundTripTime&&(A.rtt_ms=Math.round(this._roundTripTime));var k=function(){h=JSON.stringify({metadata:A,events:g||p}),b=h.length/1024},C=function(){return b<=L._options.maxPayloadKBSize};return k(),C()||(ke.info("Payload size is too big ("+b+" kb). Removing unnecessary events."),g=p.filter(function(N){return zi.indexOf(N.e)===-1}),k()),C()||(ke.info("Payload size still too big ("+b+" kb). Cropping fields.."),g.forEach(function(N){for(var O in N){var W=N[O];typeof W=="string"&&W.length>51200&&(N[O]=W.substring(0,51200))}}),k()),h};var Xi=function(p){return p.length<=57344},Qi=function(p,h,g,b){if(g&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(p,h))b();else if(z().fetch)z().fetch(p,{method:"POST",body:h,headers:{"Content-Type":"text/plain"},keepalive:Xi(h)}).then(function(A){return b(null,A.ok?null:"Error")}).catch(function(A){return b(null,A)});else{if(z().XMLHttpRequest){var L=new(z()).XMLHttpRequest;return L.onreadystatechange=function(){if(L.readyState===4)return b(null,L.status!==200?"error":void 0)},L.open("POST",p),L.setRequestHeader("Content-Type","text/plain"),void L.send(h)}b()}},Mr=Lt;function Fn(p,h){return function(g){if(Array.isArray(g))return g}(p)||function(g,b){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var A,k,C=[],N=!0,O=!1;try{for(L=L.call(g);!(N=(A=L.next()).done)&&(C.push(A.value),!b||C.length!==b);N=!0);}catch(W){O=!0,k=W}finally{try{N||L.return==null||L.return()}finally{if(O)throw k}}return C}}(p,h)||function(g,b){if(g){if(typeof g=="string")return di(g,b);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?di(g,b):void 0}}(p,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
3
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function di(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}function Fr(p,h){var g=Object.keys(p);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(p);h&&(b=b.filter(function(L){return Object.getOwnPropertyDescriptor(p,L).enumerable})),g.push.apply(g,b)}return g}function Wt(p){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?Fr(Object(g),!0).forEach(function(b){Nr(p,b,g[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(g)):Fr(Object(g)).forEach(function(b){Object.defineProperty(p,b,Object.getOwnPropertyDescriptor(g,b))})}return p}function ir(p){return ir=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},ir(p)}function Nn(p,h){if(!(p instanceof h))throw new TypeError("Cannot call a class as a function")}function ci(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Nr(p,h,g){return h in p?Object.defineProperty(p,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):p[h]=g,p}var gr=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id"],Ji=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse"],$i=["viewstart","error","ended","viewend"],Un=function(){function p(L,A){var k,C,N,O,W,me,ae,de,le,he,Ae,Xe,tt,nt,pt,Se=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Nn(this,p),Nr(this,"previousBeaconData",null),Nr(this,"lastEventTime",0),Nr(this,"rateLimited",!1),this.mux=L,this.envKey=A,this.options=Se,this.eventQueue=new Mr(jt(this.envKey,this.options)),this.sampleRate=(k=this.options.sampleRate)!==null&&k!==void 0?k:1,this.disableCookies=(C=this.options.disableCookies)!==null&&C!==void 0&&C,this.respectDoNotTrack=(N=this.options.respectDoNotTrack)!==null&&N!==void 0&&N,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:(O=this.options.platform)===null||O===void 0?void 0:O.name,viewer_application_version:(W=this.options.platform)===null||W===void 0?void 0:W.version,viewer_application_engine:(me=this.options.platform)===null||me===void 0?void 0:me.layout,viewer_device_name:(ae=this.options.platform)===null||ae===void 0?void 0:ae.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||(he=le.os)===null||he===void 0?void 0:he.family,viewer_os_architecture:(Ae=this.options.platform)===null||Ae===void 0||(Xe=Ae.os)===null||Xe===void 0?void 0:Xe.architecture,viewer_os_version:(tt=this.options.platform)===null||tt===void 0||(nt=tt.os)===null||nt===void 0?void 0:nt.version,viewer_connection_type:Vi(),page_url:z()===null||z()===void 0||(pt=z().location)===null||pt===void 0?void 0:pt.href},this.viewerData=this.disableCookies?{}:Mn()}var h,g,b;return h=p,(g=[{key:"send",value:function(L,A){var k;if(L&&A!=null&&A.view_id){if(this.respectDoNotTrack&&dt())return ke.info("Not sending `"+L+"` because Do Not Track is enabled");if(!A||ir(A)!=="object")return ke.error("A data object was expected in send() but was not provided");var C,N,O=this.disableCookies?{}:(C=oi(),N=Ue.now(),C.session_start&&(C.sst=C.session_start,delete C.session_start),C.session_id&&(C.sid=C.session_id,delete C.session_id),C.session_expires&&(C.sex=C.session_expires,delete C.session_expires),(!C.sex||C.sex<N)&&(C.sid=ne(),C.sst=N),C.sex=N+15e5,li(C),{session_id:C.sid,session_start:C.sst,session_expires:C.sex}),W=Wt(Wt(Wt(Wt(Wt({},this.pageLevelData),A),O),this.viewerData),{},{event:L,env_key:this.envKey});W.user_id&&(W.viewer_user_id=W.user_id,delete W.user_id);var me=((k=W.mux_sample_number)!==null&&k!==void 0?k:0)>=this.sampleRate,ae=vr(this._deduplicateBeaconData(L,W));if(this.lastEventTime=this.mux.utils.now(),me)return ke.info("Not sending event due to sample rate restriction",L,W,ae);if(this.envKey||ke.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",L,W,ae),!this.rateLimited){if(ke.info("Sending event",L,W,ae),this.rateLimited=!this.eventQueue.queueEvent(L,ae),this.mux.WINDOW_UNLOADING&&L==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&L==="hb"?this.eventQueue.flushEvents(!0):$i.indexOf(L)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return W.event="eventrateexceeded",ae=vr(W),this.eventQueue.queueEvent(W.event,ae),ke.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(L,A){var k=this,C={},N=A.view_id;if(N==="-1"||L==="viewstart"||L==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)C=Wt({},A),N&&(this.previousBeaconData=C),N&&L==="viewend"&&(this.previousBeaconData=null);else{var O=L.indexOf("request")===0;Object.entries(A).forEach(function(W){var me=Fn(W,2),ae=me[0],de=me[1];k.previousBeaconData&&(de!==k.previousBeaconData[ae]||gr.indexOf(ae)>-1||k.objectHasChanged(O,ae,de,k.previousBeaconData[ae])||k.eventRequiresKey(L,ae))&&(C[ae]=de,k.previousBeaconData[ae]=de)})}return C}},{key:"objectHasChanged",value:function(L,A,k,C){return!(!L||A.indexOf("request_")!==0||A!=="request_response_headers"&&ir(k)==="object"&&ir(C)==="object"&&Object.keys(k||{}).length===Object.keys(C||{}).length)}},{key:"eventRequiresKey",value:function(L,A){return L==="renditionchange"&&A.indexOf("video_source_")===0||!(A.indexOf("ad_id")!==0||!Ji.includes(L))}}])&&ci(h.prototype,g),b&&ci(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function hi(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Zi(p,h,g){return h&&hi(p.prototype,h),g&&hi(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var en=Zi(function p(h){(function(O,W){if(!(O instanceof W))throw new TypeError("Cannot call a class as a function")})(this,p);var g=0,b=0,L=0,A=0,k=0,C=0,N=0;h.on("requestcompleted",function(O,W){var me,ae,de=W.request_start,le=W.request_response_start,he=W.request_response_end,Ae=W.request_bytes_loaded;if(A++,le?(me=le-(de!=null?de:0),ae=(he!=null?he:0)-le):ae=(he!=null?he:0)-(de!=null?de:0),ae>0&&Ae&&Ae>0){var Xe=Ae/ae*8e3;k++,b+=Ae,L+=ae,h.data.view_min_request_throughput=Math.min(h.data.view_min_request_throughput||1/0,Xe),h.data.view_average_request_throughput=b/L*8e3,h.data.view_request_count=A,me>0&&(g+=me,h.data.view_max_request_latency=Math.max(h.data.view_max_request_latency||0,me),h.data.view_average_request_latency=g/k)}}),h.on("requestfailed",function(O,W){A++,C++,h.data.view_request_count=A,h.data.view_request_failed_count=C}),h.on("requestcanceled",function(O,W){A++,N++,h.data.view_request_count=A,h.data.view_request_canceled_count=N})});function fi(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function nr(p,h,g){return h&&fi(p.prototype,h),g&&fi(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Yt=nr(function p(h){var g=this;(function(b,L){if(!(b instanceof L))throw new TypeError("Cannot call a class as a function")})(this,p),h.on("before*",function(b,L){var A=L.viewer_time,k=Ue.now(),C=g._lastEventTime;if(g._lastEventTime=k,C&&k-C>36e5){var N=Object.keys(h.data).reduce(function(O,W){return W.indexOf("video_")===0?Object.assign(O,function(me,ae,de){return ae in me?Object.defineProperty(me,ae,{value:de,enumerable:!0,configurable:!0,writable:!0}):me[ae]=de,me}({},W,h.data[W])):O},{});h.mux.log.info("Received event after at least an hour inactivity, creating a new view"),h.emit("viewinit",Object.assign({viewer_time:A},N)),h.playbackHeartbeat._playheadShouldBeProgressing&&b.type!=="play"&&b.type!=="adbreakstart"&&(h.emit("play",{viewer_time:A}),b.type!=="playing"&&h.emit("playing",{viewer_time:A}))}})});function yt(p){return yt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},yt(p)}function Ft(p,h){return function(g){if(Array.isArray(g))return g}(p)||function(g,b){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var A,k,C=[],N=!0,O=!1;try{for(L=L.call(g);!(N=(A=L.next()).done)&&(C.push(A.value),!b||C.length!==b);N=!0);}catch(W){O=!0,k=W}finally{try{N||L.return==null||L.return()}finally{if(O)throw k}}return C}}(p,h)||function(g,b){if(g){if(typeof g=="string")return Me(g,b);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?Me(g,b):void 0}}(p,h)||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 Me(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}function St(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function At(p,h){return At=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,b){return g.__proto__=b,g},At(p,h)}function tn(p){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,b=pr(p);if(h){var L=pr(this).constructor;g=Reflect.construct(b,arguments,L)}else g=b.apply(this,arguments);return vi(this,g)}}function vi(p,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 ze(p)}function ze(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function pr(p){return pr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},pr(p)}var rn=["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"],ar=function(p){(function(k,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function");k.prototype=Object.create(C&&C.prototype,{constructor:{value:k,writable:!0,configurable:!0}}),Object.defineProperty(k,"prototype",{writable:!1}),C&&At(k,C)})(A,p);var h,g,b,L=tn(A);function A(k,C,N){var O;(function(le,he){if(!(le instanceof he))throw new TypeError("Cannot call a class as a function")})(this,A),(O=L.call(this)).DOM_CONTENT_LOADED_EVENT_END=ie.domContentLoadedEventEnd(),O.NAVIGATION_START=ie.navigationStart(),O.mux=k,O.id=C,(N=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}},N)).data=N.data||{},N.data.property_key&&(N.data.env_key=N.data.property_key,delete N.data.property_key),ke.setLevel(N.debug?"debug":"warn"),O.getPlayheadTime=N.getPlayheadTime,O.getStateData=N.getStateData||function(){return{}},O.getAdData=N.getAdData||function(){},O.minimumRebufferDuration=N.minimumRebufferDuration,O.sustainedRebufferThreshold=N.sustainedRebufferThreshold,O.playbackHeartbeatTime=N.playbackHeartbeatTime,O.disableRebufferTracking=N.disableRebufferTracking,O.disableRebufferTracking&&O.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."),O.disablePlayheadRebufferTracking=N.disablePlayheadRebufferTracking,O.errorTranslator=N.errorTranslator,O.playbackEventDispatcher=new Un(k,N.data.env_key,N),O.data={player_instance_id:ne(),mux_sample_rate:N.sampleRate,beacon_domain:N.beaconCollectionDomain?N.beaconCollectionDomain:N.beaconDomain},O.data.view_sequence_number=1,O.data.player_sequence_number=1,O.oldEmit=O.emit,O.emit=function(le,he){he=Object.assign({viewer_time:this.mux.utils.now()},he),this.oldEmit(le,he)};var W=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(ze(O));O.on("viewinit",function(le,he){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,he),this._initializeViewData(),this.one("play",W),this.one("adbreakstart",W)});var me=function(le){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",le)}.bind(ze(O));if(O.on("videochange",function(le,he){me(he)}),O.on("programchange",function(le,he){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),me(Object.assign(he,{view_program_changed:!0})),W(),this.emit("play"),this.emit("playing")}),O.on("fragmentchange",function(le,he){this.currentFragmentPDT=he.currentFragmentPDT,this.currentFragmentStart=he.currentFragmentStart}),O.on("destroy",O.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ae=function(){var le=O.data.view_start!==void 0;O.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",le&&O.mux.WINDOW_HIDDEN&&(O.data.player_is_paused||O.emit("hb"))};window.addEventListener("visibilitychange",ae,!1);var de=function(le){le.persisted||O.destroy()};window.addEventListener("pagehide",de,!1),O.on("destroy",function(){window.removeEventListener("visibilitychange",ae),window.removeEventListener("pagehide",de)})}return O.on("playerready",function(le,he){Object.assign(this.data,he)}),rn.forEach(function(le){O.on(le,function(he,Ae){le.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,Ae),this._sanitizeData()}),O.on("after"+le,function(){(le!=="error"||this.errorTracker.viewErrored)&&this.send(le)})}),O.on("viewend",function(le,he){Object.assign(O.data,he)}),O.one("playerready",function(le){var he=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=he-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}),O.longResumeTracker=new Yt(ze(O)),O.errorTracker=new Ge(ze(O)),new _e(ze(O)),O.seekingTracker=new Cn(ze(O)),O.playheadTime=new Pi(ze(O)),O.playbackHeartbeat=new Jr(ze(O)),new In(ze(O)),O.watchTimeTracker=new $r(ze(O)),new Cr(ze(O)),O.adTracker=new wt(ze(O)),new Oi(ze(O)),new Vt(ze(O)),new Or(ze(O)),new Hi(ze(O)),new en(ze(O)),N.hlsjs&&O.addHLSJS(N),N.dashjs&&O.addDashJS(N),O.emit("viewinit",N.data),O}return h=A,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 C=Object.assign({},this.data);if(C.video_source_is_live===void 0&&(C.player_source_duration===1/0||C.video_source_duration===1/0?C.video_source_is_live=!0:(C.player_source_duration>0||C.video_source_duration>0)&&(C.video_source_is_live=!1)),C.video_source_is_live||["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"].forEach(function(me){C[me]=void 0}),C.video_source_url=C.video_source_url||C.player_source_url,C.video_source_url){var N=Ft(mt(C.video_source_url),2),O=N[0],W=N[1];C.video_source_domain=W,C.video_source_hostname=O}delete C.ad_request_id,this.playbackEventDispatcher.send(k,C),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(C){var N=parseInt(k.data[C],10);k.data[C]=isNaN(N)?void 0:N}),["player_source_url","video_source_url"].forEach(function(C){if(k.data[C]){var N=k.data[C].toLowerCase();N.indexOf("data:")!==0&&N.indexOf("blob:")!==0||(k.data[C]="MSE style URL")}})}},{key:"_resetVideoData",value:function(k,C){var N=this;Object.keys(this.data).forEach(function(O){O.indexOf("video_")===0&&delete N.data[O]})}},{key:"_resetViewData",value:function(){var k=this;Object.keys(this.data).forEach(function(C){C.indexOf("view_")===0&&delete k.data[C]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(k,C){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var k=this,C=this.data.view_id=ne(),N=function(){C===k.data.view_id&&E(k.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",N):N()}},{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(C,N,O){var W=arguments.length>4?arguments[4]:void 0,me=C.log,ae=C.utils.secondsToMs,de=function(Oe){var J,Z=parseInt(W.version);return Z===1&&Oe.programDateTime!==null&&(J=Oe.programDateTime),Z===0&&Oe.pdt!==null&&(J=Oe.pdt),J};if(ie.exists()){var le=function(Oe,J){return C.emit(N,Oe,J)},he=function(Oe,J){var Z=J.levels,ee=J.audioTracks,Ee=J.url,Re=J.stats,Ke=J.networkDetails,ht=J.sessionData,Qe={},at={};Z.forEach(function(ce,Qt){Qe[Qt]={width:ce.width,height:ce.height,bitrate:ce.bitrate,attrs:ce.attrs}}),ee.forEach(function(ce,Qt){at[Qt]={name:ce.name,language:ce.lang,bitrate:ce.bitrate}});var Je=tr(Re),$e=Je.bytesLoaded,Rt=Je.requestStart,Lr=Je.responseStart,Ze=Je.responseEnd;le("requestcompleted",Ne(Ne({},qe(ht)),{},{request_event_type:Oe,request_bytes_loaded:$e,request_start:Rt,request_response_start:Lr,request_response_end:Ze,request_type:"manifest",request_hostname:et(Ee),request_response_headers:Mt(Ke),request_rendition_lists:{media:Qe,audio:at,video:{}}}))};O.on(W.Events.MANIFEST_LOADED,he);var Ae=function(Oe,J){var Z=J.details,ee=J.level,Ee=J.networkDetails,Re=J.stats,Ke=tr(Re),ht=Ke.bytesLoaded,Qe=Ke.requestStart,at=Ke.responseStart,Je=Ke.responseEnd,$e=Z.fragments[Z.fragments.length-1],Rt=de($e)+ae($e.duration);le("requestcompleted",{request_event_type:Oe,request_bytes_loaded:ht,request_start:Qe,request_response_start:at,request_response_end:Je,request_current_level:ee,request_type:"manifest",request_hostname:et(Z.url),request_response_headers:Mt(Ee),video_holdback:Z.holdBack&&ae(Z.holdBack),video_part_holdback:Z.partHoldBack&&ae(Z.partHoldBack),video_part_target_duration:Z.partTarget&&ae(Z.partTarget),video_target_duration:Z.targetduration&&ae(Z.targetduration),video_source_is_live:Z.live,player_manifest_newest_program_time:isNaN(Rt)?void 0:Rt})};O.on(W.Events.LEVEL_LOADED,Ae);var Xe=function(Oe,J){var Z=J.details,ee=J.networkDetails,Ee=J.stats,Re=tr(Ee),Ke=Re.bytesLoaded,ht=Re.requestStart,Qe=Re.responseStart,at=Re.responseEnd;le("requestcompleted",{request_event_type:Oe,request_bytes_loaded:Ke,request_start:ht,request_response_start:Qe,request_response_end:at,request_type:"manifest",request_hostname:et(Z.url),request_response_headers:Mt(ee)})};O.on(W.Events.AUDIO_TRACK_LOADED,Xe);var tt=function(Oe,J){var Z=J.stats,ee=J.networkDetails,Ee=J.frag;Z=Z||Ee.stats;var Re=tr(Z),Ke=Re.bytesLoaded,ht=Re.requestStart,Qe=Re.responseStart,at=Re.responseEnd,Je=ee?Mt(ee):void 0,$e={request_event_type:Oe,request_bytes_loaded:Ke,request_start:ht,request_response_start:Qe,request_response_end:at,request_hostname:ee?et(ee.responseURL):void 0,request_id:Je?Be(Je):void 0,request_response_headers:Je,request_media_duration:Ee.duration,request_url:ee==null?void 0:ee.responseURL};Ee.type==="main"?($e.request_type="media",$e.request_current_level=Ee.level,$e.request_video_width=(O.levels[Ee.level]||{}).width,$e.request_video_height=(O.levels[Ee.level]||{}).height,$e.request_labeled_bitrate=(O.levels[Ee.level]||{}).bitrate):$e.request_type=Ee.type,le("requestcompleted",$e)};O.on(W.Events.FRAG_LOADED,tt);var nt=function(Oe,J){var Z=J.frag,ee=Z.start,Ee={currentFragmentPDT:de(Z),currentFragmentStart:ae(ee)};le("fragmentchange",Ee)};O.on(W.Events.FRAG_CHANGED,nt);var pt=function(Oe,J){var Z=J.type,ee=J.details,Ee=J.response,Re=J.fatal,Ke=J.frag,ht=J.networkDetails,Qe=(Ke==null?void 0:Ke.url)||J.url||"",at=ht?Mt(ht):void 0;if(ee!==W.ErrorDetails.MANIFEST_LOAD_ERROR&&ee!==W.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&ee!==W.ErrorDetails.FRAG_LOAD_ERROR&&ee!==W.ErrorDetails.FRAG_LOAD_TIMEOUT&&ee!==W.ErrorDetails.LEVEL_LOAD_ERROR&&ee!==W.ErrorDetails.LEVEL_LOAD_TIMEOUT&&ee!==W.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&ee!==W.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&ee!==W.ErrorDetails.SUBTITLE_LOAD_ERROR&&ee!==W.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&ee!==W.ErrorDetails.KEY_LOAD_ERROR&&ee!==W.ErrorDetails.KEY_LOAD_TIMEOUT||le("requestfailed",{request_error:ee,request_url:Qe,request_hostname:et(Qe),request_id:at?Be(at):void 0,request_type:ee===W.ErrorDetails.FRAG_LOAD_ERROR||ee===W.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":ee===W.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||ee===W.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":ee===W.ErrorDetails.SUBTITLE_LOAD_ERROR||ee===W.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":ee===W.ErrorDetails.KEY_LOAD_ERROR||ee===W.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:Ee==null?void 0:Ee.code,request_error_text:Ee==null?void 0:Ee.text}),Re){var Je,$e="".concat(Qe?"url: ".concat(Qe,`
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Me(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}function kt(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Rt(p,h){return Rt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,b){return g.__proto__=b,g},Rt(p,h)}function tn(p){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,b=pr(p);if(h){var L=pr(this).constructor;g=Reflect.construct(b,arguments,L)}else g=b.apply(this,arguments);return vi(this,g)}}function vi(p,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 ze(p)}function ze(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function pr(p){return pr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},pr(p)}var rn=["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"],ar=function(p){(function(k,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function");k.prototype=Object.create(C&&C.prototype,{constructor:{value:k,writable:!0,configurable:!0}}),Object.defineProperty(k,"prototype",{writable:!1}),C&&Rt(k,C)})(A,p);var h,g,b,L=tn(A);function A(k,C,N){var O;(function(le,he){if(!(le instanceof he))throw new TypeError("Cannot call a class as a function")})(this,A),(O=L.call(this)).DOM_CONTENT_LOADED_EVENT_END=ie.domContentLoadedEventEnd(),O.NAVIGATION_START=ie.navigationStart(),O.mux=k,O.id=C,(N=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}},N)).data=N.data||{},N.data.property_key&&(N.data.env_key=N.data.property_key,delete N.data.property_key),ke.setLevel(N.debug?"debug":"warn"),O.getPlayheadTime=N.getPlayheadTime,O.getStateData=N.getStateData||function(){return{}},O.getAdData=N.getAdData||function(){},O.minimumRebufferDuration=N.minimumRebufferDuration,O.sustainedRebufferThreshold=N.sustainedRebufferThreshold,O.playbackHeartbeatTime=N.playbackHeartbeatTime,O.disableRebufferTracking=N.disableRebufferTracking,O.disableRebufferTracking&&O.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."),O.disablePlayheadRebufferTracking=N.disablePlayheadRebufferTracking,O.errorTranslator=N.errorTranslator,O.playbackEventDispatcher=new Un(k,N.data.env_key,N),O.data={player_instance_id:ne(),mux_sample_rate:N.sampleRate,beacon_domain:N.beaconCollectionDomain?N.beaconCollectionDomain:N.beaconDomain},O.data.view_sequence_number=1,O.data.player_sequence_number=1,O.oldEmit=O.emit,O.emit=function(le,he){he=Object.assign({viewer_time:this.mux.utils.now()},he),this.oldEmit(le,he)};var W=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(ze(O));O.on("viewinit",function(le,he){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,he),this._initializeViewData(),this.one("play",W),this.one("adbreakstart",W)});var me=function(le){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",le)}.bind(ze(O));if(O.on("videochange",function(le,he){me(he)}),O.on("programchange",function(le,he){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),me(Object.assign(he,{view_program_changed:!0})),W(),this.emit("play"),this.emit("playing")}),O.on("fragmentchange",function(le,he){this.currentFragmentPDT=he.currentFragmentPDT,this.currentFragmentStart=he.currentFragmentStart}),O.on("destroy",O.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ae=function(){var le=O.data.view_start!==void 0;O.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",le&&O.mux.WINDOW_HIDDEN&&(O.data.player_is_paused||O.emit("hb"))};window.addEventListener("visibilitychange",ae,!1);var de=function(le){le.persisted||O.destroy()};window.addEventListener("pagehide",de,!1),O.on("destroy",function(){window.removeEventListener("visibilitychange",ae),window.removeEventListener("pagehide",de)})}return O.on("playerready",function(le,he){Object.assign(this.data,he)}),rn.forEach(function(le){O.on(le,function(he,Ae){le.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,Ae),this._sanitizeData()}),O.on("after"+le,function(){(le!=="error"||this.errorTracker.viewErrored)&&this.send(le)})}),O.on("viewend",function(le,he){Object.assign(O.data,he)}),O.one("playerready",function(le){var he=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=he-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}),O.longResumeTracker=new Yt(ze(O)),O.errorTracker=new Ge(ze(O)),new _e(ze(O)),O.seekingTracker=new Cn(ze(O)),O.playheadTime=new Pi(ze(O)),O.playbackHeartbeat=new Jr(ze(O)),new In(ze(O)),O.watchTimeTracker=new $r(ze(O)),new Cr(ze(O)),O.adTracker=new At(ze(O)),new Oi(ze(O)),new Vt(ze(O)),new Or(ze(O)),new Hi(ze(O)),new en(ze(O)),N.hlsjs&&O.addHLSJS(N),N.dashjs&&O.addDashJS(N),O.emit("viewinit",N.data),O}return h=A,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 C=Object.assign({},this.data);if(C.video_source_is_live===void 0&&(C.player_source_duration===1/0||C.video_source_duration===1/0?C.video_source_is_live=!0:(C.player_source_duration>0||C.video_source_duration>0)&&(C.video_source_is_live=!1)),C.video_source_is_live||["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"].forEach(function(me){C[me]=void 0}),C.video_source_url=C.video_source_url||C.player_source_url,C.video_source_url){var N=Ft(mt(C.video_source_url),2),O=N[0],W=N[1];C.video_source_domain=W,C.video_source_hostname=O}delete C.ad_request_id,this.playbackEventDispatcher.send(k,C),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(C){var N=parseInt(k.data[C],10);k.data[C]=isNaN(N)?void 0:N}),["player_source_url","video_source_url"].forEach(function(C){if(k.data[C]){var N=k.data[C].toLowerCase();N.indexOf("data:")!==0&&N.indexOf("blob:")!==0||(k.data[C]="MSE style URL")}})}},{key:"_resetVideoData",value:function(k,C){var N=this;Object.keys(this.data).forEach(function(O){O.indexOf("video_")===0&&delete N.data[O]})}},{key:"_resetViewData",value:function(){var k=this;Object.keys(this.data).forEach(function(C){C.indexOf("view_")===0&&delete k.data[C]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(k,C){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var k=this,C=this.data.view_id=ne(),N=function(){C===k.data.view_id&&E(k.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",N):N()}},{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(C,N,O){var W=arguments.length>4?arguments[4]:void 0,me=C.log,ae=C.utils.secondsToMs,de=function(Oe){var J,Z=parseInt(W.version);return Z===1&&Oe.programDateTime!==null&&(J=Oe.programDateTime),Z===0&&Oe.pdt!==null&&(J=Oe.pdt),J};if(ie.exists()){var le=function(Oe,J){return C.emit(N,Oe,J)},he=function(Oe,J){var Z=J.levels,ee=J.audioTracks,Ee=J.url,Re=J.stats,Ke=J.networkDetails,ht=J.sessionData,Qe={},at={};Z.forEach(function(ce,Qt){Qe[Qt]={width:ce.width,height:ce.height,bitrate:ce.bitrate,attrs:ce.attrs}}),ee.forEach(function(ce,Qt){at[Qt]={name:ce.name,language:ce.lang,bitrate:ce.bitrate}});var Je=tr(Re),$e=Je.bytesLoaded,Dt=Je.requestStart,Lr=Je.responseStart,Ze=Je.responseEnd;le("requestcompleted",Ne(Ne({},qe(ht)),{},{request_event_type:Oe,request_bytes_loaded:$e,request_start:Dt,request_response_start:Lr,request_response_end:Ze,request_type:"manifest",request_hostname:et(Ee),request_response_headers:Mt(Ke),request_rendition_lists:{media:Qe,audio:at,video:{}}}))};O.on(W.Events.MANIFEST_LOADED,he);var Ae=function(Oe,J){var Z=J.details,ee=J.level,Ee=J.networkDetails,Re=J.stats,Ke=tr(Re),ht=Ke.bytesLoaded,Qe=Ke.requestStart,at=Ke.responseStart,Je=Ke.responseEnd,$e=Z.fragments[Z.fragments.length-1],Dt=de($e)+ae($e.duration);le("requestcompleted",{request_event_type:Oe,request_bytes_loaded:ht,request_start:Qe,request_response_start:at,request_response_end:Je,request_current_level:ee,request_type:"manifest",request_hostname:et(Z.url),request_response_headers:Mt(Ee),video_holdback:Z.holdBack&&ae(Z.holdBack),video_part_holdback:Z.partHoldBack&&ae(Z.partHoldBack),video_part_target_duration:Z.partTarget&&ae(Z.partTarget),video_target_duration:Z.targetduration&&ae(Z.targetduration),video_source_is_live:Z.live,player_manifest_newest_program_time:isNaN(Dt)?void 0:Dt})};O.on(W.Events.LEVEL_LOADED,Ae);var Xe=function(Oe,J){var Z=J.details,ee=J.networkDetails,Ee=J.stats,Re=tr(Ee),Ke=Re.bytesLoaded,ht=Re.requestStart,Qe=Re.responseStart,at=Re.responseEnd;le("requestcompleted",{request_event_type:Oe,request_bytes_loaded:Ke,request_start:ht,request_response_start:Qe,request_response_end:at,request_type:"manifest",request_hostname:et(Z.url),request_response_headers:Mt(ee)})};O.on(W.Events.AUDIO_TRACK_LOADED,Xe);var tt=function(Oe,J){var Z=J.stats,ee=J.networkDetails,Ee=J.frag;Z=Z||Ee.stats;var Re=tr(Z),Ke=Re.bytesLoaded,ht=Re.requestStart,Qe=Re.responseStart,at=Re.responseEnd,Je=ee?Mt(ee):void 0,$e={request_event_type:Oe,request_bytes_loaded:Ke,request_start:ht,request_response_start:Qe,request_response_end:at,request_hostname:ee?et(ee.responseURL):void 0,request_id:Je?Be(Je):void 0,request_response_headers:Je,request_media_duration:Ee.duration,request_url:ee==null?void 0:ee.responseURL};Ee.type==="main"?($e.request_type="media",$e.request_current_level=Ee.level,$e.request_video_width=(O.levels[Ee.level]||{}).width,$e.request_video_height=(O.levels[Ee.level]||{}).height,$e.request_labeled_bitrate=(O.levels[Ee.level]||{}).bitrate):$e.request_type=Ee.type,le("requestcompleted",$e)};O.on(W.Events.FRAG_LOADED,tt);var nt=function(Oe,J){var Z=J.frag,ee=Z.start,Ee={currentFragmentPDT:de(Z),currentFragmentStart:ae(ee)};le("fragmentchange",Ee)};O.on(W.Events.FRAG_CHANGED,nt);var pt=function(Oe,J){var Z=J.type,ee=J.details,Ee=J.response,Re=J.fatal,Ke=J.frag,ht=J.networkDetails,Qe=(Ke==null?void 0:Ke.url)||J.url||"",at=ht?Mt(ht):void 0;if(ee!==W.ErrorDetails.MANIFEST_LOAD_ERROR&&ee!==W.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&ee!==W.ErrorDetails.FRAG_LOAD_ERROR&&ee!==W.ErrorDetails.FRAG_LOAD_TIMEOUT&&ee!==W.ErrorDetails.LEVEL_LOAD_ERROR&&ee!==W.ErrorDetails.LEVEL_LOAD_TIMEOUT&&ee!==W.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&ee!==W.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&ee!==W.ErrorDetails.SUBTITLE_LOAD_ERROR&&ee!==W.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&ee!==W.ErrorDetails.KEY_LOAD_ERROR&&ee!==W.ErrorDetails.KEY_LOAD_TIMEOUT||le("requestfailed",{request_error:ee,request_url:Qe,request_hostname:et(Qe),request_id:at?Be(at):void 0,request_type:ee===W.ErrorDetails.FRAG_LOAD_ERROR||ee===W.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":ee===W.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||ee===W.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":ee===W.ErrorDetails.SUBTITLE_LOAD_ERROR||ee===W.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":ee===W.ErrorDetails.KEY_LOAD_ERROR||ee===W.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:Ee==null?void 0:Ee.code,request_error_text:Ee==null?void 0:Ee.text}),Re){var Je,$e="".concat(Qe?"url: ".concat(Qe,`
|
|
5
5
|
`):"")+"".concat(Ee&&(Ee.code||Ee.text)?"response: ".concat(Ee.code,", ").concat(Ee.text,`
|
|
6
6
|
`):"")+"".concat(J.reason?"failure reason: ".concat(J.reason,`
|
|
7
7
|
`):"")+"".concat(J.level?"level: ".concat(J.level,`
|
|
@@ -10,41 +10,41 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
10
10
|
`):"")+"".concat(J.error?"error: ".concat(J.error,`
|
|
11
11
|
`):"")+"".concat(J.event?"event: ".concat(J.event,`
|
|
12
12
|
`):"")+"".concat(J.err?"error message: ".concat((Je=J.err)===null||Je===void 0?void 0:Je.message,`
|
|
13
|
-
`):"");le("error",{player_error_code:Z,player_error_message:ee,player_error_context:$e})}};O.on(W.Events.ERROR,pt);var Se=function(Oe,J){var Z=J.frag,ee=Z&&Z._url||"";le("requestcanceled",{request_event_type:Oe,request_url:ee,request_type:"media",request_hostname:et(ee)})};O.on(W.Events.FRAG_LOAD_EMERGENCY_ABORTED,Se);var Ve=function(Oe,J){var Z=J.level,ee=O.levels[Z];if(ee&&ee.attrs&&ee.attrs.BANDWIDTH){var Ee,Re=ee.attrs.BANDWIDTH,Ke=parseFloat(ee.attrs["FRAME-RATE"]);isNaN(Ke)||(Ee=Ke),Re?le("renditionchange",{video_source_fps:Ee,video_source_bitrate:Re,video_source_width:ee.width,video_source_height:ee.height,video_source_rendition_name:ee.name,video_source_codec:ee==null?void 0:ee.videoCodec}):me.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};O.on(W.Events.LEVEL_SWITCHED,Ve),O._stopMuxMonitor=function(){O.off(W.Events.MANIFEST_LOADED,he),O.off(W.Events.LEVEL_LOADED,Ae),O.off(W.Events.AUDIO_TRACK_LOADED,Xe),O.off(W.Events.FRAG_LOADED,tt),O.off(W.Events.FRAG_CHANGED,nt),O.off(W.Events.ERROR,pt),O.off(W.Events.FRAG_LOAD_EMERGENCY_ABORTED,Se),O.off(W.Events.LEVEL_SWITCHED,Ve),O.off(W.Events.DESTROYING,O._stopMuxMonitor),delete O._stopMuxMonitor},O.on(W.Events.DESTROYING,O._stopMuxMonitor)}else me.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(C,N,O){var W=C.log;if(O&&O.on){var me=function(Se,Ve){return C.emit(N,Se,Ve)},ae=function(Se){var Ve=Se.type,Oe=(Se.data||{}).url;me("requestcompleted",{request_event_type:Ve,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:et(Oe),request_url:Oe})};O.on("manifestLoaded",ae);var de={},le=function(Se){var Ve=Se.type,Oe=Se.fragmentModel,J=(Se.chunk||{}).mediaInfo||{},Z=J.type,ee=J.bitrateList,Ee={};(ee=ee||[]).forEach(function(Ze,ce){Ee[ce]={},Ee[ce].width=Ze.width,Ee[ce].height=Ze.height,Ee[ce].bitrate=Ze.bandwidth,Ee[ce].attrs={}}),Z==="video"?de.video=Ee:Z==="audio"?de.audio=Ee:de.media=Ee;var Re=vt(Oe,O),Ke=Re.requestStart,ht=Re.requestResponseStart,Qe=Re.requestResponseEnd,at=Re.requestResponseHeaders,Je=Re.requestMediaDuration,$e=Re.requestHostname,
|
|
13
|
+
`):"");le("error",{player_error_code:Z,player_error_message:ee,player_error_context:$e})}};O.on(W.Events.ERROR,pt);var Se=function(Oe,J){var Z=J.frag,ee=Z&&Z._url||"";le("requestcanceled",{request_event_type:Oe,request_url:ee,request_type:"media",request_hostname:et(ee)})};O.on(W.Events.FRAG_LOAD_EMERGENCY_ABORTED,Se);var Ve=function(Oe,J){var Z=J.level,ee=O.levels[Z];if(ee&&ee.attrs&&ee.attrs.BANDWIDTH){var Ee,Re=ee.attrs.BANDWIDTH,Ke=parseFloat(ee.attrs["FRAME-RATE"]);isNaN(Ke)||(Ee=Ke),Re?le("renditionchange",{video_source_fps:Ee,video_source_bitrate:Re,video_source_width:ee.width,video_source_height:ee.height,video_source_rendition_name:ee.name,video_source_codec:ee==null?void 0:ee.videoCodec}):me.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};O.on(W.Events.LEVEL_SWITCHED,Ve),O._stopMuxMonitor=function(){O.off(W.Events.MANIFEST_LOADED,he),O.off(W.Events.LEVEL_LOADED,Ae),O.off(W.Events.AUDIO_TRACK_LOADED,Xe),O.off(W.Events.FRAG_LOADED,tt),O.off(W.Events.FRAG_CHANGED,nt),O.off(W.Events.ERROR,pt),O.off(W.Events.FRAG_LOAD_EMERGENCY_ABORTED,Se),O.off(W.Events.LEVEL_SWITCHED,Ve),O.off(W.Events.DESTROYING,O._stopMuxMonitor),delete O._stopMuxMonitor},O.on(W.Events.DESTROYING,O._stopMuxMonitor)}else me.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(C,N,O){var W=C.log;if(O&&O.on){var me=function(Se,Ve){return C.emit(N,Se,Ve)},ae=function(Se){var Ve=Se.type,Oe=(Se.data||{}).url;me("requestcompleted",{request_event_type:Ve,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:et(Oe),request_url:Oe})};O.on("manifestLoaded",ae);var de={},le=function(Se){var Ve=Se.type,Oe=Se.fragmentModel,J=(Se.chunk||{}).mediaInfo||{},Z=J.type,ee=J.bitrateList,Ee={};(ee=ee||[]).forEach(function(Ze,ce){Ee[ce]={},Ee[ce].width=Ze.width,Ee[ce].height=Ze.height,Ee[ce].bitrate=Ze.bandwidth,Ee[ce].attrs={}}),Z==="video"?de.video=Ee:Z==="audio"?de.audio=Ee:de.media=Ee;var Re=vt(Oe,O),Ke=Re.requestStart,ht=Re.requestResponseStart,Qe=Re.requestResponseEnd,at=Re.requestResponseHeaders,Je=Re.requestMediaDuration,$e=Re.requestHostname,Dt=Re.requestUrl,Lr=Re.requestId;me("requestcompleted",{request_event_type:Ve,request_start:Ke,request_response_start:ht,request_response_end:Qe,request_bytes_loaded:-1,request_type:Z+"_init",request_response_headers:at,request_hostname:$e,request_id:Lr,request_url:Dt,request_media_duration:Je,request_rendition_lists:de})};O.on("initFragmentLoaded",le);var he=function(Se){var Ve=Se.type,Oe=Se.fragmentModel,J=Se.chunk||{},Z=J.mediaInfo,ee=J.start,Ee=(Z||{}).type,Re=vt(Oe,O),Ke=Re.requestStart,ht=Re.requestResponseStart,Qe=Re.requestResponseEnd,at=Re.requestBytesLoaded,Je=Re.requestResponseHeaders,$e=Re.requestMediaDuration,Dt=Re.requestHostname,Lr=Re.requestUrl,Ze=Re.requestId,ce=We(Ee,O),Qt=ce.currentLevel,sr=ce.renditionWidth,or=ce.renditionHeight,kr=ce.renditionBitrate;me("requestcompleted",{request_event_type:Ve,request_start:Ke,request_response_start:ht,request_response_end:Qe,request_bytes_loaded:at,request_type:Ee,request_response_headers:Je,request_hostname:Dt,request_id:Ze,request_url:Lr,request_media_start_time:ee,request_media_duration:$e,request_current_level:Qt,request_labeled_bitrate:kr,request_video_width:sr,request_video_height:or})};O.on("mediaFragmentLoaded",he);var Ae={video:void 0,audio:void 0,totalBitrate:void 0},Xe=function(){if(Ae.video&&typeof Ae.video.bitrate=="number"){if(Ae.video.width&&Ae.video.height){var Se=Ae.video.bitrate;return Ae.audio&&typeof Ae.audio.bitrate=="number"&&(Se+=Ae.audio.bitrate),Se!==Ae.totalBitrate?(Ae.totalBitrate=Se,{video_source_bitrate:Se,video_source_height:Ae.video.height,video_source_width:Ae.video.width,video_source_codec:gt(Ae.video.codec)}):void 0}W.warn("have bitrate info for video but missing width/height")}},tt=function(Se,Ve,Oe){if(typeof Se.newQuality=="number"){var J=Se.mediaType;if(J==="audio"||J==="video"){var Z=O.getBitrateInfoListFor(J).find(function(Ee){return Ee.qualityIndex===Se.newQuality});if(Z&&typeof Z.bitrate=="number"){Ae[J]=rr(rr({},Z),{},{codec:O.getCurrentTrackFor(J).codec});var ee=Xe();ee&&me("renditionchange",ee)}else W.warn("missing bitrate info for ".concat(J))}}else W.warn("missing evt.newQuality in qualityChangeRendered event",Se)};O.on("qualityChangeRendered",tt);var nt=function(Se){var Ve=Se.request,Oe=Se.mediaType;me("requestcanceled",{request_event_type:(Ve=Ve||{}).type+"_"+Ve.action,request_url:Ve.url,request_type:Oe,request_hostname:et(Ve.url)})};O.on("fragmentLoadingAbandoned",nt);var pt=function(Se){var Ve,Oe,J=Se.error,Z=(J==null||(Ve=J.data)===null||Ve===void 0?void 0:Ve.request)||{},ee=(J==null||(Oe=J.data)===null||Oe===void 0?void 0:Oe.response)||{};(J==null?void 0:J.code)===27&&me("requestfailed",{request_error:Z.type+"_"+Z.action,request_url:Z.url,request_hostname:et(Z.url),request_type:Z.mediaType,request_error_code:ee.status,request_error_text:ee.statusText});var Ee="".concat(Z!=null&&Z.url?"url: ".concat(Z.url,`
|
|
14
14
|
`):"")+"".concat(ee!=null&&ee.status||ee!=null&&ee.statusText?"response: ".concat(ee==null?void 0:ee.status,", ").concat(ee==null?void 0:ee.statusText,`
|
|
15
|
-
`):"");me("error",{player_error_code:J==null?void 0:J.code,player_error_message:J==null?void 0:J.message,player_error_context:Ee})};O.on("error",pt),O._stopMuxMonitor=function(){O.off("manifestLoaded",ae),O.off("initFragmentLoaded",le),O.off("mediaFragmentLoaded",he),O.off("qualityChangeRendered",tt),O.off("error",pt),O.off("fragmentLoadingAbandoned",nt),delete O._stopMuxMonitor}}else W.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&&
|
|
15
|
+
`):"");me("error",{player_error_code:J==null?void 0:J.code,player_error_message:J==null?void 0:J.message,player_error_context:Ee})};O.on("error",pt),O._stopMuxMonitor=function(){O.off("manifestLoaded",ae),O.off("initFragmentLoaded",le),O.off("mediaFragmentLoaded",he),O.off("qualityChangeRendered",tt),O.off("error",pt),O.off("fragmentLoadingAbandoned",nt),delete O._stopMuxMonitor}}else W.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(h.prototype,g),b&&kt(h,b),Object.defineProperty(h,"prototype",{writable:!1}),A}(Dn),gi=ar,mr=V(153),yr=V.n(mr);function zt(p){return zt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},zt(p)}function Ur(p,h){return function(g){if(Array.isArray(g))return g}(p)||function(g,b){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var A,k,C=[],N=!0,O=!1;try{for(L=L.call(g);!(N=(A=L.next()).done)&&(C.push(A.value),!b||C.length!==b);N=!0);}catch(W){O=!0,k=W}finally{try{N||L.return==null||L.return()}finally{if(O)throw k}}return C}}(p,h)||function(g,b){if(g){if(typeof g=="string")return Tr(g,b);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?Tr(g,b):void 0}}(p,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
16
16
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Tr(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}var Bt,Bn=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Hn={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};z()&&z().WeakMap&&(Bt=new WeakMap);var pi="#EXT-X-TARGETDURATION",mi="#EXT-X-PART-INF",Gn="#EXT-X-SERVER-CONTROL",Kn="#EXTINF",nn="#EXT-X-PROGRAM-DATE-TIME",Er="#EXT-X-VERSION",yi="#EXT-X-SESSION-DATA",_r=function(p){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(p),this.manifest};_r.prototype.process=function(p){var h;for(this.buffer+=p,h=this.buffer.indexOf(`
|
|
17
17
|
`);h>-1;h=this.buffer.indexOf(`
|
|
18
18
|
`))this.processLine(this.buffer.substring(0,h)),this.buffer=this.buffer.substring(h+1)},_r.prototype.processLine=function(p){var h=p.indexOf(":"),g=on(p,h),b=g[0],L=g.length===2?br(g[1]):void 0;if(b[0]!=="#")this.currentUri.uri=b,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(b){case pi:if(!isFinite(L)||L<0)return;this.manifest.targetDuration=L,this.setHoldBack();break;case mi:Ti(this.manifest,g),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Gn:Ti(this.manifest,g),this.setHoldBack();break;case Kn:L===0?this.currentUri.duration=.01:L>0&&(this.currentUri.duration=L);break;case nn:var A=L,k=new Date(A);this.manifest.dateTimeString||(this.manifest.dateTimeString=A,this.manifest.dateTimeObject=k),this.currentUri.dateTimeString=A,this.currentUri.dateTimeObject=k;break;case Er:Ti(this.manifest,g);break;case yi:var C=_i(g[1]),N=qe(C);Object.assign(this.manifest.sessionData,N)}},_r.prototype.setHoldBack=function(){var p=this.manifest,h=p.serverControl,g=p.targetDuration,b=p.partTargetDuration;if(h){var L="holdBack",A="partHoldBack",k=g&&3*g,C=b&&2*b;g&&!h.hasOwnProperty(L)&&(h[L]=k),k&&h[L]<k&&(h[L]=k),b&&!h.hasOwnProperty(A)&&(h[A]=3*b),b&&h[A]<C&&(h[A]=C)}};var Ti=function(p,h){var g,b=Ei(h[0].replace("#EXT-X-",""));Br(h[1])?(g={},g=Object.assign(sn(h[1]),g)):g=br(h[1]),p[b]=g},Ei=function(p){return p.toLowerCase().replace(/-(\w)/g,function(h){return h[1].toUpperCase()})},br=function(p){if(p.toLowerCase()==="yes"||p.toLowerCase()==="no")return p.toLowerCase()==="yes";var h=p.indexOf(":")!==-1?p:parseFloat(p);return isNaN(h)?p:h},an=function(p){var h={},g=p.split("=");return g.length>1&&(h[Ei(g[0])]=br(g[1])),h},sn=function(p){for(var h=p.split(","),g={},b=0;h.length>b;b++){var L=h[b],A=an(L);g=Object.assign(A,g)}return g},Br=function(p){return p.indexOf("=")>-1},on=function(p,h){return h===-1?[p]:[p.substring(0,h),p.substring(h+1)]},_i=function(p){var h={};if(p){var g=p.search(",");return[p.slice(0,g),p.slice(g+1)].forEach(function(b,L){for(var A=b.replace(/['"]+/g,"").split("="),k=0;k<A.length;k++)A[k]==="DATA-ID"&&(h["DATA-ID"]=A[1-k]),A[k]==="VALUE"&&(h.VALUE=A[1-k])}),{data:h}}},ln=_r,Hr={safeCall:function(p,h,g,b){var L=b;if(p&&typeof p[h]=="function")try{L=p[h].apply(p,g)}catch(A){ke.info("safeCall error",A)}return L},safeIncrement:E,getComputedStyle:function(p,h){var g;if(p&&h&&z()&&typeof z().getComputedStyle=="function")return Bt&&Bt.has(p)&&(g=Bt.get(p)),g||(g=z().getComputedStyle(p,null),Bt&&Bt.set(p,g)),g.getPropertyValue(h)},secondsToMs:function(p){return Math.floor(1e3*p)},assign:Object.assign,headersStringToObject:be,cdnHeadersToRequestId:Be,extractHostnameAndDomain:mt,extractHostname:et,manifestParser:ln,generateShortID:ye,generateUUID:ne,now:Ue.now},un={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 Sr(p,h){return function(g){if(Array.isArray(g))return g}(p)||function(g,b){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var A,k,C=[],N=!0,O=!1;try{for(L=L.call(g);!(N=(A=L.next()).done)&&(C.push(A.value),!b||C.length!==b);N=!0);}catch(W){O=!0,k=W}finally{try{N||L.return==null||L.return()}finally{if(O)throw k}}return C}}(p,h)||function(g,b){if(g){if(typeof g=="string")return Gr(g,b);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?Gr(g,b):void 0}}(p,h)||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 Gr(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}var Tt={},Xt=function p(h){var g=arguments;typeof h=="string"?p.hasOwnProperty(h)?z().setTimeout(function(){g=Array.prototype.splice.call(g,1),p[h].apply(null,g)},0):ke.warn("`"+h+"` is an unknown task"):typeof h=="function"?z().setTimeout(function(){h(p)},0):ke.warn("`"+h+"` is invalid.")},qn={loaded:Ue.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(p,h){return function(g,b,L){var A=Ur(Te(b),3),k=A[0],C=A[1],N=A[2],O=g.log,W=g.utils.getComputedStyle,me=g.utils.secondsToMs;if(!k)return O.error("No element was found with the `"+C+"` query selector.");if(N!=="video"&&N!=="audio")return O.error("The element of `"+C+"` was not a media element.");k.mux&&(k.mux.destroy(),delete k.mux,O.warn("Already monitoring this video element, replacing existing event listeners")),(L=Object.assign({automaticErrorTracking:!0},L)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:g.VERSION},L.data),L.getPlayheadTime=function(){return me(k.currentTime)},L.getStateData=function(){var de,le,he=this.hlsjs&&this.hlsjs.url,Ae=this.dashjs&&zt(this.dashjs.getSource==="function")&&this.dashjs.getSource(),Xe={player_is_paused:k.paused,player_playhead_time:me(k.currentTime),player_width:parseInt(W(k,"width")),player_height:parseInt(W(k,"height")),player_autoplay_on:k.autoplay,player_preload_on:k.preload,player_language_code:k.lang,player_is_fullscreen:yr()&&!!(yr().fullscreenElement||yr().webkitFullscreenElement||yr().mozFullScreenElement||yr().msFullscreenElement),video_poster_url:k.poster,video_source_url:he||Ae||k.currentSrc,video_source_duration:me(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},tt=L.getPlayheadTime();if(k.getStartDate&&tt>0){var nt=k.getStartDate();if(nt&&typeof nt.getTime=="function"&&nt.getTime()){var pt=nt.getTime();if(Xe.player_program_time=pt+tt,k.seekable.length>0){var Se=pt+k.seekable.end(k.seekable.length-1);Xe.player_live_edge_program_time=Se}}}return Xe},k.mux=k.mux||{},k.mux.deleted=!1,k.mux.emit=function(de,le){g.emit(C,de,le)};var ae=function(){O.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=ae,k.mux.swapElement=ae,k.mux.emit=ae,k.mux.addHLSJS=ae,k.mux.addDashJS=ae,k.mux.removeHLSJS=ae,k.mux.removeDashJS=ae,k.mux.deleted=!0,g.emit(C,"destroy")},k.mux.swapElement=function(de){var le=Ur(Te(de),3),he=le[0],Ae=le[1],Xe=le[2];return he?Xe!=="video"&&Xe!=="audio"?g.log.error("The element of `"+Ae+"` was not a media element."):(he.muxId=k.muxId,delete k.muxId,he.mux=he.mux||{},he.mux.listeners=Object.assign({},k.mux.listeners),delete k.mux.listeners,Object.keys(he.mux.listeners).forEach(function(tt){k.removeEventListener(tt,he.mux.listeners[tt],!1),he.addEventListener(tt,he.mux.listeners[tt],!1)}),he.mux.swapElement=k.mux.swapElement,he.mux.destroy=k.mux.destroy,delete k.mux,void(k=he)):g.log.error("No element was found with the `"+Ae+"` query selector.")},k.mux.addHLSJS=function(de){g.addHLSJS(C,de)},k.mux.addDashJS=function(de){g.addDashJS(C,de)},k.mux.removeHLSJS=function(){g.removeHLSJS(C)},k.mux.removeDashJS=function(){g.removeDashJS(C)},g.init(C,L),g.emit(C,"playerready"),k.paused||(g.emit(C,"play"),k.readyState>2&&g.emit(C,"playing")),k.mux.listeners={},Bn.forEach(function(de){(de!=="error"||L.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=Hn[k.error.code]||k.error.message}g.emit(C,de,le)},k.addEventListener(de,k.mux.listeners[de],!1))})}(Xt,p,h)},destroyMonitor:function(p){var h=Sr(Te(p),1)[0];h&&h.mux&&typeof h.mux.destroy=="function"?h.mux.destroy():ke.error("A video element monitor for `"+p+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(p,h){var g=oe(p);Tt[g]?Tt[g].addHLSJS(h):ke.error("A monitor for `"+g+"` has not been initialized.")},addDashJS:function(p,h){var g=oe(p);Tt[g]?Tt[g].addDashJS(h):ke.error("A monitor for `"+g+"` has not been initialized.")},removeHLSJS:function(p){var h=oe(p);Tt[h]?Tt[h].removeHLSJS():ke.error("A monitor for `"+h+"` has not been initialized.")},removeDashJS:function(p){var h=oe(p);Tt[h]?Tt[h].removeDashJS():ke.error("A monitor for `"+h+"` has not been initialized.")},init:function(p,h){dt()&&h&&h.respectDoNotTrack&&ke.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var g=oe(p);Tt[g]=new gi(Xt,g,h)},emit:function(p,h,g){var b=oe(p);Tt[b]?(Tt[b].emit(h,g),h==="destroy"&&delete Tt[b]):ke.error("A monitor for `"+b+"` has not been initialized.")},checkDoNotTrack:dt,log:ke,utils:Hr,events:un,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Xt,qn),z()!==void 0&&typeof z().addEventListener=="function"&&z().addEventListener("pagehide",function(p){p.persisted||(Xt.WINDOW_UNLOADING=!0)},!1);var dn=Xt},655:function(K,Q,V){var re,z;function ne(ye){return ne=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(oe){return typeof oe}:function(oe){return oe&&typeof Symbol=="function"&&oe.constructor===Symbol&&oe!==Symbol.prototype?"symbol":typeof oe},ne(ye);}(function(ye){var oe=!1;if((z=typeof(re=ye)=="function"?re.call(Q,V,Q,K):re)===void 0||(K.exports=z),oe=!0,ne(Q)==="object"&&(K.exports=ye(),oe=!0),!oe){var Te=window.Cookies,we=window.Cookies=ye();we.noConflict=function(){return window.Cookies=Te,we}}})(function(){var ye=function(){for(var oe=0,Te={};oe<arguments.length;oe++){var we=arguments[oe];for(var Ie in we)Te[Ie]=we[Ie]}return Te};return function oe(Te){function we(Ie,je,ke){var dt;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(ke=ye({path:"/"},we.defaults,ke)).expires=="number"){var Ue=new Date;Ue.setMilliseconds(Ue.getMilliseconds()+864e5*ke.expires),ke.expires=Ue}try{dt=JSON.stringify(je),/^[\{\[]/.test(dt)&&(je=dt)}catch{}return je=Te.write?Te.write(je,Ie):encodeURIComponent(String(je)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),Ie=(Ie=(Ie=encodeURIComponent(String(Ie))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[Ie,"=",je,ke.expires?"; expires="+ke.expires.toUTCString():"",ke.path?"; path="+ke.path:"",ke.domain?"; domain="+ke.domain:"",ke.secure?"; secure":""].join("")}Ie||(dt={});for(var et=document.cookie?document.cookie.split("; "):[],mt=/(%[0-9A-Z]{2})+/g,ie=0;ie<et.length;ie++){var E=et[ie].split("="),te=E.slice(1).join("=");te.charAt(0)==='"'&&(te=te.slice(1,-1));try{var B=E[0].replace(mt,decodeURIComponent);if(te=Te.read?Te.read(te,B):Te(te,B)||te.replace(mt,decodeURIComponent),this.json)try{te=JSON.parse(te)}catch{}if(Ie===B){dt=te;break}Ie||(dt[B]=te)}catch{}}return dt}}return we.set=we,we.get=function(Ie){return we.call(we,Ie)},we.getJSON=function(){return we.apply({json:!0},[].slice.call(arguments))},we.defaults={},we.remove=function(Ie,je){we(Ie,"",ye(je,{expires:-1}))},we.withConverter=oe,we}(function(){})})},153:function(K,Q,V){var re,z=V.g!==void 0?V.g:typeof window!="undefined"?window:{},ne=V(558);typeof document!="undefined"?re=document:(re=z["__GLOBAL_DOCUMENT_CACHE@4"])||(re=z["__GLOBAL_DOCUMENT_CACHE@4"]=ne),K.exports=re},48:function(K,Q,V){var re;re=typeof window!="undefined"?window:V.g!==void 0?V.g:typeof self!="undefined"?self:{},K.exports=re},640:function(K,Q,V){var re,z;(function(ne,ye){"use strict";re=function(){var oe=function(){},Te="undefined",we=typeof window!==Te&&typeof window.navigator!==Te&&/Trident\/|MSIE /.test(window.navigator.userAgent),Ie=["trace","debug","info","warn","error"];function je(be,Be){var qe=be[Be];if(typeof qe.bind=="function")return qe.bind(be);try{return Function.prototype.bind.call(qe,be)}catch{return function(){return Function.prototype.apply.apply(qe,[be,arguments])}}}function ke(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function dt(be){return be==="debug"&&(be="log"),typeof console!==Te&&(be==="trace"&&we?ke:console[be]!==void 0?je(console,be):console.log!==void 0?je(console,"log"):oe)}function Ue(be,Be){for(var qe=0;qe<Ie.length;qe++){var Ot=Ie[qe];this[Ot]=qe<be?oe:this.methodFactory(Ot,be,Be)}this.log=this.debug}function et(be,Be,qe){return function(){typeof console!==Te&&(Ue.call(this,Be,qe),this[be].apply(this,arguments))}}function mt(be,Be,qe){return dt(be)||et.apply(this,arguments)}function ie(be,Be,qe){var Ot,Ne=this;Be=Be==null?"WARN":Be;var x="loglevel";function tr(Pe){var vt=(Ie[Pe]||"silent").toUpperCase();if(typeof window!==Te&&x){try{return void(window.localStorage[x]=vt)}catch{}try{window.document.cookie=encodeURIComponent(x)+"="+vt+";"}catch{}}}function Mt(){var Pe;if(typeof window!==Te&&x){try{Pe=window.localStorage[x]}catch{}if(typeof Pe===Te)try{var vt=window.document.cookie,We=vt.indexOf(encodeURIComponent(x)+"=");We!==-1&&(Pe=/^([^;]+)/.exec(vt.slice(We))[1])}catch{}return Ne.levels[Pe]===void 0&&(Pe=void 0),Pe}}function He(){if(typeof window!==Te&&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 be=="string"?x+=":"+be:typeof be=="symbol"&&(x=void 0),Ne.name=be,Ne.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Ne.methodFactory=qe||mt,Ne.getLevel=function(){return Ot},Ne.setLevel=function(Pe,vt){if(typeof Pe=="string"&&Ne.levels[Pe.toUpperCase()]!==void 0&&(Pe=Ne.levels[Pe.toUpperCase()]),!(typeof Pe=="number"&&Pe>=0&&Pe<=Ne.levels.SILENT))throw"log.setLevel() called with invalid level: "+Pe;if(Ot=Pe,vt!==!1&&tr(Pe),Ue.call(Ne,Pe,be),typeof console===Te&&Pe<Ne.levels.SILENT)return"No console available for logging"},Ne.setDefaultLevel=function(Pe){Be=Pe,Mt()||Ne.setLevel(Pe,!1)},Ne.resetLevel=function(){Ne.setLevel(Be,!1),He()},Ne.enableAll=function(Pe){Ne.setLevel(Ne.levels.TRACE,Pe)},Ne.disableAll=function(Pe){Ne.setLevel(Ne.levels.SILENT,Pe)};var rr=Mt();rr==null&&(rr=Be),Ne.setLevel(rr,!1)}var E=new ie,te={};E.getLogger=function(be){if(typeof be!="symbol"&&typeof be!="string"||be==="")throw new TypeError("You must supply a name when creating a logger.");var Be=te[be];return Be||(Be=te[be]=new ie(be,E.getLevel(),E.methodFactory)),Be};var B=typeof window!==Te?window.log:void 0;return E.noConflict=function(){return typeof window!==Te&&window.log===E&&(window.log=B),E},E.getLoggers=function(){return te},E.default=E,E},(z=typeof re=="function"?re.call(Q,V,Q,K):re)===void 0||(K.exports=z)})()},375:function(K,Q){"use strict";var V=Object.prototype.hasOwnProperty;function re(ne){try{return decodeURIComponent(ne.replace(/\+/g," "))}catch{return null}}function z(ne){try{return encodeURIComponent(ne)}catch{return null}}Q.stringify=function(ne,ye){ye=ye||"";var oe,Te,we=[];for(Te in typeof ye!="string"&&(ye="?"),ne)if(V.call(ne,Te)){if((oe=ne[Te])||oe!=null&&!isNaN(oe)||(oe=""),Te=z(Te),oe=z(oe),Te===null||oe===null)continue;we.push(Te+"="+oe)}return we.length?ye+we.join("&"):""},Q.parse=function(ne){for(var ye,oe=/([^=?#&]+)=?([^&]*)/g,Te={};ye=oe.exec(ne);){var we=re(ye[1]),Ie=re(ye[2]);we===null||Ie===null||we in Te||(Te[we]=Ie)}return Te}},558:function(){}},H={};function j(K){var Q=H[K];if(Q!==void 0)return Q.exports;var V=H[K]={exports:{}};return M[K].call(V.exports,V,V.exports,j),V.exports}return j.n=function(K){var Q=K&&K.__esModule?function(){return K.default}:function(){return K};return j.d(Q,{a:Q}),Q},j.d=function(K,Q){for(var V in Q)j.o(Q,V)&&!j.o(K,V)&&Object.defineProperty(K,V,{enumerable:!0,get:Q[V]})},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(K,Q){return Object.prototype.hasOwnProperty.call(K,Q)},j(80)}()},typeof Sn=="object"&&typeof Ta=="object"?Ta.exports=I():typeof Sn=="object"?Sn.mux=I():D.mux=I()})()});var Is=ws((Ds,Ea)=>{(function D(I){var M,H;M=this,H=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 K(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){re(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 Q(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 V(s,n,e){return n&&Q(s.prototype,n),e&&Q(s,e),Object.defineProperty(s,"prototype",{writable:!1}),s}function re(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 z(){return z=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},z.apply(this,arguments)}function ne(s,n){s.prototype=Object.create(n.prototype),s.prototype.constructor=s,oe(s,n)}function ye(s){return ye=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ye(s)}function oe(s,n){return oe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},oe(s,n)}function Te(){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 we(s,n,e){return we=Te()?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&&oe(o,i.prototype),o},we.apply(null,arguments)}function Ie(s){var n=typeof Map=="function"?new Map:void 0;return Ie=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 we(e,arguments,ye(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),oe(r,e)},Ie(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 ke(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 Ue(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var et={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 m={scheme:f.scheme,netLoc:c.netLoc,path:null,params:c.params,query:c.query,fragment:c.fragment};if(!c.netLoc&&(m.netLoc=f.netLoc,c.path[0]!=="/"))if(c.path){var T=f.path,S=T.substring(0,T.lastIndexOf("/")+1)+c.path;m.path=a.normalizePath(S)}else m.path=f.path,c.params||(m.params=f.params,c.query||(m.query=f.query));return m.path===null&&(m.path=d.alwaysNormalize?a.normalizePath(c.path):c.path),a.buildURLFromParts(m)},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})(et);var mt=et.exports,ie=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}({}),te=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}({}),B=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}({}),be=function(){},Be={trace:be,debug:be,log:be,warn:be,info:be,error:be},qe=Be;function Ot(s){var n=self.console[s];return n?n.bind(self.console,"["+s+"] >"):be}function Ne(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){qe[a]=e[a]?e[a].bind(e):Ot(a)})})(s,"debug","log","info","warn","error");try{qe.log('Debug logs enabled for "'+n+'" in hls.js version 1.4.3')}catch{qe=Be}}else qe=Be}var x=qe,tr=/^(\d+)x(\d+)$/,Mt=/(.+?)=(".*?"|.*?)(?:,|$)/g,He=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=tr.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(Mt.lastIndex=0;(t=Mt.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 rr(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var Pe=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=z(new He({}),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"]);ie(i.getTime())&&(this._endDate=i)}}return V(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(ie(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&&ie(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),s}(),vt=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}},We="audio",gt="video",Ir="audiovideo",Xr=function(){function s(n){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[We]=null,e[gt]=null,e[Ir]=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},V(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=mt.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(n){this._url=n}}]),s}(),Qr=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 vt,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}ne(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[We]=null,t[gt]=null,t[Ir]=null},V(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||!ie(this.programDateTime))return null;var t=ie(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}(Xr),Dn=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 vt,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 ne(n,s),V(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}(Xr),Ii=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},V(s,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&ie(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 Jr(s){return Uint8Array.from(atob(s),function(n){return n.charCodeAt(0)})}function xi(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=Jr(l)):(n=Ci(l).subarray(0,16),(e=new Uint8Array(16)).set(n,16-n.length),r=e)}}return r}function Ci(s){return Uint8Array.from(unescape(encodeURIComponent(s)),function(n){return n.charCodeAt(0)})}var Ge={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},xr="org.w3.clearkey",$r="com.apple.streamingkeydelivery",dr="com.microsoft.playready",Cr="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Zr(s){switch(s){case $r:return Ge.FAIRPLAY;case dr:return Ge.PLAYREADY;case Cr:return Ge.WIDEVINE;case xr:return Ge.CLEARKEY}}var Pi="edef8ba979d64acea3c827dcd51d21ed";function ei(s){switch(s){case Ge.FAIRPLAY:return $r;case Ge.PLAYREADY:return dr;case Ge.WIDEVINE:return Cr;case Ge.CLEARKEY:return xr}}function ti(s){var n=s.drmSystems,e=s.widevineLicenseUrl,t=n?[Ge.FAIRPLAY,Ge.WIDEVINE,Ge.PLAYREADY,Ge.CLEARKEY].filter(function(r){return!!n[r]}):[];return!t[Ge.WIDEVINE]&&e&&t.push(Ge.WIDEVINE),t}var ri=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function Vt(s,n,e){return Uint8Array.prototype.slice?s.slice(n,e):new Uint8Array(Array.prototype.slice.call(s,n,e))}var Pr,ii=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},Oi=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},cr=function(s,n){for(var e=n,t=0;ii(s,n);)t+=10,t+=Or(s,n+6),Oi(s,n+10)&&(t+=10),n+=t;if(t>0)return s.subarray(e,e+t)},Or=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]},Mi=function(s,n){return ii(s,n)&&Or(s,n+6)+10<=s.length-n},Fi=function(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"},In=function(s){var n=String.fromCharCode(s[0],s[1],s[2],s[3]),e=Or(s,4);return{type:n,size:e,data:s.subarray(10,10+e)}},ni=function(s){for(var n=0,e=[];ii(s,n);){for(var t=Or(s,n+6),r=(n+=10)+t;n+8<r;){var i=In(s.subarray(n)),a=xn(i);a&&e.push(a),n+=i.size+10}Oi(s,n)&&(n+=10)}return e},xn=function(s){return s.type==="PRIV"?Cn(s):s.type[0]==="W"?Ui(s):Ni(s)},Cn=function(s){if(!(s.size<2)){var n=_t(s.data,!0),e=new Uint8Array(s.data.subarray(n.length+1));return{key:s.type,info:n,data:e.buffer}}},Ni=function(s){if(!(s.size<2)){if(s.type==="TXXX"){var n=1,e=_t(s.data.subarray(n),!0);n+=e.length+1;var t=_t(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=_t(s.data.subarray(1));return{key:s.type,data:r}}},Ui=function(s){if(s.type==="WXXX"){if(s.size<2)return;var n=1,e=_t(s.data.subarray(n),!0);n+=e.length+1;var t=_t(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=_t(s.data);return{key:s.type,data:r}},Bi=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)}},_t=function(s,n){n===void 0&&(n=!1);var e=Pn();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 Pn(){return Pr||self.TextDecoder===void 0||(Pr=new self.TextDecoder("utf-8")),Pr}var wt=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},hr=Math.pow(2,32)-1,On=[].push,Hi={video:1,audio:2,id3:3,text:4};function Ye(s){return String.fromCharCode.apply(null,s)}function Gi(s,n){var e=s[n]<<8|s[n+1];return e<0?65536+e:e}function _e(s,n){var e=ai(s,n);return e<0?4294967296+e:e}function ai(s,n){return s[n]<<24|s[n+1]<<16|s[n+2]<<8|s[n+3]}function si(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 xe(s,n){var e=[];if(!n.length)return e;for(var t=s.byteLength,r=0;r<t;){var i=_e(s,r),a=i>1?r+i:t;if(Ye(s.subarray(r+4,r+8))===n[0])if(n.length===1)e.push(s.subarray(r+8,a));else{var o=xe(s.subarray(r+8,a),n.slice(1));o.length&&On.apply(e,o)}r=a}return e}function Ki(s){var n=[],e=s[0],t=8,r=_e(s,t);t+=4,t+=e===0?8:16,t+=2;var i=s.length+0,a=Gi(s,t);t+=2;for(var o=0;o<a;o++){var l=t,d=_e(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=_e(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 oi(s){for(var n=[],e=xe(s,["moov","trak"]),t=0;t<e.length;t++){var r=e[t],i=xe(r,["tkhd"])[0];if(i){var a=i[0],o=a===0?12:20,l=_e(i,o),d=xe(r,["mdia","mdhd"])[0];if(d){var u=_e(d,o=(a=d[0])===0?12:20),c=xe(r,["mdia","hdlr"])[0];if(c){var f=Ye(c.subarray(8,12)),v={soun:We,vide:gt}[f];if(v){var m=xe(r,["mdia","minf","stbl","stsd"])[0],T=void 0;m&&(T=Ye(m.subarray(12,16))),n[l]={timescale:u,type:v},n[v]={timescale:u,id:l,codec:T}}}}}}return xe(s,["moov","mvex","trex"]).forEach(function(S){var y=_e(S,4),_=n[y];_&&(_.default={duration:_e(S,12),flags:_e(S,20)})}),n}function li(s){var n=xe(s,["schm"])[0];if(n){var e=Ye(n.subarray(4,8));if(e==="cbcs"||e==="cenc")return xe(s,["schi","tenc"])[0]}return x.error("[eme] missing 'schm' box"),null}function Mn(s){var n=_e(s,0),e=8;1&n&&(e+=4),4&n&&(e+=4);for(var t=0,r=_e(s,4),i=0;i<r;i++)256&n&&(t+=_e(s,e),e+=4),512&n&&(e+=4),1024&n&&(e+=4),2048&n&&(e+=4);return t}function jt(s,n){var e=new Uint8Array(s.length+n.length);return e.set(s),e.set(n,s.length),e}function ui(s,n){var e=[],t=n.samples,r=n.timescale,i=n.id,a=!1;return xe(t,["moof"]).map(function(o){var l=o.byteOffset-8;xe(o,["traf"]).map(function(d){var u=xe(d,["tfdt"]).map(function(c){var f=c[0],v=_e(c,4);return f===1&&(v*=Math.pow(2,32),v+=_e(c,8)),v/r})[0];return u!==void 0&&(s=u),xe(d,["tfhd"]).map(function(c){var f=_e(c,4),v=16777215&_e(c,0),m=0,T=(16&v)!=0,S=0,y=(32&v)!=0,_=8;f===i&&((1&v)!=0&&(_+=8),(2&v)!=0&&(_+=4),(8&v)!=0&&(m=_e(c,_),_+=4),T&&(S=_e(c,_),_+=4),y&&(_+=4),n.type==="video"&&(a=function(R){if(!R)return!1;var w=R.indexOf("."),P=w<0?R:R.substring(0,w);return P==="hvc1"||P==="hev1"||P==="dvh1"||P==="dvhe"}(n.codec)),xe(d,["trun"]).map(function(R){var w=R[0],P=16777215&_e(R,0),F=(1&P)!=0,U=0,Y=(4&P)!=0,G=(256&P)!=0,q=0,$=(512&P)!=0,X=0,se=(1024&P)!=0,ve=(2048&P)!=0,ue=0,fe=_e(R,4),pe=8;F&&(U=_e(R,pe),pe+=4),Y&&(pe+=4);for(var ge=U+l,Le=0;Le<fe;Le++){if(G?(q=_e(R,pe),pe+=4):q=m,$?(X=_e(R,pe),pe+=4):X=S,se&&(pe+=4),ve&&(ue=w===0?_e(R,pe):ai(R,pe),pe+=4),n.type===gt)for(var De=0;De<X;){var Ce=_e(t,ge);qi(a,t[ge+=4])&&Vi(t.subarray(ge,ge+Ce),a?2:1,s+ue/r,e),ge+=Ce,De+=Ce+4}s+=q/r}}))})})}),e}function qi(s,n){if(s){var e=n>>1&63;return e===39||e===40}return(31&n)==6}function Vi(s,n,e,t){var r=ji(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=Gi(r,i);if(i+=2,c===49){var f=_e(r,i);if(i+=4,f===1195456820){var v=r[i++];if(v===3){var m=r[i++],T=64&m,S=T?2+3*(31&m):0,y=new Uint8Array(S);if(T){y[0]=m;for(var _=1;_<S;_++)y[_]=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 R=[],w=0;w<16;w++){var P=r[i++].toString(16);R.push(P.length==1?"0"+P:P),w!==3&&w!==5&&w!==7&&w!==9||R.push("-")}for(var F=o-16,U=new Uint8Array(F),Y=0;Y<F;Y++)U[Y]=r[i++];t.push({payloadType:a,pts:e,uuid:R.join(""),userData:_t(U),userDataBytes:U})}}else if(o<u)i+=o;else if(o>u)break}}function ji(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 Wi(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,m=8,T=v;T--;)m+=c[T].byteLength;var S=new Uint8Array(m);for(S[0]=m>>24&255,S[1]=m>>16&255,S[2]=m>>8&255,S[3]=255&m,S.set(d,4),T=0,m=8;T<v;T++)S.set(c[T],m),m+=c[T].byteLength;return S}([112,115,115,104],new Uint8Array([t,0,0,0]),s,i,r,l,e||new Uint8Array)}var fr={},vr=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(){fr={}};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 $r:case Cr:case dr:case xr: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),_=12;_<16;_++)y[_]=S>>8*(15-_)&255;return y}(e);return new s(this.method,this.uri,"identity",this.keyFormatVersions,t)}var r=xi(this.uri);if(r)switch(this.keyFormat){case Cr:this.pssh=r,r.length>=22&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case dr:var i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Wi(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=Jr(u).subarray(0,16);(function(S){var y=function(_,R,w){var P=_[R];_[R]=_[w],_[w]=P};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 m=fr[this.uri];if(!m){var T=Object.keys(fr).length%Number.MAX_SAFE_INTEGER;m=new Uint8Array(16),new DataView(m.buffer,12,4).setUint32(0,T),fr[this.uri]=m}this.keyId=m}return this},s}(),Yi=/\{\$([a-zA-Z0-9-_]+)\}/g;function zi(s){return Yi.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]=bt(s,i))}}function bt(s,n){if(s.variableList!==null||s.hasVariableRefs){var e=s.variableList;return n.replace(Yi,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 Xi(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 Qi(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 Mr(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var Fn={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}},di=Mr();function Fr(s,n){var e;return(e=di==null?void 0:di.isTypeSupported((n||"video")+'/mp4;codecs="'+s+'"'))!=null&&e}var Wt=/#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,ir=/#EXT-X-MEDIA:(.*)/g,Nn=/^#EXT(?:INF|-X-TARGETDURATION):/m,ci=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Nr=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("|")),gr=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 mt.buildAbsoluteURL(e,n,{alwaysNormalize:!0})},s.isMediaPlaylist=function(n){return Nn.test(n)},s.parseMasterPlaylist=function(n,e){var t,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:zi(n)},i=[];for(Wt.lastIndex=0;(t=Wt.exec(n))!=null;)if(t[1]){var a,o=new He(t[1]);ct(r,o,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=bt(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),Un((o.CODECS||"").split(/[ ,]+/).filter(function(R){return R}),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 He(f);ct(r,v,["DATA-ID","LANGUAGE","VALUE","URI"]);var m=v["DATA-ID"];m&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[m]=v);break;case"SESSION-KEY":var T=Ji(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 He(f);ct(r,S,["NAME","VALUE","QUERYPARAM"]),Xi(r,S,e);break;case"CONTENT-STEERING":var y=new He(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=$i(f)}}var _=i.length>0&&i.length<r.levels.length;return r.levels=_?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(ir.lastIndex=0;(r=ir.exec(n))!==null;){var d=new He(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 m=s.findGroup(c,v.groupId)||c[0];hi(v,m,"audioCodec"),hi(v,m,"textCodec")}f.push(v)}}return i},s.parseLevelPlaylist=function(n,e,t,r,i,a){var o,l,d,u=new Ii(e),c=u.fragments,f=null,v=0,m=0,T=0,S=0,y=null,_=new Qr(r,e),R=-1,w=!1;for(ci.lastIndex=0,u.m3u8=n,u.hasVariableRefs=zi(n);(o=ci.exec(n))!==null;){w&&(w=!1,(_=new Qr(r,e)).start=T,_.sn=v,_.cc=S,_.level=t,f&&(_.initSegment=f,_.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null));var P=o[1];if(P){_.duration=parseFloat(P);var F=(" "+o[2]).slice(1);_.title=F||null,_.tagList.push(F?["INF",P,F]:["INF",P])}else if(o[3]){if(ie(_.duration)){_.start=T,d&&fi(_,d,u),_.sn=v,_.level=t,_.cc=S,_.urlId=i,c.push(_);var U=(" "+o[3]).slice(1);_.relurl=bt(u,U),Zi(_,y),y=_,T+=_.duration,v++,m=0,w=!0}}else if(o[4]){var Y=(" "+o[4]).slice(1);y?_.setByteRange(Y,y):_.setByteRange(Y)}else if(o[5])_.rawProgramDateTime=(" "+o[5]).slice(1),_.tagList.push(["PROGRAM-DATE-TIME",_.rawProgramDateTime]),R===-1&&(R=c.length);else{if(!(o=o[0].match(Nr))){x.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<o.length&&o[l]===void 0;l++);var G=(" "+o[l]).slice(1),q=(" "+o[l+1]).slice(1),$=o[l+2]?(" "+o[l+2]).slice(1):"";switch(G){case"PLAYLIST-TYPE":u.type=q.toUpperCase();break;case"MEDIA-SEQUENCE":v=u.startSN=parseInt(q);break;case"SKIP":var X=new He(q);ct(u,X,["RECENTLY-REMOVED-DATERANGES"]);var se=X.decimalInteger("SKIPPED-SEGMENTS");if(ie(se)){u.skippedSegments=se;for(var ve=se;ve--;)c.unshift(null);v+=se}var ue=X.enumeratedString("RECENTLY-REMOVED-DATERANGES");ue&&(u.recentlyRemovedDateranges=ue.split(" "));break;case"TARGETDURATION":u.targetduration=Math.max(parseInt(q),1);break;case"VERSION":u.version=parseInt(q);break;case"EXTM3U":break;case"ENDLIST":u.live=!1;break;case"#":(q||$)&&_.tagList.push($?[q,$]:[q]);break;case"DISCONTINUITY":S++,_.tagList.push(["DIS"]);break;case"GAP":_.gap=!0,_.tagList.push([G]);break;case"BITRATE":_.tagList.push([G,q]);break;case"DATERANGE":var fe=new He(q);ct(u,fe,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),ct(u,fe,fe.clientAttrs);var pe=new Pe(fe,u.dateRanges[fe.ID]);pe.isValid||u.skippedSegments?u.dateRanges[pe.id]=pe:x.warn('Ignoring invalid DATERANGE tag: "'+q+'"'),_.tagList.push(["EXT-X-DATERANGE",q]);break;case"DEFINE":var ge=new He(q);ct(u,ge,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in ge?Qi(u,ge,a):Xi(u,ge,e);break;case"DISCONTINUITY-SEQUENCE":S=parseInt(q);break;case"KEY":var Le=Ji(q,e,u);if(Le.isSupported()){if(Le.method==="NONE"){d=void 0;break}d||(d={}),d[Le.keyFormat]&&(d=z({},d)),d[Le.keyFormat]=Le}else x.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+q+'"');break;case"START":u.startTimeOffset=$i(q);break;case"MAP":var De=new He(q);if(ct(u,De,["BYTERANGE","URI"]),_.duration){var Ce=new Qr(r,e);en(Ce,De,t,d),f=Ce,_.initSegment=f,f.rawProgramDateTime&&!_.rawProgramDateTime&&(_.rawProgramDateTime=f.rawProgramDateTime)}else en(_,De,t,d),f=_,w=!0;break;case"SERVER-CONTROL":var Fe=new He(q);u.canBlockReload=Fe.bool("CAN-BLOCK-RELOAD"),u.canSkipUntil=Fe.optionalFloat("CAN-SKIP-UNTIL",0),u.canSkipDateRanges=u.canSkipUntil>0&&Fe.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=Fe.optionalFloat("PART-HOLD-BACK",0),u.holdBack=Fe.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Et=new He(q);u.partTarget=Et.decimalFloatingPoint("PART-TARGET");break;case"PART":var rt=u.partList;rt||(rt=u.partList=[]);var Nt=m>0?rt[rt.length-1]:void 0,xt=m++,Ct=new He(q);ct(u,Ct,["BYTERANGE","URI"]);var it=new Dn(Ct,_,e,xt,Nt);rt.push(it),_.duration+=it.duration;break;case"PRELOAD-HINT":var ot=new He(q);ct(u,ot,["URI"]),u.preloadHint=ot;break;case"RENDITION-REPORT":var Gt=new He(q);ct(u,Gt,["URI"]),u.renditionReports=u.renditionReports||[],u.renditionReports.push(Gt);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&&(Zi(_,y),_.cc=S,u.fragmentHint=_,d&&fi(_,d,u));var ur=c.length,kt=c[0],ki=c[ur-1];if((T+=u.skippedSegments*u.targetduration)>0&&ur&&ki){u.averagetargetduration=T/ur;var wi=ki.sn;u.endSN=wi!=="initSegment"?wi:0,u.live||(ki.endList=!0),kt&&(u.startCC=kt.cc)}else u.endSN=0,u.startCC=0;return u.fragmentHint&&(T+=u.fragmentHint.duration),u.totalduration=T,u.endCC=S,R>0&&function(_n,Yr){for(var Dr=_n[Yr],Ai=Yr;Ai--;){var er=_n[Ai];if(!er)return;er.programDateTime=Dr.programDateTime-1e3*er.duration,Dr=er}}(c,R),u},s}();function Ji(s,n,e){var t,r,i=new He(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?gr.resolve(o,n):"",f=(d||"1").split("/").map(Number).filter(Number.isFinite);return new vr(a,c,u,f,l)}function $i(s){var n=new He(s).decimalFloatingPoint("TIME-OFFSET");return ie(n)?n:null}function Un(s,n){["video","audio","text"].forEach(function(e){var t=s.filter(function(i){return function(a,o){var l=Fn[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 hi(s,n,e){var t=n[e];t&&(s[e]=t)}function Zi(s,n){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):n!=null&&n.programDateTime&&(s.programDateTime=n.endProgramDateTime),ie(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function en(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 fi(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 nr="manifest",Yt="level",yt="audioTrack",Ft="subtitleTrack",Me="main",St="audio",At="subtitle";function tn(s){switch(s.type){case yt:return St;case Ft:return At;default:return Me}}function vi(s,n){var e=s.url;return e!==void 0&&e.indexOf("data:")!==0||(e=n.url),e}var ze=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:nr,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:Yt,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:Ft,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===nr?o.manifestLoadPolicy.default:z({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),l=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part&&(e.type===Yt&&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===Ft&&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=z({},r,{maxTimeToFirstByteMs:Math.min(f,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,r.maxTimeToFirstByteMs)})}}var v=r.errorRetry||r.timeoutRetry||{},m={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:v.maxNumRetry||0,retryDelay:v.retryDelayMs||0,maxRetryDelay:v.maxRetryDelayMs||0},T={onSuccess:function(S,y,_,R){var w=a.getInternalLoader(_);a.resetInternalLoader(_.type);var P=S.data;P.indexOf("#EXTM3U")===0?(y.parsing.start=performance.now(),gr.isMediaPlaylist(P)?a.handleTrackOrLevelPlaylist(S,y,_,R||null,w):a.handleMasterPlaylist(S,y,_,R)):a.handleManifestParsingError(S,_,new Error("no EXTM3U delimiter"),R||null,y)},onError:function(S,y,_,R){a.handleNetworkError(y,_,!1,S,R)},onTimeout:function(S,y,_){a.handleNetworkError(y,_,!0,void 0,S)}};l.load(e,m,T)},n.handleMasterPlaylist=function(e,t,r,i){var a=this.hls,o=e.data,l=vi(e,r),d=gr.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,m=d.startTimeOffset,T=d.variableList;this.variableList=T;var S=gr.parseMasterPlaylistMedia(o,l,d),y=S.AUDIO,_=y===void 0?[]:y,R=S.SUBTITLES,w=S["CLOSED-CAPTIONS"];_.length&&(_.some(function(P){return!P.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"),_.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new He({}),bitrate:0,url:""}))),a.trigger(E.MANIFEST_LOADED,{levels:c,audioTracks:_,subtitles:R,captions:w,contentSteering:u,url:l,stats:t,networkDetails:i,sessionData:f,sessionKeys:v,startTimeOffset:m,variableList:T})}},n.handleTrackOrLevelPlaylist=function(e,t,r,i,a){var o=this.hls,l=r.id,d=r.level,u=r.type,c=vi(e,r),f=ie(l)?l:0,v=ie(d)?d:f,m=tn(r),T=gr.parseLevelPlaylist(e.data,c,v,m,f,this.variableList);if(u===nr){var S={attrs:new He({}),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:te.NETWORK_ERROR,details:B.MANIFEST_PARSING_ERROR,fatal:t.type===nr,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===Yt?o+=": "+e.level+" id: "+e.id:e.type!==yt&&e.type!==Ft||(o+=" id: "+e.id+' group-id: "'+e.groupId+'"');var l=new Error(o);x.warn("[playlist-loader]: "+o);var d=B.UNKNOWN,u=!1,c=this.getInternalLoader(e);switch(e.type){case nr:d=r?B.MANIFEST_LOAD_TIMEOUT:B.MANIFEST_LOAD_ERROR,u=!0;break;case Yt:d=r?B.LEVEL_LOAD_TIMEOUT:B.LEVEL_LOAD_ERROR,u=!1;break;case yt:d=r?B.AUDIO_TRACK_LOAD_TIMEOUT:B.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case Ft:d=r?B.SUBTITLE_TRACK_LOAD_TIMEOUT:B.SUBTITLE_LOAD_ERROR,u=!1}c&&this.resetInternalLoader(e.type);var f={type:te.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=K({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,m=vi(t,i),T=tn(i),S=typeof i.level=="number"&&T===Me?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:te.NETWORK_ERROR,details:B.LEVEL_PARSING_ERROR,fatal:!1,url:m,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 nr:case Yt: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 Ft:l.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v})}}else{var _=new Error("No Segments found in Playlist");l.trigger(E.ERROR,{type:te.NETWORK_ERROR,details:B.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:_,reason:_.message,response:t,context:i,level:S,parent:T,networkDetails:a,stats:r})}},s}();function pr(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 rn(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 ar(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 gi(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 _=0,R=y;_<=R;){var w=Math.floor((R+_)/2);if(S<T[w].startTime)R=w-1;else{if(!(S>T[w].startTime&&_<y))return w;_=w+1}}return T[_].startTime-S<S-T[R].startTime?_:R}(o,l);if(c>-1)for(var f=c,v=o.length;f<v;f++){var m=o[f];if(m.startTime>=l&&m.endTime<=d)u.push(m);else if(m.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 mr="org.id3",yr="com.apple.quicktime.HLS",zt="https://aomedia.org/emsg/ID3";function Ur(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var Tr=function(){var s=Ur();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Bt(s,n){return s.getTime()/1e3-n}var Bn=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&&(ar(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 pr(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=Ur(),d=0;d<o.length;d++){var u=o[d].type;if((u!==zt||i)&&a){var c=ni(o[d].data);if(c){var f=o[d].pts,v=f+o[d].duration;v>Tr&&(v=Tr),v-f<=0&&(v=f+.25);for(var m=0;m<c.length;m++){var T=c[m];if(!Fi(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===Tr&&(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)&&gi(o,r,i,a==="audio"?function(f){return f.type===mr&&c}:a==="video"?function(f){return f.type===zt&&u}:function(f){return f.type===mr&&c||f.type===zt&&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(_){return!d.includes(_)}),c=function(){var _=u[f];Object.keys(a[_].cues).forEach(function(R){o.removeCue(a[_].cues[R])}),delete a[_]},f=u.length;f--;)c();var v=i.fragments[i.fragments.length-1];if(d.length!==0&&ie(v==null?void 0:v.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var m=v.programDateTime/1e3-v.start,T=Ur(),S=function(){var _=d[y],R=l[_],w=a[_],P=(w==null?void 0:w.cues)||{},F=(w==null?void 0:w.durationKnown)||!1,U=Bt(R.startDate,m),Y=Tr,G=R.endDate;if(G)Y=Bt(G,m),F=!0;else if(R.endOnNext&&!F){var q=d.reduce(function(ge,Le){var De=l[Le];return De.class===R.class&&De.id!==Le&&De.startDate>R.startDate&&ge.push(De),ge},[]).sort(function(ge,Le){return ge.startDate.getTime()-Le.startDate.getTime()})[0];q&&(Y=Bt(q.startDate,m),F=!0)}for(var $,X,se=Object.keys(R.attr),ve=0;ve<se.length;ve++){var ue=se[ve];if((X=ue)!=="ID"&&X!=="CLASS"&&X!=="START-DATE"&&X!=="DURATION"&&X!=="END-DATE"&&X!=="END-ON-NEXT"){var fe=P[ue];if(fe)F&&!w.durationKnown&&(fe.endTime=Y);else{var pe=R.attr[ue];fe=new T(U,Y,""),rr(ue)&&($=pe,pe=Uint8Array.from($.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),fe.value={key:ue,data:pe},fe.type=yr,fe.id=_,r.id3Track.addCue(fe),P[ue]=fe}}}a[_]={cues:P,dateRange:R,durationKnown:F}},y=0;y<d.length;y++)S()}}},s}(),Hn=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===B.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},V(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}(),pi=["NONE","TYPE-0","TYPE-1",null],mi="",Gn="YES",Kn="v2",nn=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}(),Er=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)},V(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 yi(s,n){var e=n.startPTS;if(ie(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 _r(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(ie(l)){var u=Math.abs(l-e);ie(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 m=v-s.startSN,T=s.fragments;for(T[m]=n,f=m;f>0;f--)yi(T[f],T[f-1]);for(f=m;f<T.length-1;f++)yi(T[f],T[f+1]);return s.fragmentHint&&yi(T[T.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,c}function Ti(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,_,R){for(var w=_.skippedSegments,P=Math.max(y.startSN,_.startSN)-_.startSN,F=(y.fragmentHint?1:0)+(w?_.endSN:Math.min(y.endSN,_.endSN))-_.startSN,U=_.startSN-y.startSN,Y=_.fragmentHint?_.fragments.concat(_.fragmentHint):_.fragments,G=y.fragmentHint?y.fragments.concat(y.fragmentHint):y.fragments,q=P;q<=F;q++){var $=G[U+q],X=Y[q];w&&!X&&q<w&&(X=_.fragments[q]=$),$&&X&&R($,X)}}(s,n,function(y,_){y.relurl&&(c=y.cc-_.cc),ie(y.startPTS)&&ie(y.endPTS)&&(_.start=_.startPTS=y.startPTS,_.startDTS=y.startDTS,_.maxStartPTS=y.maxStartPTS,_.endPTS=y.endPTS,_.endDTS=y.endDTS,_.minEndPTS=y.minEndPTS,_.duration=y.endPTS-y.startPTS,_.duration&&(a=_),n.PTSKnown=n.alignedSliding=!0),_.elementaryStreams=y.elementaryStreams,_.loader=y.loader,_.stats=y.stats,_.urlId=y.urlId,y.initSegment&&(_.initSegment=y.initSegment,e=y.initSegment)}),e&&(n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments).forEach(function(y){var _;y.initSegment&&y.initSegment.relurl!==((_=e)==null?void 0:_.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=z({},o),d&&d.forEach(function(y){delete u[y]}),Object.keys(l).forEach(function(y){var _=new Pe(l[y].attr,u[y]);_.isValid?u[y]=_: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 m=0;m<v.length;m++)v[m].cc+=c}n.skippedSegments&&(n.startCC=n.fragments[0].cc),function(y,_,R){if(y&&_)for(var w=0,P=0,F=y.length;P<=F;P++){var U=y[P],Y=_[P+w];U&&Y&&U.index===Y.index&&U.fragment.sn===Y.fragment.sn?R(U,Y):w--}}(s.partList,n.partList,function(y,_){_.elementaryStreams=y.elementaryStreams,_.stats=y.stats}),a?_r(n,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):Ei(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 Ei(s,n){var e=n.startSN+n.skippedSegments-s.startSN,t=s.fragments;e<0||e>=t.length||br(n,t[e].start)}function br(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 an(s,n,e){var t;return s!=null&&s.details?sn((t=s.details)==null?void 0:t.partList,n,e):null}function sn(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 Br(s){switch(s.details){case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_TIMEOUT:case B.LEVEL_LOAD_TIMEOUT:case B.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function on(s,n){var e=Br(n);return s.default[(e?"timeout":"error")+"Retry"]}function _i(s,n){var e=s.backoff==="linear"?1:Math.pow(2,n);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function ln(s){return K(K({},s),{errorRetry:null,timeoutRetry:null})}function Hr(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 un=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 Sr(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&&Gr(e,t,r)===0)return r;var i=un(n,Gr.bind(null,e,t));return!i||i===s&&r?r:i}function Gr(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 Xt,qn=3e5,dn=0,p=2,h=5,g=0,b=1,L=2,A=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)===Me?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 B.FRAG_LOAD_ERROR:case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_ERROR:case B.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case B.FRAG_GAP:case B.FRAG_PARSING_ERROR:case B.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=p);case B.LEVEL_EMPTY_ERROR:case B.LEVEL_PARSING_ERROR:var o,l,d=t.parent===Me?t.level:i.loadLevel;return void(t.details===B.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 B.LEVEL_LOAD_ERROR:case B.LEVEL_LOAD_TIMEOUT:return void(typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case B.AUDIO_TRACK_LOAD_ERROR:case B.AUDIO_TRACK_LOAD_TIMEOUT:case B.SUBTITLE_LOAD_ERROR:case B.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var u=i.levels[i.loadLevel];if(u&&(a.type===yt&&a.groupId===u.audioGroupId||a.type===Ft&&a.groupId===u.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=p,void(t.errorAction.flags=b)}return;case B.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:p,flags:L,hdcpLevel:f}));case B.BUFFER_ADD_CODEC_ERROR:case B.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:i.loadLevel));case B.INTERNAL_EXCEPTION:case B.BUFFER_APPENDING_ERROR:case B.BUFFER_APPEND_ERROR:case B.BUFFER_FULL_ERROR:case B.LEVEL_SWITCH_ERROR:case B.BUFFER_STALLED_ERROR:case B.BUFFER_SEEK_OVER_HOLE:case B.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:dn,flags:g})}if(t.type===te.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=on(this.hls.config.playlistLoadPolicy,e),a=this.playlistError++,o=(r=e.response)==null?void 0:r.code;if(Hr(i,a,Br(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=on(e.details.startsWith("key")?l:o,e),u=t.levels.reduce(function(m,T){return m+T.fragmentError},0);if(i){var c;e.details!==B.FRAG_GAP&&i.fragmentError++;var f=(c=e.response)==null?void 0:c.code;if(Hr(d,u,Br(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,m=d.length;m--;){var T=(m+r.loadLevel)%d.length;if(T!==r.loadLevel&&d[T].loadError===0){var S=d[T];if(e.details===B.FRAG_GAP&&e.frag){var y=d[T].details;if(y){var _=Sr(e.frag,y.fragments,e.frag.start);if(_!=null&&_.gap)continue}}else if(f===yt&&v===S.audioGroupId||f===Ft&&v===S.textGroupId||u===St&&i.audioGroupId===S.audioGroupId||u===At&&i.textGroupId===S.textGroupId)continue;l=T;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,{action:p,flags:g,nextAutoLevel:l}}return{action:p,flags:b}},n.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case dn:break;case p:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===B.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 b:r.resolved||(r.resolved=this.redundantFailover(e));break;case L:a&&(t.maxHdcpLevel=pi[pi.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===Me?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,m=i[v];if(!m||function(T,S,y){if(performance.now()-T.lastErrorPerfMs>qn)return!0;var _=T.details;if(S.details===B.FRAG_GAP&&_&&S.frag){var R=S.frag.start,w=Sr(null,_.fragments,R);if(w&&!w.gap)return!0}if(y&&T.errors.length<y.errors.length){var P=T.errors[T.errors.length-1];if(_&&P.frag&&S.frag&&Math.abs(P.frag.start-S.frag.start)>3*_.targetduration)return!0}return!1}(m,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 nn(u,c>=0?c:void 0,mi)}}},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&&Ti(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,m=a.lastPartSn,T=a.endSN,S=a.lastPartIndex,y=m===T;S!==-1?(c=y?T+1:m,f=y?v?0:S:S+1):c=T+1;var _=a.age,R=_+a.ageHeader,w=Math.min(R-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 P=Math.floor(w/a.targetduration);c+=P,f!==void 0&&(f+=Math.round(w%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+_.toFixed(2)+"s goal: "+w+" skip sn "+P+" 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 F=this.hls.mainForwardBufferInfo,U=F?F.end-F.len:0,Y=function(q,$){$===void 0&&($=1/0);var X=1e3*q.targetduration;if(q.updated){var se=q.fragments;if(se.length&&4*X>$){var ve=1e3*se[se.length-1].duration;ve<X&&(X=ve)}}else X/=2;return Math.round(X)}(a,1e3*(a.edge-U));a.updated&&l>this.requestScheduled+Y&&(this.requestScheduled=o.loading.start),c!==void 0&&a.canBlockReload?this.requestScheduled=o.loading.first+Y-(1e3*a.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+Y<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=Y);var G=this.requestScheduled-l;G=Math.max(0,G),this.log("reload live playlist "+e+" in "+Math.round(G)+" ms"),this.timer=self.setTimeout(function(){return i.loadPlaylist(u)},G)}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?Kn:Gn:mi}(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=mi),new nn(r,i,a)},n.checkRetry=function(e){var t=this,r=e.details,i=Br(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===p);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 m=_i(c,u);this.timer=self.setTimeout(function(){return t.loadPlaylist()},m),this.warn("Retrying playlist loading "+(u+1)+"/"+c.maxNumRetry+' after "'+r+'" in '+m+"ms")}e.levelRetry=!0,a.resolved=!0}return f},s}(),C=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}ne(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&&(Xt||(Xt=/chrome|firefox/i.test(navigator.userAgent)),Xt&&(l.audioCodec=void 0));var c=u.AUDIO,f=u.CODECS,v=u["FRAME-RATE"],m=u["PATHWAY-ID"],T=u.RESOLUTION,S=u.SUBTITLES,y=(m||".")+"-"+l.bitrate+"-"+T+"-"+v+"-"+f;(i=o[y])?i.addFallback(l):(i=new Er(l),o[y]=i,a.push(i)),N(i,"audio",c),N(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(_){var R=_.audioCodec,w=_.videoCodec,P=_.width,F=_.height,U=_.unknownCodecs;return l||(l=!(!P||!F)),d||(d=!!w),u||(u=!!R),!(U!=null&&U.length)&&(!R||Fr(R,"audio"))&&(!w||Fr(w,"video"))});if((l||d)&&u&&(c=c.filter(function(_){var R=_.videoCodec,w=_.width,P=_.height;return!!R||!(!w||!P)})),c.length!==0){r.audioTracks&&O(a=r.audioTracks.filter(function(_){return!_.audioCodec||Fr(_.audioCodec,"audio")})),r.subtitles&&O(o=r.subtitles);var f=c.slice(0);c.sort(function(_,R){return _.attrs["HDCP-LEVEL"]!==R.attrs["HDCP-LEVEL"]?(_.attrs["HDCP-LEVEL"]||"")>(R.attrs["HDCP-LEVEL"]||"")?1:-1:_.bitrate!==R.bitrate?_.bitrate-R.bitrate:_.attrs["FRAME-RATE"]!==R.attrs["FRAME-RATE"]?_.attrs.decimalFloatingPoint("FRAME-RATE")-R.attrs.decimalFloatingPoint("FRAME-RATE"):_.attrs.SCORE!==R.attrs.SCORE?_.attrs.decimalFloatingPoint("SCORE")-R.attrs.decimalFloatingPoint("SCORE"):l&&_.height!==R.height?_.height-R.height:0});var v=f[0];if(this.steering&&(c=this.steering.filterParsedLevels(c)).length!==f.length){for(var m=0;m<f.length;m++)if(f[m].pathwayId===c[0].pathwayId){v=f[m];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(_){return!!_.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 _=new Error("no level with compatible codecs found in manifest");i.hls.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:B.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:_,reason:_.message})}})},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===Yt&&r.context.level===this.level&&this.checkRetry(r)},e.onFragLoaded=function(t,r){var i=r.frag;if(i!==void 0&&i.type===Me){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},V(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:te.OTHER_ERROR,details:B.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=z({},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 m=this.switchParams(u.uri,l==null?void 0:l.details);this.loadPlaylist(m)}}}}},{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 N(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 O(s){var n={};s.forEach(function(e){var t=e.groupId||"";e.id=n[t]=n[t]||0,n[t]++})}var W="NOT_LOADED",me="APPENDING",ae="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=Ae(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),he(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=Ae(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&&he(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||he(t))},n.getState=function(e){var t=Ae(e),r=this.fragments[t];return r?r.buffered?he(r)?ae:de:me:W},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=Ae(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=Ae(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=Ae(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 he(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 Ae(s){return s.type+"_"+s.level+"_"+s.urlId+"_"+s.sn}var Xe=Math.pow(2,17),tt=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 Se({type:te.NETWORK_ERROR,details:B.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=nt(e),v=ln(a.fragLoadPolicy.default),m={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Xe};e.stats=c.stats,c.load(f,m,{onSuccess:function(T,S,y,_){r.resetLoader(e,c);var R=T.data;y.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(R.slice(0,16)),R=R.slice(16)),d({frag:e,part:null,payload:R,networkDetails:_})},onError:function(T,S,y,_){r.resetLoader(e,c),u(new Se({type:te.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:K({url:i,data:void 0},T),error:new Error("HTTP Error "+T.code+" "+T.text),networkDetails:y,stats:_}))},onAbort:function(T,S,y){r.resetLoader(e,c),u(new Se({type:te.NETWORK_ERROR,details:B.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 Se({type:te.NETWORK_ERROR,details:B.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+m.timeout+"ms"),networkDetails:y,stats:T}))},onProgress:function(T,S,y,_){t&&t({frag:e,part:null,payload:y,networkDetails:_})}})}})},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=nt(e,t),v=ln(a.fragLoadPolicy.default),m={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Xe};t.stats=c.stats,c.load(f,m,{onSuccess:function(T,S,y,_){i.resetLoader(e,c),i.updateStatsFromPart(e,t);var R={frag:e,part:t,payload:T.data,networkDetails:_};r(R),d(R)},onError:function(T,S,y,_){i.resetLoader(e,c),u(new Se({type:te.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:K({url:f.url,data:void 0},T),error:new Error("HTTP Error "+T.code+" "+T.text),networkDetails:y,stats:_}))},onAbort:function(T,S,y){e.stats.aborted=t.stats.aborted,i.resetLoader(e,c),u(new Se({type:te.NETWORK_ERROR,details:B.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 Se({type:te.NETWORK_ERROR,details:B.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+m.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 nt(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(ie(r)&&ie(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:te.MEDIA_ERROR,details:B.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return n&&(t.part=n),(n||s).stats.aborted=!0,new Se(t)}var Se=function(s){function n(e){var t;return(t=s.call(this,e.error.message)||this).data=void 0,t.data=e,t}return ne(n,s),n}(Ie(Error)),Ve=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=B.KEY_LOAD_ERROR),new Se({type:te.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,B.KEY_LOAD_ERROR,o))}var l=a.uri;if(!l)return Promise.reject(this.createKeyLoadError(e,B.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,B.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,m,T,S){var y=T.frag,_=T.keyInfo,R=T.url;if(!y.decryptdata||_!==r.keyUriToKeyInfo[R])return l(r.createKeyLoadError(y,B.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),S));_.decryptdata.key=y.decryptdata.key=new Uint8Array(v.data),y.keyLoader=null,_.loader=null,o({frag:y,keyInfo:_})},onError:function(v,m,T,S){r.resetLoader(m),l(r.createKeyLoadError(t,B.KEY_LOAD_ERROR,new Error("HTTP Error "+v.code+" loading key "+v.text),T,K({url:d.url,data:void 0},v)))},onTimeout:function(v,m,T){r.resetLoader(m),l(r.createKeyLoadError(t,B.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:function(v,m,T){r.resetLoader(m),l(r.createKeyLoadError(t,B.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}(),Oe=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}(),J={length:0,start:function(){return 0},end:function(){return 0}},Z=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,m=r[f].end;if(e+t>=v&&e<m)u=v,d=(c=m)-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),J}},s}(),ee=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 Ee(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 Re(s,n){if(s){var e=s.start+n;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function Ke(s,n){for(var e=n.fragments,t=0,r=e.length;t<r;t++)Re(e[t],s);n.fragmentHint&&Re(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=Ee(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&&ie(a.start)&&(x.log("Adjusting PTS using last level due to CC increase within current level "+r.url),Ke(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&&ie(o)&&(x.log("Adjusting PTS using programDateTime delta "+(a-i)+"ms, sliding:"+o.toFixed(3)+" "+t.url+" "),Ke(o,t))}}(e,n.details),e.alignedSliding||!n.details||e.skippedSegments||Ei(n.details,e))}function Qe(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=Ee(e,r.cc)||e[Math.round(e.length/2)-1],a=r.programDateTime,o=i.programDateTime;a!==null&&o!==null&&Ke((o-a)/1e3-(i.start-r.start),s)}}}var at=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}(),Je=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}(),$e=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],m=new Uint32Array(256),T=0,S=0,y=0;for(y=0;y<256;y++)m[y]=y<128?y<<1:y<<1^283;for(y=0;y<256;y++){var _=S^S<<1^S<<2^S<<3^S<<4;_=_>>>8^255&_^99,e[T]=_,t[_]=T;var R=m[T],w=m[R],P=m[w],F=257*m[_]^16843008*_;i[T]=F<<24|F>>>8,a[T]=F<<16|F>>>16,o[T]=F<<8|F>>>24,l[T]=F,F=16843009*P^65537*w^257*R^16843008*T,u[_]=F<<24|F>>>8,c[_]=F<<16|F>>>16,f[_]=F<<8|F>>>24,v[_]=F,T?(T=R^m[m[m[P^R]]],S^=m[m[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),m=this.sBox,T=this.rcon,S=this.invSubMix,y=S[0],_=S[1],R=S[2],w=S[3];for(o=0;o<c;o++)o<a?d=f[o]=t[o]:(u=d,o%a==0?(u=m[(u=u<<8|u>>>24)>>>24]<<24|m[u>>>16&255]<<16|m[u>>>8&255]<<8|m[255&u],u^=T[o/a|0]<<24):a>6&&o%a==4&&(u=m[u>>>24]<<24|m[u>>>16&255]<<16|m[u>>>8&255]<<8|m[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[m[u>>>24]]^_[m[u>>>16&255]]^R[m[u>>>8&255]]^w[m[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,m,T,S,y,_,R=this.keySize+6,w=this.invKeySchedule,P=this.invSBox,F=this.invSubMix,U=F[0],Y=F[1],G=F[2],q=F[3],$=this.uint8ArrayToUint32Array_(r),X=$[0],se=$[1],ve=$[2],ue=$[3],fe=new Int32Array(e),pe=new Int32Array(fe.length),ge=this.networkToHostOrderSwap;t<fe.length;){for(v=ge(fe[t]),m=ge(fe[t+1]),T=ge(fe[t+2]),S=ge(fe[t+3]),d=v^w[0],u=S^w[1],c=T^w[2],f=m^w[3],y=4,_=1;_<R;_++)i=U[d>>>24]^Y[u>>16&255]^G[c>>8&255]^q[255&f]^w[y],a=U[u>>>24]^Y[c>>16&255]^G[f>>8&255]^q[255&d]^w[y+1],o=U[c>>>24]^Y[f>>16&255]^G[d>>8&255]^q[255&u]^w[y+2],l=U[f>>>24]^Y[d>>16&255]^G[u>>8&255]^q[255&c]^w[y+3],d=i,u=a,c=o,f=l,y+=4;i=P[d>>>24]<<24^P[u>>16&255]<<16^P[c>>8&255]<<8^P[255&f]^w[y],a=P[u>>>24]<<24^P[c>>16&255]<<16^P[f>>8&255]<<8^P[255&d]^w[y+1],o=P[c>>>24]<<24^P[f>>16&255]<<16^P[d>>8&255]<<8^P[255&u]^w[y+2],l=P[f>>>24]<<24^P[d>>16&255]<<16^P[u>>8&255]<<8^P[255&c]^w[y+3],pe[t]=ge(i^X),pe[t+1]=ge(l^se),pe[t+2]=ge(o^ve),pe[t+3]=ge(a^ue),X=v,se=m,ve=T,ue=S,t+=4}return pe.buffer},s}(),Rt=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))?Vt(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=jt(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 $e),d.expandKey(t);var u=a;return this.currentResult=d.decrypt(l.buffer,0,r),this.currentIV=Vt(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 Je(a,t)),this.fastAesKey.expandKey().then(function(o){return a?(i.logOnce("WebCrypto AES decrypt"),new at(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=Vt(e,0,r),this.remainderData=Vt(e,r)),t},n.logOnce=function(e){this.logEnabled&&(x.log("[decrypter]: "+e),this.logEnabled=!1)},s}(),Lr=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},Ze="STOPPED",ce="IDLE",Qt="KEY_LOADING",sr="FRAG_LOADING",or="FRAG_LOADING_WAITING_RETRY",kr="WAITING_TRACK",Jt="PARSING",cn="PARSED",bi="ENDED",Kr="ERROR",Si="WAITING_INIT_PTS",qr="WAITING_LEVEL",Vn=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=Ze,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 tt(t.config),l.keyLoader=i,l.fragmentTracker=r,l.config=t.config,l.decrypter=new Rt(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}ne(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=Ze},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 Z.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===Ze&&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=Z.bufferInfo(a||i,l,t.maxBufferHole);if(this.log("media seeking to "+(ie(l)?l.toFixed(3):l)+", state: "+o),this.state===bi)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=Ze,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===sr||!a.fragCurrent&&l===Jt)&&(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!==Ze&&a.state!==Kr&&(a.warn(o),a.resetFragmentLoading(t))})},e.clearTrackerIfNeeded=function(t){var r,i=this.fragmentTracker;if(i.getState(t)===me){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)===ae&&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:te.MEDIA_ERROR,details:B.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!==Ze&&i.state!==Kr&&(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===Me?"level":"track")+" "+t.level+" (frag:["+((i=t.startPTS)!=null?i:NaN).toFixed(3)+"-"+((a=t.endPTS)!=null?a:NaN).toFixed(3)+"] > buffer:"+(d?Lr(Z.getBuffered(d)):"(detached)")+")"),this.state=ce,d&&(!this.loadedmetadata&&t.type==Me&&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 ee(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=Qt,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===Qt&&(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,m=c[f];return this.log("Loading part sn: "+t.sn+" p: "+m.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=m.start+m.duration,this.state=sr,v=u?u.then(function(y){return!y||l.fragContextChanged(y.frag)?null:l.doFragPartsLoad(t,m,r,a)}).catch(function(y){return l.handleFragLoadError(y)}):this.doFragPartsLoad(t,m,r,a).catch(function(y){return l.handleFragLoadError(y)}),this.hls.trigger(E.FRAG_LOADING,{frag:t,part:m,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))),ie(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=sr;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 _=y[0];return!S&&_&&a&&a(_),_}).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(m){o.fragmentLoader.loadPart(t,m,a).then(function(T){c[m.index]=T;var S=T.part;o.hls.trigger(E.FRAG_LOADED,T);var y=an(i,t.sn,m.index+1)||sn(f,t.sn,m.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===B.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(E.ERROR,r)}else this.hls.trigger(E.ERROR,{type:te.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},e._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(r&&this.state===Jt){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===Ze||this.state===Kr||(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?an(d,o,l):null,c=u?u.fragment:function(f,v,m){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&&m&&m.sn===v?m: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===Jt){var l=t.data1,d=t.data2,u=l;if(l&&d&&(u=jt(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(Z.isBuffered(r,r.currentTime)){var i=r.currentTime,a=Z.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 ie(i)?this.getFwdBufferInfoAtPos(t,i,r):null},e.getFwdBufferInfoAtPos=function(t,r,i){var a=this.config.maxBufferHole,o=Z.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 Z.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,Me);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===ae&&!!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||!ie(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 m=u[v];if(Tt(c,f,m))return m}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 un(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,m=!!(o.lowLatencyMode&&v!=null&&v.length&&c);if(m&&c&&!this.bitrateTest&&(d=d.concat(c),u=c.sn),a=t<r?Sr(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===ae&&a.gap)&&(l=a),l&&a.sn===l.sn&&(!m||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&&ie(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&&ie(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===or)||(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===B.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,m=u.retryConfig;if(d&&c===h&&m){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var T=_i(m,v);this.warn("Fragment "+a.sn+" of "+t+" "+a.level+" errored with "+r.details+", retrying loading "+(v+1)+"/"+m.maxNumRetry+" in "+T+"ms"),d.resolved=!0,this.retryDate=self.performance.now()+T,this.state=or}else m&&d?(this.resetFragmentErrors(t),v<m.maxNumRetry?l||(d.resolved=!0):x.warn(r.details+" reached or exceeded max retry ("+v+")")):this.state=Kr;this.tickImmediate()}},e.reduceLengthAndFlushBuffer=function(t){if(this.state===Jt||this.state===cn){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===St&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Ze&&(this.state=ce)},e.afterBufferFlushed=function(t,r,i){if(t){var a=Z.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,a,i),this.state===bi&&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 m=v.endPTS-v.startPTS;if(m<=0)return l.warn("Could not parse fragment "+t.sn+" "+f+" duration reliably ("+m+")"),c||!1;var T=a?0:_r(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:te.MEDIA_ERROR,details:B.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=cn,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())},V(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}(Oe);function Da(){return self.SourceBuffer||self.WebKitSourceBuffer}function Ht(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 Ia=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=jt(this.cachedData,e),this.cachedData=null);var r,i=cr(e,0),a=i?i.length:0,o=this._audioTrack,l=this._id3Track,d=i?function(v){for(var m=ni(v),T=0;T<m.length;T++){var S=m[T];if(Fi(S))return Bi(S)}}(i):void 0,u=e.length;for((this.basePTS===null||this.frameIndex===0&&ie(d))&&(this.basePTS=Zs(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:mr,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 Mi(e,a)?(i=cr(e,a),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:mr,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===u&&r!==u){var f=Vt(e,r);this.cachedData?this.cachedData=jt(this.cachedData,f):this.cachedData=f}}return{audioTrack:o,videoTrack:Ht(),id3Track:l,textTrack:Ht()}},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:Ht(),id3Track:this._id3Track,textTrack:Ht()}},n.destroy=function(){},s}(),Zs=function(s,n,e){return ie(s)?90*s:9e4*n+(e?9e4*e.baseTime/e.timescale:0)};function xa(s,n){return s[n]===255&&(246&s[n+1])==240}function Ca(s,n){return 1&s[n+1]?7:9}function jn(s,n){return(3&s[n+3])<<11|s[n+4]<<3|(224&s[n+5])>>>5}function hn(s,n){return n+1<s.length&&xa(s,n)}function eo(s,n){if(hn(s,n)){var e=Ca(s,n);if(n+e>=s.length)return!1;var t=jn(s,n);if(t<=e)return!1;var r=n+t;return r===s.length||hn(s,r)}return!1}function Pa(s,n,e,t,r){if(!s.samplerate){var i=function(a,o,l,d){var u,c,f,v,m=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(m)?y>=6?(u=5,v=new Array(4),c=y-3):(u=2,v=new Array(2),c=y):m.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(m))||!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:te.MEDIA_ERROR,details:B.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 Oa(s){return 9216e4/s}function Ma(s,n,e,t,r){var i,a=t+r*Oa(s.samplerate),o=function(m,T){var S=Ca(m,T);if(T+S<=m.length){var y=jn(m,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 to=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}ne(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=(cr(t,0)||[]).length,i=t.length;r<i;r++)if(eo(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)&&xa(i,a)&&jn(i,a)<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){Pa(t,this.observer,r,i,t.manifestCodec);var a=Ma(t,r,i,this.basePTS,this.frameIndex);if(a&&a.missing===0)return a},n}(Ia),ro=/\/emsg[-/]ID3/i,io=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=Ht("video",1),o=this.audioTrack=Ht("audio",1),l=this.txtTrack=Ht("text",1);if(this.id3Track=Ht("id3",1),this.timeOffset=0,e!=null&&e.byteLength){var d=oi(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 m=d.audio,T=m.id,S=m.timescale,y=m.codec;o.id=T,o.timescale=S,o.codec=y}l.id=Hi.text,a.sampleDuration=0,a.duration=o.duration=i}},n.resetContiguity=function(){this.remainderData=null},s.probe=function(e){return xe(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=jt(this.remainderData,e));var o=function(d){var u={valid:null,remainder:null},c=xe(d,["moof"]);if(!c)return u;if(c.length<2)return u.remainder=d,u;var f=c[c.length-1];return u.valid=Vt(d,0,f.byteOffset-8),u.remainder=Vt(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=ui(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=ui(e,t),{videoTrack:t,audioTrack:Ht(),id3Track:i,textTrack:Ht()}},n.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=xe(e.samples,["emsg"]);i&&i.forEach(function(a){var o=function(c){var f=c[0],v="",m="",T=0,S=0,y=0,_=0,R=0,w=0;if(f===0){for(;Ye(c.subarray(w,w+1))!=="\0";)v+=Ye(c.subarray(w,w+1)),w+=1;for(v+=Ye(c.subarray(w,w+1)),w+=1;Ye(c.subarray(w,w+1))!=="\0";)m+=Ye(c.subarray(w,w+1)),w+=1;m+=Ye(c.subarray(w,w+1)),w+=1,T=_e(c,12),S=_e(c,16),_=_e(c,20),R=_e(c,24),w=28}else if(f===1){T=_e(c,w+=4);var P=_e(c,w+=4),F=_e(c,w+=4);for(w+=4,y=Math.pow(2,32)*P+F,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")),_=_e(c,w),R=_e(c,w+=4),w+=4;Ye(c.subarray(w,w+1))!=="\0";)v+=Ye(c.subarray(w,w+1)),w+=1;for(v+=Ye(c.subarray(w,w+1)),w+=1;Ye(c.subarray(w,w+1))!=="\0";)m+=Ye(c.subarray(w,w+1)),w+=1;m+=Ye(c.subarray(w,w+1)),w+=1}return{schemeIdUri:v,value:m,timeScale:T,presentationTime:y,presentationTimeDelta:S,eventDuration:_,id:R,payload:c.subarray(w,c.byteLength)}}(a);if(ro.test(o.schemeIdUri)){var l=ie(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:zt,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}(),fn=null,no=[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],ao=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],so=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],oo=[0,1,1,4];function Fa(s,n,e,t,r){if(!(e+24>n.length)){var i=Na(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 Na(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*no[14*(e===3?3-t:t===3?3:4)+r-1],d=ao[3*(e===3?0:e===2?1:2)+i],u=o===3?1:2,c=so[e][t],f=oo[t],v=8*c*f,m=Math.floor(c*l/d+a)*f;if(fn===null){var T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);fn=T?parseInt(T[1]):0}return!!fn&&fn<=87&&t===2&&l>=224e3&&o===0&&(s[n+3]=128|s[n+3]),{sampleRate:d,channelCount:u,frameLength:m,samplesPerFrame:v}}}function Wn(s,n){return s[n]===255&&(224&s[n+1])==224&&(6&s[n+1])!=0}function Ua(s,n){return n+1<s.length&&Wn(s,n)}function lo(s,n){if(n+1<s.length&&Wn(s,n)){var e=Na(s,n),t=4;e!=null&&e.frameLength&&(t=e.frameLength);var r=n+t;return r===s.length||Ua(s,r)}return!1}var Ba=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),m=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 _=c();if(_===3&&v(1),T(),T(),v(1),f())for(t=_!==3?8:12,r=0;r<t;r++)f()&&S(r<6?16:64)}T();var R=c();if(R===0)c();else if(R===1)for(v(1),m(),m(),e=c(),r=0;r<e;r++)m();T(),v(1);var w=c(),P=c(),F=u(1);F===0&&v(1),v(1),f()&&(i=c(),a=c(),o=c(),l=c());var U=[1,1];if(f()&&f())switch(d()){case 1:U=[1,1];break;case 2:U=[12,11];break;case 3:U=[10,11];break;case 4:U=[16,11];break;case 5:U=[40,33];break;case 6:U=[24,11];break;case 7:U=[20,11];break;case 8:U=[32,11];break;case 9:U=[80,33];break;case 10:U=[18,11];break;case 11:U=[15,11];break;case 12:U=[64,33];break;case 13:U=[160,99];break;case 14:U=[4,3];break;case 15:U=[3,2];break;case 16:U=[2,1];break;case 255:U=[d()<<8|d(),d()<<8|d()]}return{width:Math.ceil(16*(w+1)-2*i-2*a),height:(2-F)*(P+1)*16-(F?2:4)*(o+l),pixelRatio:U}},n.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},s}(),uo=function(){function s(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Rt(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=ji(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,co=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||Yn(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:Hi[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,m=d.pid,T=l.pesData,S=d.pesData,y=null,_=this.pmtParsed,R=this._pmtId,w=e.length;if(this.remainderData&&(w=(e=jt(this.remainderData,e)).length,this.remainderData=null),w<Lt&&!i)return this.remainderData=e,{audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};var P=Math.max(0,s.syncOffset(e));(w-=(w-P)%Lt)<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,w,e.buffer.byteLength-w));for(var F=0,U=P;U<w;U+=Lt)if(e[U]===71){var Y=!!(64&e[U+1]),G=Yn(e,U),q=void 0;if((48&e[U+3])>>4>1){if((q=U+5+e[U+4])===U+Lt)continue}else q=U+4;switch(G){case c:Y&&(f&&(a=Vr(f))&&this.parseAVCPES(o,u,a,!1),f={data:[],size:0}),f&&(f.data.push(e.subarray(q,U+Lt)),f.size+=U+Lt-q);break;case v:if(Y){if(T&&(a=Vr(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(q,U+Lt)),T.size+=U+Lt-q);break;case m:Y&&(S&&(a=Vr(S))&&this.parseID3PES(d,a),S={data:[],size:0}),S&&(S.data.push(e.subarray(q,U+Lt)),S.size+=U+Lt-q);break;case 0:Y&&(q+=e[q]+1),R=this._pmtId=ho(e,q);break;case R:Y&&(q+=e[q]+1);var $=fo(e,q,this.typeSupported,r);(c=$.avc)>0&&(o.pid=c),(v=$.audio)>0&&(l.pid=v,l.segmentCodec=$.segmentCodec),(m=$.id3)>0&&(d.pid=m),y===null||_||(x.warn("MPEG-TS PMT found at "+U+" after unknown PID '"+y+"'. Backtracking to sync byte @"+P+" to parse all TS packets."),y=null,U=P-188),_=this.pmtParsed=!0;break;case 17:case 8191:break;default:y=G}}else F++;if(F>0){var X=new Error("Found "+F+" TS packet/s that do not start with 0x47");this.observer.emit(E.ERROR,E.ERROR,{type:te.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:X,reason:X.message})}o.pesData=f,l.pesData=T,d.pesData=S;var se={audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};return i&&this.extractRemainingSamples(se),se},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=Vr(l))?(this.parseAVCPES(i,o,t,!0),i.pesData=null):i.pesData=l,d&&(t=Vr(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=Vr(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 uo(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&&(zn(d,e),d=this.avcSample=vn(!1,r.pts,r.dts,"")),l.forEach(function(c){switch(c.type){case 1:a=!0,d||(d=o.avcSample=vn(!0,r.pts,r.dts,"")),d.frame=!0;var f=c.data;if(u&&f.length>4){var v=new Ba(f).readSliceType();v!==2&&v!==4&&v!==7&&v!==9||(d.key=!0)}break;case 5:a=!0,d||(d=o.avcSample=vn(!0,r.pts,r.dts,"")),d.key=!0,d.frame=!0;break;case 6:a=!0,Vi(c.data,1,r.pts,t.samples);break;case 7:if(a=!0,u=!0,!e.sps){var m=c.data,T=new Ba(m).readSPS();e.width=T.width,e.height=T.height,e.pixelRatio=T.pixelRatio,e.sps=[m],e.duration=o._duration;for(var S=m.subarray(1,4),y="avc1.",_=0;_<3;_++){var R=S[_].toString(16);R.length<2&&(R="0"+R),y+=R}e.codec=y}break;case 8:a=!0,e.pps||(e.pps=[c.data]);break;case 9:a=!1,e.audFound=!0,d&&zn(d,e),d=o.avcSample=vn(!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&&(zn(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 m=this.getLastNalUnit(e.samples);if(m&&(l&&u<=4-l&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-l)),(i=u-o-1)>0)){var T=new Uint8Array(m.data.byteLength+i);T.set(m.data,0),T.set(t.subarray(0,i),m.data.byteLength),m.data=T,m.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 _=new Uint8Array(y.data.byteLength+t.byteLength);_.set(y.data,0),_.set(t,y.data.byteLength),y.data=_}}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&&!hn(d,r);r++);if(r!==o){var m,T=r<i-1;m=T?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES";var S=new Error(m);if(x.warn("parsing error: "+m),this.observer.emit(E.ERROR,E.ERROR,{type:te.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,levelRetry:T,error:S,reason:m}),!T)return}if(Pa(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=Oa(e.samplerate);a=l.sample.pts+y}for(var _,R=0;r<i;){if(r+=(_=Ma(e,d,r,a,R)).length,_.missing){this.aacOverFlow=_;break}for(R++;r<i-1&&!hn(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(Ua(r,o)){var d=Fa(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=z({},t,{type:this._avcTrack?zt:mr,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else x.warn("[tsdemuxer]: ID3 PES unknown PTS")},s}();function vn(s,n,e,t){return{key:s,frame:!1,pts:n,dts:e,units:[],debug:t,length:0}}function Yn(s,n){return((31&s[n+1])<<8)+s[n+2]}function ho(s,n){return(31&s[n+10])<<8|s[n+11]}function fo(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=Yn(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 Vr(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 m=(n=o[f]).byteLength;if(u){if(u>m){u-=m;continue}n=n.subarray(u),m-=u,u=0}c.set(n,a),a+=m}return e&&(e-=t+3),{data:c,pts:r,dts:i,len:e}}return null}function zn(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}ne(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=(cr(t,0)||[]).length,i=t.length;r<i;r++)if(lo(t,r))return x.log("MPEG Audio sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return Wn(i,a)&&4<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){if(this.basePTS!==null)return Fa(t,r,i,this.basePTS,this.frameIndex)},n}(Ia),Ha=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}(),lr=Math.pow(2,32)-1,st=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/(lr+1)),r=Math.floor(e%(lr+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/(lr+1)),r=Math.floor(e%(lr+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/(lr+1)),o=Math.floor(t%(lr+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/(lr+1)),a=Math.floor(e%(lr+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 Xn(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 Li(s,n){return n===void 0&&(n=!1),Xn(s,1e3,1/9e4,n)}st.types=void 0,st.HDLR_TYPES=void 0,st.STTS=void 0,st.STSC=void 0,st.STCO=void 0,st.STSZ=void 0,st.VMHD=void 0,st.SMHD=void 0,st.STSD=void 0,st.FTYP=void 0,st.DINF=void 0;var gn=null,Qn=null,Jn=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,gn===null){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);gn=a?parseInt(a[1]):0}if(Qn===null){var o=navigator.userAgent.match(/Safari\/(\d+)/i);Qn=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,Dt(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,m,T,S=a,y=a,_=e.pid>-1,R=t.pid>-1,w=t.samples.length,P=e.samples.length>0,F=l&&w>0||w>1;if((!_||P)&&(!R||F)||this.ISGenerated||l){this.ISGenerated||(f=this.generateIS(e,t,a,o));var U,Y=this.isVideoContiguous,G=-1;if(F&&(G=function(ve){for(var ue=0;ue<ve.length;ue++)if(ve[ue].key)return ue;return-1}(t.samples),!Y&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,G>0){x.warn("[mp4-remuxer]: Dropped "+G+" out of "+w+" video samples due to a missing keyframe");var q=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(G),t.dropped+=G,U=y+=(t.samples[0].pts-q)/t.inputTimeScale}else G===-1&&(x.warn("[mp4-remuxer]: No keyframe found out of "+w+" video samples"),T=!1);if(this.ISGenerated){if(P&&F){var $=this.getVideoStartPts(t.samples),X=(Dt(e.samples[0].pts,$)-$)/t.inputTimeScale;S+=Math.max(0,X),y+=Math.max(0,-X)}if(P){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,R||F||d===St?y:void 0),F){var se=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,Y,se)}}else F&&(u=this.remuxVideo(t,y,Y,0));u&&(u.firstKeyFrame=G,u.independent=G!==-1,u.firstKeyFramePTS=U)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(m=Ga(r,a,this._initPTS,this._initDTS)),i.samples.length&&(v=Ka(i,a,this._initPTS))),{audio:c,video:u,initSegment:f,independent:T,text:v,id3:m}},n.generateIS=function(e,t,r,i){var a,o,l,d=e.samples,u=t.samples,c=this.typeSupported,f={},v=this._initPTS,m=!v||i,T="audio/mp4";if(m&&(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):st.initSegment([e]),metadata:{channelCount:e.channelCount}},m&&(l=e.inputTimeScale,v&&l===v.timescale?m=!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:st.initSegment([t]),metadata:{width:t.width,height:t.height}},m))if(l=t.inputTimeScale,v&&l===v.timescale)m=!1;else{var S=this.getVideoStartPts(u),y=Math.round(l*r);o=Math.min(o,Dt(u[0].dts,S)-y),a=Math.min(a,S-y)}if(Object.keys(f).length)return this.ISGenerated=!0,m?(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,m=8,T=this.videoSampleDuration,S=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,_=!1;r&&v!==null||(v=t*l-(d[0].pts-Dt(d[0].dts,d[0].pts)));for(var R=f.baseTime*l/f.timescale,w=0;w<c;w++){var P=d[w];P.pts=Dt(P.pts-R,v),P.dts=Dt(P.dts-R,v),P.dts<d[w>0?w-1:w].dts&&(_=!0)}_&&d.sort(function(bn,Ls){var hl=bn.dts-Ls.dts,fl=bn.pts-Ls.pts;return hl||fl}),a=d[0].dts;var F=(o=d[d.length-1].dts)-a,U=F?Math.round(F/(c-1)):T||e.inputTimeScale/30;if(r){var Y=a-v,G=Y>U,q=Y<-1;if((G||q)&&(G?x.warn("AVC: "+Li(Y,!0)+" ms ("+Y+"dts) hole between fragments detected, filling it"):x.warn("AVC: "+Li(-Y,!0)+" ms ("+Y+"dts) overlapping between fragments detected"),!q||v>d[0].pts)){a=v;var $=d[0].pts-Y;d[0].dts=a,d[0].pts=$,x.log("Video: First PTS/DTS adjusted: "+Li($,!0)+"/"+Li(a,!0)+", delta: "+Li(Y,!0)+" ms")}}a=Math.max(0,a);for(var X=0,se=0,ve=0;ve<c;ve++){for(var ue=d[ve],fe=ue.units,pe=fe.length,ge=0,Le=0;Le<pe;Le++)ge+=fe[Le].data.length;se+=ge,X+=pe,ue.length=ge,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 De,Ce=se+4*X+8;try{De=new Uint8Array(Ce)}catch(bn){return void this.observer.emit(E.ERROR,E.ERROR,{type:te.MUX_ERROR,details:B.REMUX_ALLOC_ERROR,fatal:!1,error:bn,bytes:Ce,reason:"fail allocating video mdat "+Ce})}var Fe=new DataView(De.buffer);Fe.setUint32(0,Ce),De.set(st.types.mdat,4);for(var Et=!1,rt=Number.POSITIVE_INFINITY,Nt=Number.POSITIVE_INFINITY,xt=Number.NEGATIVE_INFINITY,Ct=Number.NEGATIVE_INFINITY,it=0;it<c;it++){for(var ot=d[it],Gt=ot.units,ur=0,kt=0,ki=Gt.length;kt<ki;kt++){var wi=Gt[kt],_n=wi.data,Yr=wi.data.byteLength;Fe.setUint32(m,Yr),m+=4,De.set(_n,m),m+=Yr,ur+=4+Yr}var Dr=void 0;if(it<c-1)T=d[it+1].dts-ot.dts,Dr=d[it+1].pts-ot.pts;else{var Ai=this.config,er=it>0?ot.dts-d[it-1].dts:U;if(Dr=it>0?ot.pts-d[it-1].pts:U,Ai.stretchShortVideoTrack&&this.nextAudioPts!==null){var ol=Math.floor(Ai.maxBufferHole*l),ma=(i?S+i*l:this.nextAudioPts)-ot.pts;ma>ol?((T=ma-er)<0?T=er:Et=!0,x.log("[mp4-remuxer]: It is approximately "+ma/90+" ms to the next segment; using duration "+T/90+" ms for the last video frame.")):T=er}else T=er}var ll=Math.round(ot.pts-ot.dts);rt=Math.min(rt,T),xt=Math.max(xt,T),Nt=Math.min(Nt,Dr),Ct=Math.max(Ct,Dr),u.push(new qa(ot.key,T,ur,ll))}if(u.length){if(gn){if(gn<70){var _s=u[0].flags;_s.dependsOn=2,_s.isNonSync=0}}else if(Qn&&Ct-Nt<xt-rt&&U/xt<.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 ya=a,Ut=0,bs=u.length;Ut<bs;Ut++){var Ss=ya+u[Ut].duration,ul=ya+u[Ut].cts;if(Ut<bs-1){var dl=Ss+u[Ut+1].cts;u[Ut].duration=dl-ul}else u[Ut].duration=Ut?u[Ut-1].duration:U;u[Ut].cts=0,ya=Ss}}}T=Et||!T?U:T,this.nextAvcDts=v=o+T,this.videoSampleDuration=T,this.isVideoContiguous=!0;var cl={data1:st.moof(e.sequenceNumber++,a,z({},e,{samples:u})),data2:De,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,cl},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=[],m=a!==void 0,T=e.samples,S=f?0:8,y=this.nextAudioPts||-1,_=t*o,R=c.baseTime*o/c.timescale;if(this.isAudioContiguous=r=r||T.length&&y>0&&(i&&Math.abs(_-y)<9e3||Math.abs(Dt(T[0].pts-R,_)-y)<20*u),T.forEach(function(kt){kt.pts=Dt(kt.pts-R,_)}),!r||y<0){if(T=T.filter(function(kt){return kt.pts>=0}),!T.length)return;y=a===0?0:i&&!m?Math.max(0,_):T[0].pts}if(e.segmentCodec==="aac")for(var w=this.config.maxAudioFramesDrift,P=0,F=y;P<T.length;P++){var U=T[P],Y=U.pts,G=Y-F,q=Math.abs(1e3*G/o);if(G<=-w*u&&m)P===0&&(x.warn("Audio frame @ "+(Y/o).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*G/o)+" ms."),this.nextAudioPts=y=F=Y);else if(G>=w*u&&q<1e4&&m){var $=Math.round(G/u);(F=Y-$*u)<0&&($--,F+=u),P===0&&(this.nextAudioPts=y=F),x.warn("[mp4-remuxer]: Injecting "+$+" audio frame @ "+(F/o).toFixed(3)+"s due to "+Math.round(1e3*G/o)+" ms gap.");for(var X=0;X<$;X++){var se=Math.max(F,0),ve=Ha.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);ve||(x.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ve=U.unit.subarray()),T.splice(P,0,{unit:ve,pts:se}),F+=u,P++}}U.pts=F,F+=u}for(var ue,fe=null,pe=null,ge=0,Le=T.length;Le--;)ge+=T[Le].unit.byteLength;for(var De=0,Ce=T.length;De<Ce;De++){var Fe=T[De],Et=Fe.unit,rt=Fe.pts;if(pe!==null)v[De-1].duration=Math.round((rt-pe)/l);else{if(r&&e.segmentCodec==="aac"&&(rt=y),fe=rt,!(ge>0))return;ge+=S;try{ue=new Uint8Array(ge)}catch(kt){return void this.observer.emit(E.ERROR,E.ERROR,{type:te.MUX_ERROR,details:B.REMUX_ALLOC_ERROR,fatal:!1,error:kt,bytes:ge,reason:"fail allocating audio mdat "+ge})}f||(new DataView(ue.buffer).setUint32(0,ge),ue.set(st.types.mdat,4))}ue.set(Et,S);var Nt=Et.byteLength;S+=Nt,v.push(new qa(!0,d,Nt,0)),pe=rt}var xt=v.length;if(xt){var Ct=v[v.length-1];this.nextAudioPts=y=pe+l*Ct.duration;var it=f?new Uint8Array(0):st.moof(e.sequenceNumber++,fe/l,z({},e,{samples:v}));e.samples=[];var ot=fe/o,Gt=y/o,ur={data1:it,data2:ue,startPTS:ot,endPTS:Gt,startDTS:ot,endDTS:Gt,type:"audio",hasAudio:!0,hasVideo:!1,nb:xt};return this.isAudioContiguous=!0,ur}},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,m=Math.ceil((f-c)/v),T=Ha.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(x.warn("[mp4-remuxer]: remux empty Audio"),T){for(var S=[],y=0;y<m;y++){var _=c+y*v;S.push({unit:T,pts:_,dts:_})}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 Dt(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 Ga(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=Dt(o.pts-9e4*e.baseTime/e.timescale,n*i)/i,o.dts=Dt(o.dts-9e4*t.baseTime/t.timescale,n*i)/i}var l=s.samples;return s.samples=[],{samples:l}}}function Ka(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=Dt(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 $t,qa=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 go(s)},go=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},po=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&&xe(a,["moov","trak"]).forEach(function(d){var u=xe(d,["mdia","minf","stbl","stsd"])[0].subarray(8),c=xe(u,["enca"]),f=c.length>0;f||(c=xe(u,["encv"])),c.forEach(function(v){xe(f?v.subarray(28):v.subarray(78),["sinf"]).forEach(function(m){var T=li(m);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: "+wt(S)+" -> "+wt(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=oi(e);t||(t=Va(i.audio,We)),r||(r=Va(i.video,gt));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};ie(c)||(c=this.lastEndTime=a||0);var v=t.samples;if(v==null||!v.length)return f;var m={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&&(m.tracks=this.initTracks,this.emitInitSegment=!1);var S=function(G,q){for(var $=0,X=0,se=0,ve=xe(G,["moof","traf"]),ue=0;ue<ve.length;ue++){var fe=ve[ue],pe=xe(fe,["tfhd"])[0],ge=q[_e(pe,4)];if(ge){var Le=ge.default,De=_e(pe,0)|(Le==null?void 0:Le.flags),Ce=Le==null?void 0:Le.duration;8&De&&(Ce=_e(pe,2&De?12:8));for(var Fe=ge.timescale||9e4,Et=xe(fe,["trun"]),rt=0;rt<Et.length;rt++)!($=Mn(Et[rt]))&&Ce&&($=Ce*_e(Et[rt],4)),ge.type===gt?X+=$/Fe:ge.type===We&&(se+=$/Fe)}}if(X===0&&se===0){for(var Nt=0,xt=xe(G,["sidx"]),Ct=0;Ct<xt.length;Ct++){var it=Ki(xt[Ct]);it!=null&&it.references&&(Nt+=it.references.reduce(function(ot,Gt){return ot+Gt.info.duration||0},0))}return Nt}return X||se}(v,T),y=function(G,q){return xe(q,["moof","traf"]).reduce(function($,X){var se=xe(X,["tfdt"])[0],ve=se[0],ue=xe(X,["tfhd"]).reduce(function(fe,pe){var ge=_e(pe,4),Le=G[ge];if(Le){var De=_e(se,4);if(ve===1){if(De===hr)return x.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),fe;De*=hr+1,De+=_e(se,8)}var Ce=De/(Le.timescale||9e4);if(isFinite(Ce)&&(fe===null||Ce<fe))return Ce}return fe},null);return ue!==null&&isFinite(ue)&&($===null||ue<$)?ue:$},null)}(T,v),_=y===null?a:y;(function(G,q,$,X){if(G===null)return!0;var se=Math.max(X,1),ve=q-G.baseTime/G.timescale;return Math.abs(ve-$)>se}(u,_,a,S)||m.timescale!==u.timescale&&o)&&(m.initPTS=_-a,u&&u.timescale===1&&x.warn("Adjusting initPTS by "+(m.initPTS-u.baseTime)),this.initPTS=u={baseTime:m.initPTS,timescale:1});var R=e?_-u.baseTime/u.timescale:c,w=R+S;(function(G,q,$){xe(q,["moof","traf"]).forEach(function(X){xe(X,["tfhd"]).forEach(function(se){var ve=_e(se,4),ue=G[ve];if(ue){var fe=ue.timescale||9e4;xe(X,["tfdt"]).forEach(function(pe){var ge=pe[0],Le=_e(pe,4);if(ge===0)Le-=$*fe,si(pe,4,Le=Math.max(Le,0));else{Le*=Math.pow(2,32),Le+=_e(pe,8),Le-=$*fe,Le=Math.max(Le,0);var De=Math.floor(Le/(hr+1)),Ce=Math.floor(Le%(hr+1));si(pe,4,De),si(pe,8,Ce)}})}})})})(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 P=!!T.audio,F=!!T.video,U="";P&&(U+="audio"),F&&(U+="video");var Y={data1:v,startPTS:R,startDTS:R,endPTS:w,endDTS:w,type:U,hasAudio:P,hasVideo:F,nb:1,dropped:0};return f.audio=Y.type==="audio"?Y:void 0,f.video=Y.type!=="audio"?Y:void 0,f.initSegment=m,f.id3=Ga(r,a,u,u),i.samples.length&&(f.text=Ka(i,a,u)),f},s}();function Va(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===gt?"avc1.42e01e":"mp4a.40.5"}try{$t=self.performance.now.bind(self.performance)}catch{x.debug("Unable to use Performance API on this environment"),$t=typeof self!="undefined"&&self.Date.now}var $n=[{demux:io,remux:po},{demux:co,remux:Jn},{demux:to,remux:Jn},{demux:vo,remux:Jn}],Zn=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=$t();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,m=c.trackSwitch,T=c.accurateTimeOffset,S=c.timeOffset,y=c.initSegmentChange,_=u.audioCodec,R=u.videoCodec,w=u.defaultInitPts,P=u.duration,F=u.initSegmentData,U=function(ve,ue){var fe=null;return ve.byteLength>0&&ue!=null&&ue.key!=null&&ue.iv!==null&&ue.method!=null&&(fe=ue),fe}(l,t);if(U&&U.method==="AES-128"){var Y=this.getDecrypter();if(!Y.isSync())return this.decryptionPromise=Y.webCryptoDecrypt(l,U.key.buffer,U.iv.buffer).then(function(ve){var ue=a.push(ve,null,r);return a.decryptionPromise=null,ue}),this.decryptionPromise;var G=Y.softwareDecrypt(l,U.key.buffer,U.iv.buffer);if(r.part>-1&&(G=Y.flush()),!G)return o.executeEnd=$t(),ea(r);l=new Uint8Array(G)}var q=this.needsProbing(v,m);if(q){var $=this.configureTransmuxer(l);if($)return x.warn("[transmuxer] "+$.message),this.observer.emit(E.ERROR,E.ERROR,{type:te.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:$,reason:$.message}),o.executeEnd=$t(),ea(r)}(v||m||y||q)&&this.resetInitSegment(F,_,R,P,t),(v||y||q)&&this.resetInitialTimestamp(w),f||this.resetContiguity();var X=this.transmux(l,U,S,T,r),se=this.currentTransmuxState;return se.contiguous=!0,se.discontinuity=!1,se.trackSwitch=!1,o.executeEnd=$t(),X},n.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=$t();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=$t(),[ea(e)];var v=c.flush(d);return wr(v)?v.then(function(m){return t.flushRemux(l,m,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=$t()},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=$n.length;l<d;l++)if($n[l].demux.probe(e)){t=$n[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 Rt(this.config)),e},s}(),ea=function(s){return{remuxResult:{},chunkMeta:s}};function wr(s){return"then"in s&&s.then instanceof Function}var mo=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},yo=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},ja={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),m=e?e+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],v]:l._events[m].push(v):(l._events[m]=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 m=e?e+l:l;if(!this._events[m])return!1;var T,S,y=this._events[m],_=arguments.length;if(y.fn){switch(y.once&&this.removeListener(l,y.fn,void 0,!0),_){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(_-1);S<_;S++)T[S-1]=arguments[S];y.fn.apply(y.context,T)}else{var R,w=y.length;for(S=0;S<w;S++)switch(y[S].once&&this.removeListener(l,y[S].fn,void 0,!0),_){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(R=1,T=new Array(_-1);R<_;R++)T[R-1]=arguments[R];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 m=0,T=[],S=v.length;m<S;m++)(v[m].fn!==d||c&&!v[m].once||u&&v[m].context!==u)&&T.push(v[m]);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})(ja);var pn=Ue(ja.exports);function ta(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&&Wa(t,i),a&&Wa(t,a),s.postMessage({event:"transmuxComplete",data:n},t),!0}function Wa(s,n){n.data1&&s.push(n.data1.buffer),n.data2&&s.push(n.data2.buffer)}function Ya(s,n,e){n.reduce(function(t,r){return ta(s,r)||t},!1)||s.postMessage({event:"transmuxComplete",data:n[0]}),s.postMessage({event:"flush",data:e})}I!==void 0&&I&&function(s){var n=new pn,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 Zn(n,i.typeSupported,a,i.vendor,i.id),Ne(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);wr(o)?(s.transmuxer.async=!0,o.then(function(u){ta(s,u)}).catch(function(u){e(E.ERROR,{type:te.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker push error"})})):(s.transmuxer.async=!1,ta(s,o));break;case"flush":var l=i.chunkMeta,d=s.transmuxer.flush(l);wr(d)||s.transmuxer.async?(wr(d)||(d=Promise.resolve(d)),d.then(function(u){Ya(s,u,l)}).catch(function(u){e(E.ERROR,{type:te.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker flush error"})})):Ya(s,d,l)}})}(self);var ra=Mr()||{isTypeSupported:function(){return!1}},za=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 pn,this.observer.on(E.FRAG_DECRYPTED,l),this.observer.on(E.ERROR,l);var d,u,c,f,v={mp4:ra.isTypeSupported("video/mp4"),mpeg:ra.isTypeSupported("audio/mpeg"),mp3:ra.isTypeSupported('audio/mp4; codecs="mp3"')},m=navigator.vendor;if(!this.useWorker||typeof Worker=="undefined"||(o.workerPath,0))this.transmuxer=new Zn(this.observer,v,o,m,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;("+D.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:te.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:y})},T.postMessage({cmd:"init",typeSupported:v,vendor:m,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 Zn(this.observer,v,o,m,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,m=this;u.transmuxing.start=self.performance.now();var T=this.transmuxer,S=o?o.start:a.start,y=a.decryptdata,_=this.frag,R=!(_&&a.cc===_.cc),w=!(_&&u.level===_.level),P=_?u.sn-_.sn:-1,F=this.part?u.part-this.part.index:-1,U=P===0&&u.id>1&&u.id===(_==null?void 0:_.stats.chunkCount),Y=!w&&(P===1||P===0&&(F===1||U&&F<=0)),G=self.performance.now();(w||P||a.stats.parsing.start===0)&&(a.stats.parsing.start=G),!o||!F&&Y||(o.stats.parsing.start=G);var q=!(_&&((f=a.initSegment)==null?void 0:f.url)===((v=_.initSegment)==null?void 0:v.url)),$=new yo(R,Y,d,w,S,q);if(!Y||R||q){x.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
|
19
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Gr(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}var Tt={},Xt=function p(h){var g=arguments;typeof h=="string"?p.hasOwnProperty(h)?z().setTimeout(function(){g=Array.prototype.splice.call(g,1),p[h].apply(null,g)},0):ke.warn("`"+h+"` is an unknown task"):typeof h=="function"?z().setTimeout(function(){h(p)},0):ke.warn("`"+h+"` is invalid.")},qn={loaded:Ue.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(p,h){return function(g,b,L){var A=Ur(Te(b),3),k=A[0],C=A[1],N=A[2],O=g.log,W=g.utils.getComputedStyle,me=g.utils.secondsToMs;if(!k)return O.error("No element was found with the `"+C+"` query selector.");if(N!=="video"&&N!=="audio")return O.error("The element of `"+C+"` was not a media element.");k.mux&&(k.mux.destroy(),delete k.mux,O.warn("Already monitoring this video element, replacing existing event listeners")),(L=Object.assign({automaticErrorTracking:!0},L)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:g.VERSION},L.data),L.getPlayheadTime=function(){return me(k.currentTime)},L.getStateData=function(){var de,le,he=this.hlsjs&&this.hlsjs.url,Ae=this.dashjs&&zt(this.dashjs.getSource==="function")&&this.dashjs.getSource(),Xe={player_is_paused:k.paused,player_playhead_time:me(k.currentTime),player_width:parseInt(W(k,"width")),player_height:parseInt(W(k,"height")),player_autoplay_on:k.autoplay,player_preload_on:k.preload,player_language_code:k.lang,player_is_fullscreen:yr()&&!!(yr().fullscreenElement||yr().webkitFullscreenElement||yr().mozFullScreenElement||yr().msFullscreenElement),video_poster_url:k.poster,video_source_url:he||Ae||k.currentSrc,video_source_duration:me(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},tt=L.getPlayheadTime();if(k.getStartDate&&tt>0){var nt=k.getStartDate();if(nt&&typeof nt.getTime=="function"&&nt.getTime()){var pt=nt.getTime();if(Xe.player_program_time=pt+tt,k.seekable.length>0){var Se=pt+k.seekable.end(k.seekable.length-1);Xe.player_live_edge_program_time=Se}}}return Xe},k.mux=k.mux||{},k.mux.deleted=!1,k.mux.emit=function(de,le){g.emit(C,de,le)};var ae=function(){O.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=ae,k.mux.swapElement=ae,k.mux.emit=ae,k.mux.addHLSJS=ae,k.mux.addDashJS=ae,k.mux.removeHLSJS=ae,k.mux.removeDashJS=ae,k.mux.deleted=!0,g.emit(C,"destroy")},k.mux.swapElement=function(de){var le=Ur(Te(de),3),he=le[0],Ae=le[1],Xe=le[2];return he?Xe!=="video"&&Xe!=="audio"?g.log.error("The element of `"+Ae+"` was not a media element."):(he.muxId=k.muxId,delete k.muxId,he.mux=he.mux||{},he.mux.listeners=Object.assign({},k.mux.listeners),delete k.mux.listeners,Object.keys(he.mux.listeners).forEach(function(tt){k.removeEventListener(tt,he.mux.listeners[tt],!1),he.addEventListener(tt,he.mux.listeners[tt],!1)}),he.mux.swapElement=k.mux.swapElement,he.mux.destroy=k.mux.destroy,delete k.mux,void(k=he)):g.log.error("No element was found with the `"+Ae+"` query selector.")},k.mux.addHLSJS=function(de){g.addHLSJS(C,de)},k.mux.addDashJS=function(de){g.addDashJS(C,de)},k.mux.removeHLSJS=function(){g.removeHLSJS(C)},k.mux.removeDashJS=function(){g.removeDashJS(C)},g.init(C,L),g.emit(C,"playerready"),k.paused||(g.emit(C,"play"),k.readyState>2&&g.emit(C,"playing")),k.mux.listeners={},Bn.forEach(function(de){(de!=="error"||L.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=Hn[k.error.code]||k.error.message}g.emit(C,de,le)},k.addEventListener(de,k.mux.listeners[de],!1))})}(Xt,p,h)},destroyMonitor:function(p){var h=Sr(Te(p),1)[0];h&&h.mux&&typeof h.mux.destroy=="function"?h.mux.destroy():ke.error("A video element monitor for `"+p+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(p,h){var g=oe(p);Tt[g]?Tt[g].addHLSJS(h):ke.error("A monitor for `"+g+"` has not been initialized.")},addDashJS:function(p,h){var g=oe(p);Tt[g]?Tt[g].addDashJS(h):ke.error("A monitor for `"+g+"` has not been initialized.")},removeHLSJS:function(p){var h=oe(p);Tt[h]?Tt[h].removeHLSJS():ke.error("A monitor for `"+h+"` has not been initialized.")},removeDashJS:function(p){var h=oe(p);Tt[h]?Tt[h].removeDashJS():ke.error("A monitor for `"+h+"` has not been initialized.")},init:function(p,h){dt()&&h&&h.respectDoNotTrack&&ke.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var g=oe(p);Tt[g]=new gi(Xt,g,h)},emit:function(p,h,g){var b=oe(p);Tt[b]?(Tt[b].emit(h,g),h==="destroy"&&delete Tt[b]):ke.error("A monitor for `"+b+"` has not been initialized.")},checkDoNotTrack:dt,log:ke,utils:Hr,events:un,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Xt,qn),z()!==void 0&&typeof z().addEventListener=="function"&&z().addEventListener("pagehide",function(p){p.persisted||(Xt.WINDOW_UNLOADING=!0)},!1);var dn=Xt},655:function(K,Q,V){var re,z;function ne(ye){return ne=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(oe){return typeof oe}:function(oe){return oe&&typeof Symbol=="function"&&oe.constructor===Symbol&&oe!==Symbol.prototype?"symbol":typeof oe},ne(ye);}(function(ye){var oe=!1;if((z=typeof(re=ye)=="function"?re.call(Q,V,Q,K):re)===void 0||(K.exports=z),oe=!0,ne(Q)==="object"&&(K.exports=ye(),oe=!0),!oe){var Te=window.Cookies,we=window.Cookies=ye();we.noConflict=function(){return window.Cookies=Te,we}}})(function(){var ye=function(){for(var oe=0,Te={};oe<arguments.length;oe++){var we=arguments[oe];for(var Ie in we)Te[Ie]=we[Ie]}return Te};return function oe(Te){function we(Ie,je,ke){var dt;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(ke=ye({path:"/"},we.defaults,ke)).expires=="number"){var Ue=new Date;Ue.setMilliseconds(Ue.getMilliseconds()+864e5*ke.expires),ke.expires=Ue}try{dt=JSON.stringify(je),/^[\{\[]/.test(dt)&&(je=dt)}catch{}return je=Te.write?Te.write(je,Ie):encodeURIComponent(String(je)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),Ie=(Ie=(Ie=encodeURIComponent(String(Ie))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[Ie,"=",je,ke.expires?"; expires="+ke.expires.toUTCString():"",ke.path?"; path="+ke.path:"",ke.domain?"; domain="+ke.domain:"",ke.secure?"; secure":""].join("")}Ie||(dt={});for(var et=document.cookie?document.cookie.split("; "):[],mt=/(%[0-9A-Z]{2})+/g,ie=0;ie<et.length;ie++){var E=et[ie].split("="),te=E.slice(1).join("=");te.charAt(0)==='"'&&(te=te.slice(1,-1));try{var B=E[0].replace(mt,decodeURIComponent);if(te=Te.read?Te.read(te,B):Te(te,B)||te.replace(mt,decodeURIComponent),this.json)try{te=JSON.parse(te)}catch{}if(Ie===B){dt=te;break}Ie||(dt[B]=te)}catch{}}return dt}}return we.set=we,we.get=function(Ie){return we.call(we,Ie)},we.getJSON=function(){return we.apply({json:!0},[].slice.call(arguments))},we.defaults={},we.remove=function(Ie,je){we(Ie,"",ye(je,{expires:-1}))},we.withConverter=oe,we}(function(){})})},153:function(K,Q,V){var re,z=V.g!==void 0?V.g:typeof window!="undefined"?window:{},ne=V(558);typeof document!="undefined"?re=document:(re=z["__GLOBAL_DOCUMENT_CACHE@4"])||(re=z["__GLOBAL_DOCUMENT_CACHE@4"]=ne),K.exports=re},48:function(K,Q,V){var re;re=typeof window!="undefined"?window:V.g!==void 0?V.g:typeof self!="undefined"?self:{},K.exports=re},640:function(K,Q,V){var re,z;(function(ne,ye){"use strict";re=function(){var oe=function(){},Te="undefined",we=typeof window!==Te&&typeof window.navigator!==Te&&/Trident\/|MSIE /.test(window.navigator.userAgent),Ie=["trace","debug","info","warn","error"];function je(be,Be){var qe=be[Be];if(typeof qe.bind=="function")return qe.bind(be);try{return Function.prototype.bind.call(qe,be)}catch{return function(){return Function.prototype.apply.apply(qe,[be,arguments])}}}function ke(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function dt(be){return be==="debug"&&(be="log"),typeof console!==Te&&(be==="trace"&&we?ke:console[be]!==void 0?je(console,be):console.log!==void 0?je(console,"log"):oe)}function Ue(be,Be){for(var qe=0;qe<Ie.length;qe++){var Ot=Ie[qe];this[Ot]=qe<be?oe:this.methodFactory(Ot,be,Be)}this.log=this.debug}function et(be,Be,qe){return function(){typeof console!==Te&&(Ue.call(this,Be,qe),this[be].apply(this,arguments))}}function mt(be,Be,qe){return dt(be)||et.apply(this,arguments)}function ie(be,Be,qe){var Ot,Ne=this;Be=Be==null?"WARN":Be;var x="loglevel";function tr(Pe){var vt=(Ie[Pe]||"silent").toUpperCase();if(typeof window!==Te&&x){try{return void(window.localStorage[x]=vt)}catch{}try{window.document.cookie=encodeURIComponent(x)+"="+vt+";"}catch{}}}function Mt(){var Pe;if(typeof window!==Te&&x){try{Pe=window.localStorage[x]}catch{}if(typeof Pe===Te)try{var vt=window.document.cookie,We=vt.indexOf(encodeURIComponent(x)+"=");We!==-1&&(Pe=/^([^;]+)/.exec(vt.slice(We))[1])}catch{}return Ne.levels[Pe]===void 0&&(Pe=void 0),Pe}}function He(){if(typeof window!==Te&&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 be=="string"?x+=":"+be:typeof be=="symbol"&&(x=void 0),Ne.name=be,Ne.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Ne.methodFactory=qe||mt,Ne.getLevel=function(){return Ot},Ne.setLevel=function(Pe,vt){if(typeof Pe=="string"&&Ne.levels[Pe.toUpperCase()]!==void 0&&(Pe=Ne.levels[Pe.toUpperCase()]),!(typeof Pe=="number"&&Pe>=0&&Pe<=Ne.levels.SILENT))throw"log.setLevel() called with invalid level: "+Pe;if(Ot=Pe,vt!==!1&&tr(Pe),Ue.call(Ne,Pe,be),typeof console===Te&&Pe<Ne.levels.SILENT)return"No console available for logging"},Ne.setDefaultLevel=function(Pe){Be=Pe,Mt()||Ne.setLevel(Pe,!1)},Ne.resetLevel=function(){Ne.setLevel(Be,!1),He()},Ne.enableAll=function(Pe){Ne.setLevel(Ne.levels.TRACE,Pe)},Ne.disableAll=function(Pe){Ne.setLevel(Ne.levels.SILENT,Pe)};var rr=Mt();rr==null&&(rr=Be),Ne.setLevel(rr,!1)}var E=new ie,te={};E.getLogger=function(be){if(typeof be!="symbol"&&typeof be!="string"||be==="")throw new TypeError("You must supply a name when creating a logger.");var Be=te[be];return Be||(Be=te[be]=new ie(be,E.getLevel(),E.methodFactory)),Be};var B=typeof window!==Te?window.log:void 0;return E.noConflict=function(){return typeof window!==Te&&window.log===E&&(window.log=B),E},E.getLoggers=function(){return te},E.default=E,E},(z=typeof re=="function"?re.call(Q,V,Q,K):re)===void 0||(K.exports=z)})()},375:function(K,Q){"use strict";var V=Object.prototype.hasOwnProperty;function re(ne){try{return decodeURIComponent(ne.replace(/\+/g," "))}catch{return null}}function z(ne){try{return encodeURIComponent(ne)}catch{return null}}Q.stringify=function(ne,ye){ye=ye||"";var oe,Te,we=[];for(Te in typeof ye!="string"&&(ye="?"),ne)if(V.call(ne,Te)){if((oe=ne[Te])||oe!=null&&!isNaN(oe)||(oe=""),Te=z(Te),oe=z(oe),Te===null||oe===null)continue;we.push(Te+"="+oe)}return we.length?ye+we.join("&"):""},Q.parse=function(ne){for(var ye,oe=/([^=?#&]+)=?([^&]*)/g,Te={};ye=oe.exec(ne);){var we=re(ye[1]),Ie=re(ye[2]);we===null||Ie===null||we in Te||(Te[we]=Ie)}return Te}},558:function(){}},H={};function j(K){var Q=H[K];if(Q!==void 0)return Q.exports;var V=H[K]={exports:{}};return M[K].call(V.exports,V,V.exports,j),V.exports}return j.n=function(K){var Q=K&&K.__esModule?function(){return K.default}:function(){return K};return j.d(Q,{a:Q}),Q},j.d=function(K,Q){for(var V in Q)j.o(Q,V)&&!j.o(K,V)&&Object.defineProperty(K,V,{enumerable:!0,get:Q[V]})},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(K,Q){return Object.prototype.hasOwnProperty.call(K,Q)},j(80)}()},typeof Sn=="object"&&typeof Ta=="object"?Ta.exports=D():typeof Sn=="object"?Sn.mux=D():I.mux=D()})()});var Is=ws((Ds,Ea)=>{(function I(D){var M,H;M=this,H=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 K(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){re(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 Q(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 V(s,n,e){return n&&Q(s.prototype,n),e&&Q(s,e),Object.defineProperty(s,"prototype",{writable:!1}),s}function re(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 z(){return z=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},z.apply(this,arguments)}function ne(s,n){s.prototype=Object.create(n.prototype),s.prototype.constructor=s,oe(s,n)}function ye(s){return ye=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ye(s)}function oe(s,n){return oe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},oe(s,n)}function Te(){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 we(s,n,e){return we=Te()?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&&oe(o,i.prototype),o},we.apply(null,arguments)}function Ie(s){var n=typeof Map=="function"?new Map:void 0;return Ie=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 we(e,arguments,ye(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),oe(r,e)},Ie(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 ke(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 Ue(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var et={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 c=a.parseURL(l);if(!c)throw new Error("Error trying to parse relative URL.");if(c.scheme)return u.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 m={scheme:f.scheme,netLoc:c.netLoc,path:null,params:c.params,query:c.query,fragment:c.fragment};if(!c.netLoc&&(m.netLoc=f.netLoc,c.path[0]!=="/"))if(c.path){var T=f.path,S=T.substring(0,T.lastIndexOf("/")+1)+c.path;m.path=a.normalizePath(S)}else m.path=f.path,c.params||(m.params=f.params,c.query||(m.query=f.query));return m.path===null&&(m.path=u.alwaysNormalize?a.normalizePath(c.path):c.path),a.buildURLFromParts(m)},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})(et);var mt=et.exports,ie=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}({}),te=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}({}),B=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}({}),be=function(){},Be={trace:be,debug:be,log:be,warn:be,info:be,error:be},qe=Be;function Ot(s){var n=self.console[s];return n?n.bind(self.console,"["+s+"] >"):be}function Ne(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){qe[a]=e[a]?e[a].bind(e):Ot(a)})})(s,"debug","log","info","warn","error");try{qe.log('Debug logs enabled for "'+n+'" in hls.js version 1.4.5')}catch{qe=Be}}else qe=Be}var x=qe,tr=/^(\d+)x(\d+)$/,Mt=/(.+?)=(".*?"|.*?)(?:,|$)/g,He=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=tr.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(Mt.lastIndex=0;(t=Mt.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 rr(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var Pe=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=z(new He({}),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"]);ie(i.getTime())&&(this._endDate=i)}}return V(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(ie(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&&ie(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),s}(),vt=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}},We="audio",gt="video",Ir="audiovideo",Xr=function(){function s(n){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[We]=null,e[gt]=null,e[Ir]=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},V(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=mt.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(n){this._url=n}}]),s}(),Qr=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 vt,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}ne(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[We]=null,t[gt]=null,t[Ir]=null},V(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||!ie(this.programDateTime))return null;var t=ie(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}(Xr),Dn=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 vt,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 ne(n,s),V(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}(Xr),Ii=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},V(s,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&ie(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 Jr(s){return Uint8Array.from(atob(s),function(n){return n.charCodeAt(0)})}function xi(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=Jr(l)):(n=Ci(l).subarray(0,16),(e=new Uint8Array(16)).set(n,16-n.length),r=e)}}return r}function Ci(s){return Uint8Array.from(unescape(encodeURIComponent(s)),function(n){return n.charCodeAt(0)})}var Ge={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},xr="org.w3.clearkey",$r="com.apple.streamingkeydelivery",dr="com.microsoft.playready",Cr="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Zr(s){switch(s){case $r:return Ge.FAIRPLAY;case dr:return Ge.PLAYREADY;case Cr:return Ge.WIDEVINE;case xr:return Ge.CLEARKEY}}var Pi="edef8ba979d64acea3c827dcd51d21ed";function ei(s){switch(s){case Ge.FAIRPLAY:return $r;case Ge.PLAYREADY:return dr;case Ge.WIDEVINE:return Cr;case Ge.CLEARKEY:return xr}}function ti(s){var n=s.drmSystems,e=s.widevineLicenseUrl,t=n?[Ge.FAIRPLAY,Ge.WIDEVINE,Ge.PLAYREADY,Ge.CLEARKEY].filter(function(r){return!!n[r]}):[];return!t[Ge.WIDEVINE]&&e&&t.push(Ge.WIDEVINE),t}var ri=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function Vt(s,n,e){return Uint8Array.prototype.slice?s.slice(n,e):new Uint8Array(Array.prototype.slice.call(s,n,e))}var Pr,ii=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},Oi=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},cr=function(s,n){for(var e=n,t=0;ii(s,n);)t+=10,t+=Or(s,n+6),Oi(s,n+10)&&(t+=10),n+=t;if(t>0)return s.subarray(e,e+t)},Or=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]},Mi=function(s,n){return ii(s,n)&&Or(s,n+6)+10<=s.length-n},Fi=function(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"},In=function(s){var n=String.fromCharCode(s[0],s[1],s[2],s[3]),e=Or(s,4);return{type:n,size:e,data:s.subarray(10,10+e)}},ni=function(s){for(var n=0,e=[];ii(s,n);){for(var t=Or(s,n+6),r=(n+=10)+t;n+8<r;){var i=In(s.subarray(n)),a=xn(i);a&&e.push(a),n+=i.size+10}Oi(s,n)&&(n+=10)}return e},xn=function(s){return s.type==="PRIV"?Cn(s):s.type[0]==="W"?Ui(s):Ni(s)},Cn=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}}},Ni=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}}},Ui=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}},Bi=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=Pn();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 Pn(){return Pr||self.TextDecoder===void 0||(Pr=new self.TextDecoder("utf-8")),Pr}var At=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},hr=Math.pow(2,32)-1,On=[].push,Hi={video:1,audio:2,id3:3,text:4};function Ye(s){return String.fromCharCode.apply(null,s)}function Gi(s,n){var e=s[n]<<8|s[n+1];return e<0?65536+e:e}function _e(s,n){var e=ai(s,n);return e<0?4294967296+e:e}function ai(s,n){return s[n]<<24|s[n+1]<<16|s[n+2]<<8|s[n+3]}function si(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 xe(s,n){var e=[];if(!n.length)return e;for(var t=s.byteLength,r=0;r<t;){var i=_e(s,r),a=i>1?r+i:t;if(Ye(s.subarray(r+4,r+8))===n[0])if(n.length===1)e.push(s.subarray(r+8,a));else{var o=xe(s.subarray(r+8,a),n.slice(1));o.length&&On.apply(e,o)}r=a}return e}function Ki(s){var n=[],e=s[0],t=8,r=_e(s,t);t+=4,t+=e===0?8:16,t+=2;var i=s.length+0,a=Gi(s,t);t+=2;for(var o=0;o<a;o++){var l=t,u=_e(s,l);l+=4;var d=2147483647&u;if((2147483648&u)>>>31==1)return x.warn("SIDX has hierarchical references (not supported)"),null;var c=_e(s,l);l+=4,n.push({referenceSize:d,subsegmentDuration:c,info:{duration:c/r,start:i,end:i+d-1}}),i+=d,t=l+=4}return{earliestPresentationTime:0,timescale:r,version:e,referencesCount:a,references:n}}function oi(s){for(var n=[],e=xe(s,["moov","trak"]),t=0;t<e.length;t++){var r=e[t],i=xe(r,["tkhd"])[0];if(i){var a=i[0],o=a===0?12:20,l=_e(i,o),u=xe(r,["mdia","mdhd"])[0];if(u){var d=_e(u,o=(a=u[0])===0?12:20),c=xe(r,["mdia","hdlr"])[0];if(c){var f=Ye(c.subarray(8,12)),v={soun:We,vide:gt}[f];if(v){var m=xe(r,["mdia","minf","stbl","stsd"])[0],T=void 0;m&&(T=Ye(m.subarray(12,16))),n[l]={timescale:d,type:v},n[v]={timescale:d,id:l,codec:T}}}}}}return xe(s,["moov","mvex","trex"]).forEach(function(S){var y=_e(S,4),_=n[y];_&&(_.default={duration:_e(S,12),flags:_e(S,20)})}),n}function li(s){var n=xe(s,["schm"])[0];if(n){var e=Ye(n.subarray(4,8));if(e==="cbcs"||e==="cenc")return xe(s,["schi","tenc"])[0]}return x.error("[eme] missing 'schm' box"),null}function Mn(s){var n=_e(s,0),e=8;1&n&&(e+=4),4&n&&(e+=4);for(var t=0,r=_e(s,4),i=0;i<r;i++)256&n&&(t+=_e(s,e),e+=4),512&n&&(e+=4),1024&n&&(e+=4),2048&n&&(e+=4);return t}function jt(s,n){var e=new Uint8Array(s.length+n.length);return e.set(s),e.set(n,s.length),e}function ui(s,n){var e=[],t=n.samples,r=n.timescale,i=n.id,a=!1;return xe(t,["moof"]).map(function(o){var l=o.byteOffset-8;xe(o,["traf"]).map(function(u){var d=xe(u,["tfdt"]).map(function(c){var f=c[0],v=_e(c,4);return f===1&&(v*=Math.pow(2,32),v+=_e(c,8)),v/r})[0];return d!==void 0&&(s=d),xe(u,["tfhd"]).map(function(c){var f=_e(c,4),v=16777215&_e(c,0),m=0,T=(16&v)!=0,S=0,y=(32&v)!=0,_=8;f===i&&((1&v)!=0&&(_+=8),(2&v)!=0&&(_+=4),(8&v)!=0&&(m=_e(c,_),_+=4),T&&(S=_e(c,_),_+=4),y&&(_+=4),n.type==="video"&&(a=function(R){if(!R)return!1;var w=R.indexOf("."),P=w<0?R:R.substring(0,w);return P==="hvc1"||P==="hev1"||P==="dvh1"||P==="dvhe"}(n.codec)),xe(u,["trun"]).map(function(R){var w=R[0],P=16777215&_e(R,0),F=(1&P)!=0,U=0,Y=(4&P)!=0,G=(256&P)!=0,q=0,$=(512&P)!=0,X=0,se=(1024&P)!=0,ve=(2048&P)!=0,ue=0,fe=_e(R,4),pe=8;F&&(U=_e(R,pe),pe+=4),Y&&(pe+=4);for(var ge=U+l,Le=0;Le<fe;Le++){if(G?(q=_e(R,pe),pe+=4):q=m,$?(X=_e(R,pe),pe+=4):X=S,se&&(pe+=4),ve&&(ue=w===0?_e(R,pe):ai(R,pe),pe+=4),n.type===gt)for(var De=0;De<X;){var Ce=_e(t,ge);qi(a,t[ge+=4])&&Vi(t.subarray(ge,ge+Ce),a?2:1,s+ue/r,e),ge+=Ce,De+=Ce+4}s+=q/r}}))})})}),e}function qi(s,n){if(s){var e=n>>1&63;return e===39||e===40}return(31&n)==6}function Vi(s,n,e,t){var r=ji(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 c=Gi(r,i);if(i+=2,c===49){var f=_e(r,i);if(i+=4,f===1195456820){var v=r[i++];if(v===3){var m=r[i++],T=64&m,S=T?2+3*(31&m):0,y=new Uint8Array(S);if(T){y[0]=m;for(var _=1;_<S;_++)y[_]=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 R=[],w=0;w<16;w++){var P=r[i++].toString(16);R.push(P.length==1?"0"+P:P),w!==3&&w!==5&&w!==7&&w!==9||R.push("-")}for(var F=o-16,U=new Uint8Array(F),Y=0;Y<F;Y++)U[Y]=r[i++];t.push({payloadType:a,pts:e,uuid:R.join(""),userData:St(U),userDataBytes:U})}}else if(o<d)i+=o;else if(o>d)break}}function ji(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 Wi(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,c=new Array(d>1?d-1:0),f=1;f<d;f++)c[f-1]=arguments[f];for(var v=c.length,m=8,T=v;T--;)m+=c[T].byteLength;var S=new Uint8Array(m);for(S[0]=m>>24&255,S[1]=m>>16&255,S[2]=m>>8&255,S[3]=255&m,S.set(u,4),T=0,m=8;T<v;T++)S.set(c[T],m),m+=c[T].byteLength;return S}([112,115,115,104],new Uint8Array([t,0,0,0]),s,i,r,l,e||new Uint8Array)}var fr={},vr=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(){fr={}};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 $r:case Cr:case dr:case xr: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),_=12;_<16;_++)y[_]=S>>8*(15-_)&255;return y}(e);return new s(this.method,this.uri,"identity",this.keyFormatVersions,t)}var r=xi(this.uri);if(r)switch(this.keyFormat){case Cr:this.pssh=r,r.length>=22&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case dr:var i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Wi(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 c=Jr(d).subarray(0,16);(function(S){var y=function(_,R,w){var P=_[R];_[R]=_[w],_[w]=P};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 m=fr[this.uri];if(!m){var T=Object.keys(fr).length%Number.MAX_SAFE_INTEGER;m=new Uint8Array(16),new DataView(m.buffer,12,4).setUint32(0,T),fr[this.uri]=m}this.keyId=m}return this},s}(),Yi=/\{\$([a-zA-Z0-9-_]+)\}/g;function zi(s){return Yi.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]=Lt(s,i))}}function Lt(s,n){if(s.variableList!==null||s.hasVariableRefs){var e=s.variableList;return n.replace(Yi,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 Xi(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 Qi(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 Mr(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var Fn={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}},di=Mr();function Fr(s,n){var e;return(e=di==null?void 0:di.isTypeSupported((n||"video")+'/mp4;codecs="'+s+'"'))!=null&&e}var Wt=/#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,ir=/#EXT-X-MEDIA:(.*)/g,Nn=/^#EXT(?:INF|-X-TARGETDURATION):/m,ci=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Nr=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("|")),gr=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 mt.buildAbsoluteURL(e,n,{alwaysNormalize:!0})},s.isMediaPlaylist=function(n){return Nn.test(n)},s.parseMasterPlaylist=function(n,e){var t,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:zi(n)},i=[];for(Wt.lastIndex=0;(t=Wt.exec(n))!=null;)if(t[1]){var a,o=new He(t[1]);ct(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),Un((o.CODECS||"").split(/[ ,]+/).filter(function(R){return R}),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 c=t[3],f=t[4];switch(c){case"SESSION-DATA":var v=new He(f);ct(r,v,["DATA-ID","LANGUAGE","VALUE","URI"]);var m=v["DATA-ID"];m&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[m]=v);break;case"SESSION-KEY":var T=Ji(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 He(f);ct(r,S,["NAME","VALUE","QUERYPARAM"]),Xi(r,S,e);break;case"CONTENT-STEERING":var y=new He(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=$i(f)}}var _=i.length>0&&i.length<r.levels.length;return r.levels=_?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(ir.lastIndex=0;(r=ir.exec(n))!==null;){var u=new He(r[1]),d=u.TYPE;if(d){var c=o[d],f=i[d]||[];i[d]=f,ct(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(c!=null&&c.length){var m=s.findGroup(c,v.groupId)||c[0];hi(v,m,"audioCodec"),hi(v,m,"textCodec")}f.push(v)}}return i},s.parseLevelPlaylist=function(n,e,t,r,i,a){var o,l,u,d=new Ii(e),c=d.fragments,f=null,v=0,m=0,T=0,S=0,y=null,_=new Qr(r,e),R=-1,w=!1;for(ci.lastIndex=0,d.m3u8=n,d.hasVariableRefs=zi(n);(o=ci.exec(n))!==null;){w&&(w=!1,(_=new Qr(r,e)).start=T,_.sn=v,_.cc=S,_.level=t,f&&(_.initSegment=f,_.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null));var P=o[1];if(P){_.duration=parseFloat(P);var F=(" "+o[2]).slice(1);_.title=F||null,_.tagList.push(F?["INF",P,F]:["INF",P])}else if(o[3]){if(ie(_.duration)){_.start=T,u&&fi(_,u,d),_.sn=v,_.level=t,_.cc=S,_.urlId=i,c.push(_);var U=(" "+o[3]).slice(1);_.relurl=Lt(d,U),Zi(_,y),y=_,T+=_.duration,v++,m=0,w=!0}}else if(o[4]){var Y=(" "+o[4]).slice(1);y?_.setByteRange(Y,y):_.setByteRange(Y)}else if(o[5])_.rawProgramDateTime=(" "+o[5]).slice(1),_.tagList.push(["PROGRAM-DATE-TIME",_.rawProgramDateTime]),R===-1&&(R=c.length);else{if(!(o=o[0].match(Nr))){x.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<o.length&&o[l]===void 0;l++);var G=(" "+o[l]).slice(1),q=(" "+o[l+1]).slice(1),$=o[l+2]?(" "+o[l+2]).slice(1):"";switch(G){case"PLAYLIST-TYPE":d.type=q.toUpperCase();break;case"MEDIA-SEQUENCE":v=d.startSN=parseInt(q);break;case"SKIP":var X=new He(q);ct(d,X,["RECENTLY-REMOVED-DATERANGES"]);var se=X.decimalInteger("SKIPPED-SEGMENTS");if(ie(se)){d.skippedSegments=se;for(var ve=se;ve--;)c.unshift(null);v+=se}var ue=X.enumeratedString("RECENTLY-REMOVED-DATERANGES");ue&&(d.recentlyRemovedDateranges=ue.split(" "));break;case"TARGETDURATION":d.targetduration=Math.max(parseInt(q),1);break;case"VERSION":d.version=parseInt(q);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(q||$)&&_.tagList.push($?[q,$]:[q]);break;case"DISCONTINUITY":S++,_.tagList.push(["DIS"]);break;case"GAP":_.gap=!0,_.tagList.push([G]);break;case"BITRATE":_.tagList.push([G,q]);break;case"DATERANGE":var fe=new He(q);ct(d,fe,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),ct(d,fe,fe.clientAttrs);var pe=new Pe(fe,d.dateRanges[fe.ID]);pe.isValid||d.skippedSegments?d.dateRanges[pe.id]=pe:x.warn('Ignoring invalid DATERANGE tag: "'+q+'"'),_.tagList.push(["EXT-X-DATERANGE",q]);break;case"DEFINE":var ge=new He(q);ct(d,ge,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in ge?Qi(d,ge,a):Xi(d,ge,e);break;case"DISCONTINUITY-SEQUENCE":S=parseInt(q);break;case"KEY":var Le=Ji(q,e,d);if(Le.isSupported()){if(Le.method==="NONE"){u=void 0;break}u||(u={}),u[Le.keyFormat]&&(u=z({},u)),u[Le.keyFormat]=Le}else x.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+q+'"');break;case"START":d.startTimeOffset=$i(q);break;case"MAP":var De=new He(q);if(ct(d,De,["BYTERANGE","URI"]),_.duration){var Ce=new Qr(r,e);en(Ce,De,t,u),f=Ce,_.initSegment=f,f.rawProgramDateTime&&!_.rawProgramDateTime&&(_.rawProgramDateTime=f.rawProgramDateTime)}else en(_,De,t,u),f=_,w=!0;break;case"SERVER-CONTROL":var Fe=new He(q);d.canBlockReload=Fe.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=Fe.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&Fe.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=Fe.optionalFloat("PART-HOLD-BACK",0),d.holdBack=Fe.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var _t=new He(q);d.partTarget=_t.decimalFloatingPoint("PART-TARGET");break;case"PART":var rt=d.partList;rt||(rt=d.partList=[]);var Nt=m>0?rt[rt.length-1]:void 0,Ct=m++,Pt=new He(q);ct(d,Pt,["BYTERANGE","URI"]);var it=new Dn(Pt,_,e,Ct,Nt);rt.push(it),_.duration+=it.duration;break;case"PRELOAD-HINT":var ot=new He(q);ct(d,ot,["URI"]),d.preloadHint=ot;break;case"RENDITION-REPORT":var Gt=new He(q);ct(d,Gt,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(Gt);break;default:x.warn("line parsed but not handled: "+o)}}}y&&!y.relurl?(c.pop(),T-=y.duration,d.partList&&(d.fragmentHint=y)):d.partList&&(Zi(_,y),_.cc=S,d.fragmentHint=_,u&&fi(_,u,d));var ur=c.length,wt=c[0],ki=c[ur-1];if((T+=d.skippedSegments*d.targetduration)>0&&ur&&ki){d.averagetargetduration=T/ur;var wi=ki.sn;d.endSN=wi!=="initSegment"?wi:0,d.live||(ki.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,R>0&&function(_n,Yr){for(var Dr=_n[Yr],Ai=Yr;Ai--;){var er=_n[Ai];if(!er)return;er.programDateTime=Dr.programDateTime-1e3*er.duration,Dr=er}}(c,R),d},s}();function Ji(s,n,e){var t,r,i=new He(s);ct(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 c=o?gr.resolve(o,n):"",f=(u||"1").split("/").map(Number).filter(Number.isFinite);return new vr(a,c,d,f,l)}function $i(s){var n=new He(s).decimalFloatingPoint("TIME-OFFSET");return ie(n)?n:null}function Un(s,n){["video","audio","text"].forEach(function(e){var t=s.filter(function(i){return function(a,o){var l=Fn[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 hi(s,n,e){var t=n[e];t&&(s[e]=t)}function Zi(s,n){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):n!=null&&n.programDateTime&&(s.programDateTime=n.endProgramDateTime),ie(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function en(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 fi(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 nr="manifest",Yt="level",yt="audioTrack",Ft="subtitleTrack",Me="main",kt="audio",Rt="subtitle";function tn(s){switch(s.type){case yt:return kt;case Ft:return Rt;default:return Me}}function vi(s,n){var e=s.url;return e!==void 0&&e.indexOf("data:")!==0||(e=n.url),e}var ze=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:nr,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:Yt,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:Ft,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===nr?o.manifestLoadPolicy.default:z({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),l=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part&&(e.type===Yt&&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===Ft&&e.id!==null&&(i=this.hls.subtitleTracks[e.id].details),i)){var d=i.partTarget,c=i.targetduration;if(d&&c){var f=1e3*Math.max(3*d,.8*c);r=z({},r,{maxTimeToFirstByteMs:Math.min(f,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,r.maxTimeToFirstByteMs)})}}var v=r.errorRetry||r.timeoutRetry||{},m={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:v.maxNumRetry||0,retryDelay:v.retryDelayMs||0,maxRetryDelay:v.maxRetryDelayMs||0},T={onSuccess:function(S,y,_,R){var w=a.getInternalLoader(_);a.resetInternalLoader(_.type);var P=S.data;P.indexOf("#EXTM3U")===0?(y.parsing.start=performance.now(),gr.isMediaPlaylist(P)?a.handleTrackOrLevelPlaylist(S,y,_,R||null,w):a.handleMasterPlaylist(S,y,_,R)):a.handleManifestParsingError(S,_,new Error("no EXTM3U delimiter"),R||null,y)},onError:function(S,y,_,R){a.handleNetworkError(y,_,!1,S,R)},onTimeout:function(S,y,_){a.handleNetworkError(y,_,!0,void 0,S)}};l.load(e,m,T)},n.handleMasterPlaylist=function(e,t,r,i){var a=this.hls,o=e.data,l=vi(e,r),u=gr.parseMasterPlaylist(o,l);if(u.playlistParsingError)this.handleManifestParsingError(e,r,u.playlistParsingError,i,t);else{var d=u.contentSteering,c=u.levels,f=u.sessionData,v=u.sessionKeys,m=u.startTimeOffset,T=u.variableList;this.variableList=T;var S=gr.parseMasterPlaylistMedia(o,l,u),y=S.AUDIO,_=y===void 0?[]:y,R=S.SUBTITLES,w=S["CLOSED-CAPTIONS"];_.length&&(_.some(function(P){return!P.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"),_.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new He({}),bitrate:0,url:""}))),a.trigger(E.MANIFEST_LOADED,{levels:c,audioTracks:_,subtitles:R,captions:w,contentSteering:d,url:l,stats:t,networkDetails:i,sessionData:f,sessionKeys:v,startTimeOffset:m,variableList:T})}},n.handleTrackOrLevelPlaylist=function(e,t,r,i,a){var o=this.hls,l=r.id,u=r.level,d=r.type,c=vi(e,r),f=ie(l)?l:0,v=ie(u)?u:f,m=tn(r),T=gr.parseLevelPlaylist(e.data,c,v,m,f,this.variableList);if(d===nr){var S={attrs:new He({}),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:te.NETWORK_ERROR,details:B.MANIFEST_PARSING_ERROR,fatal:t.type===nr,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===Yt?o+=": "+e.level+" id: "+e.id:e.type!==yt&&e.type!==Ft||(o+=" id: "+e.id+' group-id: "'+e.groupId+'"');var l=new Error(o);x.warn("[playlist-loader]: "+o);var u=B.UNKNOWN,d=!1,c=this.getInternalLoader(e);switch(e.type){case nr:u=r?B.MANIFEST_LOAD_TIMEOUT:B.MANIFEST_LOAD_ERROR,d=!0;break;case Yt:u=r?B.LEVEL_LOAD_TIMEOUT:B.LEVEL_LOAD_ERROR,d=!1;break;case yt:u=r?B.AUDIO_TRACK_LOAD_TIMEOUT:B.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Ft:u=r?B.SUBTITLE_TRACK_LOAD_TIMEOUT:B.SUBTITLE_LOAD_ERROR,d=!1}c&&this.resetInternalLoader(e.type);var f={type:te.NETWORK_ERROR,details:u,fatal:d,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=K({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,c=i.id,f=i.groupId,v=i.deliveryDirectives,m=vi(t,i),T=tn(i),S=typeof i.level=="number"&&T===Me?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:te.NETWORK_ERROR,details:B.LEVEL_PARSING_ERROR,fatal:!1,url:m,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 nr:case Yt: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 Ft:l.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v})}}else{var _=new Error("No Segments found in Playlist");l.trigger(E.ERROR,{type:te.NETWORK_ERROR,details:B.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:_,reason:_.message,response:t,context:i,level:S,parent:T,networkDetails:a,stats:r})}},s}();function pr(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 rn(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 ar(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 gi(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=[],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 _=0,R=y;_<=R;){var w=Math.floor((R+_)/2);if(S<T[w].startTime)R=w-1;else{if(!(S>T[w].startTime&&_<y))return w;_=w+1}}return T[_].startTime-S<S-T[R].startTime?_:R}(o,l);if(c>-1)for(var f=c,v=o.length;f<v;f++){var m=o[f];if(m.startTime>=l&&m.endTime<=u)d.push(m);else if(m.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 mr="org.id3",yr="com.apple.quicktime.HLS",zt="https://aomedia.org/emsg/ID3";function Ur(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var Tr=function(){var s=Ur();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Bt(s,n){return s.getTime()/1e3-n}var Bn=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&&(ar(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 pr(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=Ur(),u=0;u<o.length;u++){var d=o[u].type;if((d!==zt||i)&&a){var c=ni(o[u].data);if(c){var f=o[u].pts,v=f+o[u].duration;v>Tr&&(v=Tr),v-f<=0&&(v=f+.25);for(var m=0;m<c.length;m++){var T=c[m];if(!Fi(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===Tr&&(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,c=u.enableID3MetadataCues;o&&(d||c)&&gi(o,r,i,a==="audio"?function(f){return f.type===mr&&c}:a==="video"?function(f){return f.type===zt&&d}:function(f){return f.type===mr&&c||f.type===zt&&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(_){return!u.includes(_)}),c=function(){var _=d[f];Object.keys(a[_].cues).forEach(function(R){o.removeCue(a[_].cues[R])}),delete a[_]},f=d.length;f--;)c();var v=i.fragments[i.fragments.length-1];if(u.length!==0&&ie(v==null?void 0:v.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var m=v.programDateTime/1e3-v.start,T=Ur(),S=function(){var _=u[y],R=l[_],w=a[_],P=(w==null?void 0:w.cues)||{},F=(w==null?void 0:w.durationKnown)||!1,U=Bt(R.startDate,m),Y=Tr,G=R.endDate;if(G)Y=Bt(G,m),F=!0;else if(R.endOnNext&&!F){var q=u.reduce(function(ge,Le){var De=l[Le];return De.class===R.class&&De.id!==Le&&De.startDate>R.startDate&&ge.push(De),ge},[]).sort(function(ge,Le){return ge.startDate.getTime()-Le.startDate.getTime()})[0];q&&(Y=Bt(q.startDate,m),F=!0)}for(var $,X,se=Object.keys(R.attr),ve=0;ve<se.length;ve++){var ue=se[ve];if((X=ue)!=="ID"&&X!=="CLASS"&&X!=="START-DATE"&&X!=="DURATION"&&X!=="END-DATE"&&X!=="END-ON-NEXT"){var fe=P[ue];if(fe)F&&!w.durationKnown&&(fe.endTime=Y);else{var pe=R.attr[ue];fe=new T(U,Y,""),rr(ue)&&($=pe,pe=Uint8Array.from($.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),fe.value={key:ue,data:pe},fe.type=yr,fe.id=_,r.id3Track.addCue(fe),P[ue]=fe}}}a[_]={cues:P,dateRange:R,durationKnown:F}},y=0;y<u.length;y++)S()}}},s}(),Hn=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===B.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 c=Math.min(2,Math.max(1,o)),f=Math.round(2/(1+Math.exp(-.75*u-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},V(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,c=u&&r||t;(d.liveSyncDuration||d.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}(),pi=["NONE","TYPE-0","TYPE-1",null],mi="",Gn="YES",Kn="v2",nn=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}(),Er=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)},V(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 yi(s,n){var e=n.startPTS;if(ie(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 _r(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(ie(l)){var d=Math.abs(l-e);ie(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 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 m=v-s.startSN,T=s.fragments;for(T[m]=n,f=m;f>0;f--)yi(T[f],T[f-1]);for(f=m;f<T.length-1;f++)yi(T[f],T[f+1]);return s.fragmentHint&&yi(T[T.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,c}function Ti(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,c=0;if(function(y,_,R){for(var w=_.skippedSegments,P=Math.max(y.startSN,_.startSN)-_.startSN,F=(y.fragmentHint?1:0)+(w?_.endSN:Math.min(y.endSN,_.endSN))-_.startSN,U=_.startSN-y.startSN,Y=_.fragmentHint?_.fragments.concat(_.fragmentHint):_.fragments,G=y.fragmentHint?y.fragments.concat(y.fragmentHint):y.fragments,q=P;q<=F;q++){var $=G[U+q],X=Y[q];w&&!X&&q<w&&(X=_.fragments[q]=$),$&&X&&R($,X)}}(s,n,function(y,_){y.relurl&&(c=y.cc-_.cc),ie(y.startPTS)&&ie(y.endPTS)&&(_.start=_.startPTS=y.startPTS,_.startDTS=y.startDTS,_.maxStartPTS=y.maxStartPTS,_.endPTS=y.endPTS,_.endDTS=y.endDTS,_.minEndPTS=y.minEndPTS,_.duration=y.endPTS-y.startPTS,_.duration&&(a=_),n.PTSKnown=n.alignedSliding=!0),_.elementaryStreams=y.elementaryStreams,_.loader=y.loader,_.stats=y.stats,_.urlId=y.urlId,y.initSegment&&(_.initSegment=y.initSegment,e=y.initSegment)}),e&&(n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments).forEach(function(y){var _;y.initSegment&&y.initSegment.relurl!==((_=e)==null?void 0:_.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=z({},o),u&&u.forEach(function(y){delete d[y]}),Object.keys(l).forEach(function(y){var _=new Pe(l[y].attr,d[y]);_.isValid?d[y]=_:x.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(l[y].attr)+'"')}),d));var v=n.fragments;if(c){x.warn("discontinuity sliding from playlist, take drift into account");for(var m=0;m<v.length;m++)v[m].cc+=c}n.skippedSegments&&(n.startCC=n.fragments[0].cc),function(y,_,R){if(y&&_)for(var w=0,P=0,F=y.length;P<=F;P++){var U=y[P],Y=_[P+w];U&&Y&&U.index===Y.index&&U.fragment.sn===Y.fragment.sn?R(U,Y):w--}}(s.partList,n.partList,function(y,_){_.elementaryStreams=y.elementaryStreams,_.stats=y.stats}),a?_r(n,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):Ei(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 Ei(s,n){var e=n.startSN+n.skippedSegments-s.startSN,t=s.fragments;e<0||e>=t.length||br(n,t[e].start)}function br(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 an(s,n,e){var t;return s!=null&&s.details?sn((t=s.details)==null?void 0:t.partList,n,e):null}function sn(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 Br(s){switch(s.details){case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_TIMEOUT:case B.LEVEL_LOAD_TIMEOUT:case B.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function on(s,n){var e=Br(n);return s.default[(e?"timeout":"error")+"Retry"]}function _i(s,n){var e=s.backoff==="linear"?1:Math.pow(2,n);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function ln(s){return K(K({},s),{errorRetry:null,timeoutRetry:null})}function Hr(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 un=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 Sr(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&&Gr(e,t,r)===0)return r;var i=un(n,Gr.bind(null,e,t));return!i||i===s&&r?r:i}function Gr(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 Xt,qn=3e5,dn=0,p=2,h=5,g=0,b=1,L=2,A=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)===Me?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 B.FRAG_LOAD_ERROR:case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_ERROR:case B.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case B.FRAG_GAP:case B.FRAG_PARSING_ERROR:case B.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=p);case B.LEVEL_EMPTY_ERROR:case B.LEVEL_PARSING_ERROR:var o,l,u=t.parent===Me?t.level:i.loadLevel;return void(t.details===B.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 B.LEVEL_LOAD_ERROR:case B.LEVEL_LOAD_TIMEOUT:return void(typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case B.AUDIO_TRACK_LOAD_ERROR:case B.AUDIO_TRACK_LOAD_TIMEOUT:case B.SUBTITLE_LOAD_ERROR:case B.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var d=i.levels[i.loadLevel];if(d&&(a.type===yt&&a.groupId===d.audioGroupId||a.type===Ft&&a.groupId===d.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=p,void(t.errorAction.flags=b)}return;case B.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:p,flags:L,hdcpLevel:f}));case B.BUFFER_ADD_CODEC_ERROR:case B.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:i.loadLevel));case B.INTERNAL_EXCEPTION:case B.BUFFER_APPENDING_ERROR:case B.BUFFER_APPEND_ERROR:case B.BUFFER_FULL_ERROR:case B.LEVEL_SWITCH_ERROR:case B.BUFFER_STALLED_ERROR:case B.BUFFER_SEEK_OVER_HOLE:case B.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:dn,flags:g})}if(t.type===te.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=on(this.hls.config.playlistLoadPolicy,e),a=this.playlistError++,o=(r=e.response)==null?void 0:r.code;if(Hr(i,a,Br(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,u=on(e.details.startsWith("key")?l:o,e),d=t.levels.reduce(function(m,T){return m+T.fragmentError},0);if(i){var c;e.details!==B.FRAG_GAP&&i.fragmentError++;var f=(c=e.response)==null?void 0:c.code;if(Hr(u,d,Br(e),f))return{action:h,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,c=(o=e.context)!=null?o:{},f=c.type,v=c.groupId,m=u.length;m--;){var T=(m+r.loadLevel)%u.length;if(T!==r.loadLevel&&u[T].loadError===0){var S=u[T];if(e.details===B.FRAG_GAP&&e.frag){var y=u[T].details;if(y){var _=Sr(e.frag,y.fragments,e.frag.start);if(_!=null&&_.gap)continue}}else if(f===yt&&v===S.audioGroupId||f===Ft&&v===S.textGroupId||d===kt&&i.audioGroupId===S.audioGroupId||d===Rt&&i.textGroupId===S.textGroupId)continue;l=T;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:p,flags:g,nextAutoLevel:l}}return{action:p,flags:b}},n.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case dn:break;case p:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===B.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 b:r.resolved||(r.resolved=this.redundantFailover(e));break;case L:a&&(t.maxHdcpLevel=pi[pi.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===Me?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+c)%l,m=i[v];if(!m||function(T,S,y){if(performance.now()-T.lastErrorPerfMs>qn)return!0;var _=T.details;if(S.details===B.FRAG_GAP&&_&&S.frag){var R=S.frag.start,w=Sr(null,_.fragments,R);if(w&&!w.gap)return!0}if(y&&T.errors.length<y.errors.length){var P=T.errors[T.errors.length-1];if(_&&P.frag&&S.frag&&Math.abs(P.frag.start-S.frag.start)>3*_.targetduration)return!0}return!1}(m,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}},c=1;c<l;c++){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),c=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);c>=0&&f>t.partTarget&&(c+=1)}return new nn(d,c>=0?c:void 0,mi)}}},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&&Ti(r,a),!this.canLoad||!a.live)return;var d,c=void 0,f=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var v=this.hls.config.lowLatencyMode,m=a.lastPartSn,T=a.endSN,S=a.lastPartIndex,y=m===T;S!==-1?(c=y?T+1:m,f=y?v?0:S:S+1):c=T+1;var _=a.age,R=_+a.ageHeader,w=Math.min(R-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 P=Math.floor(w/a.targetduration);c+=P,f!==void 0&&(f+=Math.round(w%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+_.toFixed(2)+"s goal: "+w+" skip sn "+P+" to part "+f)}a.tuneInGoal=w}if(d=this.getDeliveryDirectives(a,t.deliveryDirectives,c,f),v||!y)return void this.loadPlaylist(d)}else a.canBlockReload&&(d=this.getDeliveryDirectives(a,t.deliveryDirectives,c,f));var F=this.hls.mainForwardBufferInfo,U=F?F.end-F.len:0,Y=function(q,$){$===void 0&&($=1/0);var X=1e3*q.targetduration;if(q.updated){var se=q.fragments;if(se.length&&4*X>$){var ve=1e3*se[se.length-1].duration;ve<X&&(X=ve)}}else X/=2;return Math.round(X)}(a,1e3*(a.edge-U));a.updated&&l>this.requestScheduled+Y&&(this.requestScheduled=o.loading.start),c!==void 0&&a.canBlockReload?this.requestScheduled=o.loading.first+Y-(1e3*a.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+Y<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=Y);var G=this.requestScheduled-l;G=Math.max(0,G),this.log("reload live playlist "+e+" in "+Math.round(G)+" ms"),this.timer=self.setTimeout(function(){return i.loadPlaylist(d)},G)}else this.clearTimer()},n.getDeliveryDirectives=function(e,t,r,i){var a=function(o,l){var u=o.canSkipUntil,d=o.canSkipDateRanges,c=o.endSN;return u&&(l!==void 0?l-c:0)<u?d?Kn:Gn:mi}(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=mi),new nn(r,i,a)},n.checkRetry=function(e){var t=this,r=e.details,i=Br(e),a=e.errorAction,o=a||{},l=o.action,u=o.retryCount,d=u===void 0?0:u,c=o.retryConfig,f=!!a&&!!c&&(l===h||!a.resolved&&l===p);if(f){var v;if(this.requestScheduled=-1,d>=c.maxNumRetry)return!1;if(i&&(v=e.context)!=null&&v.deliveryDirectives)this.warn("Retrying playlist loading "+(d+1)+"/"+c.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var m=_i(c,d);this.timer=self.setTimeout(function(){return t.loadPlaylist()},m),this.warn("Retrying playlist loading "+(d+1)+"/"+c.maxNumRetry+' after "'+r+'" in '+m+"ms")}e.levelRetry=!0,a.resolved=!0}return f},s}(),C=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}ne(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&&(Xt||(Xt=/chrome|firefox/i.test(navigator.userAgent)),Xt&&(l.audioCodec=void 0));var c=d.AUDIO,f=d.CODECS,v=d["FRAME-RATE"],m=d["PATHWAY-ID"],T=d.RESOLUTION,S=d.SUBTITLES,y=(m||".")+"-"+l.bitrate+"-"+T+"-"+v+"-"+f;(i=o[y])?i.addFallback(l):(i=new Er(l),o[y]=i,a.push(i)),N(i,"audio",c),N(i,"text",S)}),this.filterAndSortMediaOptions(a,r)},e.filterAndSortMediaOptions=function(t,r){var i=this,a=[],o=[],l=!1,u=!1,d=!1,c=t.filter(function(_){var R=_.audioCodec,w=_.videoCodec,P=_.width,F=_.height,U=_.unknownCodecs;return l||(l=!(!P||!F)),u||(u=!!w),d||(d=!!R),!(U!=null&&U.length)&&(!R||Fr(R,"audio"))&&(!w||Fr(w,"video"))});if((l||u)&&d&&(c=c.filter(function(_){var R=_.videoCodec,w=_.width,P=_.height;return!!R||!(!w||!P)})),c.length!==0){r.audioTracks&&O(a=r.audioTracks.filter(function(_){return!_.audioCodec||Fr(_.audioCodec,"audio")})),r.subtitles&&O(o=r.subtitles);var f=c.slice(0);c.sort(function(_,R){return _.attrs["HDCP-LEVEL"]!==R.attrs["HDCP-LEVEL"]?(_.attrs["HDCP-LEVEL"]||"")>(R.attrs["HDCP-LEVEL"]||"")?1:-1:_.bitrate!==R.bitrate?_.bitrate-R.bitrate:_.attrs["FRAME-RATE"]!==R.attrs["FRAME-RATE"]?_.attrs.decimalFloatingPoint("FRAME-RATE")-R.attrs.decimalFloatingPoint("FRAME-RATE"):_.attrs.SCORE!==R.attrs.SCORE?_.attrs.decimalFloatingPoint("SCORE")-R.attrs.decimalFloatingPoint("SCORE"):l&&_.height!==R.height?_.height-R.height:0});var v=f[0];if(this.steering&&(c=this.steering.filterParsedLevels(c)).length!==f.length){for(var m=0;m<f.length;m++)if(f[m].pathwayId===c[0].pathwayId){v=f[m];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=d&&!u,y={levels:c,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(_){return!!_.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 _=new Error("no level with compatible codecs found in manifest");i.hls.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:B.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:_,reason:_.message})}})},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===Yt&&r.context.level===this.level&&this.checkRetry(r)},e.onFragLoaded=function(t,r){var i=r.frag;if(i!==void 0&&i.type===Me){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},V(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:te.OTHER_ERROR,details:B.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],c=d.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=d,o!==t||!d.details||!l||u!==c){this.log("Switching to level "+t+(c?" with Pathway "+c:"")+" from level "+o+(u?" with Pathway "+u:""));var f=z({},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 m=this.switchParams(d.uri,l==null?void 0:l.details);this.loadPlaylist(m)}}}}},{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 N(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 O(s){var n={};s.forEach(function(e){var t=e.groupId||"";e.id=n[t]=n[t]||0,n[t]++})}var W="NOT_LOADED",me="APPENDING",ae="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(c){var f=!a.isTimeBuffered(c.startPTS,c.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=Ae(i),l=this.fragments[o];if(l){var u=!i.relurl;Object.keys(r).forEach(function(d){var c=i.elementaryStreams[d];if(c){var f=r[d],v=u||c.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),he(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=Ae(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,c=0;c<i.length;c++){var f=i.start(c)-this.bufferPadding,v=i.end(c)+this.bufferPadding;if(d>=f&&u<=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,u=this.fragments;return Object.keys(u).forEach(function(d){var c=u[d];c&&he(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||he(t))},n.getState=function(e){var t=Ae(e),r=this.fragments[t];return r?r.buffered?he(r)?ae:de:me:W},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=Ae(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 c=o[d];r.detectEvictedFragments(d,c,l,a)})}},n.onFragBuffered=function(e,t){this.detectPartialFragments(t)},n.hasFragment=function(e){var t=Ae(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=Ae(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 he(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 Ae(s){return s.type+"_"+s.level+"_"+s.urlId+"_"+s.sn}var Xe=Math.pow(2,17),tt=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 Se({type:te.NETWORK_ERROR,details:B.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 c=r.loader=e.loader=o?new o(a):new l(a),f=nt(e),v=ln(a.fragLoadPolicy.default),m={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Xe};e.stats=c.stats,c.load(f,m,{onSuccess:function(T,S,y,_){r.resetLoader(e,c);var R=T.data;y.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(R.slice(0,16)),R=R.slice(16)),u({frag:e,part:null,payload:R,networkDetails:_})},onError:function(T,S,y,_){r.resetLoader(e,c),d(new Se({type:te.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:K({url:i,data:void 0},T),error:new Error("HTTP Error "+T.code+" "+T.text),networkDetails:y,stats:_}))},onAbort:function(T,S,y){r.resetLoader(e,c),d(new Se({type:te.NETWORK_ERROR,details:B.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:y,stats:T}))},onTimeout:function(T,S,y){r.resetLoader(e,c),d(new Se({type:te.NETWORK_ERROR,details:B.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+m.timeout+"ms"),networkDetails:y,stats:T}))},onProgress:function(T,S,y,_){t&&t({frag:e,part:null,payload:y,networkDetails:_})}})}})},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 c=i.loader=e.loader=o?new o(a):new l(a),f=nt(e,t),v=ln(a.fragLoadPolicy.default),m={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Xe};t.stats=c.stats,c.load(f,m,{onSuccess:function(T,S,y,_){i.resetLoader(e,c),i.updateStatsFromPart(e,t);var R={frag:e,part:t,payload:T.data,networkDetails:_};r(R),u(R)},onError:function(T,S,y,_){i.resetLoader(e,c),d(new Se({type:te.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:K({url:f.url,data:void 0},T),error:new Error("HTTP Error "+T.code+" "+T.text),networkDetails:y,stats:_}))},onAbort:function(T,S,y){e.stats.aborted=t.stats.aborted,i.resetLoader(e,c),d(new Se({type:te.NETWORK_ERROR,details:B.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),d(new Se({type:te.NETWORK_ERROR,details:B.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+m.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,c=i.loading;d.start?d.first+=c.first-c.start:(d.start=c.start,d.first=c.first),d.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 nt(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(ie(r)&&ie(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:te.MEDIA_ERROR,details:B.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return n&&(t.part=n),(n||s).stats.aborted=!0,new Se(t)}var Se=function(s){function n(e){var t;return(t=s.call(this,e.error.message)||this).data=void 0,t.data=e,t}return ne(n,s),n}(Ie(Error)),Ve=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=B.KEY_LOAD_ERROR),new Se({type:te.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,B.KEY_LOAD_ERROR,o))}var l=a.uri;if(!l)return Promise.reject(this.createKeyLoadError(e,B.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(c){return a.key=c.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,B.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,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:function(v,m,T,S){var y=T.frag,_=T.keyInfo,R=T.url;if(!y.decryptdata||_!==r.keyUriToKeyInfo[R])return l(r.createKeyLoadError(y,B.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),S));_.decryptdata.key=y.decryptdata.key=new Uint8Array(v.data),y.keyLoader=null,_.loader=null,o({frag:y,keyInfo:_})},onError:function(v,m,T,S){r.resetLoader(m),l(r.createKeyLoadError(t,B.KEY_LOAD_ERROR,new Error("HTTP Error "+v.code+" loading key "+v.text),T,K({url:u.url,data:void 0},v)))},onTimeout:function(v,m,T){r.resetLoader(m),l(r.createKeyLoadError(t,B.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:function(v,m,T){r.resetLoader(m),l(r.createKeyLoadError(t,B.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};a.load(u,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}(),Oe=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}(),J={length:0,start:function(){return 0},end:function(){return 0}},Z=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,c=e,f=0;f<r.length;f++){var v=r[f].start,m=r[f].end;if(e+t>=v&&e<m)d=v,u=(c=m)-e;else if(e+t<v){l=v;break}}return{len:u,start:d||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),J}},s}(),ee=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 Ee(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 Re(s,n){if(s){var e=s.start+n;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function Ke(s,n){for(var e=n.fragments,t=0,r=e.length;t<r;t++)Re(e[t],s);n.fragmentHint&&Re(n.fragmentHint,s),n.alignedSliding=!0}function ht(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,c=l.fragments;if(c.length&&d.length){var f=Ee(d,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&&ie(a.start)&&(x.log("Adjusting PTS using last level due to CC increase within current level "+r.url),Ke(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&&ie(o)&&(x.log("Adjusting PTS using programDateTime delta "+(a-i)+"ms, sliding:"+o.toFixed(3)+" "+t.url+" "),Ke(o,t))}}(e,n.details),e.alignedSliding||!n.details||e.skippedSegments||Ei(n.details,e))}function Qe(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=Ee(e,r.cc)||e[Math.round(e.length/2)-1],a=r.programDateTime,o=i.programDateTime;a!==null&&o!==null&&Ke((o-a)/1e3-(i.start-r.start),s)}}}var at=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}(),Je=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}(),$e=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],c=u[1],f=u[2],v=u[3],m=new Uint32Array(256),T=0,S=0,y=0;for(y=0;y<256;y++)m[y]=y<128?y<<1:y<<1^283;for(y=0;y<256;y++){var _=S^S<<1^S<<2^S<<3^S<<4;_=_>>>8^255&_^99,e[T]=_,t[_]=T;var R=m[T],w=m[R],P=m[w],F=257*m[_]^16843008*_;i[T]=F<<24|F>>>8,a[T]=F<<16|F>>>16,o[T]=F<<8|F>>>24,l[T]=F,F=16843009*P^65537*w^257*R^16843008*T,d[_]=F<<24|F>>>8,c[_]=F<<16|F>>>16,f[_]=F<<8|F>>>24,v[_]=F,T?(T=R^m[m[m[P^R]]],S^=m[m[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,c=this.ksRows=4*(a+6+1),f=this.keySchedule=new Uint32Array(c),v=this.invKeySchedule=new Uint32Array(c),m=this.sBox,T=this.rcon,S=this.invSubMix,y=S[0],_=S[1],R=S[2],w=S[3];for(o=0;o<c;o++)o<a?u=f[o]=t[o]:(d=u,o%a==0?(d=m[(d=d<<8|d>>>24)>>>24]<<24|m[d>>>16&255]<<16|m[d>>>8&255]<<8|m[255&d],d^=T[o/a|0]<<24):a>6&&o%a==4&&(d=m[d>>>24]<<24|m[d>>>16&255]<<16|m[d>>>8&255]<<8|m[255&d]),f[o]=u=(f[o-a]^d)>>>0);for(l=0;l<c;l++)o=c-l,d=3&l?f[o]:f[o-4],v[l]=l<4||o<=4?d:y[m[d>>>24]]^_[m[d>>>16&255]]^R[m[d>>>8&255]]^w[m[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,c,f,v,m,T,S,y,_,R=this.keySize+6,w=this.invKeySchedule,P=this.invSBox,F=this.invSubMix,U=F[0],Y=F[1],G=F[2],q=F[3],$=this.uint8ArrayToUint32Array_(r),X=$[0],se=$[1],ve=$[2],ue=$[3],fe=new Int32Array(e),pe=new Int32Array(fe.length),ge=this.networkToHostOrderSwap;t<fe.length;){for(v=ge(fe[t]),m=ge(fe[t+1]),T=ge(fe[t+2]),S=ge(fe[t+3]),u=v^w[0],d=S^w[1],c=T^w[2],f=m^w[3],y=4,_=1;_<R;_++)i=U[u>>>24]^Y[d>>16&255]^G[c>>8&255]^q[255&f]^w[y],a=U[d>>>24]^Y[c>>16&255]^G[f>>8&255]^q[255&u]^w[y+1],o=U[c>>>24]^Y[f>>16&255]^G[u>>8&255]^q[255&d]^w[y+2],l=U[f>>>24]^Y[u>>16&255]^G[d>>8&255]^q[255&c]^w[y+3],u=i,d=a,c=o,f=l,y+=4;i=P[u>>>24]<<24^P[d>>16&255]<<16^P[c>>8&255]<<8^P[255&f]^w[y],a=P[d>>>24]<<24^P[c>>16&255]<<16^P[f>>8&255]<<8^P[255&u]^w[y+1],o=P[c>>>24]<<24^P[f>>16&255]<<16^P[u>>8&255]<<8^P[255&d]^w[y+2],l=P[f>>>24]<<24^P[u>>16&255]<<16^P[d>>8&255]<<8^P[255&c]^w[y+3],pe[t]=ge(i^X),pe[t+1]=ge(l^se),pe[t+2]=ge(o^ve),pe[t+3]=ge(a^ue),X=v,se=m,ve=T,ue=S,t+=4}return pe.buffer},s}(),Dt=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))?Vt(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=jt(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 $e),u.expandKey(t);var d=a;return this.currentResult=u.decrypt(l.buffer,0,r),this.currentIV=Vt(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 Je(a,t)),this.fastAesKey.expandKey().then(function(o){return a?(i.logOnce("WebCrypto AES decrypt"),new at(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=Vt(e,0,r),this.remainderData=Vt(e,r)),t},n.logOnce=function(e){this.logEnabled&&(x.log("[decrypter]: "+e),this.logEnabled=!1)},s}(),Lr=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},Ze="STOPPED",ce="IDLE",Qt="KEY_LOADING",sr="FRAG_LOADING",or="FRAG_LOADING_WAITING_RETRY",kr="WAITING_TRACK",Jt="PARSING",cn="PARSED",bi="ENDED",Kr="ERROR",Si="WAITING_INIT_PTS",qr="WAITING_LEVEL",Vn=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=Ze,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 tt(t.config),l.keyLoader=i,l.fragmentTracker=r,l.config=t.config,l.decrypter=new Dt(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}ne(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=Ze},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 Z.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===Ze&&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=Z.bufferInfo(a||i,l,t.maxBufferHole);if(this.log("media seeking to "+(ie(l)?l.toFixed(3):l)+", state: "+o),this.state===bi)this.resetLoadingState();else if(r){var d=t.maxFragLookUpTolerance,c=r.start-d,f=r.start+r.duration+d;if(!u.len||f<u.start||c>u.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||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=Ze,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===sr||!a.fragCurrent&&l===Jt)&&(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!==Ze&&a.state!==Kr&&(a.warn(o),a.resetFragmentLoading(t))})},e.clearTrackerIfNeeded=function(t){var r,i=this.fragmentTracker;if(i.getState(t)===me){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)===ae&&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(c){throw o.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:B.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:d,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 u=t.stats;i.state=ce,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!==Ze&&i.state!==Kr&&(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===Me?"level":"track")+" "+t.level+" (frag:["+((i=t.startPTS)!=null?i:NaN).toFixed(3)+"-"+((a=t.endPTS)!=null?a:NaN).toFixed(3)+"] > buffer:"+(u?Lr(Z.getBuffered(u)):"(detached)")+")"),this.state=ce,u&&(!this.loadedmetadata&&t.type==Me&&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 ee(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=Qt,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===Qt&&(l.state=ce),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 c=u.partList;if(c&&a){i>t.end&&u.fragmentHint&&(t=u.fragmentHint);var f=this.getNextPart(c,t,i);if(f>-1){var v,m=c[f];return this.log("Loading part sn: "+t.sn+" p: "+m.index+" cc: "+t.cc+" of playlist ["+u.startSN+"-"+u.endSN+"] parts [0-"+f+"-"+(c.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=m.start+m.duration,this.state=sr,v=d?d.then(function(y){return!y||l.fragContextChanged(y.frag)?null:l.doFragPartsLoad(t,m,r,a)}).catch(function(y){return l.handleFragLoadError(y)}):this.doFragPartsLoad(t,m,r,a).catch(function(y){return l.handleFragLoadError(y)}),this.hls.trigger(E.FRAG_LOADING,{frag:t,part:m,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+" "+(u?"of ["+u.startSN+"-"+u.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),ie(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=sr;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 _=y[0];return!S&&_&&a&&a(_),_}).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,c=[],f=(d=i.details)==null?void 0:d.partList;(function v(m){o.fragmentLoader.loadPart(t,m,a).then(function(T){c[m.index]=T;var S=T.part;o.hls.trigger(E.FRAG_LOADED,T);var y=an(i,t.sn,m.index+1)||sn(f,t.sn,m.index+1);if(!y)return l({frag:t,part:S,partsLoaded:c});v(y)}).catch(u)})(r)})},e.handleFragLoadError=function(t){if("data"in t){var r=t.data;t.data&&r.details===B.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(E.ERROR,r)}else this.hls.trigger(E.ERROR,{type:te.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},e._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(r&&this.state===Jt){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===Ze||this.state===Kr||(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 u=r[a],d=l>-1?an(u,o,l):null,c=d?d.fragment:function(f,v,m){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&&m&&m.sn===v?m:null)}(u,o,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:d,level:u}):null},e.bufferFragmentData=function(t,r,i,a){var o;if(t&&this.state===Jt){var l=t.data1,u=t.data2,d=l;if(l&&u&&(d=jt(l,u)),(o=d)!=null&&o.length){var c={type:t.type,frag:r,part:i,chunkMeta:a,parent:r.type,data:d};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(Z.isBuffered(r,r.currentTime)){var i=r.currentTime,a=Z.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 ie(i)?this.getFwdBufferInfoAtPos(t,i,r):null},e.getFwdBufferInfoAtPos=function(t,r,i){var a=this.config.maxBufferHole,o=Z.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 Z.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,Me);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 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===ae&&!!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 c=t[u];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=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,c,f){if(c===null||!Array.isArray(d)||!d.length||!ie(c)||c<(d[0].programDateTime||0)||c>=(d[d.length-1].endProgramDateTime||0))return null;f=f||0;for(var v=0;v<d.length;++v){var m=d[v];if(Tt(c,f,m))return m}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,c){return un(d,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 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,c=i.fragmentHint,f=o.maxFragLookUpTolerance,v=i.partList,m=!!(o.lowLatencyMode&&v!=null&&v.length&&c);if(m&&c&&!this.bitrateTest&&(u=u.concat(c),d=c.sn),a=t<r?Sr(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===ae&&a.gap)&&(l=a),l&&a.sn===l.sn&&(!m||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 c=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;(!d&&i.readyState<4||o<u-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: "+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,c=!r,f=t.alignedSliding&&ie(d);if(c||!f&&!d){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: "+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&&ie(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===or)||(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===B.FRAG_GAP;l&&this.fragmentTracker.fragBuffered(a,!0);var u=r.errorAction,d=u||{},c=d.action,f=d.retryCount,v=f===void 0?0:f,m=d.retryConfig;if(u&&c===h&&m){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var T=_i(m,v);this.warn("Fragment "+a.sn+" of "+t+" "+a.level+" errored with "+r.details+", retrying loading "+(v+1)+"/"+m.maxNumRetry+" in "+T+"ms"),u.resolved=!0,this.retryDate=self.performance.now()+T,this.state=or}else m&&u?(this.resetFragmentErrors(t),v<m.maxNumRetry?l||(u.resolved=!0):x.warn(r.details+" reached or exceeded max retry ("+v+")")):this.state=Kr;this.tickImmediate()}},e.reduceLengthAndFlushBuffer=function(t){if(this.state===Jt||this.state===cn){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!==Ze&&(this.state=ce)},e.afterBufferFlushed=function(t,r,i){if(t){var a=Z.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,a,i),this.state===bi&&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,u=i.details;if(u){if(Object.keys(t.elementaryStreams).reduce(function(c,f){var v=t.elementaryStreams[f];if(v){var m=v.endPTS-v.startPTS;if(m<=0)return l.warn("Could not parse fragment "+t.sn+" "+f+" duration reliably ("+m+")"),c||!1;var T=a?0:_r(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 c},!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:te.MEDIA_ERROR,details:B.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=cn,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())},V(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}(Oe);function Da(){return self.SourceBuffer||self.WebKitSourceBuffer}function Ht(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 Ia=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=jt(this.cachedData,e),this.cachedData=null);var r,i=cr(e,0),a=i?i.length:0,o=this._audioTrack,l=this._id3Track,u=i?function(v){for(var m=ni(v),T=0;T<m.length;T++){var S=m[T];if(Fi(S))return Bi(S)}}(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&ie(u))&&(this.basePTS=eo(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:mr,duration:Number.POSITIVE_INFINITY});a<d;){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=d}else Mi(e,a)?(i=cr(e,a),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:mr,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===d&&r!==d){var f=Vt(e,r);this.cachedData?this.cachedData=jt(this.cachedData,f):this.cachedData=f}}return{audioTrack:o,videoTrack:Ht(),id3Track:l,textTrack:Ht()}},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:Ht(),id3Track:this._id3Track,textTrack:Ht()}},n.destroy=function(){},s}(),eo=function(s,n,e){return ie(s)?90*s:9e4*n+(e?9e4*e.baseTime/e.timescale:0)};function xa(s,n){return s[n]===255&&(246&s[n+1])==240}function Ca(s,n){return 1&s[n+1]?7:9}function jn(s,n){return(3&s[n+3])<<11|s[n+4]<<3|(224&s[n+5])>>>5}function hn(s,n){return n+1<s.length&&xa(s,n)}function to(s,n){if(hn(s,n)){var e=Ca(s,n);if(n+e>=s.length)return!1;var t=jn(s,n);if(t<=e)return!1;var r=n+t;return r===s.length||hn(s,r)}return!1}function Pa(s,n,e,t,r){if(!s.samplerate){var i=function(a,o,l,u){var d,c,f,v,m=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(m)?y>=6?(d=5,v=new Array(4),c=y-3):(d=2,v=new Array(2),c=y):m.indexOf("android")!==-1?(d=2,v=new Array(2),c=y):(d=5,v=new Array(4),u&&(u.indexOf("mp4a.40.29")!==-1||u.indexOf("mp4a.40.5")!==-1)||!u&&y>=6?c=y-3:((u&&u.indexOf("mp4a.40.2")!==-1&&(y>=6&&f===1||/vivaldi/i.test(m))||!u&&f===1)&&(d=2,v=new Array(2)),c=y)),v[0]=d<<3,v[0]|=(14&y)>>1,v[1]|=(1&y)<<7,v[1]|=f<<3,d===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."+d,manifestCodec:T};a.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:B.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 Oa(s){return 9216e4/s}function Ma(s,n,e,t,r){var i,a=t+r*Oa(s.samplerate),o=function(m,T){var S=Ca(m,T);if(T+S<=m.length){var y=jn(m,T)-S;if(y>0)return{headerLength:S,frameLength:y}}}(n,e);if(o){var l=o.frameLength,u=o.headerLength,d=u+l,c=Math.max(0,e+d-n.length);c?(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 c||s.samples.push(f),{sample:f,length:d,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 ro=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}ne(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=(cr(t,0)||[]).length,i=t.length;r<i;r++)if(to(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)&&xa(i,a)&&jn(i,a)<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){Pa(t,this.observer,r,i,t.manifestCodec);var a=Ma(t,r,i,this.basePTS,this.frameIndex);if(a&&a.missing===0)return a},n}(Ia),io=/\/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=Ht("video",1),o=this.audioTrack=Ht("audio",1),l=this.txtTrack=Ht("text",1);if(this.id3Track=Ht("id3",1),this.timeOffset=0,e!=null&&e.byteLength){var u=oi(e);if(u.video){var d=u.video,c=d.id,f=d.timescale,v=d.codec;a.id=c,a.timescale=l.timescale=f,a.codec=v}if(u.audio){var m=u.audio,T=m.id,S=m.timescale,y=m.codec;o.id=T,o.timescale=S,o.codec=y}l.id=Hi.text,a.sampleDuration=0,a.duration=o.duration=i}},n.resetContiguity=function(){this.remainderData=null},s.probe=function(e){return xe(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=jt(this.remainderData,e));var o=function(u){var d={valid:null,remainder:null},c=xe(u,["moof"]);if(!c)return d;if(c.length<2)return d.remainder=u,d;var f=c[c.length-1];return d.valid=Vt(u,0,f.byteOffset-8),d.remainder=Vt(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=ui(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=ui(e,t),{videoTrack:t,audioTrack:Ht(),id3Track:i,textTrack:Ht()}},n.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=xe(e.samples,["emsg"]);i&&i.forEach(function(a){var o=function(c){var f=c[0],v="",m="",T=0,S=0,y=0,_=0,R=0,w=0;if(f===0){for(;Ye(c.subarray(w,w+1))!=="\0";)v+=Ye(c.subarray(w,w+1)),w+=1;for(v+=Ye(c.subarray(w,w+1)),w+=1;Ye(c.subarray(w,w+1))!=="\0";)m+=Ye(c.subarray(w,w+1)),w+=1;m+=Ye(c.subarray(w,w+1)),w+=1,T=_e(c,12),S=_e(c,16),_=_e(c,20),R=_e(c,24),w=28}else if(f===1){T=_e(c,w+=4);var P=_e(c,w+=4),F=_e(c,w+=4);for(w+=4,y=Math.pow(2,32)*P+F,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")),_=_e(c,w),R=_e(c,w+=4),w+=4;Ye(c.subarray(w,w+1))!=="\0";)v+=Ye(c.subarray(w,w+1)),w+=1;for(v+=Ye(c.subarray(w,w+1)),w+=1;Ye(c.subarray(w,w+1))!=="\0";)m+=Ye(c.subarray(w,w+1)),w+=1;m+=Ye(c.subarray(w,w+1)),w+=1}return{schemeIdUri:v,value:m,timeScale:T,presentationTime:y,presentationTimeDelta:S,eventDuration:_,id:R,payload:c.subarray(w,c.byteLength)}}(a);if(io.test(o.schemeIdUri)){var l=ie(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:zt,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}(),fn=null,ao=[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],so=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],oo=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],lo=[0,1,1,4];function Fa(s,n,e,t,r){if(!(e+24>n.length)){var i=Na(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 Na(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*ao[14*(e===3?3-t:t===3?3:4)+r-1],u=so[3*(e===3?0:e===2?1:2)+i],d=o===3?1:2,c=oo[e][t],f=lo[t],v=8*c*f,m=Math.floor(c*l/u+a)*f;if(fn===null){var T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);fn=T?parseInt(T[1]):0}return!!fn&&fn<=87&&t===2&&l>=224e3&&o===0&&(s[n+3]=128|s[n+3]),{sampleRate:u,channelCount:d,frameLength:m,samplesPerFrame:v}}}function Wn(s,n){return s[n]===255&&(224&s[n+1])==224&&(6&s[n+1])!=0}function Ua(s,n){return n+1<s.length&&Wn(s,n)}function uo(s,n){if(n+1<s.length&&Wn(s,n)){var e=Na(s,n),t=4;e!=null&&e.frameLength&&(t=e.frameLength);var r=n+t;return r===s.length||Ua(s,r)}return!1}var Ba=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),c=this.readUEG.bind(this),f=this.readBoolean.bind(this),v=this.skipBits.bind(this),m=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 _=c();if(_===3&&v(1),T(),T(),v(1),f())for(t=_!==3?8:12,r=0;r<t;r++)f()&&S(r<6?16:64)}T();var R=c();if(R===0)c();else if(R===1)for(v(1),m(),m(),e=c(),r=0;r<e;r++)m();T(),v(1);var w=c(),P=c(),F=d(1);F===0&&v(1),v(1),f()&&(i=c(),a=c(),o=c(),l=c());var U=[1,1];if(f()&&f())switch(u()){case 1:U=[1,1];break;case 2:U=[12,11];break;case 3:U=[10,11];break;case 4:U=[16,11];break;case 5:U=[40,33];break;case 6:U=[24,11];break;case 7:U=[20,11];break;case 8:U=[32,11];break;case 9:U=[80,33];break;case 10:U=[18,11];break;case 11:U=[15,11];break;case 12:U=[64,33];break;case 13:U=[160,99];break;case 14:U=[4,3];break;case 15:U=[3,2];break;case 16:U=[2,1];break;case 255:U=[u()<<8|u(),u()<<8|u()]}return{width:Math.ceil(16*(w+1)-2*i-2*a),height:(2-F)*(P+1)*16-(F?2:4)*(o+l),pixelRatio:U}},n.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},s}(),co=function(){function s(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Dt(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=ji(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,ho=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=Yn(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:Hi[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,c=o.pid,f=o.pesData,v=l.pid,m=u.pid,T=l.pesData,S=u.pesData,y=null,_=this.pmtParsed,R=this._pmtId,w=e.length;if(this.remainderData&&(w=(e=jt(this.remainderData,e)).length,this.remainderData=null),w<Et&&!i)return this.remainderData=e,{audioTrack:l,videoTrack:o,id3Track:u,textTrack:d};var P=Math.max(0,s.syncOffset(e));(w-=(w-P)%Et)<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,w,e.buffer.byteLength-w));for(var F=0,U=P;U<w;U+=Et)if(e[U]===71){var Y=!!(64&e[U+1]),G=Yn(e,U),q=void 0;if((48&e[U+3])>>4>1){if((q=U+5+e[U+4])===U+Et)continue}else q=U+4;switch(G){case c:Y&&(f&&(a=Vr(f))&&this.parseAVCPES(o,d,a,!1),f={data:[],size:0}),f&&(f.data.push(e.subarray(q,U+Et)),f.size+=U+Et-q);break;case v:if(Y){if(T&&(a=Vr(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(q,U+Et)),T.size+=U+Et-q);break;case m:Y&&(S&&(a=Vr(S))&&this.parseID3PES(u,a),S={data:[],size:0}),S&&(S.data.push(e.subarray(q,U+Et)),S.size+=U+Et-q);break;case 0:Y&&(q+=e[q]+1),R=this._pmtId=fo(e,q);break;case R:Y&&(q+=e[q]+1);var $=vo(e,q,this.typeSupported,r);(c=$.avc)>0&&(o.pid=c),(v=$.audio)>0&&(l.pid=v,l.segmentCodec=$.segmentCodec),(m=$.id3)>0&&(u.pid=m),y===null||_||(x.warn("MPEG-TS PMT found at "+U+" after unknown PID '"+y+"'. Backtracking to sync byte @"+P+" to parse all TS packets."),y=null,U=P-188),_=this.pmtParsed=!0;break;case 17:case 8191:break;default:y=G}}else F++;if(F>0){var X=new Error("Found "+F+" TS packet/s that do not start with 0x47");this.observer.emit(E.ERROR,E.ERROR,{type:te.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:X,reason:X.message})}o.pesData=f,l.pesData=T,u.pesData=S;var se={audioTrack:l,videoTrack:o,id3Track:u,textTrack:d};return i&&this.extractRemainingSamples(se),se},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=Vr(l))?(this.parseAVCPES(i,o,t,!0),i.pesData=null):i.pesData=l,u&&(t=Vr(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=Vr(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 co(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&&(zn(u,e),u=this.avcSample=vn(!1,r.pts,r.dts,"")),l.forEach(function(c){switch(c.type){case 1:a=!0,u||(u=o.avcSample=vn(!0,r.pts,r.dts,"")),u.frame=!0;var f=c.data;if(d&&f.length>4){var v=new Ba(f).readSliceType();v!==2&&v!==4&&v!==7&&v!==9||(u.key=!0)}break;case 5:a=!0,u||(u=o.avcSample=vn(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:a=!0,Vi(c.data,1,r.pts,t.samples);break;case 7:if(a=!0,d=!0,!e.sps){var m=c.data,T=new Ba(m).readSPS();e.width=T.width,e.height=T.height,e.pixelRatio=T.pixelRatio,e.sps=[m],e.duration=o._duration;for(var S=m.subarray(1,4),y="avc1.",_=0;_<3;_++){var R=S[_].toString(16);R.length<2&&(R="0"+R),y+=R}e.codec=y}break;case 8:a=!0,e.pps||(e.pps=[c.data]);break;case 9:a=!1,e.audFound=!0,u&&zn(u,e),u=o.avcSample=vn(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,u&&(u.debug+="unknown NAL "+c.type+" ")}u&&a&&u.units.push(c)}),i&&u&&(zn(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,c=-1,f=0;for(o===-1&&(c=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(c>=0){var v={data:t.subarray(c,d-o-1),type:f};u.push(v)}else{var m=this.getLastNalUnit(e.samples);if(m&&(l&&d<=4-l&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-l)),(i=d-o-1)>0)){var T=new Uint8Array(m.data.byteLength+i);T.set(m.data,0),T.set(t.subarray(0,i),m.data.byteLength),m.data=T,m.state=0}}d<a?(c=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(c>=0&&o>=0){var S={data:t.subarray(c,a),type:f,state:o};u.push(S)}if(u.length===0){var y=this.getLastNalUnit(e.samples);if(y){var _=new Uint8Array(y.data.byteLength+t.byteLength);_.set(y.data,0),_.set(t,y.data.byteLength),y.data=_}}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,c=l.sample.unit.byteLength;if(d===-1){var f=new Uint8Array(c+u.byteLength);f.set(l.sample.unit,0),f.set(u,c),u=f}else{var v=c-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&&!hn(u,r);r++);if(r!==o){var m,T=r<i-1;m=T?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES";var S=new Error(m);if(x.warn("parsing error: "+m),this.observer.emit(E.ERROR,E.ERROR,{type:te.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,levelRetry:T,error:S,reason:m}),!T)return}if(Pa(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=Oa(e.samplerate);a=l.sample.pts+y}for(var _,R=0;r<i;){if(r+=(_=Ma(e,u,r,a,R)).length,_.missing){this.aacOverFlow=_;break}for(R++;r<i-1&&!hn(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(Ua(r,o)){var u=Fa(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=z({},t,{type:this._avcTrack?zt:mr,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else x.warn("[tsdemuxer]: ID3 PES unknown PTS")},s}();function vn(s,n,e,t){return{key:s,frame:!1,pts:n,dts:e,units:[],debug:t,length:0}}function Yn(s,n){return((31&s[n+1])<<8)+s[n+2]}function fo(s,n){return(31&s[n+10])<<8|s[n+11]}function vo(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=Yn(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 Vr(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 c=new Uint8Array(s.size),f=0,v=o.length;f<v;f++){var m=(n=o[f]).byteLength;if(d){if(d>m){d-=m;continue}n=n.subarray(d),m-=d,d=0}c.set(n,a),a+=m}return e&&(e-=t+3),{data:c,pts:r,dts:i,len:e}}return null}function zn(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 go=function(s){function n(){return s.apply(this,arguments)||this}ne(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=(cr(t,0)||[]).length,i=t.length;r<i;r++)if(uo(t,r))return x.log("MPEG Audio sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return Wn(i,a)&&4<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){if(this.basePTS!==null)return Fa(t,r,i,this.basePTS,this.frameIndex)},n}(Ia),Ha=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}(),lr=Math.pow(2,32)-1,st=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/(lr+1)),r=Math.floor(e%(lr+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/(lr+1)),r=Math.floor(e%(lr+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],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,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,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/(lr+1)),o=Math.floor(t%(lr+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/(lr+1)),a=Math.floor(e%(lr+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,c=12+16*d,f=new Uint8Array(c);for(e+=8+c,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 Xn(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 Li(s,n){return n===void 0&&(n=!1),Xn(s,1e3,1/9e4,n)}st.types=void 0,st.HDLR_TYPES=void 0,st.STTS=void 0,st.STSC=void 0,st.STCO=void 0,st.STSZ=void 0,st.VMHD=void 0,st.SMHD=void 0,st.STSD=void 0,st.FTYP=void 0,st.DINF=void 0;var gn=null,Qn=null,Jn=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,gn===null){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);gn=a?parseInt(a[1]):0}if(Qn===null){var o=navigator.userAgent.match(/Safari\/(\d+)/i);Qn=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,It(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,c,f,v,m,T,S=a,y=a,_=e.pid>-1,R=t.pid>-1,w=t.samples.length,P=e.samples.length>0,F=l&&w>0||w>1;if((!_||P)&&(!R||F)||this.ISGenerated||l){this.ISGenerated||(f=this.generateIS(e,t,a,o));var U,Y=this.isVideoContiguous,G=-1;if(F&&(G=function(ve){for(var ue=0;ue<ve.length;ue++)if(ve[ue].key)return ue;return-1}(t.samples),!Y&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,G>0){x.warn("[mp4-remuxer]: Dropped "+G+" out of "+w+" video samples due to a missing keyframe");var q=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(G),t.dropped+=G,U=y+=(t.samples[0].pts-q)/t.inputTimeScale}else G===-1&&(x.warn("[mp4-remuxer]: No keyframe found out of "+w+" video samples"),T=!1);if(this.ISGenerated){if(P&&F){var $=this.getVideoStartPts(t.samples),X=(It(e.samples[0].pts,$)-$)/t.inputTimeScale;S+=Math.max(0,X),y+=Math.max(0,-X)}if(P){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,R||F||u===kt?y:void 0),F){var se=c?c.endPTS-c.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,Y,se)}}else F&&(d=this.remuxVideo(t,y,Y,0));d&&(d.firstKeyFrame=G,d.independent=G!==-1,d.firstKeyFramePTS=U)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(m=Ga(r,a,this._initPTS,this._initDTS)),i.samples.length&&(v=Ka(i,a,this._initPTS))),{audio:c,video:d,initSegment:f,independent:T,text:v,id3:m}},n.generateIS=function(e,t,r,i){var a,o,l,u=e.samples,d=t.samples,c=this.typeSupported,f={},v=this._initPTS,m=!v||i,T="audio/mp4";if(m&&(a=o=1/0),e.config&&u.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):st.initSegment([e]),metadata:{channelCount:e.channelCount}},m&&(l=e.inputTimeScale,v&&l===v.timescale?m=!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:st.initSegment([t]),metadata:{width:t.width,height:t.height}},m))if(l=t.inputTimeScale,v&&l===v.timescale)m=!1;else{var S=this.getVideoStartPts(d),y=Math.round(l*r);o=Math.min(o,It(d[0].dts,S)-y),a=Math.min(a,S-y)}if(Object.keys(f).length)return this.ISGenerated=!0,m?(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=[],c=u.length,f=this._initPTS,v=this.nextAvcDts,m=8,T=this.videoSampleDuration,S=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,_=!1;r&&v!==null||(v=t*l-(u[0].pts-It(u[0].dts,u[0].pts)));for(var R=f.baseTime*l/f.timescale,w=0;w<c;w++){var P=u[w];P.pts=It(P.pts-R,v),P.dts=It(P.dts-R,v),P.dts<u[w>0?w-1:w].dts&&(_=!0)}_&&u.sort(function(bn,Ls){var fl=bn.dts-Ls.dts,vl=bn.pts-Ls.pts;return fl||vl}),a=u[0].dts;var F=(o=u[u.length-1].dts)-a,U=F?Math.round(F/(c-1)):T||e.inputTimeScale/30;if(r){var Y=a-v,G=Y>U,q=Y<-1;if((G||q)&&(G?x.warn("AVC: "+Li(Y,!0)+" ms ("+Y+"dts) hole between fragments detected, filling it"):x.warn("AVC: "+Li(-Y,!0)+" ms ("+Y+"dts) overlapping between fragments detected"),!q||v>=u[0].pts)){a=v;var $=u[0].pts-Y;u[0].dts=a,u[0].pts=$,x.log("Video: First PTS/DTS adjusted: "+Li($,!0)+"/"+Li(a,!0)+", delta: "+Li(Y,!0)+" ms")}}a=Math.max(0,a);for(var X=0,se=0,ve=0;ve<c;ve++){for(var ue=u[ve],fe=ue.units,pe=fe.length,ge=0,Le=0;Le<pe;Le++)ge+=fe[Le].data.length;se+=ge,X+=pe,ue.length=ge,ue.dts=Math.max(ue.dts,a),S=Math.min(ue.pts,S),y=Math.max(ue.pts,y)}o=u[c-1].dts;var De,Ce=se+4*X+8;try{De=new Uint8Array(Ce)}catch(bn){return void this.observer.emit(E.ERROR,E.ERROR,{type:te.MUX_ERROR,details:B.REMUX_ALLOC_ERROR,fatal:!1,error:bn,bytes:Ce,reason:"fail allocating video mdat "+Ce})}var Fe=new DataView(De.buffer);Fe.setUint32(0,Ce),De.set(st.types.mdat,4);for(var _t=!1,rt=Number.POSITIVE_INFINITY,Nt=Number.POSITIVE_INFINITY,Ct=Number.NEGATIVE_INFINITY,Pt=Number.NEGATIVE_INFINITY,it=0;it<c;it++){for(var ot=u[it],Gt=ot.units,ur=0,wt=0,ki=Gt.length;wt<ki;wt++){var wi=Gt[wt],_n=wi.data,Yr=wi.data.byteLength;Fe.setUint32(m,Yr),m+=4,De.set(_n,m),m+=Yr,ur+=4+Yr}var Dr=void 0;if(it<c-1)T=u[it+1].dts-ot.dts,Dr=u[it+1].pts-ot.pts;else{var Ai=this.config,er=it>0?ot.dts-u[it-1].dts:U;if(Dr=it>0?ot.pts-u[it-1].pts:U,Ai.stretchShortVideoTrack&&this.nextAudioPts!==null){var ll=Math.floor(Ai.maxBufferHole*l),ma=(i?S+i*l:this.nextAudioPts)-ot.pts;ma>ll?((T=ma-er)<0?T=er:_t=!0,x.log("[mp4-remuxer]: It is approximately "+ma/90+" ms to the next segment; using duration "+T/90+" ms for the last video frame.")):T=er}else T=er}var ul=Math.round(ot.pts-ot.dts);rt=Math.min(rt,T),Ct=Math.max(Ct,T),Nt=Math.min(Nt,Dr),Pt=Math.max(Pt,Dr),d.push(new qa(ot.key,T,ur,ul))}if(d.length){if(gn){if(gn<70){var _s=d[0].flags;_s.dependsOn=2,_s.isNonSync=0}}else if(Qn&&Pt-Nt<Ct-rt&&U/Ct<.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 ya=a,Ut=0,bs=d.length;Ut<bs;Ut++){var Ss=ya+d[Ut].duration,dl=ya+d[Ut].cts;if(Ut<bs-1){var cl=Ss+d[Ut+1].cts;d[Ut].duration=cl-dl}else d[Ut].duration=Ut?d[Ut-1].duration:U;d[Ut].cts=0,ya=Ss}}}T=_t||!T?U:T,this.nextAvcDts=v=o+T,this.videoSampleDuration=T,this.isVideoContiguous=!0;var hl={data1:st.moof(e.sequenceNumber++,a,z({},e,{samples:d})),data2:De,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,hl},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,c=this._initPTS,f=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,v=[],m=a!==void 0,T=e.samples,S=f?0:8,y=this.nextAudioPts||-1,_=t*o,R=c.baseTime*o/c.timescale;if(this.isAudioContiguous=r=r||T.length&&y>0&&(i&&Math.abs(_-y)<9e3||Math.abs(It(T[0].pts-R,_)-y)<20*d),T.forEach(function(wt){wt.pts=It(wt.pts-R,_)}),!r||y<0){if(T=T.filter(function(wt){return wt.pts>=0}),!T.length)return;y=a===0?0:i&&!m?Math.max(0,_):T[0].pts}if(e.segmentCodec==="aac")for(var w=this.config.maxAudioFramesDrift,P=0,F=y;P<T.length;P++){var U=T[P],Y=U.pts,G=Y-F,q=Math.abs(1e3*G/o);if(G<=-w*d&&m)P===0&&(x.warn("Audio frame @ "+(Y/o).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*G/o)+" ms."),this.nextAudioPts=y=F=Y);else if(G>=w*d&&q<1e4&&m){var $=Math.round(G/d);(F=Y-$*d)<0&&($--,F+=d),P===0&&(this.nextAudioPts=y=F),x.warn("[mp4-remuxer]: Injecting "+$+" audio frame @ "+(F/o).toFixed(3)+"s due to "+Math.round(1e3*G/o)+" ms gap.");for(var X=0;X<$;X++){var se=Math.max(F,0),ve=Ha.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);ve||(x.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ve=U.unit.subarray()),T.splice(P,0,{unit:ve,pts:se}),F+=d,P++}}U.pts=F,F+=d}for(var ue,fe=null,pe=null,ge=0,Le=T.length;Le--;)ge+=T[Le].unit.byteLength;for(var De=0,Ce=T.length;De<Ce;De++){var Fe=T[De],_t=Fe.unit,rt=Fe.pts;if(pe!==null)v[De-1].duration=Math.round((rt-pe)/l);else{if(r&&e.segmentCodec==="aac"&&(rt=y),fe=rt,!(ge>0))return;ge+=S;try{ue=new Uint8Array(ge)}catch(wt){return void this.observer.emit(E.ERROR,E.ERROR,{type:te.MUX_ERROR,details:B.REMUX_ALLOC_ERROR,fatal:!1,error:wt,bytes:ge,reason:"fail allocating audio mdat "+ge})}f||(new DataView(ue.buffer).setUint32(0,ge),ue.set(st.types.mdat,4))}ue.set(_t,S);var Nt=_t.byteLength;S+=Nt,v.push(new qa(!0,u,Nt,0)),pe=rt}var Ct=v.length;if(Ct){var Pt=v[v.length-1];this.nextAudioPts=y=pe+l*Pt.duration;var it=f?new Uint8Array(0):st.moof(e.sequenceNumber++,fe/l,z({},e,{samples:v}));e.samples=[];var ot=fe/o,Gt=y/o,ur={data1:it,data2:ue,startPTS:ot,endPTS:Gt,startDTS:ot,endDTS:Gt,type:"audio",hasAudio:!0,hasVideo:!1,nb:Ct};return this.isAudioContiguous=!0,ur}},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,c=(l!==null?l:i.startDTS*a)+d,f=i.endDTS*a+d,v=1024*o,m=Math.ceil((f-c)/v),T=Ha.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(x.warn("[mp4-remuxer]: remux empty Audio"),T){for(var S=[],y=0;y<m;y++){var _=c+y*v;S.push({unit:T,pts:_,dts:_})}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 It(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 Ga(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=It(o.pts-e.baseTime*i/e.timescale,n*i)/i,o.dts=It(o.dts-t.baseTime*i/t.timescale,n*i)/i}var l=s.samples;return s.samples=[],{samples:l}}}function Ka(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=It(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 $t,qa=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 po(s)},po=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},mo=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&&xe(a,["moov","trak"]).forEach(function(u){var d=xe(u,["mdia","minf","stbl","stsd"])[0].subarray(8),c=xe(d,["enca"]),f=c.length>0;f||(c=xe(d,["encv"])),c.forEach(function(v){xe(f?v.subarray(28):v.subarray(78),["sinf"]).forEach(function(m){var T=li(m);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: "+At(S)+" -> "+At(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=oi(e);t||(t=Va(i.audio,We)),r||(r=Va(i.video,gt));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,c=this.lastEndTime,f={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};ie(c)||(c=this.lastEndTime=a||0);var v=t.samples;if(v==null||!v.length)return f;var m={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&&(m.tracks=this.initTracks,this.emitInitSegment=!1);var S=function(G,q){for(var $=0,X=0,se=0,ve=xe(G,["moof","traf"]),ue=0;ue<ve.length;ue++){var fe=ve[ue],pe=xe(fe,["tfhd"])[0],ge=q[_e(pe,4)];if(ge){var Le=ge.default,De=_e(pe,0)|(Le==null?void 0:Le.flags),Ce=Le==null?void 0:Le.duration;8&De&&(Ce=_e(pe,2&De?12:8));for(var Fe=ge.timescale||9e4,_t=xe(fe,["trun"]),rt=0;rt<_t.length;rt++)!($=Mn(_t[rt]))&&Ce&&($=Ce*_e(_t[rt],4)),ge.type===gt?X+=$/Fe:ge.type===We&&(se+=$/Fe)}}if(X===0&&se===0){for(var Nt=0,Ct=xe(G,["sidx"]),Pt=0;Pt<Ct.length;Pt++){var it=Ki(Ct[Pt]);it!=null&&it.references&&(Nt+=it.references.reduce(function(ot,Gt){return ot+Gt.info.duration||0},0))}return Nt}return X||se}(v,T),y=function(G,q){return xe(q,["moof","traf"]).reduce(function($,X){var se=xe(X,["tfdt"])[0],ve=se[0],ue=xe(X,["tfhd"]).reduce(function(fe,pe){var ge=_e(pe,4),Le=G[ge];if(Le){var De=_e(se,4);if(ve===1){if(De===hr)return x.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),fe;De*=hr+1,De+=_e(se,8)}var Ce=De/(Le.timescale||9e4);if(isFinite(Ce)&&(fe===null||Ce<fe))return Ce}return fe},null);return ue!==null&&isFinite(ue)&&($===null||ue<$)?ue:$},null)}(T,v),_=y===null?a:y;(function(G,q,$,X){if(G===null)return!0;var se=Math.max(X,1),ve=q-G.baseTime/G.timescale;return Math.abs(ve-$)>se}(d,_,a,S)||m.timescale!==d.timescale&&o)&&(m.initPTS=_-a,d&&d.timescale===1&&x.warn("Adjusting initPTS by "+(m.initPTS-d.baseTime)),this.initPTS=d={baseTime:m.initPTS,timescale:1});var R=e?_-d.baseTime/d.timescale:c,w=R+S;(function(G,q,$){xe(q,["moof","traf"]).forEach(function(X){xe(X,["tfhd"]).forEach(function(se){var ve=_e(se,4),ue=G[ve];if(ue){var fe=ue.timescale||9e4;xe(X,["tfdt"]).forEach(function(pe){var ge=pe[0],Le=_e(pe,4);if(ge===0)Le-=$*fe,si(pe,4,Le=Math.max(Le,0));else{Le*=Math.pow(2,32),Le+=_e(pe,8),Le-=$*fe,Le=Math.max(Le,0);var De=Math.floor(Le/(hr+1)),Ce=Math.floor(Le%(hr+1));si(pe,4,De),si(pe,8,Ce)}})}})})})(T,v,d.baseTime/d.timescale),S>0?this.lastEndTime=w:(x.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var P=!!T.audio,F=!!T.video,U="";P&&(U+="audio"),F&&(U+="video");var Y={data1:v,startPTS:R,startDTS:R,endPTS:w,endDTS:w,type:U,hasAudio:P,hasVideo:F,nb:1,dropped:0};return f.audio=Y.type==="audio"?Y:void 0,f.video=Y.type!=="audio"?Y:void 0,f.initSegment=m,f.id3=Ga(r,a,d,d),i.samples.length&&(f.text=Ka(i,a,d)),f},s}();function Va(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===gt?"avc1.42e01e":"mp4a.40.5"}try{$t=self.performance.now.bind(self.performance)}catch{x.debug("Unable to use Performance API on this environment"),$t=typeof self!="undefined"&&self.Date.now}var $n=[{demux:no,remux:mo},{demux:ho,remux:Jn},{demux:ro,remux:Jn},{demux:go,remux:Jn}],Zn=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=$t();var l=new Uint8Array(e),u=this.currentTransmuxState,d=this.transmuxConfig;i&&(this.currentTransmuxState=i);var c=i||u,f=c.contiguous,v=c.discontinuity,m=c.trackSwitch,T=c.accurateTimeOffset,S=c.timeOffset,y=c.initSegmentChange,_=d.audioCodec,R=d.videoCodec,w=d.defaultInitPts,P=d.duration,F=d.initSegmentData,U=function(ve,ue){var fe=null;return ve.byteLength>0&&ue!=null&&ue.key!=null&&ue.iv!==null&&ue.method!=null&&(fe=ue),fe}(l,t);if(U&&U.method==="AES-128"){var Y=this.getDecrypter();if(!Y.isSync())return this.decryptionPromise=Y.webCryptoDecrypt(l,U.key.buffer,U.iv.buffer).then(function(ve){var ue=a.push(ve,null,r);return a.decryptionPromise=null,ue}),this.decryptionPromise;var G=Y.softwareDecrypt(l,U.key.buffer,U.iv.buffer);if(r.part>-1&&(G=Y.flush()),!G)return o.executeEnd=$t(),ea(r);l=new Uint8Array(G)}var q=this.needsProbing(v,m);if(q){var $=this.configureTransmuxer(l);if($)return x.warn("[transmuxer] "+$.message),this.observer.emit(E.ERROR,E.ERROR,{type:te.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:$,reason:$.message}),o.executeEnd=$t(),ea(r)}(v||m||y||q)&&this.resetInitSegment(F,_,R,P,t),(v||y||q)&&this.resetInitialTimestamp(w),f||this.resetContiguity();var X=this.transmux(l,U,S,T,r),se=this.currentTransmuxState;return se.contiguous=!0,se.discontinuity=!1,se.trackSwitch=!1,o.executeEnd=$t(),X},n.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=$t();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 c=this.demuxer,f=this.remuxer;if(!c||!f)return r.executeEnd=$t(),[ea(e)];var v=c.flush(u);return wr(v)?v.then(function(m){return t.flushRemux(l,m,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,c=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,c,d,!0,this.id);e.push({remuxResult:f,chunkMeta:r}),r.transmuxing.executeEnd=$t()},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=$n.length;l<u;l++)if($n[l].demux.probe(e)){t=$n[l];break}if(!t)return new Error("Failed to find demuxer by probing fragment data");var d=this.demuxer,c=this.remuxer,f=t.remux,v=t.demux;c&&c 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 Dt(this.config)),e},s}(),ea=function(s){return{remuxResult:{},chunkMeta:s}};function wr(s){return"then"in s&&s.then instanceof Function}var yo=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},To=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},ja={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,c,f){if(typeof d!="function")throw new TypeError("The listener must be a function");var v=new r(d,c||l,f),m=e?e+u:u;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],v]:l._events[m].push(v):(l._events[m]=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 c=0,f=d.length,v=new Array(f);c<f;c++)v[c]=d[c].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,c,f,v){var m=e?e+l:l;if(!this._events[m])return!1;var T,S,y=this._events[m],_=arguments.length;if(y.fn){switch(y.once&&this.removeListener(l,y.fn,void 0,!0),_){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,c),!0;case 5:return y.fn.call(y.context,u,d,c,f),!0;case 6:return y.fn.call(y.context,u,d,c,f,v),!0}for(S=1,T=new Array(_-1);S<_;S++)T[S-1]=arguments[S];y.fn.apply(y.context,T)}else{var R,w=y.length;for(S=0;S<w;S++)switch(y[S].once&&this.removeListener(l,y[S].fn,void 0,!0),_){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,c);break;default:if(!T)for(R=1,T=new Array(_-1);R<_;R++)T[R-1]=arguments[R];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,c){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||c&&!v.once||d&&v.context!==d||a(this,f);else{for(var m=0,T=[],S=v.length;m<S;m++)(v[m].fn!==u||c&&!v[m].once||d&&v[m].context!==d)&&T.push(v[m]);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})(ja);var pn=Ue(ja.exports);function ta(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&&Wa(t,i),a&&Wa(t,a),s.postMessage({event:"transmuxComplete",data:n},t),!0}function Wa(s,n){n.data1&&s.push(n.data1.buffer),n.data2&&s.push(n.data2.buffer)}function Ya(s,n,e){n.reduce(function(t,r){return ta(s,r)||t},!1)||s.postMessage({event:"transmuxComplete",data:n[0]}),s.postMessage({event:"flush",data:e})}D!==void 0&&D&&function(s){var n=new pn,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 Zn(n,i.typeSupported,a,i.vendor,i.id),Ne(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);wr(o)?(s.transmuxer.async=!0,o.then(function(d){ta(s,d)}).catch(function(d){e(E.ERROR,{type:te.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:d,err:d,reason:"transmuxer-worker push error"})})):(s.transmuxer.async=!1,ta(s,o));break;case"flush":var l=i.chunkMeta,u=s.transmuxer.flush(l);wr(u)||s.transmuxer.async?(wr(u)||(u=Promise.resolve(u)),u.then(function(d){Ya(s,d,l)}).catch(function(d){e(E.ERROR,{type:te.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:d,err:d,reason:"transmuxer-worker flush error"})})):Ya(s,u,l)}})}(self);var ra=Mr()||{isTypeSupported:function(){return!1}},za=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 pn,this.observer.on(E.FRAG_DECRYPTED,l),this.observer.on(E.ERROR,l);var u,d,c,f,v={mp4:ra.isTypeSupported("video/mp4"),mpeg:ra.isTypeSupported("audio/mpeg"),mp3:ra.isTypeSupported('audio/mp4; codecs="mp3"')},m=navigator.vendor;if(!this.useWorker||typeof Worker=="undefined"||(o.workerPath,0))this.transmuxer=new Zn(this.observer,v,o,m,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=(u=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+I.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:te.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:y})},T.postMessage({cmd:"init",typeSupported:v,vendor:m,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 Zn(this.observer,v,o,m,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,c){var f,v,m=this;d.transmuxing.start=self.performance.now();var T=this.transmuxer,S=o?o.start:a.start,y=a.decryptdata,_=this.frag,R=!(_&&a.cc===_.cc),w=!(_&&d.level===_.level),P=_?d.sn-_.sn:-1,F=this.part?d.part-this.part.index:-1,U=P===0&&d.id>1&&d.id===(_==null?void 0:_.stats.chunkCount),Y=!w&&(P===1||P===0&&(F===1||U&&F<=0)),G=self.performance.now();(w||P||a.stats.parsing.start===0)&&(a.stats.parsing.start=G),!o||!F&&Y||(o.stats.parsing.start=G);var q=!(_&&((f=a.initSegment)==null?void 0:f.url)===((v=_.initSegment)==null?void 0:v.url)),$=new To(R,Y,u,w,S,q);if(!Y||R||q){x.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+d.sn+" p: "+d.part+" level: "+d.level+" id: "+d.id+`
|
|
21
21
|
discontinuity: `+R+`
|
|
22
22
|
trackSwitch: `+w+`
|
|
23
23
|
contiguous: `+Y+`
|
|
24
|
-
accurateTimeOffset: `+
|
|
24
|
+
accurateTimeOffset: `+u+`
|
|
25
25
|
timeOffset: `+S+`
|
|
26
|
-
initSegmentChange: `+q);var X=new mo(r,i,t,l,c);this.configureTransmuxer(X)}if(this.frag=a,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:u,state:$},e instanceof ArrayBuffer?[e]:[]);else if(T){var se=T.push(e,y,u,$);wr(se)?(T.async=!0,se.then(function(ve){m.handleTransmuxComplete(ve)}).catch(function(ve){m.transmuxerError(ve,u,"transmuxer-interface push error")})):(T.async=!1,this.handleTransmuxComplete(se))}},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);wr(i)||r.async?(wr(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:te.MEDIA_ERROR,details:B.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}(),To=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)&&Z.getBuffered(i).length){var c=Z.bufferInfo(i,o,0),f=c.len>0,v=c.nextStart||0;if(f||v){if(l){var m=c.len>2,T=!v||t&&t.start<=o||v-o>2&&!this.fragmentTracker.getPartialFragment(o);if(m||T)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var S,y=Math.max(v,c.start||0)-o,_=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,R=!(_==null||(S=_.details)==null)&&S.live?2*_.details.targetduration:2,w=this.fragmentTracker.getPartialFragment(o);if(y>0&&(y<=R||w))return void this._trySkipBufferHole(w)}var P=self.performance.now();if(a!==null){var F=P-a;if(l||!(F>=250)||(this._reportStall(c),this.media)){var U=Z.bufferInfo(i,o,r.maxBufferHole);this._tryFixBufferStall(U,F)}}else this.stalled=P}}}else if(this.moved=!0,a!==null){if(this.stallReported){var Y=self.performance.now()-a;x.warn("playback not stuck anymore @"+o+", after "+Math.round(Y)+"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:te.MEDIA_ERROR,details:B.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=Z.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 m=f.getAppendedFrag(0,Me);m&&l<m.end&&(v=!0)}if(!v){var T=e||f.getAppendedFrag(a,Me);if(T){for(var S=!1,y=T.end;y<l;){var _=f.getPartialFragment(y);if(!_){S=!0;break}y+=_.duration}if(S)return 0}}}var R=Math.max(l+.05,a+.1);if(x.warn("skipping hole, adjusting currentTime from "+a+" to "+R),this.moved=!0,this.stalled=null,i.currentTime=R,e&&!e.gap){var w=new Error("fragment loaded with buffer holes, seeking from "+a+" to "+R);r.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:B.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:w,reason:w.message,frag:e})}return R}}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:te.MEDIA_ERROR,details:B.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:te.MEDIA_ERROR,details:B.BUFFER_STALLED_ERROR,error:d,fatal:!0})}}},s}(),Eo=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[stream-controller]",Me)||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}ne(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=Ze},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 or: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=bi)}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 m=u.len,T=this.getMaxBufferLength(d.maxBitrate);if(!(m>=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 _,R=((_=this.backtrackFragment)!=null?_:y).sn-v.startSN,w=v.fragments[R-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 P=this.audioOnly&&!this.altAudio?We:gt,F=(P===gt?this.videoBuffer:this.mediaBuffer)||this.media;F&&this.afterBufferFlushed(F,P,Me)}y=this.getNextFragmentLoopLoading(y,v,u,Me,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===W||a===ae?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,Me)},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,m=f.duration,T=Math.max(c.end,v+Math.min(Math.max(m-this.config.maxFragLookUpTolerance,.5*m),.75*m));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 Qt:case sr:case or:case Jt:case cn: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 To(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;ie(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=Da())==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!==sr&&this.state!==or||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,m=this._getAudioCodec(d),T=this.transmuxer=this.transmuxer||new za(this.hls,Me,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),S=a?a.index:-1,y=S!==-1,_=new ee(i.level,i.sn,i.stats.chunkCount,o.byteLength,S,y),R=this.initPTS[i.cc];T.push(o,v,m,c,i,a,u.totalduration,f,_,R)}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===Me){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===cn&&(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=Kr;else switch(r.details){case B.FRAG_GAP:case B.FRAG_PARSING_ERROR:case B.FRAG_DECRYPT_ERROR:case B.FRAG_LOAD_ERROR:case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_ERROR:case B.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Me,r);break;case B.LEVEL_LOAD_ERROR:case B.LEVEL_LOAD_TIMEOUT:case B.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==qr||((i=r.context)==null?void 0:i.type)!==Yt||(this.state=ce);break;case B.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case B.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.checkBuffer=function(){var t=this.media,r=this.gapController;if(t&&r&&t.readyState){if(this.loadedmetadata||!Z.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!==We||this.audioOnly&&!this.altAudio){var a=(i===gt?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,i,Me)}},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=Z.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,m=o.text,T=o.id3,S=o.initSegment,y=f.details,_=this.altAudio?void 0:o.audio;if(this.fragContextChanged(u))this.fragmentTracker.removeFragment(u);else{if(this.state=Jt,S){if(S!=null&&S.tracks){var R=u.initSegment||u;this._bufferInitSegment(f,S.tracks,R,l),a.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:R,id:i,tracks:S.tracks})}var w=S.initPTS,P=S.timescale;ie(w)&&(this.initPTS[u.cc]={baseTime:w,timescale:P},a.trigger(E.INIT_PTS_FOUND,{frag:u,id:i,initPTS:w,timescale:P}))}if(v&&o.independent!==!1){if(y){var F=v.startPTS,U=v.endPTS,Y=v.startDTS,G=v.endDTS;if(c)c.elementaryStreams[v.type]={startPTS:F,endPTS:U,startDTS:Y,endDTS:G};else if(v.firstKeyFrame&&v.independent&&l.id===1&&(this.couldBacktrack=!0),v.dropped&&v.independent){var q=this.getMainFwdBufferInfo();if((q?q.end:this.getLoadPosition())+this.config.maxBufferHole<(v.firstKeyFramePTS?v.firstKeyFramePTS:F)-this.config.maxBufferHole)return void this.backtrack(u);u.setElementaryStreamInfo(v.type,u.start,U,u.start,G,!0)}u.setElementaryStreamInfo(v.type,F,U,Y,G),this.backtrackFragment&&(this.backtrackFragment=u),this.bufferFragmentData(v,u,c,l)}}else if(o.independent===!1)return void this.backtrack(u);if(_){var $=_.startPTS,X=_.endPTS,se=_.startDTS,ve=_.endDTS;c&&(c.elementaryStreams[We]={startPTS:$,endPTS:X,startDTS:se,endDTS:ve}),u.setElementaryStreamInfo(We,$,X,se,ve),this.bufferFragmentData(_,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&&m){var fe={id:i,frag:u,details:y,samples:m.samples};a.trigger(E.FRAG_PARSING_USERDATA,fe)}}}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i,a){var o=this;if(this.state===Jt){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 m=r[v].initSegment;m!=null&&m.byteLength&&o.hls.trigger(E.BUFFER_APPENDING,{type:v,data:m,frag:i,part:null,chunkMeta:a,parent:i.type})}),this.tick()}},e.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Me)},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(Z.isBuffered(t,i)?r=this.getAppendedFrag(i):Z.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}))}}},V(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&&ie(r)&&ie(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}(Vn),jr=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 jr(e),this.fast_=new jr(t),this.defaultTTFB_=i,this.ttfb_=new jr(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 jr(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new jr(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new jr(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}(),bo=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;ie(a)&&ie(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 m=c.len/v;if(!(m>=2*d/v)){var T=l.loading.first?l.loading.first-l.loading.start:-1,S=l.loaded&&T>-1,y=this.bwEstimator.getEstimate(),_=r.levels,R=r.minAutoLevel,w=_[e.level],P=l.total||Math.max(l.loaded,Math.round(d*w.maxBitrate/8)),F=u-T;F<1&&S&&(F=Math.min(u,8*l.loaded/y));var U=S?1e3*l.loaded/F:0,Y=U?(P-l.loaded)/U:8*P/y+f/1e3;if(!(Y<=m)){var G,q=U?8*U:y,$=Number.POSITIVE_INFINITY;for(G=e.level-1;G>R;G--){var X=_[G].maxBitrate;if(($=this.getTimeToLoadFrag(f/1e3,q,d*X,!_[G].details))<m)break}$>=Y||$>10*d||(r.nextLoadLevel=G,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: `+q);var X=new yo(r,i,t,l,c);this.configureTransmuxer(X)}if(this.frag=a,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:d,state:$},e instanceof ArrayBuffer?[e]:[]);else if(T){var se=T.push(e,y,d,$);wr(se)?(T.async=!0,se.then(function(ve){m.handleTransmuxComplete(ve)}).catch(function(ve){m.transmuxerError(ve,d,"transmuxer-interface push error")})):(T.async=!1,this.handleTransmuxComplete(se))}},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);wr(i)||r.async?(wr(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:te.MEDIA_ERROR,details:B.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}(),Eo=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)&&Z.getBuffered(i).length){var c=Z.bufferInfo(i,o,0),f=c.len>0,v=c.nextStart||0;if(f||v){if(l){var m=c.len>2,T=!v||t&&t.start<=o||v-o>2&&!this.fragmentTracker.getPartialFragment(o);if(m||T)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var S,y=Math.max(v,c.start||0)-o,_=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,R=!(_==null||(S=_.details)==null)&&S.live?2*_.details.targetduration:2,w=this.fragmentTracker.getPartialFragment(o);if(y>0&&(y<=R||w))return void this._trySkipBufferHole(w)}var P=self.performance.now();if(a!==null){var F=P-a;if(l||!(F>=250)||(this._reportStall(c),this.media)){var U=Z.bufferInfo(i,o,r.maxBufferHole);this._tryFixBufferStall(U,F)}}else this.stalled=P}}}else if(this.moved=!0,a!==null){if(this.stallReported){var Y=self.performance.now()-a;x.warn("playback not stuck anymore @"+o+", after "+Math.round(Y)+"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:te.MEDIA_ERROR,details:B.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=Z.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,c=l-a;if(c>0&&(u||d)){if(c>t.maxBufferHole){var f=this.fragmentTracker,v=!1;if(a===0){var m=f.getAppendedFrag(0,Me);m&&l<m.end&&(v=!0)}if(!v){var T=e||f.getAppendedFrag(a,Me);if(T){for(var S=!1,y=T.end;y<l;){var _=f.getPartialFragment(y);if(!_){S=!0;break}y+=_.duration}if(S)return 0}}}var R=Math.max(l+.05,a+.1);if(x.warn("skipping hole, adjusting currentTime from "+a+" to "+R),this.moved=!0,this.stalled=null,i.currentTime=R,e&&!e.gap){var w=new Error("fragment loaded with buffer holes, seeking from "+a+" to "+R);r.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:B.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:w,reason:w.message,frag:e})}return R}}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:te.MEDIA_ERROR,details:B.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:te.MEDIA_ERROR,details:B.BUFFER_STALLED_ERROR,error:u,fatal:!0})}}},s}(),_o=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[stream-controller]",Me)||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}ne(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=Ze},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}if(this.hls.nextLoadLevel!==this.level){this.state=ce;break}break;case or:var o,l=self.performance.now(),u=this.retryDate;(!u||l>=u||(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 u=i[l],d=this.getMainFwdBufferInfo();if(d!==null){var c=this.getLevelDetails();if(c&&this._streamEnded(d,c)){var f={};return this.altAudio&&(f.type="video"),this.hls.trigger(E.BUFFER_EOS,f),void(this.state=bi)}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 m=d.len,T=this.getMaxBufferLength(u.maxBitrate);if(!(m>=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 _,R=((_=this.backtrackFragment)!=null?_:y).sn-v.startSN,w=v.fragments[R-1];w&&y.cc===w.cc&&(y=w,this.fragmentTracker.removeFragment(w))}else this.backtrackFragment&&d.len&&(this.backtrackFragment=null);if(y&&this.isLoopLoading(y,S)){if(!y.gap){var P=this.audioOnly&&!this.altAudio?We:gt,F=(P===gt?this.videoBuffer:this.mediaBuffer)||this.media;F&&this.afterBufferFlushed(F,P,Me)}y=this.getNextFragmentLoopLoading(y,v,d,Me,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===W||a===ae?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,Me)},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 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,m=f.duration,T=Math.max(c.end,v+Math.min(Math.max(m-this.config.maxFragLookUpTolerance,.5*m),.75*m));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 Qt:case sr:case or:case Jt:case cn: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 Eo(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;ie(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=Da())==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,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],c=this.fragCurrent;!c||this.state!==sr&&this.state!==or||c.level===r.level&&c.urlId===d.urlId||!c.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=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 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 c=u.videoCodec,f=d.PTSKnown||!d.live,v=(r=i.initSegment)==null?void 0:r.data,m=this._getAudioCodec(u),T=this.transmuxer=this.transmuxer||new za(this.hls,Me,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),S=a?a.index:-1,y=S!==-1,_=new ee(i.level,i.sn,i.stats.chunkCount,o.byteLength,S,y),R=this.initPTS[i.cc];T.push(o,v,m,c,i,a,d.totalduration,f,_,R)}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 c=o[u];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===Me){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===cn&&(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=Kr;else switch(r.details){case B.FRAG_GAP:case B.FRAG_PARSING_ERROR:case B.FRAG_DECRYPT_ERROR:case B.FRAG_LOAD_ERROR:case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_ERROR:case B.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Me,r);break;case B.LEVEL_LOAD_ERROR:case B.LEVEL_LOAD_TIMEOUT:case B.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==qr||((i=r.context)==null?void 0:i.type)!==Yt||(this.state=ce);break;case B.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case B.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.checkBuffer=function(){var t=this.media,r=this.gapController;if(t&&r&&t.readyState){if(this.loadedmetadata||!Z.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!==We||this.audioOnly&&!this.altAudio){var a=(i===gt?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,i,Me)}},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=Z.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,u=this.getCurrentContext(l);if(u){var d=u.frag,c=u.part,f=u.level,v=o.video,m=o.text,T=o.id3,S=o.initSegment,y=f.details,_=this.altAudio?void 0:o.audio;if(this.fragContextChanged(d))this.fragmentTracker.removeFragment(d);else{if(this.state=Jt,S){if(S!=null&&S.tracks){var R=d.initSegment||d;this._bufferInitSegment(f,S.tracks,R,l),a.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:R,id:i,tracks:S.tracks})}var w=S.initPTS,P=S.timescale;ie(w)&&(this.initPTS[d.cc]={baseTime:w,timescale:P},a.trigger(E.INIT_PTS_FOUND,{frag:d,id:i,initPTS:w,timescale:P}))}if(v&&o.independent!==!1){if(y){var F=v.startPTS,U=v.endPTS,Y=v.startDTS,G=v.endDTS;if(c)c.elementaryStreams[v.type]={startPTS:F,endPTS:U,startDTS:Y,endDTS:G};else if(v.firstKeyFrame&&v.independent&&l.id===1&&(this.couldBacktrack=!0),v.dropped&&v.independent){var q=this.getMainFwdBufferInfo();if((q?q.end:this.getLoadPosition())+this.config.maxBufferHole<(v.firstKeyFramePTS?v.firstKeyFramePTS:F)-this.config.maxBufferHole)return void this.backtrack(d);d.setElementaryStreamInfo(v.type,d.start,U,d.start,G,!0)}d.setElementaryStreamInfo(v.type,F,U,Y,G),this.backtrackFragment&&(this.backtrackFragment=d),this.bufferFragmentData(v,d,c,l)}}else if(o.independent===!1)return void this.backtrack(d);if(_){var $=_.startPTS,X=_.endPTS,se=_.startDTS,ve=_.endDTS;c&&(c.elementaryStreams[We]={startPTS:$,endPTS:X,startDTS:se,endDTS:ve}),d.setElementaryStreamInfo(We,$,X,se,ve),this.bufferFragmentData(_,d,c,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&&m){var fe={id:i,frag:d,details:y,samples:m.samples};a.trigger(E.FRAG_PARSING_USERDATA,fe)}}}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i,a){var o=this;if(this.state===Jt){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 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+"]")}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 m=r[v].initSegment;m!=null&&m.byteLength&&o.hls.trigger(E.BUFFER_APPENDING,{type:v,data:m,frag:i,part:null,chunkMeta:a,parent:i.type})}),this.tick()}},e.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Me)},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(Z.isBuffered(t,i)?r=this.getAppendedFrag(i):Z.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}))}}},V(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&&ie(r)&&ie(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}(Vn),jr=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}(),bo=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 jr(e),this.fast_=new jr(t),this.defaultTTFB_=i,this.ttfb_=new jr(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 jr(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new jr(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new jr(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}(),So=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 bo(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;ie(a)&&ie(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 c=r.mainForwardBufferInfo;if(c!==null){var f=this.bwEstimator.getEstimateTTFB(),v=Math.abs(a.playbackRate);if(!(d<=Math.max(f,u/(2*v)*1e3))){var m=c.len/v;if(!(m>=2*u/v)){var T=l.loading.first?l.loading.first-l.loading.start:-1,S=l.loaded&&T>-1,y=this.bwEstimator.getEstimate(),_=r.levels,R=r.minAutoLevel,w=_[e.level],P=l.total||Math.max(l.loaded,Math.round(u*w.maxBitrate/8)),F=d-T;F<1&&S&&(F=Math.min(d,8*l.loaded/y));var U=S?1e3*l.loaded/F:0,Y=U?(P-l.loaded)/U:8*P/y+f/1e3;if(!(Y<=m)){var G,q=U?8*U:y,$=Number.POSITIVE_INFINITY;for(G=e.level-1;G>R;G--){var X=_[G].maxBitrate;if(($=this.getTimeToLoadFrag(f/1e3,q,u*X,!_[G].details))<m)break}$>=Y||$>10*u||(r.nextLoadLevel=G,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: `+m.toFixed(3)+` s
|
|
28
28
|
Estimated load time for current fragment: `+Y.toFixed(3)+` s
|
|
29
29
|
Estimated load time for down switch fragment: `+$.toFixed(3)+` s
|
|
30
30
|
TTFB estimate: `+T+`
|
|
31
31
|
Current BW estimate: `+(ie(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 `+G),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===Me&&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!==Me||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,m=this.findBestLevel(c,o,i,v,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(m>=0)return m;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 _=this.bitrateTestDelay;_&&(T=(d?Math.min(d,a.maxLoadingDelay):a.maxLoadingDelay)-_,x.trace("[abr] bitrate test took "+Math.round(1e3*_)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*T)+" ms"),S=y=1)}return m=this.findBestLevel(c,o,i,v+T,S,y),Math.max(m,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],m=!(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,_=t,R=-1,w=r;w>=t;w--){var P=f[w];if(!P||T&&P.codecSet!==T)P&&(_=Math.min(w,_),R=Math.max(w,R));else{R!==-1&&x.trace("[abr] Skipped level(s) "+_+"-"+R+' with CODECS:"'+f[R].attrs.CODECS+'"; not compatible with "'+v.attrs.CODECS+'"');var F=P.details,U=(u?F==null?void 0:F.partTarget:F==null?void 0:F.averagetargetduration)||S,Y=void 0;Y=w<=c?a*e:o*e;var G=f[w].maxBitrate,q=this.getTimeToLoadFrag(y,Y,G*U,F===void 0);if(x.trace("[abr] level:"+w+" adjustedbw-bitrate:"+Math.round(Y-G)+" avgDuration:"+U.toFixed(1)+" maxFetchDuration:"+i.toFixed(1)+" fetchDuration:"+q.toFixed(1)),Y>G&&(q===0||!ie(q)||m&&!this.bitrateTestDelay||q<i))return w}}return-1},V(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}(),Xa=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}(),So=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[audio-stream-controller]",St)||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}ne(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===Si&&this.tick()}},e.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=Ze);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=kr),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.doTick=function(){switch(this.state){case ce:this.doTickIdle();break;case kr: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=Si}break;case or: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 Si:var u=this.waitingData;if(u){var c=u.frag,f=u.part,v=u.cache,m=u.complete;if(this.initPTS[c.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=sr;var T={frag:c,part:f,payload:v.flush(),networkDetails:null};this._handleFragmentLoadProgress(T),m&&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=Z.bufferInfo(this.mediaBuffer,S,this.config.maxBufferHole);Gr(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=kr;else{var u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,We,St));var c=this.getFwdBufferInfo(u,St);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=bi);var m=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Me),T=c.len,S=this.getMaxBufferLength(m==null?void 0:m.len);if(!(T>=S)||v){var y=d.fragments[0].start,_=c.end;if(v&&i){var R=this.getLoadPosition();f&&v.attrs!==f.attrs&&(_=R),d.PTSKnown&&R<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(_,d),P=!1;if(w&&this.isLoopLoading(w,_)&&(P=!!w.gap,w=this.getNextFragmentLoopLoading(w,d,c,Me,S)),w){var F=m&&w.start>m.end+d.targetduration;if(F||(m==null||!m.len)&&c.len){var U=this.getAppendedFrag(w.start,Me);if(U===null||(P||(P=!!U.gap||!!F&&m.len===0),F&&!P||P&&c.nextStart&&c.nextStart<U.end))return}this.loadFragment(w,l,_)}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 Er(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=Ze),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?(Qe(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!==kr||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",m=this.transmuxer;m||(m=this.transmuxer=new za(this.hls,St,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,_=y!==-1,R=new ee(i.level,i.sn,i.stats.chunkCount,o.byteLength,y,_);m.push(o,S,v,"",i,a,f.totalduration,!1,R,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 Xa,complete:!1}).cache.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=Si}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===St)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,K({},l)))}this.fragBufferedComplete(a,o)}else this.loadedmetadata||a.type!==Me||(i=this.videoBuffer||this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)},e.onError=function(t,r){var i;if(r.fatal)this.state=Kr;else switch(r.details){case B.FRAG_GAP:case B.FRAG_PARSING_ERROR:case B.FRAG_DECRYPT_ERROR:case B.FRAG_LOAD_ERROR:case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_ERROR:case B.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(St,r);break;case B.AUDIO_TRACK_LOAD_ERROR:case B.AUDIO_TRACK_LOAD_TIMEOUT:case B.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==kr||((i=r.context)==null?void 0:i.type)!==yt||(this.state=ce);break;case B.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 B.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.onBufferFlushed=function(t,r){r.type===We&&(this.bufferFlushed=!0,this.state===bi&&(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,m=o.text,T=o.id3,S=o.initSegment;if(!this.fragContextChanged(u)&&f){if(this.state=Jt,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 _=v.startPTS,R=v.endPTS,w=v.startDTS,P=v.endDTS;c&&(c.elementaryStreams[We]={startPTS:_,endPTS:R,startDTS:w,endDTS:P}),u.setElementaryStreamInfo(We,_,R,w,P),this.bufferFragmentData(v,u,c,l)}if(T!=null&&(r=T.samples)!=null&&r.length){var F=z({id:i,frag:u,details:f},T);a.trigger(E.FRAG_PARSING_METADATA,F)}if(m){var U=z({id:i,frag:u,details:f},m);a.trigger(E.FRAG_PARSING_USERDATA,U)}}else this.fragmentTracker.removeFragment(u)}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i){if(this.state===Jt){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===W||o===ae?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=Si):(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,K({},t))},n}(Vn),Lo=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}ne(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,K({},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:te.MEDIA_ERROR,details:B.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})}},V(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 Qa(s,n){if(s.length!==n.length)return!1;for(var e=0;e<s.length;e++)if(!ko(s[e].attrs,n[e].attrs))return!1;return!0}function ko(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 wo=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[subtitle-stream-controller]",At)||this).levels=[],a.currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a._registerListeners(),a}ne(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,At)}},e.onFragBuffered=function(t,r){var i;this.loadedmetadata||r.frag.type!==Me||(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)===At&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Ze&&(this.state=ce))},e.onSubtitleTracksUpdated=function(t,r){var i=this,a=r.subtitleTracks;Qa(this.levels,a)?this.levels=a.map(function(o){return new Er(o)}):(this.tracksBuffered=[],this.levels=a.map(function(o){var l=new Er(o);return i.tracksBuffered[l.id]=[],l}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,At),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&&br(a,c=v.start):a.hasProgramDateTime&&f.hasProgramDateTime?(Qe(a,f),c=a.fragments[0].start):v&&br(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&&(Sr(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:te.MEDIA_ERROR,details:B.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=Z.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],d-o,l.maxBufferHole),c=u.end,f=u.len,v=this.getFwdBufferInfo(this.media,Me);if(f>this.getMaxBufferLength(v==null?void 0:v.len)+o)return;var m=a.fragments,T=m.length,S=a.edge,y=null,_=this.fragPrevious;if(c<S){var R=l.maxFragLookUpTolerance;!(y=Sr(_,m,Math.max(m[0].start,c),R))&&_&&_.start<m[0].start&&(y=m[0])}else y=m[T-1];if(!y)return;y=this.mapToInitFragWhenRequired(y),this.fragmentTracker.getState(y)===W&&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))},V(n,[{key:"mediaBufferTimeRanges",get:function(){return new Ao(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(Vn),Ao=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)}}},Ro=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}ne(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),ia(this.media.textTracks).forEach(function(t){ar(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===Ft&&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=ia(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 m=this.switchParams(o.url,r==null?void 0:r.details);this.loadPlaylist(m)}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=ia(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)}},V(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 ia(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 Do=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}(),Ja=Mr(),$a=/([ha]vc.)(?:\.[^.,]+)+/,Io=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 Do(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&&Ja){var i=this.mediaSource=new Ja;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,m=(o.levelCodec||o.codec).replace($a,"$1"),T=(c||u).replace($a,"$1");if(m!==T){var S=f+";codecs="+(c||u);r.appendChangeType(a,S),x.log("[buffer-controller]: switching codec "+m+" 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],m=self.performance.now();v.start=m;var T=u.stats.buffering,S=c?c.stats.buffering:null;T.start===0&&(T.start=m),S&&S.start===0&&(S.start=m);var y=o.audio,_=!1;d==="audio"&&(y==null?void 0:y.container)==="audio/mpeg"&&(_=!this.lastMpegAudioChunk||f.id===1||this.lastMpegAudioChunk.sn!==f.sn,this.lastMpegAudioChunk=f);var R=u.start,w={execute:function(){if(v.executeStart=self.performance.now(),_){var P=r.sourceBuffer[d];if(P){var F=R-P.timestampOffset;Math.abs(F)>=.1&&(x.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+R+" (delta: "+F+") sn: "+u.sn+")"),P.timestampOffset=R)}}r.appendExecutor(l,d)},onStart:function(){},onComplete:function(){var P=self.performance.now();v.executeEnd=v.end=P,T.first===0&&(T.first=P),S&&S.first===0&&(S.first=P);var F=r.sourceBuffer,U={};for(var Y in F)U[Y]=Z.getBuffered(F[Y]);r.appendError=0,r.hls.trigger(E.BUFFER_APPENDED,{type:d,frag:u,part:c,chunkMeta:f,parent:u.type,timeRanges:U})},onError:function(P){x.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",P);var F={type:te.MEDIA_ERROR,parent:u.type,details:B.BUFFER_APPEND_ERROR,frag:u,part:c,chunkMeta:f,error:P,err:P,fatal:!1};P.code===DOMException.QUOTA_EXCEEDED_ERR?F.details=B.BUFFER_FULL_ERROR:(r.appendError++,F.details=B.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(x.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),F.fatal=!0)),i.trigger(E.ERROR,F)}};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[Ir]?o.push("audiovideo"):(l[We]&&o.push("audio"),l[gt]&&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(ie(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 m=Z.getBuffered(v);if(m.length>0&&c>m.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&&m.end(m.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=ie(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||!ie(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:te.MEDIA_ERROR,details:B.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:te.MEDIA_ERROR,details:B.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:te.MEDIA_ERROR,details:B.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=ie(i.duration)?i.duration:1/0,u=ie(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}(),Za={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},es=function(s){var n=s;return Za.hasOwnProperty(s)&&(n=Za[s]),String.fromCharCode(n)},Ar=15,Zt=100,xo={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Co={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Po={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Oo={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Mo=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Fo=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}(),Rr=function(s){for(var n=[],e=0;e<s.length;e++)n.push(s[e].toString(16));return n},ts=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}(),No=function(){function s(e,t,r,i,a,o){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new ts(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}(),Uo=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<Zt;t++)this.chars.push(new No);this.logger=e,this.pos=0,this.currPenState=new ts}var n=s.prototype;return n.equals=function(e){for(var t=!0,r=0;r<Zt;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<Zt;t++)this.chars[t].copy(e.chars[t])},n.isEmpty=function(){for(var e=!0,t=0;t<Zt;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>Zt&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Zt)},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=es(e);this.pos>=Zt?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<Zt;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<Zt;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}(),na=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<Ar;t++)this.rows.push(new Uo(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<Ar;e++)this.rows[e].clear();this.currRow=14},n.equals=function(e){for(var t=!0,r=0;r<Ar;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<Ar;t++)this.rows[t].copy(e.rows[t])},n.isEmpty=function(){for(var e=!0,t=0;t<Ar;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<Ar;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<Ar;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}(),rs=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 na(r),this.nonDisplayedMemory=new na(r),this.lastOutputScreen=new na(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}(),is=function(){function s(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new Fo;this.channels=[null,new rs(e,t,i),new rs(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,"["+Rr([t[l],t[l+1]])+"] -> ("+Rr([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 "+Rr([i,a])+" orig: "+Rr([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(ns(e,t,r))return Wr(null,null,r),this.logger.log(3,"Repeated command ("+Rr([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),Wr(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 ("+Rr([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(ns(e,t,i))return Wr(null,null,i),!0;var a=e<=23?1:2;r=t>=64&&t<=95?a===1?xo[e]:Po[e]:a===1?Co[e]:Oo[e];var o=this.channels[a];return!!o&&(o.setPAC(this.interpretPAC(r,t)),Wr(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 '"+es(i)+"' in channel "+r),a=[i]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var l=Rr(a);this.logger.log(3,"Char codes = "+l.join(",")),Wr(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=Mo[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),Wr(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 Wr(s,n,e){e.a=s,e.b=n}function ns(s,n,e){return e.a===s&&e.b===n}var mn=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}(),aa=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,m=o,T=l,S=null,y="",_=!0,R="auto",w="start",P=50,F="middle",U=50,Y="middle";Object.defineProperty(d,"id",r({},u,{get:function(){return c},set:function(G){c=""+G}})),Object.defineProperty(d,"pauseOnExit",r({},u,{get:function(){return f},set:function(G){f=!!G}})),Object.defineProperty(d,"startTime",r({},u,{get:function(){return v},set:function(G){if(typeof G!="number")throw new TypeError("Start time must be set to a number.");v=G,this.hasBeenReset=!0}})),Object.defineProperty(d,"endTime",r({},u,{get:function(){return m},set:function(G){if(typeof G!="number")throw new TypeError("End time must be set to a number.");m=G,this.hasBeenReset=!0}})),Object.defineProperty(d,"text",r({},u,{get:function(){return T},set:function(G){T=""+G,this.hasBeenReset=!0}})),Object.defineProperty(d,"region",r({},u,{get:function(){return S},set:function(G){S=G,this.hasBeenReset=!0}})),Object.defineProperty(d,"vertical",r({},u,{get:function(){return y},set:function(G){var q=function($){return e(s,$)}(G);if(q===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"snapToLines",r({},u,{get:function(){return _},set:function(G){_=!!G,this.hasBeenReset=!0}})),Object.defineProperty(d,"line",r({},u,{get:function(){return R},set:function(G){if(typeof G!="number"&&G!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");R=G,this.hasBeenReset=!0}})),Object.defineProperty(d,"lineAlign",r({},u,{get:function(){return w},set:function(G){var q=t(G);if(!q)throw new SyntaxError("An invalid or illegal string was specified.");w=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"position",r({},u,{get:function(){return P},set:function(G){if(G<0||G>100)throw new Error("Position must be between 0 and 100.");P=G,this.hasBeenReset=!0}})),Object.defineProperty(d,"positionAlign",r({},u,{get:function(){return F},set:function(G){var q=t(G);if(!q)throw new SyntaxError("An invalid or illegal string was specified.");F=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"size",r({},u,{get:function(){return U},set:function(G){if(G<0||G>100)throw new Error("Size must be between 0 and 100.");U=G,this.hasBeenReset=!0}})),Object.defineProperty(d,"align",r({},u,{get:function(){return Y},set:function(G){var q=t(G);if(!q)throw new SyntaxError("An invalid or illegal string was specified.");Y=q,this.hasBeenReset=!0}})),d.displayState=void 0}return i.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},i}(),Bo=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 as(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 Ho=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 ss(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 sa=new aa(0,0,""),yn=sa.align==="middle"?"middle":"center";function Go(s,n,e){var t=s;function r(){var a=as(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 Ho;ss(a,function(c,f){var v;switch(c){case"region":for(var m=e.length-1;m>=0;m--)if(e[m].id===f){l.set(c,e[m].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",yn,"end"]);break;case"position":v=f.split(","),l.percent(c,v[0]),v.length===2&&l.alt("positionAlign",v[1],["start",yn,"end","line-left","line-right","auto"]);break;case"size":l.percent(c,f);break;case"align":l.alt(c,f,["start",yn,"end","left","right"])}},/:/,/\s/),o.region=l.get("region",null),o.vertical=l.get("vertical","");var d=l.get("line","auto");d==="auto"&&sa.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",yn);var u=l.get("position","auto");u==="auto"&&sa.position===50&&(u=o.align==="start"||o.align==="left"?0:o.align==="end"||o.align==="right"?100:50),o.position=u}(s,n)}function os(s){return s.replace(/<br(?: \/)?>/gi,`
|
|
35
|
-
`)}var
|
|
36
|
-
`;)++
|
|
37
|
-
`&&++
|
|
33
|
+
Aborting and switching to level `+G),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===Me&&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 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!==Me||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,c=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,f=r.mainForwardBufferInfo,v=(f?f.len:0)/d,m=this.findBestLevel(c,o,i,v,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(m>=0)return m;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 _=this.bitrateTestDelay;_&&(T=(u?Math.min(u,a.maxLoadingDelay):a.maxLoadingDelay)-_,x.trace("[abr] bitrate test took "+Math.round(1e3*_)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*T)+" ms"),S=y=1)}return m=this.findBestLevel(c,o,i,v+T,S,y),Math.max(m,0)},n.findBestLevel=function(e,t,r,i,a,o){for(var l,u=this.fragCurrent,d=this.partCurrent,c=this.lastLoadedFragLevel,f=this.hls.levels,v=f[c],m=!(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,_=t,R=-1,w=r;w>=t;w--){var P=f[w];if(!P||T&&P.codecSet!==T)P&&(_=Math.min(w,_),R=Math.max(w,R));else{R!==-1&&x.trace("[abr] Skipped level(s) "+_+"-"+R+' with CODECS:"'+f[R].attrs.CODECS+'"; not compatible with "'+v.attrs.CODECS+'"');var F=P.details,U=(d?F==null?void 0:F.partTarget:F==null?void 0:F.averagetargetduration)||S,Y=void 0;Y=w<=c?a*e:o*e;var G=f[w].maxBitrate,q=this.getTimeToLoadFrag(y,Y,G*U,F===void 0);if(x.trace("[abr] level:"+w+" adjustedbw-bitrate:"+Math.round(Y-G)+" avgDuration:"+U.toFixed(1)+" maxFetchDuration:"+i.toFixed(1)+" fetchDuration:"+q.toFixed(1)),Y>G&&(q===0||!ie(q)||m&&!this.bitrateTestDelay||q<i))return w}}return-1},V(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}(),Xa=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}(),Lo=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}ne(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===Si&&this.tick()}},e.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=Ze);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=kr),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.doTick=function(){switch(this.state){case ce:this.doTickIdle();break;case kr: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=Si}break;case or: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=ce);break;case Si:var d=this.waitingData;if(d){var c=d.frag,f=d.part,v=d.cache,m=d.complete;if(this.initPTS[c.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=sr;var T={frag:c,part:f,payload:v.flush(),networkDetails:null};this._handleFragmentLoadProgress(T),m&&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=Z.bufferInfo(this.mediaBuffer,S,this.config.maxBufferHole);Gr(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],u=l.details;if(!u||u.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(u))this.state=kr;else{var d=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&d&&(this.bufferFlushed=!1,this.afterBufferFlushed(d,We,kt));var c=this.getFwdBufferInfo(d,kt);if(c!==null){var f=this.bufferedTrack,v=this.switchingTrack;if(!v&&this._streamEnded(c,u))return t.trigger(E.BUFFER_EOS,{type:"audio"}),void(this.state=bi);var m=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Me),T=c.len,S=this.getMaxBufferLength(m==null?void 0:m.len);if(!(T>=S)||v){var y=u.fragments[0].start,_=c.end;if(v&&i){var R=this.getLoadPosition();f&&v.attrs!==f.attrs&&(_=R),u.PTSKnown&&R<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(_,u),P=!1;if(w&&this.isLoopLoading(w,_)&&(P=!!w.gap,w=this.getNextFragmentLoopLoading(w,u,c,Me,S)),w){var F=m&&w.start>m.end+u.targetduration;if(F||(m==null||!m.len)&&c.len){var U=this.getAppendedFrag(w.start,Me);if(U===null||(P||(P=!!U.gap||!!F&&m.len===0),F&&!P||P&&c.nextStart&&c.nextStart<U.end))return}this.loadFragment(w,l,_)}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 Er(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=Ze),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 c=this.mainDetails;if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed||!c)return;!u.details&&o.hasProgramDateTime&&c.hasProgramDateTime?(Qe(o,c),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!==kr||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,u=this.trackId,d=this.levels;if(d){var c=d[u];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",m=this.transmuxer;m||(m=this.transmuxer=new za(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,_=y!==-1,R=new ee(i.level,i.sn,i.stats.chunkCount,o.byteLength,y,_);m.push(o,S,v,"",i,a,f.totalduration,!1,R,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 Xa,complete:!1}).cache.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=Si}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,K({},o)))}this.fragBufferedComplete(i,a)}else if(!this.loadedmetadata&&i.type===Me){var l=this.videoBuffer||this.media;l&&Z.getBuffered(l).length&&(this.loadedmetadata=!0)}},e.onError=function(t,r){var i;if(r.fatal)this.state=Kr;else switch(r.details){case B.FRAG_GAP:case B.FRAG_PARSING_ERROR:case B.FRAG_DECRYPT_ERROR:case B.FRAG_LOAD_ERROR:case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_ERROR:case B.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(kt,r);break;case B.AUDIO_TRACK_LOAD_ERROR:case B.AUDIO_TRACK_LOAD_TIMEOUT:case B.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==kr||((i=r.context)==null?void 0:i.type)!==yt||(this.state=ce);break;case B.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 B.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.onBufferFlushed=function(t,r){r.type===We&&(this.bufferFlushed=!0,this.state===bi&&(this.state=ce))},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,c=u.part,f=u.level.details,v=o.audio,m=o.text,T=o.id3,S=o.initSegment;if(!this.fragContextChanged(d)&&f){if(this.state=Jt,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 _=v.startPTS,R=v.endPTS,w=v.startDTS,P=v.endDTS;c&&(c.elementaryStreams[We]={startPTS:_,endPTS:R,startDTS:w,endDTS:P}),d.setElementaryStreamInfo(We,_,R,w,P),this.bufferFragmentData(v,d,c,l)}if(T!=null&&(r=T.samples)!=null&&r.length){var F=z({id:i,frag:d,details:f},T);a.trigger(E.FRAG_PARSING_METADATA,F)}if(m){var U=z({id:i,frag:d,details:f},m);a.trigger(E.FRAG_PARSING_USERDATA,U)}}else this.fragmentTracker.removeFragment(d)}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i){if(this.state===Jt){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===W||o===ae?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=Si):(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,K({},t))},n}(Vn),ko=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}ne(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,K({},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:te.MEDIA_ERROR,details:B.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})}},V(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 Qa(s,n){if(s.length!==n.length)return!1;for(var e=0;e<s.length;e++)if(!wo(s[e].attrs,n[e].attrs))return!1;return!0}function wo(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 Ao=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[subtitle-stream-controller]",Rt)||this).levels=[],a.currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a._registerListeners(),a}ne(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,u=i.start,d=0;d<o.length;d++)if(u>=o[d].start&&u<=o[d].end){l=o[d];break}var c=i.start+i.duration;l?l.end=c:(l={start:u,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 u=a-l[o].details.targetduration;if(u<=0)return;r.endOffsetSubtitles=Math.max(0,u),this.tracksBuffered.forEach(function(d){for(var c=0;c<d.length;)if(d[c].end<=u)d.shift();else{if(!(d[c].start<u))break;d[c].start=u,c++}}),this.fragmentTracker.removeFragmentsInRange(i,u,Rt)}},e.onFragBuffered=function(t,r){var i;this.loadedmetadata||r.frag.type!==Me||(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)===Rt&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Ze&&(this.state=ce))},e.onSubtitleTracksUpdated=function(t,r){var i=this,a=r.subtitleTracks;Qa(this.levels,a)?this.levels=a.map(function(o){return new Er(o)}):(this.tracksBuffered=[],this.levels=a.map(function(o){var l=new Er(o);return i.tracksBuffered[l.id]=[],l}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Rt),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 c=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?(c=this.alignPlaylists(a,d.details))===0&&v&&br(a,c=v.start):a.hasProgramDateTime&&f.hasProgramDateTime?(Qe(a,f),c=a.fragments[0].start):v&&br(a,c=v.start)}d.details=a,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(d.details,c),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===ce&&(Sr(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:te.MEDIA_ERROR,details:B.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:i}),d}).then(function(d){var c=performance.now();l.trigger(E.FRAG_DECRYPTED,{frag:i,payload:d,stats:{tstart:u,tdecrypt:c}})}).catch(function(d){r.warn(d.name+": "+d.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,u=this.getLoadPosition(),d=Z.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],u-o,l.maxBufferHole),c=d.end,f=d.len,v=this.getFwdBufferInfo(this.media,Me);if(f>this.getMaxBufferLength(v==null?void 0:v.len)+o)return;var m=a.fragments,T=m.length,S=a.edge,y=null,_=this.fragPrevious;if(c<S){var R=l.maxFragLookUpTolerance;!(y=Sr(_,m,Math.max(m[0].start,c),R))&&_&&_.start<m[0].start&&(y=m[0])}else y=m[T-1];if(!y)return;y=this.mapToInitFragWhenRequired(y),this.fragmentTracker.getState(y)===W&&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))},V(n,[{key:"mediaBufferTimeRanges",get:function(){return new Ro(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(Vn),Ro=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)}}},Do=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}ne(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),ia(this.media.textTracks).forEach(function(t){ar(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===Ft&&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=ia(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 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,c=o.name,f=o.type,v=o.url;this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:l,groupId:d,name:c,type:f,url:v});var m=this.switchParams(o.url,r==null?void 0:r.details);this.loadPlaylist(m)}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=ia(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)}},V(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 ia(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 Io=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}(),Ja=Mr(),$a=/([ha]vc.)(?:\.[^.,]+)+/,xo=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 Io(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&&Ja){var i=this.mediaSource=new Ja;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,c=l.levelCodec,f=l.container,v=l.metadata,m=(o.levelCodec||o.codec).replace($a,"$1"),T=(c||d).replace($a,"$1");if(m!==T){var S=f+";codecs="+(c||d);r.appendChangeType(a,S),x.log("[buffer-controller]: switching codec "+m+" to "+T),r.tracks[a]={buffer:o.buffer,codec:d,container:f,levelCodec:c,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,c=t.part,f=t.chunkMeta,v=f.buffering[u],m=self.performance.now();v.start=m;var T=d.stats.buffering,S=c?c.stats.buffering:null;T.start===0&&(T.start=m),S&&S.start===0&&(S.start=m);var y=o.audio,_=!1;u==="audio"&&(y==null?void 0:y.container)==="audio/mpeg"&&(_=!this.lastMpegAudioChunk||f.id===1||this.lastMpegAudioChunk.sn!==f.sn,this.lastMpegAudioChunk=f);var R=d.start,w={execute:function(){if(v.executeStart=self.performance.now(),_){var P=r.sourceBuffer[u];if(P){var F=R-P.timestampOffset;Math.abs(F)>=.1&&(x.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+R+" (delta: "+F+") sn: "+d.sn+")"),P.timestampOffset=R)}}r.appendExecutor(l,u)},onStart:function(){},onComplete:function(){var P=self.performance.now();v.executeEnd=v.end=P,T.first===0&&(T.first=P),S&&S.first===0&&(S.first=P);var F=r.sourceBuffer,U={};for(var Y in F)U[Y]=Z.getBuffered(F[Y]);r.appendError=0,r.hls.trigger(E.BUFFER_APPENDED,{type:u,frag:d,part:c,chunkMeta:f,parent:d.type,timeRanges:U})},onError:function(P){x.error("[buffer-controller]: Error encountered while trying to append to the "+u+" SourceBuffer",P);var F={type:te.MEDIA_ERROR,parent:d.type,details:B.BUFFER_APPEND_ERROR,frag:d,part:c,chunkMeta:f,error:P,err:P,fatal:!1};P.code===DOMException.QUOTA_EXCEEDED_ERR?F.details=B.BUFFER_FULL_ERROR:(r.appendError++,F.details=B.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(x.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),F.fatal=!0)),i.trigger(E.ERROR,F)}};a.append(w,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[Ir]?o.push("audiovideo"):(l[We]&&o.push("audio"),l[gt]&&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(ie(o)&&!(o<0)){var l=r.currentTime,u=t.levelTargetDuration,d=Math.max(o,u),c=Math.floor(l/u)*u-d;a.forEach(function(f){var v=i[f];if(v){var m=Z.getBuffered(v);if(m.length>0&&c>m.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&&m.end(m.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: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=ie(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||!ie(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:te.MEDIA_ERROR,details:B.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(c){x.error("[buffer-controller]: error while trying to add sourceBuffer: "+c.message),this.hls.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:B.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:te.MEDIA_ERROR,details:B.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=ie(i.duration)?i.duration:1/0,d=ie(a.duration)?a.duration:1/0,c=Math.max(0,t),f=Math.min(r,u,d);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}(),Za={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},es=function(s){var n=s;return Za.hasOwnProperty(s)&&(n=Za[s]),String.fromCharCode(n)},Ar=15,Zt=100,Co={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Po={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Oo={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Mo={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Fo=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],No=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}(),Rr=function(s){for(var n=[],e=0;e<s.length;e++)n.push(s[e].toString(16));return n},ts=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}(),Uo=function(){function s(e,t,r,i,a,o){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new ts(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}(),Bo=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<Zt;t++)this.chars.push(new Uo);this.logger=e,this.pos=0,this.currPenState=new ts}var n=s.prototype;return n.equals=function(e){for(var t=!0,r=0;r<Zt;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<Zt;t++)this.chars[t].copy(e.chars[t])},n.isEmpty=function(){for(var e=!0,t=0;t<Zt;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>Zt&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Zt)},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=es(e);this.pos>=Zt?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<Zt;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<Zt;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}(),na=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<Ar;t++)this.rows.push(new Bo(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<Ar;e++)this.rows[e].clear();this.currRow=14},n.equals=function(e){for(var t=!0,r=0;r<Ar;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<Ar;t++)this.rows[t].copy(e.rows[t])},n.isEmpty=function(){for(var e=!0,t=0;t<Ar;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<Ar;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 c=e.indent,f=Math.max(c-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<Ar;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}(),rs=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 na(r),this.nonDisplayedMemory=new na(r),this.lastOutputScreen=new na(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}(),is=function(){function s(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new No;this.channels=[null,new rs(e,t,i),new rs(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,"["+Rr([t[l],t[l+1]])+"] -> ("+Rr([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 "+Rr([i,a])+" orig: "+Rr([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(ns(e,t,r))return Wr(null,null,r),this.logger.log(3,"Repeated command ("+Rr([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),Wr(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 ("+Rr([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(ns(e,t,i))return Wr(null,null,i),!0;var a=e<=23?1:2;r=t>=64&&t<=95?a===1?Co[e]:Oo[e]:a===1?Po[e]:Mo[e];var o=this.channels[a];return!!o&&(o.setPAC(this.interpretPAC(r,t)),Wr(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 '"+es(i)+"' in channel "+r),a=[i]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var l=Rr(a);this.logger.log(3,"Char codes = "+l.join(",")),Wr(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=Fo[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),Wr(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 Wr(s,n,e){e.a=s,e.b=n}function ns(s,n,e){return e.a===s&&e.b===n}var mn=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}(),aa=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 c=arguments[d];for(var f in c)a[f]=c[f]}return a}function i(a,o,l){var u=this,d={enumerable:!0};u.hasBeenReset=!1;var c="",f=!1,v=a,m=o,T=l,S=null,y="",_=!0,R="auto",w="start",P=50,F="middle",U=50,Y="middle";Object.defineProperty(u,"id",r({},d,{get:function(){return c},set:function(G){c=""+G}})),Object.defineProperty(u,"pauseOnExit",r({},d,{get:function(){return f},set:function(G){f=!!G}})),Object.defineProperty(u,"startTime",r({},d,{get:function(){return v},set:function(G){if(typeof G!="number")throw new TypeError("Start time must be set to a number.");v=G,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",r({},d,{get:function(){return m},set:function(G){if(typeof G!="number")throw new TypeError("End time must be set to a number.");m=G,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",r({},d,{get:function(){return T},set:function(G){T=""+G,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",r({},d,{get:function(){return S},set:function(G){S=G,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",r({},d,{get:function(){return y},set:function(G){var q=function($){return e(s,$)}(G);if(q===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",r({},d,{get:function(){return _},set:function(G){_=!!G,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",r({},d,{get:function(){return R},set:function(G){if(typeof G!="number"&&G!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");R=G,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",r({},d,{get:function(){return w},set:function(G){var q=t(G);if(!q)throw new SyntaxError("An invalid or illegal string was specified.");w=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",r({},d,{get:function(){return P},set:function(G){if(G<0||G>100)throw new Error("Position must be between 0 and 100.");P=G,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",r({},d,{get:function(){return F},set:function(G){var q=t(G);if(!q)throw new SyntaxError("An invalid or illegal string was specified.");F=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",r({},d,{get:function(){return U},set:function(G){if(G<0||G>100)throw new Error("Size must be between 0 and 100.");U=G,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",r({},d,{get:function(){return Y},set:function(G){var q=t(G);if(!q)throw new SyntaxError("An invalid or illegal string was specified.");Y=q,this.hasBeenReset=!0}})),u.displayState=void 0}return i.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},i}(),Ho=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 as(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 Go=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 ss(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 sa=new aa(0,0,""),yn=sa.align==="middle"?"middle":"center";function Ko(s,n,e){var t=s;function r(){var a=as(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 Go;ss(a,function(c,f){var v;switch(c){case"region":for(var m=e.length-1;m>=0;m--)if(e[m].id===f){l.set(c,e[m].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",yn,"end"]);break;case"position":v=f.split(","),l.percent(c,v[0]),v.length===2&&l.alt("positionAlign",v[1],["start",yn,"end","line-left","line-right","auto"]);break;case"size":l.percent(c,f);break;case"align":l.alt(c,f,["start",yn,"end","left","right"])}},/:/,/\s/),o.region=l.get("region",null),o.vertical=l.get("vertical","");var u=l.get("line","auto");u==="auto"&&sa.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",yn);var d=l.get("position","auto");d==="auto"&&sa.position===50&&(d=o.align==="start"||o.align==="left"?0:o.align==="end"||o.align==="right"?100:50),o.position=d}(s,n)}function os(s){return s.replace(/<br(?: \/)?>/gi,`
|
|
35
|
+
`)}var qo=function(){function s(){this.state="INITIAL",this.buffer="",this.decoder=new Ho,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=os(u);d<u.length&&u[d]!=="\r"&&u[d]!==`
|
|
36
|
+
`;)++d;var c=u.slice(0,d);return u[d]==="\r"&&++d,u[d]===`
|
|
37
|
+
`&&++d,t.buffer=u.slice(d),c}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)?ss(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 aa(0,0,""),t.state="CUE",i.indexOf("-->")===-1){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Ko(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}(),Vo=/\r\n|\n\r|\n|\r/g,oa=function(s,n,e){return e===void 0&&(e=0),s.slice(e,e+n.length)===n},la=function(s){for(var n=5381,e=s.length;e;)n=33*n^s.charCodeAt(--e);return(n>>>0).toString()};function ua(s,n,e){return la(s.toString())+la(n.toString())+la(e)}function jo(s,n,e,t,r,i,a){var o,l,u,d=new qo,c=St(new Uint8Array(s)).trim().replace(Vo,`
|
|
41
41
|
`).split(`
|
|
42
|
-
`),f=[],v=(o=n.baseTime,(l=n.timescale)===void 0&&(l=1),Xn(o,9e4,1/l)),m="00:00.000",T=0,S=0,y=!0;
|
|
43
|
-
`)}),
|
|
44
|
-
`:(i=t.childNodes)!=null&&i.length?hs(t,n):n?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function ha(s,n,e){return s&&s.hasAttributeNS(n,e)?s.getAttributeNS(n,e):null}function fs(s){return new Error("Could not parse ttml timestamp "+s)}function fa(s,n){if(!s)return null;var e=as(s);return e===null&&(ls.test(s)?e=function(t,r){var i=ls.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):us.test(s)&&(e=function(t,r){var i=us.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 Wo=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 mn(this,"textTrack1"),r=new mn(this,"textTrack2"),i=new mn(this,"textTrack3"),a=new mn(this,"textTrack4");this.cea608Parser1=new is(1,t,r),this.cea608Parser2=new is(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],m=(o=v[0],l=v[1],d=t,u=r,Math.min(l,u)-Math.max(o,d));if(m>=0&&(v[0]=Math.min(v[0],t),v[1]=Math.max(v[1],r),c=!0,m/(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,ar(r[e]),pr(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){ar(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++)ar(t[r])}},n.onSubtitleTracksUpdated=function(e,t){var r=this,i=t.subtitleTracks||[],a=i.some(function(d){return d.textCodec===da});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){if(Qa(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(Yo(o[v],d)){f=o[v];break}f&&(c=f)}if(c)ar(c);else{var m=r._captionsOrSubtitlesFromCharacteristics(d);(c=r.createTextTrack(m,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===Me){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===At)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===da?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;ds(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;Vo((i=e.initSegment)!=null&&i.data?jt(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||ds(t,this.initPTS[e.cc],function(){i.textCodec=da,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 rn(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===At){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!==Me||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 gi(d[c],r,i)})}if(this.config.renderTextTracksNatively&&r===0&&a!==void 0){var u=this.textTracks;Object.keys(u).forEach(function(c){return gi(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 Yo(s,n){return!!s&&s.label===n.name&&!(s.textTrack1||s.textTrack2)}var zo=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},V(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}(),Xo=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}(),Tn="[eme]",vs=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,Tn),this.log=x.log.bind(x,Tn),this.warn=x.warn.bind(x,Tn),this.error=x.error.bind(x,Tn),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===Ge.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 It?v:new It({type:te.KEY_SYSTEM_ERROR,details:B.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 ri===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 m;switch(u){case Ge.FAIRPLAY:m=["cenc","sinf"];break;case Ge.WIDEVINE:case Ge.PLAYREADY:m=["cenc"];break;case Ge.CLEARKEY:m=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+u)}return function(T,S,y,_){return[{initDataTypes:T,persistentState:_.persistentState||"not-allowed",distinctiveIdentifier:_.distinctiveIdentifier||"not-allowed",sessionTypes:_.sessionTypes||[_.sessionType||"temporary"],audioCapabilities:S.map(function(R){return{contentType:'audio/mp4; codecs="'+R+'"',robustness:_.audioRobustness||"",encryptionScheme:_.audioEncryptionScheme||null}}),videoCapabilities:y.map(function(R){return{contentType:'video/mp4; codecs="'+R+'"',robustness:_.videoRobustness||"",encryptionScheme:_.videoEncryptionScheme||null}})}]}(m,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: '+wt(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 wt(e.keyId)},n.updateKeySession=function(e,t){var r,i=e.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+wt(((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=ti(t.config),o=e.map(Zr).filter(function(l){return!!l&&a.indexOf(l)!==-1});return t.getKeySystemSelectionPromise(o).then(function(l){var d=l.keySystem,u=ei(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 It?this.hls.trigger(E.ERROR,e.data):this.hls.trigger(E.ERROR,{type:te.KEY_SYSTEM_ERROR,details:B.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=Zr(e.keyFormat),a=i?[i]:ti(this.config);return this.attemptKeySystemAccess(a)}return r},n.getKeySystemSelectionPromise=function(e){if(e.length||(e=ti(this.config)),e.length===0)throw new It({type:te.KEY_SYSTEM_ERROR,details:B.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[Ge.FAIRPLAY]){var l=Ye(new Uint8Array(i));try{var d=Jr(JSON.parse(l).sinf),u=li(new Uint8Array(d));if(!u)return;a=u.subarray(8,24),o=Ge.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var c=function(R){if(!(R instanceof ArrayBuffer)||R.byteLength<32)return null;var w={version:0,systemId:"",kids:null,data:null},P=new DataView(R),F=P.getUint32(0);if(R.byteLength!==F&&F>44||P.getUint32(4)!==1886614376||(w.version=P.getUint32(8)>>>24,w.version>1))return null;w.systemId=wt(new Uint8Array(R,12,16));var U=P.getUint32(28);if(w.version===0){if(F-32<U)return null;w.data=new Uint8Array(R,32,U)}else if(w.version===1){w.kids=[];for(var Y=0;Y<U;Y++)w.kids.push(new Uint8Array(R,32+16*Y,16))}return w}(i);if(c===null)return;c.version===0&&c.systemId===Pi&&c.data&&(a=c.data.subarray(8,24)),o=function(R){if(R===Pi)return Ge.WIDEVINE}(c.systemId)}if(o&&a){for(var f=wt(a),v=this.keyIdToKeySessionPromise,m=this.mediaKeySessions,T=v[f],S=function(){var R=m[y],w=R.decryptdata;if(w.pssh||!w.keyId)return"continue";var P=wt(w.keyId);return f===P||w.uri.replace(/-/g,"").indexOf(f)!==-1?(T=v[P],delete v[P],w.pssh=new Uint8Array(i),w.keyId=a,T=v[f]=T.then(function(){return t.generateRequestWithPreferredKeySession(R,r,i,"encrypted-event-key-match")}),"break"):void 0},y=0;y<m.length;y++){var _=S();if(_!=="continue"&&_==="break")break}T||(T=v[f]=this.getKeySystemSelectionPromise([o]).then(function(R){var w,P=R.keySystem,F=R.mediaKeys;t.throwIfDestroyed();var U=new vr("ISO-23001-7",f,(w=ei(P))!=null?w:"");return U.pssh=new Uint8Array(i),U.keyId=a,t.attemptSetMediaKeys(P,F).then(function(){t.throwIfDestroyed();var Y=t.createMediaKeySessionContext({decryptdata:U,keySystem:P,mediaKeys:F});return t.generateRequestWithPreferredKeySession(Y,r,i,"encrypted-event-no-match")})})),T.catch(function(R){return t.handleError(R)})}}},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 pn;e.mediaKeysSession.onmessage=function(T){var S=e.mediaKeysSession;if(S){var y=T.messageType,_=T.message;l.log('"'+y+'" message event for session "'+S.sessionId+'" message size: '+_.byteLength),y==="license-request"||y==="license-renewal"?l.renewLicense(e,_).catch(function(R){l.handleError(R),v.emit("error",R)}):y==="license-release"?e.keySystem===Ge.FAIRPLAY&&(l.updateKeySession(e,Ci("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 m=new Promise(function(T,S){v.on("error",S),v.on("keyStatus",function(y){y.startsWith("usable")?T():y==="output-restricted"?S(new It({type:te.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):y==="internal-error"?S(new It({type:te.KEY_SYSTEM_ERROR,details:B.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 It({type:te.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_SESSION,error:T,fatal:!1},"Error generating key-session request: "+T)}).then(function(){return m}).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: '+wt("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))+" session keyId: "+wt(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,m,T){a(f.data)},onError:function(f,v,m,T){o(new It({type:te.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:K({url:l.url,data:void 0},f)},'"'+e+'" certificate request failed ('+i+"). Status: "+f.code+" ("+f.text+")"))},onTimeout:function(f,v,m){o(new It({type:te.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},'"'+e+'" certificate request timed out ('+i+")"))},onAbort:function(f,v,m){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 It({type:te.KEY_SYSTEM_ERROR,details:B.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 It({type:te.KEY_SYSTEM_ERROR,details:B.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 It({type:te.KEY_SYSTEM_ERROR,details:B.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 m=v-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+m+" 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={},vr.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}();vs.CDMCleanupPromise=void 0;var It=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 ne(n,s),n}(Ie(Error)),Qo="m",En="a",va="v",ga="av",gs="i",Jo="tt",$o=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:Qo,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!==va&&d!==En&&d!=ga||(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={}),z(t,this.createData());var r=t.ot===gs||t.ot===va||t.ot===ga;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={}),z(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"?Jo:e.sn==="initSegment"?gs:t==="audio"?En:t==="main"?this.hls.audioTracks.length?va:ga:void 0},n.getTopBandwidth=function(e){var t,r=0,i=this.hls;if(e===En)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=ke(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===En?this.audioBuffer:this.videoBuffer;return r&&t?1e3*Z.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)},V(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)},V(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=ke(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,m=void 0;m=u==="ot"||u==="sf"||u==="st"?u+"="+c:v==="boolean"?u:v==="number"?u+"="+c:u+"="+JSON.stringify(c),r.push(m)}}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}(),Zo=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)===p&&r.flags===b){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=z({},f);v.details=void 0,v.url=ms(f.uri,f.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",u);var m=new He(f.attrs);m["PATHWAY-ID"]=l;var T=m.AUDIO&&m.AUDIO+"_clone_"+l,S=m.SUBTITLES&&m.SUBTITLES+"_clone_"+l;T&&(i[m.AUDIO]=T,m.AUDIO=T),S&&(a[m.SUBTITLES]=S,m.SUBTITLES=S),v.attrs=m;var y=new Er(v);return N(y,"audio",T),N(y,"text",S),y});r.push.apply(r,c),ps(t.audioTracks,i,u,l),ps(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,m,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 _=y["RELOAD-URI"],R=y["PATHWAY-CLONES"],w=y["PATHWAY-PRIORITY"];if(_)try{r.uri=new self.URL(_,t).href}catch{return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+_)}r.scheduleRefresh(r.uri||T.url),R&&r.clonePathways(R),w&&r.updatePathwayPriority(w)}else r.log("Steering VERSION "+y.VERSION+" not supported!")},onError:function(v,m,T,S){if(r.log("Error loading steering manifest: "+v.code+" "+v.text+" ("+m.url+")"),r.stopLoad(),v.code===410)return r.enabled=!1,void r.log("Steering manifest "+m.url+" no longer available");var y=1e3*r.timeToLoad;if(v.code!==429)r.scheduleRefresh(r.uri||m.url,y);else{var _=r.loader;if(typeof(_==null?void 0:_.getResponseHeader)=="function"){var R=_.getResponseHeader("Retry-After");R&&(y=1e3*parseFloat(R))}r.log("Steering manifest "+m.url+" rate limited")}},onTimeout:function(v,m,T){r.log("Timeout loading steering manifest ("+m.url+")"),r.scheduleRefresh(r.uri||m.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 ps(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=z({},a);return o.details=void 0,o.attrs=new He(o.attrs),o.url=o.attrs.URI=ms(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 ms(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 el=/^age:\s*[\d.]+\s*$/im,ys=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 vt,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&&ie(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;Hr(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(Hr(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=_i(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&&el.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}(),tl=/(\d+)-(\d+)\/(\d+)/,Ts=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||rl,this.controller=new self.AbortController,this.stats=new vt}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(m,T){var S={method:"GET",mode:"cors",credentials:"same-origin",signal:T,headers:new self.Headers(z({},m.headers))};return m.rangeEnd&&S.headers.set("Range","bytes="+m.rangeStart+"-"+String(m.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&&ie(f)?f:v,this.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(a,e,i.response)},t.timeout),self.fetch(this.request).then(function(m){i.response=i.loader=m;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)),!m.ok){var S=m.status,y=m.statusText;throw new il(y||"fetch, bad network response",S,m)}return a.loading.first=T,a.total=function(_){var R=_.get("Content-Range");if(R){var w=function(F){var U=tl.exec(F);if(U)return parseInt(U[2])-parseInt(U[1])+1}(R);if(ie(w))return w}var P=_.get("Content-Length");if(P)return parseInt(P)}(m.headers)||a.total,l&&ie(t.highWaterMark)?i.loadProgressively(m,a,e,t.highWaterMark,l):d?m.arrayBuffer():e.responseType==="json"?m.json():m.text()}).then(function(m){var T=i.response;self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var S=m[u];S&&(a.loaded=a.total=S);var y={url:T.url,data:m,code:T.status};l&&!ie(t.highWaterMark)&&l(a,e,m,T),r.onSuccess(y,a,e,T)}).catch(function(m){if(self.clearTimeout(i.requestTimeout),!a.aborted){var T=m&&m.code||0,S=m?m.message:null;r.onError({code:T,text:S},e,m?m.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 Xa,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 rl(s,n){return new self.Request(s.url,n)}var il=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 ne(n,s),n}(Ie(Error)),nl=/\s/,al=K(K({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:ys,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:bo,bufferController:Io,capLevelController:zo,errorController:A,fpsController:Xo,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:ri,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++)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 m=os(l.trim()),T=ua(n,e,m);s!=null&&(f=s.cues)!=null&&f.getCueById(T)||((i=new u(n,e,m)).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 rn(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:wo,subtitleTrackController:Ro,timelineController:Wo,audioStreamController:So,audioTrackController:Lo,emeController:vs,cmcdController:$o,contentSteeringController:Zo});function pa(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(pa):Object.keys(s).reduce(function(n,e){return n[e]=pa(s[e]),n},{}):s}function sl(s){var n=s.loader;n!==Ts&&n!==ys?(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=Ts,s.progressive=!0,s.enableSoftwareAES=!0,x.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Es=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 pn,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,Ne(e.debug||!1,"Hls instance");var t=this.config=function($,X){if((X.liveSyncDurationCount||X.liveMaxLatencyDurationCount)&&(X.liveSyncDuration||X.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(X.liveMaxLatencyDurationCount!==void 0&&(X.liveSyncDurationCount===void 0||X.liveMaxLatencyDurationCount<=X.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(X.liveMaxLatencyDuration!==void 0&&(X.liveSyncDuration===void 0||X.liveMaxLatencyDuration<=X.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var se=pa($),ve=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(ue){var fe=(ue==="level"?"playlist":ue)+"LoadPolicy",pe=X[fe]===void 0,ge=[];ve.forEach(function(Le){var De=ue+"Loading"+Le,Ce=X[De];if(Ce!==void 0&&pe){ge.push(De);var Fe=se[fe].default;switch(X[fe]={default:Fe},Le){case"TimeOut":Fe.maxLoadTimeMs=Ce,Fe.maxTimeToFirstByteMs=Ce;break;case"MaxRetry":Fe.errorRetry.maxNumRetry=Ce,Fe.timeoutRetry.maxNumRetry=Ce;break;case"RetryDelay":Fe.errorRetry.retryDelayMs=Ce,Fe.timeoutRetry.retryDelayMs=Ce;break;case"MaxRetryTimeout":Fe.errorRetry.maxRetryDelayMs=Ce,Fe.timeoutRetry.maxRetryDelayMs=Ce}}}),ge.length&&x.warn('hls.js config: "'+ge.join('", "')+'" setting(s) are deprecated, use "'+fe+'": '+JSON.stringify(X[fe]))}),K(K({},se),X)}(s.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&sl(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),m=new ze(this),T=new Bn(this),S=t.contentSteeringController,y=S?new S(this):null,_=this.levelController=new C(this,y),R=new le(this),w=new Ve(this.config),P=this.streamController=new Eo(this,R,w);f.setStreamController(P),v.setStreamController(P);var F=[m,_,P];y&&F.splice(1,0,y),this.networkControllers=F;var U=[u,c,f,v,T,R];this.audioTrackController=this.createController(t.audioTrackController,F);var Y=t.audioStreamController;Y&&F.push(new Y(this,R,w)),this.subtitleTrackController=this.createController(t.subtitleTrackController,F);var G=t.subtitleStreamController;G&&F.push(new G(this,R,w)),this.createController(t.timelineController,U),w.emeController=this.emeController=this.createController(t.emeController,U),this.cmcdController=this.createController(t.cmcdController,U),this.latencyController=this.createController(Hn,U),this.coreComponents=U,F.push(d);var q=d.onErrorOut;typeof q=="function"&&this.on(E.ERROR,q,d)}s.isSupported=function(){return function(){var e=Mr();if(!e)return!1;var t=Da(),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:te.OTHER_ERROR,details:B.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=mt.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)},V(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){pi.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 te}},{key:"ErrorDetails",get:function(){return B}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:al},set:function(e){s.defaultConfig=e}}]),s}();return Es.defaultConfig=void 0,Es},typeof Ds=="object"&&typeof Ea!="undefined"?Ea.exports=H():typeof define=="function"&&define.amd?define(H):(M=typeof globalThis!="undefined"?globalThis:M||self).Hls=H()})(!1)});var Rn=As(Rs());var xs=As(Is()),El=xs.default,lt=El;var zr=class extends Error{constructor(M,H=zr.MEDIA_ERR_CUSTOM,j,K){var Q;super(M);this.name="MediaError",this.code=H,this.context=K,this.fatal=j!=null?j:H>=zr.MEDIA_ERR_NETWORK&&H<=zr.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(Q=zr.defaultMessages[this.code])!=null?Q:"")}},ft=zr;ft.MEDIA_ERR_ABORTED=1,ft.MEDIA_ERR_NETWORK=2,ft.MEDIA_ERR_DECODE=3,ft.MEDIA_ERR_SRC_NOT_SUPPORTED=4,ft.MEDIA_ERR_ENCRYPTED=5,ft.MEDIA_ERR_CUSTOM=100,ft.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 _l=D=>D==null,_a=(D,I)=>_l(I)?!1:D in I,Ln={ANY:"any",MUTED:"muted"},Kt={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},ba={MSE:"mse",NATIVE:"native"},kn={HEADER:"header",QUERY:"query",NONE:"none"},Xl=Object.values(kn),qt={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},wn={HLS:qt.M3U8},Ql=Object.keys(wn),Jl=[...Object.values(qt),"hls","HLS"];var Pt=(D,I,M,H,j=D)=>{j.addEventListener(I,M,H),D.addEventListener("teardown",()=>{j.removeEventListener(I,M)},{once:!0})};function Cs(D,I,M){I&&M>I&&(M=I);for(let H=0;H<D.length;H++)if(D.start(H)<=M&&D.end(H)>=M)return!0;return!1}var Ps=D=>{let I=D.indexOf("?");if(I<0)return[D];let M=D.slice(0,I),H=D.slice(I);return[M,H]},Ri=D=>{let I=D.type;if(I){let H=I.toUpperCase();return _a(H,wn)?wn[H]:I}let{src:M}=D;return M?bl(M):""},Sa=D=>D==="VOD"?Kt.ON_DEMAND:Kt.LIVE,La=D=>D==="EVENT"?Number.POSITIVE_INFINITY:D==="VOD"?Number.NaN:0,bl=D=>{let I="";try{I=new URL(D).pathname}catch{console.error("invalid url")}let M=I.lastIndexOf(".");if(M<0)return"";let j=I.slice(M+1).toUpperCase();return _a(j,qt)?qt[j]:""};var Sl=Object.values(Ln),Os=D=>typeof D=="boolean"||typeof D=="string"&&Sl.includes(D),Ms=({autoplay:D},I,M)=>{let H=!1,j=!1,K=Os(D)?D:!!D,Q=()=>{H||Pt(I,"playing",()=>{H=!0},{once:!0})};if(Q(),Pt(I,"loadstart",()=>{H=!1,Q(),ka(I,K)},{once:!0}),Pt(I,"loadstart",()=>{M||(j=!Number.isFinite(I.duration)),ka(I,K)},{once:!0}),M&&M.once(lt.Events.LEVEL_LOADED,(re,z)=>{var ne;j=(ne=z.details.live)!=null?ne:!1}),!K){let re=()=>{!j||(M!=null&&M.liveSyncPosition?I.currentTime=M.liveSyncPosition:Number.isFinite(I.seekable.end(0))&&(I.currentTime=I.seekable.end(0)))};M&&Pt(I,"play",()=>{I.preload==="metadata"?M.once(lt.Events.LEVEL_UPDATED,re):re()},{once:!0})}return re=>{H||(K=Os(re)?re:!!re,ka(I,K))}},ka=(D,I)=>{if(!I)return;let M=D.muted,H=()=>D.muted=M;switch(I){case Ln.ANY:D.play().catch(()=>{D.muted=!0,D.play().catch(H)});break;case Ln.MUTED:D.muted=!0,D.play().catch(H);break;default:D.play().catch(()=>{});break}};var Fs=({preload:D,src:I},M,H)=>{let j=ye=>{ye!=null&&["","none","metadata","auto"].includes(ye)?M.setAttribute("preload",ye):M.removeAttribute("preload")};if(!H)return j(D),j;let K=!1,Q=!1,V=H.config.maxBufferLength,re=H.config.maxBufferSize,z=ye=>{j(ye);let oe=ye!=null?ye:M.preload;Q||oe==="none"||(oe==="metadata"?(H.config.maxBufferLength=1,H.config.maxBufferSize=1):(H.config.maxBufferLength=V,H.config.maxBufferSize=re),ne())},ne=()=>{!K&&I&&(K=!0,H.loadSource(I))};return Pt(M,"play",()=>{Q=!0,H.config.maxBufferLength=V,H.config.maxBufferSize=re,ne()},{once:!0}),z(D),z};function Ns(D,I){I.on(lt.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(j,{tracks:K})=>{K.forEach(Q=>{var z;let V=(z=Q.subtitleTrack)!=null?z:Q.closedCaptions,re=I.subtitleTracks.findIndex(({lang:ne,name:ye,type:oe})=>ne==(V==null?void 0:V.lang)&&ye===Q.label&&oe.toLowerCase()===Q.kind);wa(D,Q.kind,Q.label,V==null?void 0:V.lang,`${Q.kind}${re}`)})});let M=()=>{var Q;if(!I.subtitleTracks.length)return;let j=Array.from(D.textTracks).find(V=>V.id&&V.mode==="showing"&&["subtitles","captions"].includes(V.kind)),K=`${(Q=I.subtitleTracks[I.subtitleTrack])==null?void 0:Q.type.toLowerCase()}${I.subtitleTrack}`;if(j&&(I.subtitleTrack<0||(j==null?void 0:j.id)!==K)){let V=I.subtitleTracks.findIndex(({lang:re,name:z,type:ne})=>re==j.language&&z===j.label&&ne.toLowerCase()===j.kind);I.subtitleTrack=V}j&&(j==null?void 0:j.id)===K&&j.cues&&Array.from(j.cues).forEach(V=>{j.addCue(V)})};D.textTracks.addEventListener("change",M),I.on(lt.Events.CUES_PARSED,(j,{track:K,cues:Q})=>{let V=D.textTracks.getTrackById(K);if(!V)return;let re=V.mode==="disabled";re&&(V.mode="hidden"),Q.forEach(z=>{var ne;(ne=V.cues)!=null&&ne.getCueById(z.id)||V.addCue(z)}),re&&(V.mode="disabled")}),I.once(lt.Events.DESTROYING,()=>{D.textTracks.removeEventListener("change",M),D.querySelectorAll("track[data-removeondestroy]").forEach(K=>{K.remove()})});let H=()=>{Array.from(D.textTracks).forEach(j=>{var K,Q;if(!["subtitles","caption"].includes(j.kind)&&j.label==="thumbnails"){if(!((K=j.cues)!=null&&K.length)){let V=D.querySelector('track[label="thumbnails"]'),re=(Q=V==null?void 0:V.getAttribute("src"))!=null?Q:"";V==null||V.removeAttribute("src"),setTimeout(()=>{V==null||V.setAttribute("src",re)},0)}j.mode!=="hidden"&&(j.mode="hidden")}})};I.once(lt.Events.MANIFEST_LOADED,H),I.once(lt.Events.MEDIA_ATTACHED,H)}function wa(D,I,M,H,j){let K=document.createElement("track");return K.kind=I,K.label=M,H&&(K.srclang=H),j&&(K.id=j),K.track.mode=["subtitles","captions"].includes(I)?"disabled":"hidden",K.setAttribute("data-removeondestroy",""),D.append(K),K.track}function Ll(D,I){let M=Array.prototype.find.call(D.querySelectorAll("track"),H=>H.track===I);M==null||M.remove()}var Di="cuepoints",Aa=Object.freeze({label:Di}),An=(D,{label:I=Di}=Aa)=>{var M;return(M=Array.from(D.querySelectorAll("track")).find(H=>H.track.label===I&&H.track.kind==="metadata"))==null?void 0:M.track};async function Us(D,I,M=Aa){let H=An(D,M);if(!H){let{label:j=Di}=M;H=wa(D,"metadata",j),H.mode="hidden",await new Promise(K=>setTimeout(()=>K(void 0),0))}return H.mode!=="hidden"&&(H.mode="hidden"),[...I].sort(({time:j},{time:K})=>K-j).forEach(({time:j,value:K})=>{var ye,oe;let Q=Array.prototype.findIndex.call(H==null?void 0:H.cues,Te=>Te.startTime>=j),V=(ye=H==null?void 0:H.cues)==null?void 0:ye[Q],re=V?V.startTime:Number.isFinite(D.duration)?D.duration:Number.MAX_SAFE_INTEGER,z=(oe=H==null?void 0:H.cues)==null?void 0:oe[Q-1];z&&(z.endTime=j);let ne=new VTTCue(j,re,JSON.stringify(K!=null?K:null));H.addCue(ne)}),H}var Bs=D=>({time:D.startTime,value:JSON.parse(D.text)});function kl(D,I={label:Di}){let M=An(D,I);return M!=null&&M.cues?Array.from(M.cues,H=>Bs(H)):[]}function Hs(D,I={label:Di}){var K,Q;let M=An(D,I);if(!((K=M==null?void 0:M.activeCues)!=null&&K.length))return;let{currentTime:H}=D,j=Array.prototype.find.call((Q=M.activeCues)!=null?Q:[],({startTime:V,endTime:re})=>V<=H&&re>H);return Bs(j)}async function Gs(D,I=Aa){return new Promise(M=>{Pt(D,"loadstart",async()=>{let H=await Us(D,[],I);Pt(D,"cuechange",()=>{let j=Hs(D);if(j){let K=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:j});D.dispatchEvent(K)}},{},H),M(H)})})}function wl(D,I){if(I){let M=I.playingDate;if(M!=null)return new Date(M.getTime()-D.currentTime*1e3)}return typeof D.getStartDate=="function"?D.getStartDate():new Date(NaN)}function Al(D,I){if(I&&I.playingDate)return I.playingDate;if(typeof D.getStartDate=="function"){let M=D.getStartDate();return new Date(M.getTime()+D.currentTime*1e3)}return new Date(NaN)}var Rl=async D=>fetch(D).then(I=>I.text()).then(I=>{let M=I.split(`
|
|
42
|
+
`),f=[],v=(o=n.baseTime,(l=n.timescale)===void 0&&(l=1),Xn(o,9e4,1/l)),m="00:00.000",T=0,S=0,y=!0;d.oncue=function(_){var R=e[t],w=e.ccOffset,P=(T-v)/9e4;R!=null&&R.new&&(S!==void 0?w=e.ccOffset=R.start:function(G,q,$){var X=G[q],se=G[X.prevCC];if(!se||!se.new&&X.new)return G.ccOffset=G.presentationOffset=X.start,void(X.new=!1);for(;(ve=se)!=null&&ve.new;){var ve;G.ccOffset+=X.start-se.start,X.new=!1,se=G[(X=se).prevCC]}G.presentationOffset=$}(e,t,P)),P&&(w=P-e.presentationOffset);var F=_.endTime-_.startTime,U=It(9e4*(_.startTime+w-S),9e4*r)/9e4;_.startTime=Math.max(U,0),_.endTime=Math.max(U+F,0);var Y=_.text.trim();_.text=decodeURIComponent(encodeURIComponent(Y)),_.id||(_.id=ua(_.startTime,_.endTime,Y)),_.endTime>0&&f.push(_)},d.onparsingerror=function(_){u=_},d.onflush=function(){u?a(u):i(f)},c.forEach(function(_){if(y){if(oa(_,"X-TIMESTAMP-MAP=")){y=!1,_.slice(16).split(",").forEach(function(R){oa(R,"LOCAL:")?m=R.slice(6):oa(R,"MPEGTS:")&&(T=parseInt(R.slice(7)))});try{S=function(R){var w=parseInt(R.slice(-3)),P=parseInt(R.slice(-6,-4)),F=parseInt(R.slice(-9,-7)),U=R.length>9?parseInt(R.substring(0,R.indexOf(":"))):0;if(!(ie(w)&&ie(P)&&ie(F)&&ie(U)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+R);return w+=1e3*P,(w+=6e4*F)+36e5*U}(m)/1e3}catch(R){u=R}return}_===""&&(y=!1)}d.parse(_+`
|
|
43
|
+
`)}),d.flush()}var da="stpp.ttml.im1t",ls=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,us=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Wo={left:"start",center:"center",right:"end",start:"start",end:"end"};function ds(s,n,e,t){var r=xe(new Uint8Array(s),["mdat"]);if(r.length!==0){var i,a,o,l,u=r.map(function(c){return St(c)}),d=(i=n.baseTime,a=1,(o=n.timescale)===void 0&&(o=1),l===void 0&&(l=!1),Xn(i,a,1/o,l));try{u.forEach(function(c){return e(function(f,v){var m=new DOMParser().parseFromString(f,"text/xml").getElementsByTagName("tt")[0];if(!m)throw new Error("Invalid ttml");var T={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(T).reduce(function(P,F){return P[F]=m.getAttribute("ttp:"+F)||T[F],P},{}),y=m.getAttribute("xml:space")!=="preserve",_=cs(ca(m,"styling","style")),R=cs(ca(m,"layout","region")),w=ca(m,"body","[begin]");return[].map.call(w,function(P){var F=hs(P,y);if(!F||!P.hasAttribute("begin"))return null;var U=fa(P.getAttribute("begin"),S),Y=fa(P.getAttribute("dur"),S),G=fa(P.getAttribute("end"),S);if(U===null)throw fs(P);if(G===null){if(Y===null)throw fs(P);G=U+Y}var q=new aa(U-v,G-v,F);q.id=ua(q.startTime,q.endTime,q.text);var $=function(ve,ue,fe){var pe="http://www.w3.org/ns/ttml#styling",ge=null,Le=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],De=ve!=null&&ve.hasAttribute("style")?ve.getAttribute("style"):null;return De&&fe.hasOwnProperty(De)&&(ge=fe[De]),Le.reduce(function(Ce,Fe){var _t=ha(ue,pe,Fe)||ha(ve,pe,Fe)||ha(ge,pe,Fe);return _t&&(Ce[Fe]=_t),Ce},{})}(R[P.getAttribute("region")],_[P.getAttribute("style")],_),X=$.textAlign;if(X){var se=Wo[X];se&&(q.lineAlign=se),q.align=X}return z(q,$),q}).filter(function(P){return P!==null})}(c,d))})}catch(c){t(c)}}else t(new Error("Could not parse IMSC1 mdat"))}function ca(s,n,e){var t=s.getElementsByTagName(n)[0];return t?[].slice.call(t.querySelectorAll(e)):[]}function cs(s){return s.reduce(function(n,e){var t=e.getAttribute("xml:id");return t&&(n[t]=e),n},{})}function hs(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?hs(t,n):n?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function ha(s,n,e){return s&&s.hasAttributeNS(n,e)?s.getAttributeNS(n,e):null}function fs(s){return new Error("Could not parse ttml timestamp "+s)}function fa(s,n){if(!s)return null;var e=as(s);return e===null&&(ls.test(s)?e=function(t,r){var i=ls.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):us.test(s)&&(e=function(t,r){var i=us.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 Yo=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 mn(this,"textTrack1"),r=new mn(this,"textTrack2"),i=new mn(this,"textTrack3"),a=new mn(this,"textTrack4");this.cea608Parser1=new is(1,t,r),this.cea608Parser2=new is(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,c=!1,f=a.length;f--;){var v=a[f],m=(o=v[0],l=v[1],u=t,d=r,Math.min(l,d)-Math.max(o,u));if(m>=0&&(v[0]=Math.min(v[0],t),v[1]=Math.max(v[1],r),c=!0,m/(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,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,ar(r[e]),pr(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){ar(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++)ar(t[r])}},n.onSubtitleTracksUpdated=function(e,t){var r=this,i=t.subtitleTracks||[],a=i.some(function(u){return u.textCodec===da});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){if(Qa(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 c;if(o&&d<o.length){for(var f=null,v=0;v<o.length;v++)if(zo(o[v],u)){f=o[v];break}f&&(c=f)}if(c)ar(c);else{var m=r._captionsOrSubtitlesFromCharacteristics(u);(c=r.createTextTrack(m,u.name,u.lang))&&(c.mode="disabled")}c&&(c.groupId=u.groupId,r.textTracks.push(c))})}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===Me){var l,u,d=t.frag.sn,c=(l=t==null||(u=t.part)==null?void 0:u.index)!=null?l:-1;d===a+1||d===a&&c===o+1||(r.reset(),i.reset()),this.lastSn=d,this.lastPartIndex=c}},n.onFragLoaded=function(e,t){var r=t.frag,i=t.payload,a=this.initPTS,o=this.unparsedVttFrags;if(r.type===Rt)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],c=this.vttCCs;c[r.cc]||(c[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),d&&d.textCodec===da?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;ds(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;jo((i=e.initSegment)!=null&&i.data?jt(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||ds(t,this.initPTS[e.cc],function(){i.textCodec=da,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 rn(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===Rt){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!==Me||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(c){return gi(u[c],r,i)})}if(this.config.renderTextTracksNatively&&r===0&&a!==void 0){var d=this.textTracks;Object.keys(d).forEach(function(c){return gi(d[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++],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 zo(s,n){return!!s&&s.label===n.name&&!(s.textTrack1||s.textTrack2)}var Xo=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},V(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}(),Qo=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 c=d.currentLevel;x.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=c)&&(c-=1,d.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.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}(),Tn="[eme]",vs=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,Tn),this.log=x.log.bind(x,Tn),this.warn=x.warn.bind(x,Tn),this.error=x.error.bind(x,Tn),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===Ge.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(c){var f=c.shift();t.getMediaKeysPromise(f,a,o).then(function(v){return l({keySystem:f,mediaKeys:v})}).catch(function(v){c.length?d(c):u(v instanceof xt?v:new xt({type:te.KEY_SYSTEM_ERROR,details:B.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 ri===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,c,f,v){var m;switch(d){case Ge.FAIRPLAY:m=["cenc","sinf"];break;case Ge.WIDEVINE:case Ge.PLAYREADY:m=["cenc"];break;case Ge.CLEARKEY:m=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+d)}return function(T,S,y,_){return[{initDataTypes:T,persistentState:_.persistentState||"not-allowed",distinctiveIdentifier:_.distinctiveIdentifier||"not-allowed",sessionTypes:_.sessionTypes||[_.sessionType||"temporary"],audioCapabilities:S.map(function(R){return{contentType:'audio/mp4; codecs="'+R+'"',robustness:_.audioRobustness||"",encryptionScheme:_.audioEncryptionScheme||null}}),videoCapabilities:y.map(function(R){return{contentType:'video/mp4; codecs="'+R+'"',robustness:_.videoRobustness||"",encryptionScheme:_.videoEncryptionScheme||null}})}]}(m,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 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 c=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+'"'),c.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: '+At(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 At(e.keyId)},n.updateKeySession=function(e,t){var r,i=e.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+At(((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=ti(t.config),o=e.map(Zr).filter(function(l){return!!l&&a.indexOf(l)!==-1});return t.getKeySystemSelectionPromise(o).then(function(l){var u=l.keySystem,d=ei(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 c=t.createMediaKeySessionContext({keySystem:u,mediaKeys:d,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 xt?this.hls.trigger(E.ERROR,e.data):this.hls.trigger(E.ERROR,{type:te.KEY_SYSTEM_ERROR,details:B.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=Zr(e.keyFormat),a=i?[i]:ti(this.config);return this.attemptKeySystemAccess(a)}return r},n.getKeySystemSelectionPromise=function(e){if(e.length||(e=ti(this.config)),e.length===0)throw new xt({type:te.KEY_SYSTEM_ERROR,details:B.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[Ge.FAIRPLAY]){var l=Ye(new Uint8Array(i));try{var u=Jr(JSON.parse(l).sinf),d=li(new Uint8Array(u));if(!d)return;a=d.subarray(8,24),o=Ge.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var c=function(R){if(!(R instanceof ArrayBuffer)||R.byteLength<32)return null;var w={version:0,systemId:"",kids:null,data:null},P=new DataView(R),F=P.getUint32(0);if(R.byteLength!==F&&F>44||P.getUint32(4)!==1886614376||(w.version=P.getUint32(8)>>>24,w.version>1))return null;w.systemId=At(new Uint8Array(R,12,16));var U=P.getUint32(28);if(w.version===0){if(F-32<U)return null;w.data=new Uint8Array(R,32,U)}else if(w.version===1){w.kids=[];for(var Y=0;Y<U;Y++)w.kids.push(new Uint8Array(R,32+16*Y,16))}return w}(i);if(c===null)return;c.version===0&&c.systemId===Pi&&c.data&&(a=c.data.subarray(8,24)),o=function(R){if(R===Pi)return Ge.WIDEVINE}(c.systemId)}if(o&&a){for(var f=At(a),v=this.keyIdToKeySessionPromise,m=this.mediaKeySessions,T=v[f],S=function(){var R=m[y],w=R.decryptdata;if(w.pssh||!w.keyId)return"continue";var P=At(w.keyId);return f===P||w.uri.replace(/-/g,"").indexOf(f)!==-1?(T=v[P],delete v[P],w.pssh=new Uint8Array(i),w.keyId=a,T=v[f]=T.then(function(){return t.generateRequestWithPreferredKeySession(R,r,i,"encrypted-event-key-match")}),"break"):void 0},y=0;y<m.length;y++){var _=S();if(_!=="continue"&&_==="break")break}T||(T=v[f]=this.getKeySystemSelectionPromise([o]).then(function(R){var w,P=R.keySystem,F=R.mediaKeys;t.throwIfDestroyed();var U=new vr("ISO-23001-7",f,(w=ei(P))!=null?w:"");return U.pssh=new Uint8Array(i),U.keyId=a,t.attemptSetMediaKeys(P,F).then(function(){t.throwIfDestroyed();var Y=t.createMediaKeySessionContext({decryptdata:U,keySystem:P,mediaKeys:F});return t.generateRequestWithPreferredKeySession(Y,r,i,"encrypted-event-no-match")})})),T.catch(function(R){return t.handleError(R)})}}},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 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 pn;e.mediaKeysSession.onmessage=function(T){var S=e.mediaKeysSession;if(S){var y=T.messageType,_=T.message;l.log('"'+y+'" message event for session "'+S.sessionId+'" message size: '+_.byteLength),y==="license-request"||y==="license-renewal"?l.renewLicense(e,_).catch(function(R){l.handleError(R),v.emit("error",R)}):y==="license-release"?e.keySystem===Ge.FAIRPLAY&&(l.updateKeySession(e,Ci("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 m=new Promise(function(T,S){v.on("error",S),v.on("keyStatus",function(y){y.startsWith("usable")?T():y==="output-restricted"?S(new xt({type:te.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):y==="internal-error"?S(new xt({type:te.KEY_SYSTEM_ERROR,details:B.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 xt({type:te.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_SESSION,error:T,fatal:!1},"Error generating key-session request: "+T)}).then(function(){return m}).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: '+At("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))+" session keyId: "+At(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},c={onSuccess:function(f,v,m,T){a(f.data)},onError:function(f,v,m,T){o(new xt({type:te.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:K({url:l.url,data:void 0},f)},'"'+e+'" certificate request failed ('+i+"). Status: "+f.code+" ("+f.text+")"))},onTimeout:function(f,v,m){o(new xt({type:te.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},'"'+e+'" certificate request timed out ('+i+")"))},onAbort:function(f,v,m){o(new Error("aborted"))}};r.load(l,d,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 xt({type:te.KEY_SYSTEM_ERROR,details:B.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 xt({type:te.KEY_SYSTEM_ERROR,details:B.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 c=r.config.licenseResponseCallback;if(c)try{d=c.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 xt({type:te.KEY_SYSTEM_ERROR,details:B.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 m=v-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+m+" 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 c=d.xhr,f=d.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={},vr.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}();vs.CDMCleanupPromise=void 0;var xt=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 ne(n,s),n}(Ie(Error)),Jo="m",En="a",va="v",ga="av",gs="i",$o="tt",Zo=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:Jo,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!==va&&u!==En&&u!=ga||(d.br=l.bitrate/1e3,d.tb=t.getTopBandwidth(u)/1e3,d.bl=t.getBufferLength(u)),t.apply(a,d)}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={}),z(t,this.createData());var r=t.ot===gs||t.ot===va||t.ot===ga;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={}),z(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"?$o:e.sn==="initSegment"?gs:t==="audio"?En:t==="main"?this.hls.audioTracks.length?va:ga:void 0},n.getTopBandwidth=function(e){var t,r=0,i=this.hls;if(e===En)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=ke(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===En?this.audioBuffer:this.videoBuffer;return r&&t?1e3*Z.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)},V(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)},V(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=ke(Object.keys(e||{}).sort());!(t=u()).done;){var d=t.value,c=e[d];if(i(c)&&!(d==="v"&&c===1||d=="pr"&&c===1)){var f=l[d];f&&(c=f(c));var v=typeof c,m=void 0;m=d==="ot"||d==="sf"||d==="st"?d+"="+c:v==="boolean"?d:v==="number"?d+"="+c:d+"="+JSON.stringify(c),r.push(m)}}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 c=s.serialize(i[d]);c&&(t["CMCD-"+r[d]]=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}(),el=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)===p&&r.flags===b){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,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 c=t.getLevelsForPathway(u).map(function(f){var v=z({},f);v.details=void 0,v.url=ms(f.uri,f.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",d);var m=new He(f.attrs);m["PATHWAY-ID"]=l;var T=m.AUDIO&&m.AUDIO+"_clone_"+l,S=m.SUBTITLES&&m.SUBTITLES+"_clone_"+l;T&&(i[m.AUDIO]=T,m.AUDIO=T),S&&(a[m.SUBTITLES]=S,m.SUBTITLES=S),v.attrs=m;var y=new Er(v);return N(y,"audio",T),N(y,"text",S),y});r.push.apply(r,c),ps(t.audioTracks,i,d,l),ps(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||{},c={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:d.maxNumRetry||0,retryDelay:d.retryDelayMs||0,maxRetryDelay:d.maxRetryDelayMs||0},f={onSuccess:function(v,m,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 _=y["RELOAD-URI"],R=y["PATHWAY-CLONES"],w=y["PATHWAY-PRIORITY"];if(_)try{r.uri=new self.URL(_,t).href}catch{return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+_)}r.scheduleRefresh(r.uri||T.url),R&&r.clonePathways(R),w&&r.updatePathwayPriority(w)}else r.log("Steering VERSION "+y.VERSION+" not supported!")},onError:function(v,m,T,S){if(r.log("Error loading steering manifest: "+v.code+" "+v.text+" ("+m.url+")"),r.stopLoad(),v.code===410)return r.enabled=!1,void r.log("Steering manifest "+m.url+" no longer available");var y=1e3*r.timeToLoad;if(v.code!==429)r.scheduleRefresh(r.uri||m.url,y);else{var _=r.loader;if(typeof(_==null?void 0:_.getResponseHeader)=="function"){var R=_.getResponseHeader("Retry-After");R&&(y=1e3*parseFloat(R))}r.log("Steering manifest "+m.url+" rate limited")}},onTimeout:function(v,m,T){r.log("Timeout loading steering manifest ("+m.url+")"),r.scheduleRefresh(r.uri||m.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 ps(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=z({},a);return o.details=void 0,o.attrs=new He(o.attrs),o.url=o.attrs.URI=ms(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 ms(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 tl=/^age:\s*[\d.]+\s*$/im,ys=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 vt,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&&ie(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 c=this.callbacks.onProgress;if(c&&c(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;Hr(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(Hr(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=_i(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&&tl.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}(),rl=/(\d+)-(\d+)\/(\d+)/,Ts=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||il,this.controller=new self.AbortController,this.stats=new vt}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(m,T){var S={method:"GET",mode:"cors",credentials:"same-origin",signal:T,headers:new self.Headers(z({},m.headers))};return m.rangeEnd&&S.headers.set("Range","bytes="+m.rangeStart+"-"+String(m.rangeEnd-1)),S}(e,this.controller.signal),l=r.onProgress,u=e.responseType==="arraybuffer",d=u?"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&&ie(f)?f:v,this.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(a,e,i.response)},t.timeout),self.fetch(this.request).then(function(m){i.response=i.loader=m;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)),!m.ok){var S=m.status,y=m.statusText;throw new nl(y||"fetch, bad network response",S,m)}return a.loading.first=T,a.total=function(_){var R=_.get("Content-Range");if(R){var w=function(F){var U=rl.exec(F);if(U)return parseInt(U[2])-parseInt(U[1])+1}(R);if(ie(w))return w}var P=_.get("Content-Length");if(P)return parseInt(P)}(m.headers)||a.total,l&&ie(t.highWaterMark)?i.loadProgressively(m,a,e,t.highWaterMark,l):u?m.arrayBuffer():e.responseType==="json"?m.json():m.text()}).then(function(m){var T=i.response;self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var S=m[d];S&&(a.loaded=a.total=S);var y={url:T.url,data:m,code:T.status};l&&!ie(t.highWaterMark)&&l(a,e,m,T),r.onSuccess(y,a,e,T)}).catch(function(m){if(self.clearTimeout(i.requestTimeout),!a.aborted){var T=m&&m.code||0,S=m?m.message:null;r.onError({code:T,text:S},e,m?m.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 Xa,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 c=d.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),u()}).catch(function(){return Promise.reject()})}()},s}();function il(s,n){return new self.Request(s.url,n)}var nl=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 ne(n,s),n}(Ie(Error)),al=/\s/,sl=K(K({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:ys,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:So,bufferController:xo,capLevelController:Xo,errorController:A,fpsController:Qo,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:ri,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,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++)al.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 m=os(l.trim()),T=ua(n,e,m);s!=null&&(f=s.cues)!=null&&f.getCueById(T)||((i=new d(n,e,m)).id=T,i.line=c+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 rn(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:Ao,subtitleTrackController:Do,timelineController:Yo,audioStreamController:Lo,audioTrackController:ko,emeController:vs,cmcdController:Zo,contentSteeringController:el});function pa(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(pa):Object.keys(s).reduce(function(n,e){return n[e]=pa(s[e]),n},{}):s}function ol(s){var n=s.loader;n!==Ts&&n!==ys?(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=Ts,s.progressive=!0,s.enableSoftwareAES=!0,x.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Es=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 pn,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,Ne(e.debug||!1,"Hls instance");var t=this.config=function($,X){if((X.liveSyncDurationCount||X.liveMaxLatencyDurationCount)&&(X.liveSyncDuration||X.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(X.liveMaxLatencyDurationCount!==void 0&&(X.liveSyncDurationCount===void 0||X.liveMaxLatencyDurationCount<=X.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(X.liveMaxLatencyDuration!==void 0&&(X.liveSyncDuration===void 0||X.liveMaxLatencyDuration<=X.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var se=pa($),ve=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(ue){var fe=(ue==="level"?"playlist":ue)+"LoadPolicy",pe=X[fe]===void 0,ge=[];ve.forEach(function(Le){var De=ue+"Loading"+Le,Ce=X[De];if(Ce!==void 0&&pe){ge.push(De);var Fe=se[fe].default;switch(X[fe]={default:Fe},Le){case"TimeOut":Fe.maxLoadTimeMs=Ce,Fe.maxTimeToFirstByteMs=Ce;break;case"MaxRetry":Fe.errorRetry.maxNumRetry=Ce,Fe.timeoutRetry.maxNumRetry=Ce;break;case"RetryDelay":Fe.errorRetry.retryDelayMs=Ce,Fe.timeoutRetry.retryDelayMs=Ce;break;case"MaxRetryTimeout":Fe.errorRetry.maxRetryDelayMs=Ce,Fe.timeoutRetry.maxRetryDelayMs=Ce}}}),ge.length&&x.warn('hls.js config: "'+ge.join('", "')+'" setting(s) are deprecated, use "'+fe+'": '+JSON.stringify(X[fe]))}),K(K({},se),X)}(s.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&ol(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),c=this.bufferController=new i(this),f=this.capLevelController=new a(this),v=new l(this),m=new ze(this),T=new Bn(this),S=t.contentSteeringController,y=S?new S(this):null,_=this.levelController=new C(this,y),R=new le(this),w=new Ve(this.config),P=this.streamController=new _o(this,R,w);f.setStreamController(P),v.setStreamController(P);var F=[m,_,P];y&&F.splice(1,0,y),this.networkControllers=F;var U=[d,c,f,v,T,R];this.audioTrackController=this.createController(t.audioTrackController,F);var Y=t.audioStreamController;Y&&F.push(new Y(this,R,w)),this.subtitleTrackController=this.createController(t.subtitleTrackController,F);var G=t.subtitleStreamController;G&&F.push(new G(this,R,w)),this.createController(t.timelineController,U),w.emeController=this.emeController=this.createController(t.emeController,U),this.cmcdController=this.createController(t.cmcdController,U),this.latencyController=this.createController(Hn,U),this.coreComponents=U,F.push(u);var q=u.onErrorOut;typeof q=="function"&&this.on(E.ERROR,q,u)}s.isSupported=function(){return function(){var e=Mr();if(!e)return!1;var t=Da(),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:te.OTHER_ERROR,details:B.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=mt.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)},V(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){pi.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 te}},{key:"ErrorDetails",get:function(){return B}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:sl},set:function(e){s.defaultConfig=e}}]),s}();return Es.defaultConfig=void 0,Es},typeof Ds=="object"&&typeof Ea!="undefined"?Ea.exports=H():typeof define=="function"&&define.amd?define(H):(M=typeof globalThis!="undefined"?globalThis:M||self).Hls=H()})(!1)});var Rn=As(Rs());var xs=As(Is()),_l=xs.default,lt=_l;var zr=class extends Error{constructor(M,H=zr.MEDIA_ERR_CUSTOM,j,K){var Q;super(M);this.name="MediaError",this.code=H,this.context=K,this.fatal=j!=null?j:H>=zr.MEDIA_ERR_NETWORK&&H<=zr.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(Q=zr.defaultMessages[this.code])!=null?Q:"")}},ft=zr;ft.MEDIA_ERR_ABORTED=1,ft.MEDIA_ERR_NETWORK=2,ft.MEDIA_ERR_DECODE=3,ft.MEDIA_ERR_SRC_NOT_SUPPORTED=4,ft.MEDIA_ERR_ENCRYPTED=5,ft.MEDIA_ERR_CUSTOM=100,ft.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 bl=I=>I==null,_a=(I,D)=>bl(D)?!1:I in D,Ln={ANY:"any",MUTED:"muted"},Kt={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},ba={MSE:"mse",NATIVE:"native"},kn={HEADER:"header",QUERY:"query",NONE:"none"},Zl=Object.values(kn),qt={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},wn={HLS:qt.M3U8},eu=Object.keys(wn),tu=[...Object.values(qt),"hls","HLS"];var bt=(I,D,M,H,j=I)=>{j.addEventListener(D,M,H),I.addEventListener("teardown",()=>{j.removeEventListener(D,M)},{once:!0})};function Cs(I,D,M){D&&M>D&&(M=D);for(let H=0;H<I.length;H++)if(I.start(H)<=M&&I.end(H)>=M)return!0;return!1}var Ps=I=>{let D=I.indexOf("?");if(D<0)return[I];let M=I.slice(0,D),H=I.slice(D);return[M,H]},Ri=I=>{let D=I.type;if(D){let H=D.toUpperCase();return _a(H,wn)?wn[H]:D}let{src:M}=I;return M?Sl(M):""},Sa=I=>I==="VOD"?Kt.ON_DEMAND:Kt.LIVE,La=I=>I==="EVENT"?Number.POSITIVE_INFINITY:I==="VOD"?Number.NaN:0,Sl=I=>{let D="";try{D=new URL(I).pathname}catch{console.error("invalid url")}let M=D.lastIndexOf(".");if(M<0)return"";let j=D.slice(M+1).toUpperCase();return _a(j,qt)?qt[j]:""};var Ll=Object.values(Ln),Os=I=>typeof I=="boolean"||typeof I=="string"&&Ll.includes(I),Ms=({autoplay:I},D,M)=>{let H=!1,j=!1,K=Os(I)?I:!!I,Q=()=>{H||bt(D,"playing",()=>{H=!0},{once:!0})};if(Q(),bt(D,"loadstart",()=>{H=!1,Q(),ka(D,K)},{once:!0}),bt(D,"loadstart",()=>{M||(j=!Number.isFinite(D.duration)),ka(D,K)},{once:!0}),M&&M.once(lt.Events.LEVEL_LOADED,(re,z)=>{var ne;j=(ne=z.details.live)!=null?ne:!1}),!K){let re=()=>{!j||(M!=null&&M.liveSyncPosition?D.currentTime=M.liveSyncPosition:Number.isFinite(D.seekable.end(0))&&(D.currentTime=D.seekable.end(0)))};M&&bt(D,"play",()=>{D.preload==="metadata"?M.once(lt.Events.LEVEL_UPDATED,re):re()},{once:!0})}return re=>{H||(K=Os(re)?re:!!re,ka(D,K))}},ka=(I,D)=>{if(!D)return;let M=I.muted,H=()=>I.muted=M;switch(D){case Ln.ANY:I.play().catch(()=>{I.muted=!0,I.play().catch(H)});break;case Ln.MUTED:I.muted=!0,I.play().catch(H);break;default:I.play().catch(()=>{});break}};var Fs=({preload:I,src:D},M,H)=>{let j=ye=>{ye!=null&&["","none","metadata","auto"].includes(ye)?M.setAttribute("preload",ye):M.removeAttribute("preload")};if(!H)return j(I),j;let K=!1,Q=!1,V=H.config.maxBufferLength,re=H.config.maxBufferSize,z=ye=>{j(ye);let oe=ye!=null?ye:M.preload;Q||oe==="none"||(oe==="metadata"?(H.config.maxBufferLength=1,H.config.maxBufferSize=1):(H.config.maxBufferLength=V,H.config.maxBufferSize=re),ne())},ne=()=>{!K&&D&&(K=!0,H.loadSource(D))};return bt(M,"play",()=>{Q=!0,H.config.maxBufferLength=V,H.config.maxBufferSize=re,ne()},{once:!0}),z(I),z};function Ns(I,D){D.on(lt.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(j,{tracks:K})=>{K.forEach(Q=>{var z;let V=(z=Q.subtitleTrack)!=null?z:Q.closedCaptions,re=D.subtitleTracks.findIndex(({lang:ne,name:ye,type:oe})=>ne==(V==null?void 0:V.lang)&&ye===Q.label&&oe.toLowerCase()===Q.kind);wa(I,Q.kind,Q.label,V==null?void 0:V.lang,`${Q.kind}${re}`)})});let M=()=>{var Q;if(!D.subtitleTracks.length)return;let j=Array.from(I.textTracks).find(V=>V.id&&V.mode==="showing"&&["subtitles","captions"].includes(V.kind)),K=`${(Q=D.subtitleTracks[D.subtitleTrack])==null?void 0:Q.type.toLowerCase()}${D.subtitleTrack}`;if(j&&(D.subtitleTrack<0||(j==null?void 0:j.id)!==K)){let V=D.subtitleTracks.findIndex(({lang:re,name:z,type:ne})=>re==j.language&&z===j.label&&ne.toLowerCase()===j.kind);D.subtitleTrack=V}j&&(j==null?void 0:j.id)===K&&j.cues&&Array.from(j.cues).forEach(V=>{j.addCue(V)})};I.textTracks.addEventListener("change",M),D.on(lt.Events.CUES_PARSED,(j,{track:K,cues:Q})=>{let V=I.textTracks.getTrackById(K);if(!V)return;let re=V.mode==="disabled";re&&(V.mode="hidden"),Q.forEach(z=>{var ne;(ne=V.cues)!=null&&ne.getCueById(z.id)||V.addCue(z)}),re&&(V.mode="disabled")}),D.once(lt.Events.DESTROYING,()=>{I.textTracks.removeEventListener("change",M),I.querySelectorAll("track[data-removeondestroy]").forEach(K=>{K.remove()})});let H=()=>{Array.from(I.textTracks).forEach(j=>{var K,Q;if(!["subtitles","caption"].includes(j.kind)&&j.label==="thumbnails"){if(!((K=j.cues)!=null&&K.length)){let V=I.querySelector('track[label="thumbnails"]'),re=(Q=V==null?void 0:V.getAttribute("src"))!=null?Q:"";V==null||V.removeAttribute("src"),setTimeout(()=>{V==null||V.setAttribute("src",re)},0)}j.mode!=="hidden"&&(j.mode="hidden")}})};D.once(lt.Events.MANIFEST_LOADED,H),D.once(lt.Events.MEDIA_ATTACHED,H)}function wa(I,D,M,H,j){let K=document.createElement("track");return K.kind=D,K.label=M,H&&(K.srclang=H),j&&(K.id=j),K.track.mode=["subtitles","captions"].includes(D)?"disabled":"hidden",K.setAttribute("data-removeondestroy",""),I.append(K),K.track}function kl(I,D){let M=Array.prototype.find.call(I.querySelectorAll("track"),H=>H.track===D);M==null||M.remove()}var Di="cuepoints",Aa=Object.freeze({label:Di}),An=(I,{label:D=Di}=Aa)=>{var M;return(M=Array.from(I.querySelectorAll("track")).find(H=>H.track.label===D&&H.track.kind==="metadata"))==null?void 0:M.track};async function Us(I,D,M=Aa){let H=An(I,M);if(!H){let{label:j=Di}=M;H=wa(I,"metadata",j),H.mode="hidden",await new Promise(K=>setTimeout(()=>K(void 0),0))}return H.mode!=="hidden"&&(H.mode="hidden"),[...D].sort(({time:j},{time:K})=>K-j).forEach(({time:j,value:K})=>{var ye,oe;let Q=Array.prototype.findIndex.call(H==null?void 0:H.cues,Te=>Te.startTime>=j),V=(ye=H==null?void 0:H.cues)==null?void 0:ye[Q],re=V?V.startTime:Number.isFinite(I.duration)?I.duration:Number.MAX_SAFE_INTEGER,z=(oe=H==null?void 0:H.cues)==null?void 0:oe[Q-1];z&&(z.endTime=j);let ne=new VTTCue(j,re,JSON.stringify(K!=null?K:null));H.addCue(ne)}),H}var Bs=I=>({time:I.startTime,value:JSON.parse(I.text)});function wl(I,D={label:Di}){let M=An(I,D);return M!=null&&M.cues?Array.from(M.cues,H=>Bs(H)):[]}function Hs(I,D={label:Di}){var K,Q;let M=An(I,D);if(!((K=M==null?void 0:M.activeCues)!=null&&K.length))return;let{currentTime:H}=I,j=Array.prototype.find.call((Q=M.activeCues)!=null?Q:[],({startTime:V,endTime:re})=>V<=H&&re>H);return Bs(j)}async function Gs(I,D=Aa){return new Promise(M=>{bt(I,"loadstart",async()=>{let H=await Us(I,[],D);bt(I,"cuechange",()=>{let j=Hs(I);if(j){let K=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:j});I.dispatchEvent(K)}},{},H),M(H)})})}function Al(I,D){if(D){let M=D.playingDate;if(M!=null)return new Date(M.getTime()-I.currentTime*1e3)}return typeof I.getStartDate=="function"?I.getStartDate():new Date(NaN)}function Rl(I,D){if(D&&D.playingDate)return D.playingDate;if(typeof I.getStartDate=="function"){let M=I.getStartDate();return new Date(M.getTime()+I.currentTime*1e3)}return new Date(NaN)}var Dl=async I=>fetch(I).then(D=>D.text()).then(D=>{let M=D.split(`
|
|
46
46
|
`).find((H,j,K)=>j&&K[j-1].startsWith("#EXT-X-STREAM-INF"));return fetch(M).then(H=>H.text()).then(H=>H.split(`
|
|
47
|
-
`))}),
|
|
47
|
+
`))}),Il=I=>{var Q,V;let M=(V=((Q=I.find(re=>re.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?Q:"").split(":")[1])==null?void 0:V.trim(),H=Sa(M),j=La(M),K;if(H===Kt.LIVE){let re=I.find(ne=>ne.startsWith("#EXT-X-PART-INF"));!!re?K=+re.split(":")[1].split("=")[1]*2:K=+I.find(oe=>oe.startsWith("#EXT-X-TARGETDURATION")).split(":")[1]*3}return{streamType:H,targetLiveWindow:j,liveEdgeStartOffset:K}},xl=async(I,D)=>{if(D===qt.MP4)return{streamType:Kt.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(D===qt.M3U8){let M=await Dl(I);return Il(M)}return console.error(`Media type ${D} is an unrecognized or unsupported type for src ${I}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},Ks=async(I,D,M=Ri({src:I}))=>{var Q,V,re;let{streamType:H,targetLiveWindow:j,liveEdgeStartOffset:K}=await xl(I,M);((Q=ut.get(D))!=null?Q:{}).liveEdgeStartOffset=K,((V=ut.get(D))!=null?V:{}).targetLiveWindow=j,D.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((re=ut.get(D))!=null?re:{}).streamType=H,D.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Cl=I=>{var Q;let D=I.type,M=Sa(D),H=La(D),j,K=!!((Q=I.partList)!=null&&Q.length);return M===Kt.LIVE&&(j=K?I.partTarget*2:I.targetduration*3),{streamType:M,targetLiveWindow:H,liveEdgeStartOffset:j,lowLatency:K}},Pl=(I,D,M)=>{var V,re,z,ne,ye,oe,Te,we;let{streamType:H,targetLiveWindow:j,liveEdgeStartOffset:K,lowLatency:Q}=Cl(I);if(H===Kt.LIVE){Q?(M.config.backBufferLength=(V=M.userConfig.backBufferLength)!=null?V:4,M.config.maxFragLookUpTolerance=(re=M.userConfig.maxFragLookUpTolerance)!=null?re:.001,M.config.abrBandWidthUpFactor=(z=M.userConfig.abrBandWidthUpFactor)!=null?z:M.config.abrBandWidthFactor):M.config.backBufferLength=(ne=M.userConfig.backBufferLength)!=null?ne:8;let Ie=Object.freeze({get length(){return D.seekable.length},start(je){return D.seekable.start(je)},end(je){var ke;return je>this.length?D.seekable.end(je):(ke=M.liveSyncPosition)!=null?ke:D.seekable.end(je)}});((ye=ut.get(D))!=null?ye:{}).seekable=Ie}((oe=ut.get(D))!=null?oe:{}).liveEdgeStartOffset=K,((Te=ut.get(D))!=null?Te:{}).targetLiveWindow=j,D.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((we=ut.get(D))!=null?we:{}).streamType=H,D.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},qs,Vs,Ol=(Vs=(qs=globalThis==null?void 0:globalThis.navigator)==null?void 0:qs.userAgent)!=null?Vs:"",Ml=Ol.toLowerCase().indexOf("android")!==-1,ut=new WeakMap,Ys="mux.com",js,Ws,zs=(Ws=(js=lt).isSupported)==null?void 0:Ws.call(js),Fl=Ml,Ru=()=>Rn.default.utils.now(),Nl=Rn.default.utils.generateUUID,Du=(I,{domain:D=Ys,maxResolution:M=""}={})=>{if(!I)return;let[H,j=""]=Ps(I),K=new URL(`https://stream.${D}/${H}.m3u8${j}`);return M&&K.searchParams.set("max_resolution",M),K.toString()},Ul=I=>{if(!I)return;let[D]=I.split("?");return D||void 0},Bl=I=>{if(!I||!I.startsWith("https://stream."))return;let[D]=new URL(I).pathname.slice(1).split(".m3u8");return D||void 0},Hl=I=>{var D,M,H;return(D=I==null?void 0:I.metadata)!=null&&D.video_id?I.metadata.video_id:Js(I)&&(H=(M=Ul(I.playbackId))!=null?M:Bl(I.src))!=null?H:I.src},Iu=I=>{var D;return(D=ut.get(I))==null?void 0:D.error},xu=I=>{var D,M;return(M=(D=ut.get(I))==null?void 0:D.streamType)!=null?M:Kt.UNKNOWN},Cu=I=>{var D,M;return(M=(D=ut.get(I))==null?void 0:D.targetLiveWindow)!=null?M:Number.NaN},Gl=I=>{var D,M;return(M=(D=ut.get(I))==null?void 0:D.seekable)!=null?M:I.seekable},Pu=I=>{var H;let D=(H=ut.get(I))==null?void 0:H.liveEdgeStartOffset;if(typeof D!="number")return Number.NaN;let M=Gl(I);return M.length?M.end(M.length-1)-D:Number.NaN},Kl=(I,D,M=.001)=>Math.abs(I-D)<=M,Xs=(I,D,M=.001)=>I>D||Kl(I,D,M),ql=I=>I.paused&&Xs(I.currentTime,I.duration),Vl=(I,D)=>D?I.ended:I.ended||ql(I),Ou=(I,D,M)=>{jl(D,M);let{metadata:H={}}=I,{view_session_id:j=Nl()}=H,K=Hl(I);H.view_session_id=j,H.video_id=K,I.metadata=H,ut.set(D,{});let Q=Wl(I,D);zl(I,D,Q),Xl(I,D,Q),Gs(D);let V=Ms(I,D,Q),re=Fs(I,D,Q);return{engine:Q,setAutoplay:V,setPreload:re}},jl=(I,D)=>{let M=D==null?void 0:D.engine;M&&(M.detachMedia(),M.destroy()),(I==null?void 0:I.mux)&&!I.mux.deleted&&(I.mux.destroy(),delete I.mux),I&&(I.removeAttribute("src"),I.load(),I.removeEventListener("error",Zs),I.removeEventListener("error",Ra),I.removeEventListener("durationchange",$s),ut.delete(I),I.dispatchEvent(new Event("teardown")))};function Qs(I,D){var z;let M=Ri(I);if(!(M===qt.M3U8))return!0;let j=!M||((z=D.canPlayType(M))!=null?z:!0),{preferPlayback:K}=I,Q=K===ba.MSE,V=K===ba.NATIVE;return j&&(V||!(zs&&(Q||Fl)))}var Wl=(I,D)=>{let{debug:M,streamType:H,startTime:j=-1,metadata:K,preferCmcd:Q}=I,re=Ri(I)===qt.M3U8,z=Qs(I,D);if(re&&!z&&zs){let ne={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},ye=Yl(H),oe=Q!==kn.NONE?{useHeaders:Q===kn.HEADER,sessionId:K==null?void 0:K.view_session_id,contentId:K==null?void 0:K.video_id}:void 0;return new lt({debug:M,startPosition:j,cmcd:oe,...ne,...ye})}},Yl=I=>I===Kt.LIVE?{backBufferLength:8}:{},Js=({playbackId:I,src:D,customDomain:M})=>{if(I)return!0;if(typeof D!="string")return!1;let H=window==null?void 0:window.location.href,j=new URL(D,H).hostname.toLocaleLowerCase();return j.includes(Ys)||!!M&&j.includes(M.toLocaleLowerCase())},zl=(I,D,M)=>{var K;let{envKey:H}=I,j=Js(I);if(H||j){let{playerInitTime:Q,playerSoftwareName:V,playerSoftwareVersion:re,beaconCollectionDomain:z,debug:ne,disableCookies:ye}=I,oe={...I.metadata,video_title:((K=I==null?void 0:I.metadata)==null?void 0:K.video_title)||void 0},Te=we=>typeof we.player_error_code=="string"?!1:typeof I.errorTranslator=="function"?I.errorTranslator(we):we;Rn.default.monitor(D,{debug:ne,beaconCollectionDomain:z,hlsjs:M,Hls:M?lt:void 0,automaticErrorTracking:!1,errorTranslator:Te,disableCookies:ye,data:{...H?{env_key:H}:{},player_software_name:V,player_software:V,player_software_version:re,player_init_time:Q,...oe}})}},Xl=(I,D,M)=>{var K;let H=Qs(I,D),{src:j}=I;if(D&&H){let Q=Ri(I);typeof j=="string"?(D.preload==="none"?bt(D,"loadstart",()=>Ks(j,D,Q)):Ks(j,D,Q),D.setAttribute("src",j),I.startTime&&(((K=ut.get(D))!=null?K:{}).startTime=I.startTime,D.addEventListener("durationchange",$s,{once:!0}))):D.removeAttribute("src"),D.addEventListener("error",Zs),D.addEventListener("error",Ra),D.addEventListener("emptied",()=>{D.querySelectorAll("track[data-removeondestroy]").forEach(re=>{re.remove()})},{once:!0}),bt(D,"pause",()=>{!Vl(D)||D.ended||D.dispatchEvent(new Event("ended"))}),bt(D,"play",()=>{D.ended||!Xs(D.currentTime,D.duration)||(D.currentTime=D.seekable.start(0))})}else M&&j?(M.once(lt.Events.LEVEL_LOADED,(Q,V)=>{Pl(V.details,D,M)}),M.on(lt.Events.ERROR,(Q,V)=>{let re={[lt.ErrorTypes.NETWORK_ERROR]:ft.MEDIA_ERR_NETWORK,[lt.ErrorTypes.MEDIA_ERROR]:ft.MEDIA_ERR_DECODE},z=new ft("",re[V.type]);z.fatal=V.fatal,z.data=V,D.dispatchEvent(new CustomEvent("error",{detail:z}))}),D.addEventListener("error",Ra),Ns(D,M),M.attachMedia(D)):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 $s(I){var H;let D=I.target,M=(H=ut.get(D))==null?void 0:H.startTime;if(!!M&&Cs(D.seekable,D.duration,M)){let j=D.preload==="auto";j&&(D.preload="none"),D.currentTime=M,j&&(D.preload="auto")}}async function Zs(I){if(!I.isTrusted)return;I.stopImmediatePropagation();let D=I.target;if(!(D!=null&&D.error))return;let{message:M,code:H}=D.error,j=new ft(M,H);if(D.src&&(H!==ft.MEDIA_ERR_DECODE||H!==void 0))try{let{status:K}=await fetch(D.src);j.data={response:{code:K}}}catch{}D.dispatchEvent(new CustomEvent("error",{detail:j}))}function Ra(I){var H,j;if(!(I instanceof CustomEvent)||!(I.detail instanceof ft))return;let D=I.target,M=I.detail;!M||!M.fatal||(((H=ut.get(D))!=null?H:{}).error=M,(j=D.mux)==null||j.emit("error",{player_error_code:M.code,player_error_message:M.message,player_error_context:M.context}))}var export_mux=Rn.default;export{Ln as AutoplayTypes,Zl as CmcdTypeValues,kn as CmcdTypes,qt as ExtensionMimeTypeMap,lt as Hls,ft as MediaError,wn as MimeTypeShorthandMap,ba as PlaybackTypes,Kt as StreamTypes,Us as addCuePoints,wa as addTextTrack,tu as allMediaTypes,Ru as generatePlayerInitTime,Nl as generateUUID,Hs as getActiveCuePoint,wl as getCuePoints,An as getCuePointsTrack,Rl as getCurrentPdt,Vl as getEnded,Iu as getError,Pu as getLiveEdgeStart,Dl as getMediaPlaylistLinesFromMultivariantPlaylistSrc,Gl as getSeekable,Al as getStartDate,Cl as getStreamInfoFromHlsjsLevelDetails,Il as getStreamInfoFromPlaylistLines,xl as getStreamInfoFromSrcAndType,xu as getStreamType,Yl as getStreamTypeConfig,Cu as getTargetLiveWindow,Ou as initialize,_a as isKeyOf,Js as isMuxVideoSrc,ql as isPseudoEnded,Xl as loadMedia,export_mux as mux,ut as muxMediaState,kl as removeTextTrack,Gs as setupCuePoints,Wl as setupHls,zl as setupMux,eu as shorthandKeys,jl as teardown,Du as toMuxVideoURL,Pl as updateStreamInfoFromHlsjsLevelDetails,Ks as updateStreamInfoFromSrc};
|
|
48
48
|
/*!
|
|
49
49
|
* JavaScript Cookie v2.1.3
|
|
50
50
|
* https://github.com/js-cookie/js-cookie
|