@mux/playback-core 0.18.4 → 0.18.5
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 +44 -45
- package/dist/playback-core.js.map +4 -4
- package/dist/playback-core.mjs +44 -45
- package/dist/playback-core.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/hls.d.ts +1 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types-ts3.4/hls.d.ts +1 -2
- package/dist/types-ts3.4/index.d.ts +2 -2
- package/package.json +3 -3
package/dist/playback-core.js
CHANGED
|
@@ -1,50 +1,49 @@
|
|
|
1
|
-
"use strict";(()=>{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,q){K.exports=q(728).default},728:function(K,Q,q){"use strict";q.d(Q,{default:function(){return dn}});var re=q(48),z=q.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=q(640),Ie=q.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 yt(p)[0]},yt=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(yt(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(yt(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=q(375),si=q(655),xe=q.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
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function
|
|
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&&(Tt(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(yt(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
|
-
`):"")+"".concat(
|
|
6
|
-
`):"")+"".concat(
|
|
7
|
-
`):"")+"".concat(
|
|
8
|
-
`):"")+"".concat(
|
|
9
|
-
`):"")+"".concat(
|
|
10
|
-
`):"")+"".concat(
|
|
11
|
-
`):"")+"".concat(
|
|
12
|
-
`):"")+"".concat(
|
|
13
|
-
`):"");
|
|
14
|
-
`):"")+"".concat(
|
|
15
|
-
`):"");
|
|
16
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function
|
|
17
|
-
`);
|
|
18
|
-
`))this.processLine(this.buffer.substring(0,
|
|
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 Et={},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);Et[g]?Et[g].addHLSJS(h):ke.error("A monitor for `"+g+"` has not been initialized.")},addDashJS:function(p,h){var g=oe(p);Et[g]?Et[g].addDashJS(h):ke.error("A monitor for `"+g+"` has not been initialized.")},removeHLSJS:function(p){var h=oe(p);Et[h]?Et[h].removeHLSJS():ke.error("A monitor for `"+h+"` has not been initialized.")},removeDashJS:function(p){var h=oe(p);Et[h]?Et[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);Et[g]=new gi(Xt,g,h)},emit:function(p,h,g){var b=oe(p);Et[b]?(Et[b].emit(h,g),h==="destroy"&&delete Et[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,q){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,q,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("; "):[],yt=/(%[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(yt,decodeURIComponent);if(te=Te.read?Te.read(te,B):Te(te,B)||te.replace(yt,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,q){var re,z=q.g!==void 0?q.g:typeof window!="undefined"?window:{},ne=q(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,q){var re;re=typeof window!="undefined"?window:q.g!==void 0?q.g:typeof self!="undefined"?self:{},K.exports=re},640:function(K,Q,q){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 yt(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||yt,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,q,Q,K):re)===void 0||(K.exports=z)})()},375:function(K,Q){"use strict";var q=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(q.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 q=H[K]={exports:{}};return M[K].call(q.exports,q,q.exports,j),q.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 q in Q)j.o(Q,q)&&!j.o(K,q)&&Object.defineProperty(K,q,{enumerable:!0,get:Q[q]})},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 q(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 yt=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 q(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},q(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=yt.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},q(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),q(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},q(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,V=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?(V=_e(R,pe),pe+=4):V=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+=V/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 yt.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),V=(" "+o[l+1]).slice(1),$=o[l+2]?(" "+o[l+2]).slice(1):"";switch(G){case"PLAYLIST-TYPE":d.type=V.toUpperCase();break;case"MEDIA-SEQUENCE":v=d.startSN=parseInt(V);break;case"SKIP":var X=new He(V);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(V),1);break;case"VERSION":d.version=parseInt(V);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(V||$)&&_.tagList.push($?[V,$]:[V]);break;case"DISCONTINUITY":S++,_.tagList.push(["DIS"]);break;case"GAP":_.gap=!0,_.tagList.push([G]);break;case"BITRATE":_.tagList.push([G,V]);break;case"DATERANGE":var fe=new He(V);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: "'+V+'"'),_.tagList.push(["EXT-X-DATERANGE",V]);break;case"DEFINE":var ge=new He(V);ct(d,ge,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in ge?Qi(d,ge,a):Xi(d,ge,e);break;case"DISCONTINUITY-SEQUENCE":S=parseInt(V);break;case"KEY":var Le=Ji(V,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: "'+V+'"');break;case"START":d.startTimeOffset=$i(V);break;case"MAP":var De=new He(V);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(V);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 bt=new He(V);d.partTarget=bt.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(V);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(V);ct(d,ot,["URI"]),d.preloadHint=ot;break;case"RENDITION-REPORT":var Gt=new He(V);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",Tt="audioTrack",Ft="subtitleTrack",Me="main",kt="audio",Rt="subtitle";function tn(s){switch(s.type){case Tt: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:Tt,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===Tt&&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!==Tt&&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 Tt: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 Tt: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 V=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];V&&(Y=Bt(V.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},q(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)},q(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,V=P;V<=F;V++){var $=G[U+V],X=Y[V];w&&!X&&V<w&&(X=_.fragments[V]=$),$&&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 Et(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===Tt&&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===Tt&&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(V,$){$===void 0&&($=1/0);var X=1e3*V.targetduration;if(V.updated){var se=V.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},q(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],V=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]^V[255&f]^w[y],a=U[d>>>24]^Y[c>>16&255]^G[f>>8&255]^V[255&u]^w[y+1],o=U[c>>>24]^Y[f>>16&255]^G[u>>8&255]^V[255&d]^w[y+2],l=U[f>>>24]^Y[u>>16&255]^G[d>>8&255]^V[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(Et(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())},q(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}(),_t=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-_t)+1,i=0;i<r;){for(var a=!1,o=-1,l=0,u=i;u<t;u+=_t){if(e[u]!==71){if(l)return-1;break}if(l++,o===-1&&(o=u)!==0&&(r=Math.min(o+18612,e.length-_t)+1),a||(a=Yn(e,u)===0),a&&l>1&&(o===0&&l>2||u+_t>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<_t&&!i)return this.remainderData=e,{audioTrack:l,videoTrack:o,id3Track:u,textTrack:d};var P=Math.max(0,s.syncOffset(e));(w-=(w-P)%_t)<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,w,e.buffer.byteLength-w));for(var F=0,U=P;U<w;U+=_t)if(e[U]===71){var Y=!!(64&e[U+1]),G=Yn(e,U),V=void 0;if((48&e[U+3])>>4>1){if((V=U+5+e[U+4])===U+_t)continue}else V=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(V,U+_t)),f.size+=U+_t-V);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(V,U+_t)),T.size+=U+_t-V);break;case m:Y&&(S&&(a=Vr(S))&&this.parseID3PES(u,a),S={data:[],size:0}),S&&(S.data.push(e.subarray(V,U+_t)),S.size+=U+_t-V);break;case 0:Y&&(V+=e[V]+1),R=this._pmtId=fo(e,V);break;case R:Y&&(V+=e[V]+1);var $=vo(e,V,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 V=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(G),t.dropped+=G,U=y+=(t.samples[0].pts-V)/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,V=Y<-1;if((G||V)&&(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"),!V||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 bt=!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:bt=!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=bt||!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,V=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&&V<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],bt=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(bt,S);var Nt=bt.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,V){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=V[_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,bt=xe(fe,["trun"]),rt=0;rt<bt.length;rt++)!($=Mn(bt[rt]))&&Ce&&($=Ce*_e(bt[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,V){return xe(V,["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,V,$,X){if(G===null)return!0;var se=Math.max(X,1),ve=V-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,V,$){xe(V,["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 V=this.needsProbing(v,m);if(V){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||V)&&this.resetInitSegment(F,_,R,P,t),(v||y||V)&&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 V=!(_&&((f=a.initSegment)==null?void 0:f.url)===((v=_.initSegment)==null?void 0:v.url)),$=new To(R,Y,u,w,S,V);if(!Y||R||V){x.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+d.sn+" p: "+d.part+" level: "+d.level+" id: "+d.id+`
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
timeOffset: `+S+`
|
|
26
|
-
initSegmentChange: `+V);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 V=this.getMainFwdBufferInfo();if((V?V.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}))}}},q(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,V=U?8*U:y,$=Number.POSITIVE_INFINITY;for(G=e.level-1;G>R;G--){var X=_[G].maxBitrate;if(($=this.getTimeToLoadFrag(f/1e3,V,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
|
-
|
|
28
|
-
Estimated load time for
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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],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,V=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:"+V.toFixed(1)),Y>G&&(V===0||!ie(V)||m&&!this.bitrateTestDelay||V<i))return w}}return-1},q(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)!==Tt||(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===Tt&&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})}},q(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))},q(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)}},q(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 V=function($){return e(s,$)}(G);if(V===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=V,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",r({},d,{get:function(){return _},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 V=t(G);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");w=V,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 V=t(G);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");F=V,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 V=t(G);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");Y=V,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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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+=`
|
|
1
|
+
"use strict";(()=>{var Kl=Object.create;var Sn=Object.defineProperty;var Vl=Object.getOwnPropertyDescriptor;var ql=Object.getOwnPropertyNames;var Wl=Object.getPrototypeOf,jl=Object.prototype.hasOwnProperty;var Yl=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var zl=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ql(e))!jl.call(a,r)&&r!==t&&Sn(a,r,{get:()=>e[r],enumerable:!(i=Vl(e,r))||i.enumerable});return a};var Xl=(a,e,t)=>(t=a!=null?Kl(Wl(a)):{},zl(e||!a||!a.__esModule?Sn(t,"default",{value:a,enumerable:!0}):t,a));var An=Yl((ci,er)=>{(function(){var a,e;a=this,e=function(){return function(){var t={80:function(s,n,o){s.exports=o(728).default},728:function(s,n,o){"use strict";o.d(n,{default:function(){return Bl}});var l=o(48),c=o.n(l),u=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(p){var f=16*Math.random()|0;return(p==="x"?f:3&f|8).toString(16)})},d=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},h=function(p){return p&&p.nodeName!==void 0?(p.muxId||(p.muxId=p.id||d()),p.muxId):p},m=function(p){var f;p&&p.nodeName!==void 0?p=h(f=p):f=document.querySelector(p);var g=f&&f.nodeName?f.nodeName.toLowerCase():"";return[f,p,g]},y=o(640),E=o.n(y),b=E().methodFactory;E().methodFactory=function(p,f,g){var T=b(p,f,g);return function(){for(var x=["[mux]"],S=0;S<arguments.length;S++)x.push(arguments[S]);T.apply(void 0,x)}},E().setLevel(E().getLevel());var A=E();function D(){return(c().doNotTrack||c().navigator&&c().navigator.doNotTrack)==="1"}var L={now:function(){var p=c().performance,f=p&&p.timing,g=f&&f.navigationStart,T=typeof g=="number"&&typeof p.now=="function"?g+p.now():Date.now();return Math.round(T)}},F=function(p){return k(p)[0]},k=function(p){if(typeof p!="string"||p==="")return["localhost"];var f,g=(p.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return g&&(f=(g.match(/[^\.]+\.[^\.]+$/)||[])[0]),[g,f]},G={exists:function(){var p=c().performance;return(p&&p.timing)!==void 0},domContentLoadedEventEnd:function(){var p=c().performance,f=p&&p.timing;return f&&f.domContentLoadedEventEnd},navigationStart:function(){var p=c().performance,f=p&&p.timing;return f&&f.navigationStart}};function M(p,f,g){g=g===void 0?1:g,p[f]=p[f]||0,p[f]+=g}var $=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],K=["x-cdn","content-type"].concat($);function P(p){var f={};return(p=p||"").trim().split(/[\r\n]+/).forEach(function(g){if(g){var T=g.split(": "),x=T.shift();x&&(K.indexOf(x.toLowerCase())>=0||x.toLowerCase().indexOf("x-litix-")===0)&&(f[x]=T.join(": "))}}),f}function q(p){if(p){var f=$.find(function(g){return p[g]!==void 0});return f?p[f]:void 0}}var H=function(p){var f={};for(var g in p){var T=p[g];T["DATA-ID"].search("io.litix.data.")!==-1&&(f[T["DATA-ID"].replace("io.litix.data.","")]=T.VALUE)}return f};function ce(p,f){var g=Object.keys(p);if(Object.getOwnPropertySymbols){var T=Object.getOwnPropertySymbols(p);f&&(T=T.filter(function(x){return Object.getOwnPropertyDescriptor(p,x).enumerable})),g.push.apply(g,T)}return g}function oe(p){for(var f=1;f<arguments.length;f++){var g=arguments[f]!=null?arguments[f]:{};f%2?ce(Object(g),!0).forEach(function(T){le(p,T,g[T])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(g)):ce(Object(g)).forEach(function(T){Object.defineProperty(p,T,Object.getOwnPropertyDescriptor(g,T))})}return p}function le(p,f,g){return f in p?Object.defineProperty(p,f,{value:g,enumerable:!0,configurable:!0,writable:!0}):p[f]=g,p}var Te=function(p){if(!p)return{};var f=G.navigationStart(),g=p.loading,T=g?g.start:p.trequest,x=g?g.first:p.tfirst,S=g?g.end:p.tload;return{bytesLoaded:p.total,requestStart:Math.round(f+T),responseStart:Math.round(f+x),responseEnd:Math.round(f+S)}},ge=function(p){if(p&&typeof p.getAllResponseHeaders=="function")return P(p.getAllResponseHeaders())};function j(p,f){var g=Object.keys(p);if(Object.getOwnPropertySymbols){var T=Object.getOwnPropertySymbols(p);f&&(T=T.filter(function(x){return Object.getOwnPropertyDescriptor(p,x).enumerable})),g.push.apply(g,T)}return g}function X(p){for(var f=1;f<arguments.length;f++){var g=arguments[f]!=null?arguments[f]:{};f%2?j(Object(g),!0).forEach(function(T){Y(p,T,g[T])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(g)):j(Object(g)).forEach(function(T){Object.defineProperty(p,T,Object.getOwnPropertyDescriptor(g,T))})}return p}function Y(p,f,g){return f in p?Object.defineProperty(p,f,{value:g,enumerable:!0,configurable:!0,writable:!0}):p[f]=g,p}var de=function(p,f){if(!p||typeof p.getRequests!="function")return{};var g=p.getRequests({state:"executed"});if(g.length===0)return{};var T,x=g[g.length-1],S=F(x.url),_=x.url,R=x.bytesLoaded,O=new Date(x.requestStartDate).getTime(),I=new Date(x.firstByteDate).getTime(),U=new Date(x.requestEndDate).getTime(),se=isNaN(x.duration)?0:x.duration,Q=typeof f.getMetricsFor=="function"?f.getMetricsFor(x.mediaType).HttpList:f.getDashMetrics().getHttpRequests(x.mediaType);return Q.length>0&&(T=P(Q[Q.length-1]._responseHeaders||"")),{requestStart:O,requestResponseStart:I,requestResponseEnd:U,requestBytesLoaded:R,requestResponseHeaders:T,requestMediaDuration:se,requestHostname:S,requestUrl:_,requestId:T?q(T):void 0}},he=function(p,f){var g=f.getQualityFor(p),T=f.getCurrentTrackFor(p).bitrateList;return T?{currentLevel:g,renditionWidth:T[g].width||null,renditionHeight:T[g].height||null,renditionBitrate:T[g].bandwidth}:{}},_e=function(p){var f;return(f=p.match(/.*codecs\*?="(.*)"/))===null||f===void 0?void 0:f[1]};function Ge(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}var qe=0,We=function(){function p(){(function(x,S){if(!(x instanceof S))throw new TypeError("Cannot call a class as a function")})(this,p)}var f,g,T;return f=p,g=[{key:"on",value:function(x,S,_){return S._eventEmitterGuid=S._eventEmitterGuid||++qe,this._listeners=this._listeners||{},this._listeners[x]=this._listeners[x]||[],_&&(S=S.bind(_)),this._listeners[x].push(S),S}},{key:"off",value:function(x,S){var _=this._listeners&&this._listeners[x];_&&_.forEach(function(R,O){R._eventEmitterGuid===S._eventEmitterGuid&&_.splice(O,1)})}},{key:"one",value:function(x,S,_){var R=this;S._eventEmitterGuid=S._eventEmitterGuid||++qe;var O=function I(){R.off(x,I),S.apply(_||this,arguments)};O._eventEmitterGuid=S._eventEmitterGuid,this.on(x,O)}},{key:"emit",value:function(x,S){var _=this;if(this._listeners){S=S||{};var R=this._listeners["before*"]||[],O=this._listeners[x]||[],I=this._listeners["after"+x]||[],U=function(se,Q){(se=se.slice()).forEach(function(Z){Z.call(_,{type:x},Q)})};U(R,S),U(O,S),U(I,S)}}}],g&&Ge(f.prototype,g),T&&Ge(f,T),Object.defineProperty(f,"prototype",{writable:!1}),p}(),pt=We;function kt(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}var Lo=function(){function p(x){var S=this;(function(_,R){if(!(_ instanceof R))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=x,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,x.on("playing",function(){S._playheadShouldBeProgressing=!0}),x.on("play",this._startPlaybackHeartbeatInterval.bind(this)),x.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),x.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),x.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),x.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),x.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),x.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),x.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),x.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),x.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),x.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),x.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),x.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),x.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),x.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),x.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),x.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),x.on("seeked",function(){x.data.player_is_paused?S._stopPlaybackHeartbeatInterval():S._startPlaybackHeartbeatInterval()}),x.on("timeupdate",function(){S._playbackHeartbeatInterval!==null&&x.emit("playbackheartbeat")}),x.on("devicesleep",function(_,R){S._playbackHeartbeatInterval!==null&&(c().clearInterval(S._playbackHeartbeatInterval),x.emit("playbackheartbeatend",{viewer_time:R.viewer_time}),S._playbackHeartbeatInterval=null)})}var f,g,T;return f=p,(g=[{key:"_startPlaybackHeartbeatInterval",value:function(){var x=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=c().setInterval(function(){x.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(c().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&kt(f.prototype,g),T&&kt(f,T),Object.defineProperty(f,"prototype",{writable:!1}),p}();function $s(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}function Ro(p,f,g){return f&&$s(p.prototype,f),g&&$s(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Io=Ro(function p(f){var g=this;(function(T,x){if(!(T instanceof x))throw new TypeError("Cannot call a class as a function")})(this,p),f.on("viewinit",function(){g.viewErrored=!1}),f.on("error",function(T,x){try{var S=f.errorTranslator({player_error_code:x.player_error_code,player_error_message:x.player_error_message,player_error_context:x.player_error_context});S?(f.data.player_error_code=S.player_error_code||x.player_error_code,f.data.player_error_message=S.player_error_message||x.player_error_message,f.data.player_error_context=S.player_error_context||x.player_error_context,g.viewErrored=!0):(delete f.data.player_error_code,delete f.data.player_error_message,delete f.data.player_error_context)}catch(_){f.mux.log.warn("Exception in error translator callback.",_),g.viewErrored=!0}})});function Gs(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}var Do=function(){function p(x){(function(S,_){if(!(S instanceof _))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=x,this._watchTimeTrackerLastCheckedTime=null,x.on("playbackheartbeat",this._updateWatchTime.bind(this)),x.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var f,g,T;return f=p,(g=[{key:"_updateWatchTime",value:function(x,S){var _=S.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=_),M(this.pm.data,"view_watch_time",_-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=_}},{key:"_clearWatchTimeState",value:function(x,S){this._updateWatchTime(x,S),this._watchTimeTrackerLastCheckedTime=null}}])&&Gs(f.prototype,g),T&&Gs(f,T),Object.defineProperty(f,"prototype",{writable:!1}),p}();function Hs(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}var wo=function(){function p(x){(function(S,_){if(!(S instanceof _))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=x,this._playbackTimeTrackerLastPlayheadPosition=-1,x.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),x.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),x.on("seeking",this._clearPlaybackTimeState.bind(this))}var f,g,T;return f=p,(g=[{key:"_updatePlaybackTime",value:function(){var x=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&x>this._playbackTimeTrackerLastPlayheadPosition){var S=x-this._playbackTimeTrackerLastPlayheadPosition;S<=1e3&&M(this.pm.data,"view_content_playback_time",S)}this._playbackTimeTrackerLastPlayheadPosition=x}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&Hs(f.prototype,g),T&&Hs(f,T),Object.defineProperty(f,"prototype",{writable:!1}),p}();function Ks(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}var ko=function(){function p(x){(function(_,R){if(!(_ instanceof R))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=x;var S=this._updatePlayheadTime.bind(this);x.on("playbackheartbeat",S),x.on("playbackheartbeatend",S),x.on("timeupdate",S),x.on("destroy",function(){x.off("timeupdate",S)})}var f,g,T;return f=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(x,S){var _=this,R=function(){_.pm.currentFragmentPDT&&_.pm.currentFragmentStart&&(_.pm.data.player_program_time=_.pm.currentFragmentPDT+_.pm.data.player_playhead_time-_.pm.currentFragmentStart)};if(S&&S.player_playhead_time)this.pm.data.player_playhead_time=S.player_playhead_time,R(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var O=this.pm.getPlayheadTime();O!==void 0&&(this.pm.data.player_playhead_time=O,R(),this._updateMaxPlayheadPosition())}}}])&&Ks(f.prototype,g),T&&Ks(f,T),Object.defineProperty(f,"prototype",{writable:!1}),p}();function Vs(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}function Co(p,f,g){return f&&Vs(p.prototype,f),g&&Vs(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var qs=3e5,Po=Co(function p(f){if(function(S,_){if(!(S instanceof _))throw new TypeError("Cannot call a class as a function")}(this,p),!f.disableRebufferTracking){var g,T=function(S,_){x(_),g=void 0},x=function(S){if(g){var _=S.viewer_time-g;M(f.data,"view_rebuffer_duration",_),g=S.viewer_time,f.data.view_rebuffer_duration>qs&&(f.emit("viewend"),f.send("viewend"),f.mux.log.warn("Ending view after rebuffering for longer than ".concat(qs,"ms, future events will be ignored unless a programchange or videochange occurs.")))}f.data.view_watch_time>=0&&f.data.view_rebuffer_count>0&&(f.data.view_rebuffer_frequency=f.data.view_rebuffer_count/f.data.view_watch_time,f.data.view_rebuffer_percentage=f.data.view_rebuffer_duration/f.data.view_watch_time)};f.on("playbackheartbeat",function(S,_){return x(_)}),f.on("rebufferstart",function(S,_){g||(M(f.data,"view_rebuffer_count",1),g=_.viewer_time,f.one("rebufferend",T))}),f.on("viewinit",function(){g=void 0,f.off("rebufferend",T)})}});function Ws(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}var Oo=function(){function p(x){var S=this;(function(_,R){if(!(_ instanceof R))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=x,x.disableRebufferTracking||x.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,x.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),x.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),x.on("seeking",function(){S._cleanupRebufferTracker(null,{viewer_time:L.now()})}))}var f,g,T;return f=p,g=[{key:"_checkIfRebuffering",value:function(x,S){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(x,S);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var _=S.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&_>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=S.viewer_time}else this._cleanupRebufferTracker(x,S,!0);else this._prepareRebufferTrackerState(S.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(x){this._lastCheckedTime=x,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=x}},{key:"_cleanupRebufferTracker",value:function(x,S){var _=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:S.viewer_time});else{if(this._lastCheckedTime===null)return;var R=this.pm.data.player_playhead_time-this._lastPlayheadTime,O=S.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&R>0&&O-R>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+O-R}))}_?this._prepareRebufferTrackerState(S.viewer_time):this._clearRebufferTrackerState()}}],g&&Ws(f.prototype,g),T&&Ws(f,T),Object.defineProperty(f,"prototype",{writable:!1}),p}(),Mo=Oo;function js(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}var Fo=function(){function p(x){var S=this;(function(_,R){if(!(_ instanceof R))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=x,x.on("viewinit",function(){var _=x.data,R=_.view_id;if(!_.view_program_changed){var O=function(I,U){var se=U.viewer_time;I.type==="playing"&&x.data.view_time_to_first_frame===void 0?S.calculateTimeToFirstFrame(se||L.now(),R):I.type!=="adplaying"||x.data.view_time_to_first_frame!==void 0&&!S._inPrerollPosition()||S.calculateTimeToFirstFrame(se||L.now(),R)};x.one("playing",O),x.one("adplaying",O),x.one("viewend",function(){x.off("playing",O),x.off("adplaying",O)})}})}var f,g,T;return f=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(x,S){S===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:x}),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))}}])&&js(f.prototype,g),T&&js(f,T),Object.defineProperty(f,"prototype",{writable:!1}),p}();function Ys(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}function No(p,f,g){return f&&Ys(p.prototype,f),g&&Ys(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Uo=No(function p(f){var g=this;(function(T,x){if(!(T instanceof x))throw new TypeError("Cannot call a class as a function")})(this,p),f.on("viewinit",function(){g._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(T){f.on(T,function(){if(g._lastPlayheadPosition>=0&&f.data.player_playhead_time>=0&&g._lastPlayerWidth>=0&&g._lastSourceWidth>0&&g._lastPlayerHeight>=0&&g._lastSourceHeight>0){var x=f.data.player_playhead_time-g._lastPlayheadPosition;if(x<0)return void(g._lastPlayheadPosition=-1);var S=Math.min(g._lastPlayerWidth/g._lastSourceWidth,g._lastPlayerHeight/g._lastSourceHeight),_=Math.max(0,S-1),R=Math.max(0,1-S);f.data.view_max_upscale_percentage=Math.max(f.data.view_max_upscale_percentage||0,_),f.data.view_max_downscale_percentage=Math.max(f.data.view_max_downscale_percentage||0,R),M(f.data,"view_total_content_playback_time",x),M(f.data,"view_total_upscaling",_*x),M(f.data,"view_total_downscaling",R*x)}g._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(T){f.on(T,function(){g._lastPlayheadPosition=f.data.player_playhead_time,g._lastPlayerWidth=f.data.player_width,g._lastPlayerHeight=f.data.player_height,g._lastSourceWidth=f.data.video_source_width,g._lastSourceHeight=f.data.video_source_height})})});function zs(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}function Bo(p,f,g){return f&&zs(p.prototype,f),g&&zs(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var $o=Bo(function p(f){var g=this;(function(T,x){if(!(T instanceof x))throw new TypeError("Cannot call a class as a function")})(this,p),this.isSeeking=!1,f.on("seeking",function(T,x){Object.assign(f.data,x),g._lastSeekingTime=L.now(),g.isSeeking===!1&&(g.isSeeking=!0,f.send("seeking"))}),f.on("seeked",function(){g.isSeeking=!1;var T=g._lastSeekingTime||L.now(),x=L.now()-T;M(f.data,"view_seek_count",1),M(f.data,"view_seek_duration",x);var S=f.data.view_max_seek_time||0;f.data.view_max_seek_time=Math.max(S,x)}),f.on("viewend",function(){g.isSeeking=!1})});function Xs(p,f){return function(g){if(Array.isArray(g))return g}(p)||function(g,T){var x=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(x!=null){var S,_,R=[],O=!0,I=!1;try{for(x=x.call(g);!(O=(S=x.next()).done)&&(R.push(S.value),!T||R.length!==T);O=!0);}catch(U){I=!0,_=U}finally{try{O||x.return==null||x.return()}finally{if(I)throw _}}return R}}(p,f)||function(g,T){if(g){if(typeof g=="string")return Qs(g,T);var x=Object.prototype.toString.call(g).slice(8,-1);return x==="Object"&&g.constructor&&(x=g.constructor.name),x==="Map"||x==="Set"?Array.from(g):x==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x)?Qs(g,T):void 0}}(p,f)||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 Qs(p,f){(f==null||f>p.length)&&(f=p.length);for(var g=0,T=new Array(f);g<f;g++)T[g]=p[g];return T}function Js(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}var Zs=function(p,f){p.push(f),p.sort(function(g,T){return g.viewer_time-T.viewer_time})},Go=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Ho=function(){function p(x){var S=this;(function(R,O){if(!(R instanceof O))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=x,x.on("viewinit",function(){S.isAdBreak=!1,S._currentAdRequestNumber=0,S._currentAdResponseNumber=0,S._adRequests=[],S._adResponses=[],S._adHasPlayed=!1,S._wouldBeNewAdPlay=!0,S._prerollPlayTime=void 0}),Go.forEach(function(R){return x.on(R,S._updateAdData.bind(S))});var _=function(){S.isAdBreak=!1};x.on("adbreakstart",function(){S.isAdBreak=!0}),x.on("play",_),x.on("playing",_),x.on("viewend",_),x.on("adrequest",function(R,O){O=Object.assign({ad_request_id:"generatedAdRequestId"+S._currentAdRequestNumber++},O),Zs(S._adRequests,O),M(x.data,"view_ad_request_count"),S.inPrerollPosition()&&(x.data.view_preroll_requested=!0,S._adHasPlayed||M(x.data,"view_preroll_request_count"))}),x.on("adresponse",function(R,O){O=Object.assign({ad_request_id:"generatedAdRequestId"+S._currentAdResponseNumber++},O),Zs(S._adResponses,O);var I=S.findAdRequest(O.ad_request_id);I&&M(x.data,"view_ad_request_time",Math.max(0,O.viewer_time-I.viewer_time))}),x.on("adplay",function(R,O){S._adHasPlayed=!0,S._wouldBeNewAdPlay&&(S._wouldBeNewAdPlay=!1,M(x.data,"view_ad_played_count")),S.inPrerollPosition()&&!x.data.view_preroll_played&&(x.data.view_preroll_played=!0,S._adRequests.length>0&&(x.data.view_preroll_request_time=Math.max(0,O.viewer_time-S._adRequests[0].viewer_time)),x.data.view_start&&(x.data.view_startup_preroll_request_time=Math.max(0,O.viewer_time-x.data.view_start)),S._prerollPlayTime=O.viewer_time)}),x.on("adplaying",function(R,O){S.inPrerollPosition()&&x.data.view_preroll_load_time===void 0&&S._prerollPlayTime!==void 0&&(x.data.view_preroll_load_time=O.viewer_time-S._prerollPlayTime,x.data.view_startup_preroll_load_time=O.viewer_time-S._prerollPlayTime)}),x.on("adended",function(){S._wouldBeNewAdPlay=!0}),x.on("aderror",function(){S._wouldBeNewAdPlay=!0})}var f,g,T;return f=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(x){for(var S=0;S<this._adRequests.length;S++)if(this._adRequests[S].ad_request_id===x)return this._adRequests[S]}},{key:"_updateAdData",value:function(x,S){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&S.ad_tag_url){var _=Xs(k(S.ad_tag_url),2),R=_[0],O=_[1];this.pm.data.view_preroll_ad_tag_domain=O,this.pm.data.view_preroll_ad_tag_hostname=R}if(!this.pm.data.view_preroll_ad_asset_hostname&&S.ad_asset_url){var I=Xs(k(S.ad_asset_url),2),U=I[0],se=I[1];this.pm.data.view_preroll_ad_asset_domain=se,this.pm.data.view_preroll_ad_asset_hostname=U}}this.pm.data.ad_asset_url=S==null?void 0:S.ad_asset_url,this.pm.data.ad_tag_url=S==null?void 0:S.ad_tag_url,this.pm.data.ad_creative_id=S==null?void 0:S.ad_creative_id,this.pm.data.ad_id=S==null?void 0:S.ad_id,this.pm.data.ad_universal_id=S==null?void 0:S.ad_universal_id}}])&&Js(f.prototype,g),T&&Js(f,T),Object.defineProperty(f,"prototype",{writable:!1}),p}();function en(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}function Ko(p,f,g){return f&&en(p.prototype,f),g&&en(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Vo=Ko(function p(f){var g,T;(function(R,O){if(!(R instanceof O))throw new TypeError("Cannot call a class as a function")})(this,p);var x=function(){f.disableRebufferTracking||g&&(M(f.data,"view_waiting_rebuffer_duration",L.now()-g),g=!1,c().clearInterval(T))},S=!1,_=function(){S=!1,x()};f.on("waiting",function(){S&&(f.disableRebufferTracking||(M(f.data,"view_waiting_rebuffer_count",1),g=L.now(),T=c().setInterval(function(){if(g){var R=L.now();M(f.data,"view_waiting_rebuffer_duration",R-g),g=R}},250)))}),f.on("playing",function(){x(),S=!0}),f.on("pause",_),f.on("seeking",_)});function tn(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}function qo(p,f,g){return f&&tn(p.prototype,f),g&&tn(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Wo=qo(function p(f){var g=this;(function(S,_){if(!(S instanceof _))throw new TypeError("Cannot call a class as a function")})(this,p);var T=function(){g.lastWallClockTime=L.now(),f.on("before*",x)},x=function(S){var _=L.now(),R=g.lastWallClockTime;g.lastWallClockTime=_,_-R>3e4&&(f.emit("devicesleep",{viewer_time:R}),Object.assign(f.data,{viewer_time:R}),f.send("devicesleep"),f.emit("devicewake",{viewer_time:_}),Object.assign(f.data,{viewer_time:_}),f.send("devicewake"))};f.one("playbackheartbeat",T),f.on("playbackheartbeatend",function(){f.off("before*",x),f.one("playbackheartbeat",T)})}),rn=o(375),jo=o(655),sn=o.n(jo),nn="muxData",an=function(){var p;try{p=rn.parse(sn().get(nn)||"")}catch{p={}}return p},on=function(p){try{sn().set(nn,rn.stringify(p),{expires:7300})}catch{}},Yo=function(){var p=an();return p.mux_viewer_id=p.mux_viewer_id||u(),p.msn=p.msn||Math.random(),on(p),{mux_viewer_id:p.mux_viewer_id,mux_sample_number:p.msn}};function zo(p,f){var g=f.beaconCollectionDomain,T=f.beaconDomain;if(g)return"https://"+g;var x=T||"litix.io";return(p=p||"inferred").match(/^[a-z0-9]+$/)?"https://"+p+"."+x:"https://img.litix.io/a.gif"}var ln=function(){var p;switch(cn()){case"cellular":p="cellular";break;case"ethernet":p="wired";break;case"wifi":p="wifi";break;case void 0:break;default:p="other"}return p},cn=function(){var p=c().navigator,f=p&&(p.connection||p.mozConnection||p.webkitConnection);return f&&f.type};ln.getConnectionFromAPI=cn;var Xo=ln,Qo=dn({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"}),un=dn({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 dn(p){var f={};for(var g in p)p.hasOwnProperty(g)&&(f[p[g]]=g);return f}function Yi(p){var f={},g={};return Object.keys(p).forEach(function(T){var x=!1;if(p.hasOwnProperty(T)&&p[T]!==void 0){var S=T.split("_"),_=S[0],R=Qo[_];R||(A.info("Data key word `"+S[0]+"` not expected in "+T),R=_+"_"),S.splice(1).forEach(function(O){O==="url"&&(x=!0),un[O]?R+=un[O]:Number(O)&&Math.floor(Number(O))===Number(O)?R+=O:(A.info("Data key word `"+O+"` not expected in "+T),R+="_"+O+"_")}),x?g[R]=p[T]:f[R]=p[T]}}),Object.assign(f,g)}var Jo={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Zo=["hb","requestcompleted","requestfailed","requestcanceled"],el="https://img.litix.io",yt=function(p){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=p||el,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},Jo,f)};yt.prototype.queueEvent=function(p,f){var g=Object.assign({},f);return(this._eventQueue.length<=this._options.maxQueueLength||p==="eventrateexceeded")&&(this._eventQueue.push(g),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},yt.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())},yt.prototype.destroy=function(){var p=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,p?this._clearBeaconQueue():this.flushEvents(),c().clearTimeout(this._sendTimeout)},yt.prototype._clearBeaconQueue=function(){var p=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,f=this._eventQueue.slice(p);p>0&&Object.assign(f[f.length-1],Yi({mux_view_message:"event queue truncated"}));var g=this._createPayload(f);hn(this._beaconUrl,g,!0,function(){})},yt.prototype._sendBeaconQueue=function(){var p=this;if(!this._postInFlight){var f=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var g=this._createPayload(f),T=L.now();hn(this._beaconUrl,g,!1,function(x,S){S?(p._eventQueue=f.concat(p._eventQueue),p._failureCount+=1,A.info("Error sending beacon: "+S)):p._failureCount=0,p._roundTripTime=L.now()-T,p._postInFlight=!1})}},yt.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},yt.prototype._startBeaconSending=function(){var p=this;c().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=c().setTimeout(function(){p._eventQueue.length&&p._sendBeaconQueue(),p._startBeaconSending()},this._getNextBeaconTime()))},yt.prototype._createPayload=function(p){var f,g,T,x=this,S={transmission_timestamp:Math.round(L.now())};this._roundTripTime&&(S.rtt_ms=Math.round(this._roundTripTime));var _=function(){f=JSON.stringify({metadata:S,events:g||p}),T=f.length/1024},R=function(){return T<=x._options.maxPayloadKBSize};return _(),R()||(A.info("Payload size is too big ("+T+" kb). Removing unnecessary events."),g=p.filter(function(O){return Zo.indexOf(O.e)===-1}),_()),R()||(A.info("Payload size still too big ("+T+" kb). Cropping fields.."),g.forEach(function(O){for(var I in O){var U=O[I];typeof U=="string"&&U.length>51200&&(O[I]=U.substring(0,51200))}}),_()),f};var tl=function(p){return p.length<=57344},hn=function(p,f,g,T){if(g&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(p,f))T();else if(c().fetch)c().fetch(p,{method:"POST",body:f,headers:{"Content-Type":"text/plain"},keepalive:tl(f)}).then(function(S){return T(null,S.ok?null:"Error")}).catch(function(S){return T(null,S)});else{if(c().XMLHttpRequest){var x=new(c()).XMLHttpRequest;return x.onreadystatechange=function(){if(x.readyState===4)return T(null,x.status!==200?"error":void 0)},x.open("POST",p),x.setRequestHeader("Content-Type","text/plain"),void x.send(f)}T()}},il=yt;function rl(p,f){return function(g){if(Array.isArray(g))return g}(p)||function(g,T){var x=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(x!=null){var S,_,R=[],O=!0,I=!1;try{for(x=x.call(g);!(O=(S=x.next()).done)&&(R.push(S.value),!T||R.length!==T);O=!0);}catch(U){I=!0,_=U}finally{try{O||x.return==null||x.return()}finally{if(I)throw _}}return R}}(p,f)||function(g,T){if(g){if(typeof g=="string")return fn(g,T);var x=Object.prototype.toString.call(g).slice(8,-1);return x==="Object"&&g.constructor&&(x=g.constructor.name),x==="Map"||x==="Set"?Array.from(g):x==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x)?fn(g,T):void 0}}(p,f)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function fn(p,f){(f==null||f>p.length)&&(f=p.length);for(var g=0,T=new Array(f);g<f;g++)T[g]=p[g];return T}function gn(p,f){var g=Object.keys(p);if(Object.getOwnPropertySymbols){var T=Object.getOwnPropertySymbols(p);f&&(T=T.filter(function(x){return Object.getOwnPropertyDescriptor(p,x).enumerable})),g.push.apply(g,T)}return g}function Ct(p){for(var f=1;f<arguments.length;f++){var g=arguments[f]!=null?arguments[f]:{};f%2?gn(Object(g),!0).forEach(function(T){ai(p,T,g[T])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(g)):gn(Object(g)).forEach(function(T){Object.defineProperty(p,T,Object.getOwnPropertyDescriptor(g,T))})}return p}function Gt(p){return Gt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f},Gt(p)}function sl(p,f){if(!(p instanceof f))throw new TypeError("Cannot call a class as a function")}function mn(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}function ai(p,f,g){return f in p?Object.defineProperty(p,f,{value:g,enumerable:!0,configurable:!0,writable:!0}):p[f]=g,p}var nl=["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"],al=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse"],ol=["viewstart","error","ended","viewend"],ll=function(){function p(x,S){var _,R,O,I,U,se,Q,Z,z,te,me,Pe,Oe,je,it,fe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};sl(this,p),ai(this,"previousBeaconData",null),ai(this,"lastEventTime",0),ai(this,"rateLimited",!1),this.mux=x,this.envKey=S,this.options=fe,this.eventQueue=new il(zo(this.envKey,this.options)),this.sampleRate=(_=this.options.sampleRate)!==null&&_!==void 0?_:1,this.disableCookies=(R=this.options.disableCookies)!==null&&R!==void 0&&R,this.respectDoNotTrack=(O=this.options.respectDoNotTrack)!==null&&O!==void 0&&O,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:(I=this.options.platform)===null||I===void 0?void 0:I.name,viewer_application_version:(U=this.options.platform)===null||U===void 0?void 0:U.version,viewer_application_engine:(se=this.options.platform)===null||se===void 0?void 0:se.layout,viewer_device_name:(Q=this.options.platform)===null||Q===void 0?void 0:Q.product,viewer_device_category:"",viewer_device_manufacturer:(Z=this.options.platform)===null||Z===void 0?void 0:Z.manufacturer,viewer_os_family:(z=this.options.platform)===null||z===void 0||(te=z.os)===null||te===void 0?void 0:te.family,viewer_os_architecture:(me=this.options.platform)===null||me===void 0||(Pe=me.os)===null||Pe===void 0?void 0:Pe.architecture,viewer_os_version:(Oe=this.options.platform)===null||Oe===void 0||(je=Oe.os)===null||je===void 0?void 0:je.version,viewer_connection_type:Xo(),page_url:c()===null||c()===void 0||(it=c().location)===null||it===void 0?void 0:it.href},this.viewerData=this.disableCookies?{}:Yo()}var f,g,T;return f=p,(g=[{key:"send",value:function(x,S){var _;if(x&&S!=null&&S.view_id){if(this.respectDoNotTrack&&D())return A.info("Not sending `"+x+"` because Do Not Track is enabled");if(!S||Gt(S)!=="object")return A.error("A data object was expected in send() but was not provided");var R,O,I=this.disableCookies?{}:(R=an(),O=L.now(),R.session_start&&(R.sst=R.session_start,delete R.session_start),R.session_id&&(R.sid=R.session_id,delete R.session_id),R.session_expires&&(R.sex=R.session_expires,delete R.session_expires),(!R.sex||R.sex<O)&&(R.sid=u(),R.sst=O),R.sex=O+15e5,on(R),{session_id:R.sid,session_start:R.sst,session_expires:R.sex}),U=Ct(Ct(Ct(Ct(Ct({},this.pageLevelData),S),I),this.viewerData),{},{event:x,env_key:this.envKey});U.user_id&&(U.viewer_user_id=U.user_id,delete U.user_id);var se=((_=U.mux_sample_number)!==null&&_!==void 0?_:0)>=this.sampleRate,Q=Yi(this._deduplicateBeaconData(x,U));if(this.lastEventTime=this.mux.utils.now(),se)return A.info("Not sending event due to sample rate restriction",x,U,Q);if(this.envKey||A.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",x,U,Q),!this.rateLimited){if(A.info("Sending event",x,U,Q),this.rateLimited=!this.eventQueue.queueEvent(x,Q),this.mux.WINDOW_UNLOADING&&x==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&x==="hb"?this.eventQueue.flushEvents(!0):ol.indexOf(x)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return U.event="eventrateexceeded",Q=Yi(U),this.eventQueue.queueEvent(U.event,Q),A.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(x,S){var _=this,R={},O=S.view_id;if(O==="-1"||x==="viewstart"||x==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)R=Ct({},S),O&&(this.previousBeaconData=R),O&&x==="viewend"&&(this.previousBeaconData=null);else{var I=x.indexOf("request")===0;Object.entries(S).forEach(function(U){var se=rl(U,2),Q=se[0],Z=se[1];_.previousBeaconData&&(Z!==_.previousBeaconData[Q]||nl.indexOf(Q)>-1||_.objectHasChanged(I,Q,Z,_.previousBeaconData[Q])||_.eventRequiresKey(x,Q))&&(R[Q]=Z,_.previousBeaconData[Q]=Z)})}return R}},{key:"objectHasChanged",value:function(x,S,_,R){return!(!x||S.indexOf("request_")!==0||S!=="request_response_headers"&&Gt(_)==="object"&&Gt(R)==="object"&&Object.keys(_||{}).length===Object.keys(R||{}).length)}},{key:"eventRequiresKey",value:function(x,S){return x==="renditionchange"&&S.indexOf("video_source_")===0||!(S.indexOf("ad_id")!==0||!al.includes(x))}}])&&mn(f.prototype,g),T&&mn(f,T),Object.defineProperty(f,"prototype",{writable:!1}),p}();function pn(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}function cl(p,f,g){return f&&pn(p.prototype,f),g&&pn(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var ul=cl(function p(f){(function(I,U){if(!(I instanceof U))throw new TypeError("Cannot call a class as a function")})(this,p);var g=0,T=0,x=0,S=0,_=0,R=0,O=0;f.on("requestcompleted",function(I,U){var se,Q,Z=U.request_start,z=U.request_response_start,te=U.request_response_end,me=U.request_bytes_loaded;if(S++,z?(se=z-(Z!=null?Z:0),Q=(te!=null?te:0)-z):Q=(te!=null?te:0)-(Z!=null?Z:0),Q>0&&me&&me>0){var Pe=me/Q*8e3;_++,T+=me,x+=Q,f.data.view_min_request_throughput=Math.min(f.data.view_min_request_throughput||1/0,Pe),f.data.view_average_request_throughput=T/x*8e3,f.data.view_request_count=S,se>0&&(g+=se,f.data.view_max_request_latency=Math.max(f.data.view_max_request_latency||0,se),f.data.view_average_request_latency=g/_)}}),f.on("requestfailed",function(I,U){S++,R++,f.data.view_request_count=S,f.data.view_request_failed_count=R}),f.on("requestcanceled",function(I,U){S++,O++,f.data.view_request_count=S,f.data.view_request_canceled_count=O})});function yn(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}function dl(p,f,g){return f&&yn(p.prototype,f),g&&yn(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var hl=dl(function p(f){var g=this;(function(T,x){if(!(T instanceof x))throw new TypeError("Cannot call a class as a function")})(this,p),f.on("before*",function(T,x){var S=x.viewer_time,_=L.now(),R=g._lastEventTime;if(g._lastEventTime=_,R&&_-R>36e5){var O=Object.keys(f.data).reduce(function(I,U){return U.indexOf("video_")===0?Object.assign(I,function(se,Q,Z){return Q in se?Object.defineProperty(se,Q,{value:Z,enumerable:!0,configurable:!0,writable:!0}):se[Q]=Z,se}({},U,f.data[U])):I},{});f.mux.log.info("Received event after at least an hour inactivity, creating a new view"),f.emit("viewinit",Object.assign({viewer_time:S},O)),f.playbackHeartbeat._playheadShouldBeProgressing&&T.type!=="play"&&T.type!=="adbreakstart"&&(f.emit("play",{viewer_time:S}),T.type!=="playing"&&f.emit("playing",{viewer_time:S}))}})});function zi(p){return zi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f},zi(p)}function fl(p,f){return function(g){if(Array.isArray(g))return g}(p)||function(g,T){var x=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(x!=null){var S,_,R=[],O=!0,I=!1;try{for(x=x.call(g);!(O=(S=x.next()).done)&&(R.push(S.value),!T||R.length!==T);O=!0);}catch(U){I=!0,_=U}finally{try{O||x.return==null||x.return()}finally{if(I)throw _}}return R}}(p,f)||function(g,T){if(g){if(typeof g=="string")return vn(g,T);var x=Object.prototype.toString.call(g).slice(8,-1);return x==="Object"&&g.constructor&&(x=g.constructor.name),x==="Map"||x==="Set"?Array.from(g):x==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x)?vn(g,T):void 0}}(p,f)||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 vn(p,f){(f==null||f>p.length)&&(f=p.length);for(var g=0,T=new Array(f);g<f;g++)T[g]=p[g];return T}function Tn(p,f){for(var g=0;g<f.length;g++){var T=f[g];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(p,T.key,T)}}function Xi(p,f){return Xi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,T){return g.__proto__=T,g},Xi(p,f)}function gl(p){var f=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,T=oi(p);if(f){var x=oi(this).constructor;g=Reflect.construct(T,arguments,x)}else g=T.apply(this,arguments);return ml(this,g)}}function ml(p,f){if(f&&(zi(f)==="object"||typeof f=="function"))return f;if(f!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return De(p)}function De(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function oi(p){return oi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(f){return f.__proto__||Object.getPrototypeOf(f)},oi(p)}var pl=["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"],yl=function(p){(function(_,R){if(typeof R!="function"&&R!==null)throw new TypeError("Super expression must either be null or a function");_.prototype=Object.create(R&&R.prototype,{constructor:{value:_,writable:!0,configurable:!0}}),Object.defineProperty(_,"prototype",{writable:!1}),R&&Xi(_,R)})(S,p);var f,g,T,x=gl(S);function S(_,R,O){var I;(function(z,te){if(!(z instanceof te))throw new TypeError("Cannot call a class as a function")})(this,S),(I=x.call(this)).DOM_CONTENT_LOADED_EVENT_END=G.domContentLoadedEventEnd(),I.NAVIGATION_START=G.navigationStart(),I.mux=_,I.id=R,(O=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(z){return z}},O)).data=O.data||{},O.data.property_key&&(O.data.env_key=O.data.property_key,delete O.data.property_key),A.setLevel(O.debug?"debug":"warn"),I.getPlayheadTime=O.getPlayheadTime,I.getStateData=O.getStateData||function(){return{}},I.getAdData=O.getAdData||function(){},I.minimumRebufferDuration=O.minimumRebufferDuration,I.sustainedRebufferThreshold=O.sustainedRebufferThreshold,I.playbackHeartbeatTime=O.playbackHeartbeatTime,I.disableRebufferTracking=O.disableRebufferTracking,I.disableRebufferTracking&&I.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."),I.disablePlayheadRebufferTracking=O.disablePlayheadRebufferTracking,I.errorTranslator=O.errorTranslator,I.playbackEventDispatcher=new ll(_,O.data.env_key,O),I.data={player_instance_id:u(),mux_sample_rate:O.sampleRate,beacon_domain:O.beaconCollectionDomain?O.beaconCollectionDomain:O.beaconDomain},I.data.view_sequence_number=1,I.data.player_sequence_number=1,I.oldEmit=I.emit,I.emit=function(z,te){te=Object.assign({viewer_time:this.mux.utils.now()},te),this.oldEmit(z,te)};var U=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(De(I));I.on("viewinit",function(z,te){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,te),this._initializeViewData(),this.one("play",U),this.one("adbreakstart",U)});var se=function(z){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",z)}.bind(De(I));if(I.on("videochange",function(z,te){se(te)}),I.on("programchange",function(z,te){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."),se(Object.assign(te,{view_program_changed:!0})),U(),this.emit("play"),this.emit("playing")}),I.on("fragmentchange",function(z,te){this.currentFragmentPDT=te.currentFragmentPDT,this.currentFragmentStart=te.currentFragmentStart}),I.on("destroy",I.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var Q=function(){var z=I.data.view_start!==void 0;I.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",z&&I.mux.WINDOW_HIDDEN&&(I.data.player_is_paused||I.emit("hb"))};window.addEventListener("visibilitychange",Q,!1);var Z=function(z){z.persisted||I.destroy()};window.addEventListener("pagehide",Z,!1),I.on("destroy",function(){window.removeEventListener("visibilitychange",Q),window.removeEventListener("pagehide",Z)})}return I.on("playerready",function(z,te){Object.assign(this.data,te)}),pl.forEach(function(z){I.on(z,function(te,me){z.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,me),this._sanitizeData()}),I.on("after"+z,function(){(z!=="error"||this.errorTracker.viewErrored)&&this.send(z)})}),I.on("viewend",function(z,te){Object.assign(I.data,te)}),I.one("playerready",function(z){var te=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=te-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}),I.longResumeTracker=new hl(De(I)),I.errorTracker=new Io(De(I)),new Wo(De(I)),I.seekingTracker=new $o(De(I)),I.playheadTime=new ko(De(I)),I.playbackHeartbeat=new Lo(De(I)),new Uo(De(I)),I.watchTimeTracker=new Do(De(I)),new wo(De(I)),I.adTracker=new Ho(De(I)),new Mo(De(I)),new Po(De(I)),new Fo(De(I)),new Vo(De(I)),new ul(De(I)),O.hlsjs&&I.addHLSJS(O),O.dashjs&&I.addDashJS(O),I.emit("viewinit",O.data),I}return f=S,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(_){if(this.data.view_id){var R=Object.assign({},this.data);if(R.video_source_is_live===void 0&&(R.player_source_duration===1/0||R.video_source_duration===1/0?R.video_source_is_live=!0:(R.player_source_duration>0||R.video_source_duration>0)&&(R.video_source_is_live=!1)),R.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(se){R[se]=void 0}),R.video_source_url=R.video_source_url||R.player_source_url,R.video_source_url){var O=fl(k(R.video_source_url),2),I=O[0],U=O[1];R.video_source_domain=U,R.video_source_hostname=I}delete R.ad_request_id,this.playbackEventDispatcher.send(_,R),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),_==="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 _=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(R){var O=parseInt(_.data[R],10);_.data[R]=isNaN(O)?void 0:O}),["player_source_url","video_source_url"].forEach(function(R){if(_.data[R]){var O=_.data[R].toLowerCase();O.indexOf("data:")!==0&&O.indexOf("blob:")!==0||(_.data[R]="MSE style URL")}})}},{key:"_resetVideoData",value:function(_,R){var O=this;Object.keys(this.data).forEach(function(I){I.indexOf("video_")===0&&delete O.data[I]})}},{key:"_resetViewData",value:function(){var _=this;Object.keys(this.data).forEach(function(R){R.indexOf("view_")===0&&delete _.data[R]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(_,R){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var _=this,R=this.data.view_id=u(),O=function(){R===_.data.view_id&&M(_.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",O):O()}},{key:"_restartHeartBeat",value:function(){var _=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){_.data.player_is_paused||_.emit("hb")},1e4))}},{key:"addHLSJS",value:function(_){_.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=_.hlsjs,function(R,O,I){var U=arguments.length>4?arguments[4]:void 0,se=R.log,Q=R.utils.secondsToMs,Z=function(pe){var V,ee=parseInt(U.version);return ee===1&&pe.programDateTime!==null&&(V=pe.programDateTime),ee===0&&pe.pdt!==null&&(V=pe.pdt),V};if(G.exists()){var z=function(pe,V){return R.emit(O,pe,V)},te=function(pe,V){var ee=V.levels,W=V.audioTracks,ae=V.url,ue=V.stats,Le=V.networkDetails,Ye=V.sessionData,Me={},He={};ee.forEach(function(Re,qt){Me[qt]={width:Re.width,height:Re.height,bitrate:Re.bitrate,attrs:Re.attrs}}),W.forEach(function(Re,qt){He[qt]={name:Re.name,language:Re.lang,bitrate:Re.bitrate}});var we=Te(ue),ke=we.bytesLoaded,Et=we.requestStart,Vt=we.responseStart,St=we.responseEnd;z("requestcompleted",oe(oe({},H(Ye)),{},{request_event_type:pe,request_bytes_loaded:ke,request_start:Et,request_response_start:Vt,request_response_end:St,request_type:"manifest",request_hostname:F(ae),request_response_headers:ge(Le),request_rendition_lists:{media:Me,audio:He,video:{}}}))};I.on(U.Events.MANIFEST_LOADED,te);var me=function(pe,V){var ee=V.details,W=V.level,ae=V.networkDetails,ue=V.stats,Le=Te(ue),Ye=Le.bytesLoaded,Me=Le.requestStart,He=Le.responseStart,we=Le.responseEnd,ke=ee.fragments[ee.fragments.length-1],Et=Z(ke)+Q(ke.duration);z("requestcompleted",{request_event_type:pe,request_bytes_loaded:Ye,request_start:Me,request_response_start:He,request_response_end:we,request_current_level:W,request_type:"manifest",request_hostname:F(ee.url),request_response_headers:ge(ae),video_holdback:ee.holdBack&&Q(ee.holdBack),video_part_holdback:ee.partHoldBack&&Q(ee.partHoldBack),video_part_target_duration:ee.partTarget&&Q(ee.partTarget),video_target_duration:ee.targetduration&&Q(ee.targetduration),video_source_is_live:ee.live,player_manifest_newest_program_time:isNaN(Et)?void 0:Et})};I.on(U.Events.LEVEL_LOADED,me);var Pe=function(pe,V){var ee=V.details,W=V.networkDetails,ae=V.stats,ue=Te(ae),Le=ue.bytesLoaded,Ye=ue.requestStart,Me=ue.responseStart,He=ue.responseEnd;z("requestcompleted",{request_event_type:pe,request_bytes_loaded:Le,request_start:Ye,request_response_start:Me,request_response_end:He,request_type:"manifest",request_hostname:F(ee.url),request_response_headers:ge(W)})};I.on(U.Events.AUDIO_TRACK_LOADED,Pe);var Oe=function(pe,V){var ee=V.stats,W=V.networkDetails,ae=V.frag;ee=ee||ae.stats;var ue=Te(ee),Le=ue.bytesLoaded,Ye=ue.requestStart,Me=ue.responseStart,He=ue.responseEnd,we=W?ge(W):void 0,ke={request_event_type:pe,request_bytes_loaded:Le,request_start:Ye,request_response_start:Me,request_response_end:He,request_hostname:W?F(W.responseURL):void 0,request_id:we?q(we):void 0,request_response_headers:we,request_media_duration:ae.duration,request_url:W==null?void 0:W.responseURL};ae.type==="main"?(ke.request_type="media",ke.request_current_level=ae.level,ke.request_video_width=(I.levels[ae.level]||{}).width,ke.request_video_height=(I.levels[ae.level]||{}).height,ke.request_labeled_bitrate=(I.levels[ae.level]||{}).bitrate):ke.request_type=ae.type,z("requestcompleted",ke)};I.on(U.Events.FRAG_LOADED,Oe);var je=function(pe,V){var ee=V.frag,W=ee.start,ae={currentFragmentPDT:Z(ee),currentFragmentStart:Q(W)};z("fragmentchange",ae)};I.on(U.Events.FRAG_CHANGED,je);var it=function(pe,V){var ee=V.type,W=V.details,ae=V.response,ue=V.fatal,Le=V.frag,Ye=V.networkDetails,Me=(Le==null?void 0:Le.url)||V.url||"",He=Ye?ge(Ye):void 0;if(W!==U.ErrorDetails.MANIFEST_LOAD_ERROR&&W!==U.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&W!==U.ErrorDetails.FRAG_LOAD_ERROR&&W!==U.ErrorDetails.FRAG_LOAD_TIMEOUT&&W!==U.ErrorDetails.LEVEL_LOAD_ERROR&&W!==U.ErrorDetails.LEVEL_LOAD_TIMEOUT&&W!==U.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&W!==U.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&W!==U.ErrorDetails.SUBTITLE_LOAD_ERROR&&W!==U.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&W!==U.ErrorDetails.KEY_LOAD_ERROR&&W!==U.ErrorDetails.KEY_LOAD_TIMEOUT||z("requestfailed",{request_error:W,request_url:Me,request_hostname:F(Me),request_id:He?q(He):void 0,request_type:W===U.ErrorDetails.FRAG_LOAD_ERROR||W===U.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":W===U.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||W===U.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":W===U.ErrorDetails.SUBTITLE_LOAD_ERROR||W===U.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":W===U.ErrorDetails.KEY_LOAD_ERROR||W===U.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:ae==null?void 0:ae.code,request_error_text:ae==null?void 0:ae.text}),ue){var we,ke="".concat(Me?"url: ".concat(Me,`
|
|
5
|
+
`):"")+"".concat(ae&&(ae.code||ae.text)?"response: ".concat(ae.code,", ").concat(ae.text,`
|
|
6
|
+
`):"")+"".concat(V.reason?"failure reason: ".concat(V.reason,`
|
|
7
|
+
`):"")+"".concat(V.level?"level: ".concat(V.level,`
|
|
8
|
+
`):"")+"".concat(V.parent?"parent stream controller: ".concat(V.parent,`
|
|
9
|
+
`):"")+"".concat(V.buffer?"buffer length: ".concat(V.buffer,`
|
|
10
|
+
`):"")+"".concat(V.error?"error: ".concat(V.error,`
|
|
11
|
+
`):"")+"".concat(V.event?"event: ".concat(V.event,`
|
|
12
|
+
`):"")+"".concat(V.err?"error message: ".concat((we=V.err)===null||we===void 0?void 0:we.message,`
|
|
13
|
+
`):"");z("error",{player_error_code:ee,player_error_message:W,player_error_context:ke})}};I.on(U.Events.ERROR,it);var fe=function(pe,V){var ee=V.frag,W=ee&&ee._url||"";z("requestcanceled",{request_event_type:pe,request_url:W,request_type:"media",request_hostname:F(W)})};I.on(U.Events.FRAG_LOAD_EMERGENCY_ABORTED,fe);var Ae=function(pe,V){var ee=V.level,W=I.levels[ee];if(W&&W.attrs&&W.attrs.BANDWIDTH){var ae,ue=W.attrs.BANDWIDTH,Le=parseFloat(W.attrs["FRAME-RATE"]);isNaN(Le)||(ae=Le),ue?z("renditionchange",{video_source_fps:ae,video_source_bitrate:ue,video_source_width:W.width,video_source_height:W.height,video_source_rendition_name:W.name,video_source_codec:W==null?void 0:W.videoCodec}):se.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};I.on(U.Events.LEVEL_SWITCHED,Ae),I._stopMuxMonitor=function(){I.off(U.Events.MANIFEST_LOADED,te),I.off(U.Events.LEVEL_LOADED,me),I.off(U.Events.AUDIO_TRACK_LOADED,Pe),I.off(U.Events.FRAG_LOADED,Oe),I.off(U.Events.FRAG_CHANGED,je),I.off(U.Events.ERROR,it),I.off(U.Events.FRAG_LOAD_EMERGENCY_ABORTED,fe),I.off(U.Events.LEVEL_SWITCHED,Ae),I.off(U.Events.DESTROYING,I._stopMuxMonitor),delete I._stopMuxMonitor},I.on(U.Events.DESTROYING,I._stopMuxMonitor)}else se.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,_.hlsjs,{},_.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var _;this.hlsjs&&((_=this.hlsjs)&&typeof _._stopMuxMonitor=="function"&&_._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(_){_.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=_.dashjs,function(R,O,I){var U=R.log;if(I&&I.on){var se=function(fe,Ae){return R.emit(O,fe,Ae)},Q=function(fe){var Ae=fe.type,pe=(fe.data||{}).url;se("requestcompleted",{request_event_type:Ae,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:F(pe),request_url:pe})};I.on("manifestLoaded",Q);var Z={},z=function(fe){var Ae=fe.type,pe=fe.fragmentModel,V=(fe.chunk||{}).mediaInfo||{},ee=V.type,W=V.bitrateList,ae={};(W=W||[]).forEach(function(St,Re){ae[Re]={},ae[Re].width=St.width,ae[Re].height=St.height,ae[Re].bitrate=St.bandwidth,ae[Re].attrs={}}),ee==="video"?Z.video=ae:ee==="audio"?Z.audio=ae:Z.media=ae;var ue=de(pe,I),Le=ue.requestStart,Ye=ue.requestResponseStart,Me=ue.requestResponseEnd,He=ue.requestResponseHeaders,we=ue.requestMediaDuration,ke=ue.requestHostname,Et=ue.requestUrl,Vt=ue.requestId;se("requestcompleted",{request_event_type:Ae,request_start:Le,request_response_start:Ye,request_response_end:Me,request_bytes_loaded:-1,request_type:ee+"_init",request_response_headers:He,request_hostname:ke,request_id:Vt,request_url:Et,request_media_duration:we,request_rendition_lists:Z})};I.on("initFragmentLoaded",z);var te=function(fe){var Ae=fe.type,pe=fe.fragmentModel,V=fe.chunk||{},ee=V.mediaInfo,W=V.start,ae=(ee||{}).type,ue=de(pe,I),Le=ue.requestStart,Ye=ue.requestResponseStart,Me=ue.requestResponseEnd,He=ue.requestBytesLoaded,we=ue.requestResponseHeaders,ke=ue.requestMediaDuration,Et=ue.requestHostname,Vt=ue.requestUrl,St=ue.requestId,Re=he(ae,I),qt=Re.currentLevel,$l=Re.renditionWidth,Gl=Re.renditionHeight,Hl=Re.renditionBitrate;se("requestcompleted",{request_event_type:Ae,request_start:Le,request_response_start:Ye,request_response_end:Me,request_bytes_loaded:He,request_type:ae,request_response_headers:we,request_hostname:Et,request_id:St,request_url:Vt,request_media_start_time:W,request_media_duration:ke,request_current_level:qt,request_labeled_bitrate:Hl,request_video_width:$l,request_video_height:Gl})};I.on("mediaFragmentLoaded",te);var me={video:void 0,audio:void 0,totalBitrate:void 0},Pe=function(){if(me.video&&typeof me.video.bitrate=="number"){if(me.video.width&&me.video.height){var fe=me.video.bitrate;return me.audio&&typeof me.audio.bitrate=="number"&&(fe+=me.audio.bitrate),fe!==me.totalBitrate?(me.totalBitrate=fe,{video_source_bitrate:fe,video_source_height:me.video.height,video_source_width:me.video.width,video_source_codec:_e(me.video.codec)}):void 0}U.warn("have bitrate info for video but missing width/height")}},Oe=function(fe,Ae,pe){if(typeof fe.newQuality=="number"){var V=fe.mediaType;if(V==="audio"||V==="video"){var ee=I.getBitrateInfoListFor(V).find(function(ae){return ae.qualityIndex===fe.newQuality});if(ee&&typeof ee.bitrate=="number"){me[V]=X(X({},ee),{},{codec:I.getCurrentTrackFor(V).codec});var W=Pe();W&&se("renditionchange",W)}else U.warn("missing bitrate info for ".concat(V))}}else U.warn("missing evt.newQuality in qualityChangeRendered event",fe)};I.on("qualityChangeRendered",Oe);var je=function(fe){var Ae=fe.request,pe=fe.mediaType;se("requestcanceled",{request_event_type:(Ae=Ae||{}).type+"_"+Ae.action,request_url:Ae.url,request_type:pe,request_hostname:F(Ae.url)})};I.on("fragmentLoadingAbandoned",je);var it=function(fe){var Ae,pe,V=fe.error,ee=(V==null||(Ae=V.data)===null||Ae===void 0?void 0:Ae.request)||{},W=(V==null||(pe=V.data)===null||pe===void 0?void 0:pe.response)||{};(V==null?void 0:V.code)===27&&se("requestfailed",{request_error:ee.type+"_"+ee.action,request_url:ee.url,request_hostname:F(ee.url),request_type:ee.mediaType,request_error_code:W.status,request_error_text:W.statusText});var ae="".concat(ee!=null&&ee.url?"url: ".concat(ee.url,`
|
|
14
|
+
`):"")+"".concat(W!=null&&W.status||W!=null&&W.statusText?"response: ".concat(W==null?void 0:W.status,", ").concat(W==null?void 0:W.statusText,`
|
|
15
|
+
`):"");se("error",{player_error_code:V==null?void 0:V.code,player_error_message:V==null?void 0:V.message,player_error_context:ae})};I.on("error",it),I._stopMuxMonitor=function(){I.off("manifestLoaded",Q),I.off("initFragmentLoaded",z),I.off("mediaFragmentLoaded",te),I.off("qualityChangeRendered",Oe),I.off("error",it),I.off("fragmentLoadingAbandoned",je),delete I._stopMuxMonitor}}else U.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,_.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var _;this.dashjs&&((_=this.dashjs)&&typeof _._stopMuxMonitor=="function"&&_._stopMuxMonitor(),this.dashjs=void 0)}}],g&&Tn(f.prototype,g),T&&Tn(f,T),Object.defineProperty(f,"prototype",{writable:!1}),S}(pt),vl=yl,Tl=o(153),Ht=o.n(Tl);function Qi(p){return Qi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f},Qi(p)}function En(p,f){return function(g){if(Array.isArray(g))return g}(p)||function(g,T){var x=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(x!=null){var S,_,R=[],O=!0,I=!1;try{for(x=x.call(g);!(O=(S=x.next()).done)&&(R.push(S.value),!T||R.length!==T);O=!0);}catch(U){I=!0,_=U}finally{try{O||x.return==null||x.return()}finally{if(I)throw _}}return R}}(p,f)||function(g,T){if(g){if(typeof g=="string")return xn(g,T);var x=Object.prototype.toString.call(g).slice(8,-1);return x==="Object"&&g.constructor&&(x=g.constructor.name),x==="Map"||x==="Set"?Array.from(g):x==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x)?xn(g,T):void 0}}(p,f)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
16
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function xn(p,f){(f==null||f>p.length)&&(f=p.length);for(var g=0,T=new Array(f);g<f;g++)T[g]=p[g];return T}var Pt,El=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],xl={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};c()&&c().WeakMap&&(Pt=new WeakMap);var bl="#EXT-X-TARGETDURATION",_l="#EXT-X-PART-INF",Sl="#EXT-X-SERVER-CONTROL",Al="#EXTINF",Ll="#EXT-X-PROGRAM-DATE-TIME",Rl="#EXT-X-VERSION",Il="#EXT-X-SESSION-DATA",li=function(p){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(p),this.manifest};li.prototype.process=function(p){var f;for(this.buffer+=p,f=this.buffer.indexOf(`
|
|
17
|
+
`);f>-1;f=this.buffer.indexOf(`
|
|
18
|
+
`))this.processLine(this.buffer.substring(0,f)),this.buffer=this.buffer.substring(f+1)},li.prototype.processLine=function(p){var f=p.indexOf(":"),g=Cl(p,f),T=g[0],x=g.length===2?Zi(g[1]):void 0;if(T[0]!=="#")this.currentUri.uri=T,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(T){case bl:if(!isFinite(x)||x<0)return;this.manifest.targetDuration=x,this.setHoldBack();break;case _l:Ji(this.manifest,g),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Sl:Ji(this.manifest,g),this.setHoldBack();break;case Al:x===0?this.currentUri.duration=.01:x>0&&(this.currentUri.duration=x);break;case Ll:var S=x,_=new Date(S);this.manifest.dateTimeString||(this.manifest.dateTimeString=S,this.manifest.dateTimeObject=_),this.currentUri.dateTimeString=S,this.currentUri.dateTimeObject=_;break;case Rl:Ji(this.manifest,g);break;case Il:var R=Pl(g[1]),O=H(R);Object.assign(this.manifest.sessionData,O)}},li.prototype.setHoldBack=function(){var p=this.manifest,f=p.serverControl,g=p.targetDuration,T=p.partTargetDuration;if(f){var x="holdBack",S="partHoldBack",_=g&&3*g,R=T&&2*T;g&&!f.hasOwnProperty(x)&&(f[x]=_),_&&f[x]<_&&(f[x]=_),T&&!f.hasOwnProperty(S)&&(f[S]=3*T),T&&f[S]<R&&(f[S]=R)}};var Ji=function(p,f){var g,T=bn(f[0].replace("#EXT-X-",""));kl(f[1])?(g={},g=Object.assign(wl(f[1]),g)):g=Zi(f[1]),p[T]=g},bn=function(p){return p.toLowerCase().replace(/-(\w)/g,function(f){return f[1].toUpperCase()})},Zi=function(p){if(p.toLowerCase()==="yes"||p.toLowerCase()==="no")return p.toLowerCase()==="yes";var f=p.indexOf(":")!==-1?p:parseFloat(p);return isNaN(f)?p:f},Dl=function(p){var f={},g=p.split("=");return g.length>1&&(f[bn(g[0])]=Zi(g[1])),f},wl=function(p){for(var f=p.split(","),g={},T=0;f.length>T;T++){var x=f[T],S=Dl(x);g=Object.assign(S,g)}return g},kl=function(p){return p.indexOf("=")>-1},Cl=function(p,f){return f===-1?[p]:[p.substring(0,f),p.substring(f+1)]},Pl=function(p){var f={};if(p){var g=p.search(",");return[p.slice(0,g),p.slice(g+1)].forEach(function(T,x){for(var S=T.replace(/['"]+/g,"").split("="),_=0;_<S.length;_++)S[_]==="DATA-ID"&&(f["DATA-ID"]=S[1-_]),S[_]==="VALUE"&&(f.VALUE=S[1-_])}),{data:f}}},Ol=li,Ml={safeCall:function(p,f,g,T){var x=T;if(p&&typeof p[f]=="function")try{x=p[f].apply(p,g)}catch(S){A.info("safeCall error",S)}return x},safeIncrement:M,getComputedStyle:function(p,f){var g;if(p&&f&&c()&&typeof c().getComputedStyle=="function")return Pt&&Pt.has(p)&&(g=Pt.get(p)),g||(g=c().getComputedStyle(p,null),Pt&&Pt.set(p,g)),g.getPropertyValue(f)},secondsToMs:function(p){return Math.floor(1e3*p)},assign:Object.assign,headersStringToObject:P,cdnHeadersToRequestId:q,extractHostnameAndDomain:k,extractHostname:F,manifestParser:Ol,generateShortID:d,generateUUID:u,now:L.now},Fl={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 Nl(p,f){return function(g){if(Array.isArray(g))return g}(p)||function(g,T){var x=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(x!=null){var S,_,R=[],O=!0,I=!1;try{for(x=x.call(g);!(O=(S=x.next()).done)&&(R.push(S.value),!T||R.length!==T);O=!0);}catch(U){I=!0,_=U}finally{try{O||x.return==null||x.return()}finally{if(I)throw _}}return R}}(p,f)||function(g,T){if(g){if(typeof g=="string")return _n(g,T);var x=Object.prototype.toString.call(g).slice(8,-1);return x==="Object"&&g.constructor&&(x=g.constructor.name),x==="Map"||x==="Set"?Array.from(g):x==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x)?_n(g,T):void 0}}(p,f)||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 _n(p,f){(f==null||f>p.length)&&(f=p.length);for(var g=0,T=new Array(f);g<f;g++)T[g]=p[g];return T}var tt={},Kt=function p(f){var g=arguments;typeof f=="string"?p.hasOwnProperty(f)?c().setTimeout(function(){g=Array.prototype.splice.call(g,1),p[f].apply(null,g)},0):A.warn("`"+f+"` is an unknown task"):typeof f=="function"?c().setTimeout(function(){f(p)},0):A.warn("`"+f+"` is invalid.")},Ul={loaded:L.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(p,f){return function(g,T,x){var S=En(m(T),3),_=S[0],R=S[1],O=S[2],I=g.log,U=g.utils.getComputedStyle,se=g.utils.secondsToMs;if(!_)return I.error("No element was found with the `"+R+"` query selector.");if(O!=="video"&&O!=="audio")return I.error("The element of `"+R+"` was not a media element.");_.mux&&(_.mux.destroy(),delete _.mux,I.warn("Already monitoring this video element, replacing existing event listeners")),(x=Object.assign({automaticErrorTracking:!0},x)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:g.VERSION},x.data),x.getPlayheadTime=function(){return se(_.currentTime)},x.getStateData=function(){var Z,z,te=this.hlsjs&&this.hlsjs.url,me=this.dashjs&&Qi(this.dashjs.getSource==="function")&&this.dashjs.getSource(),Pe={player_is_paused:_.paused,player_playhead_time:se(_.currentTime),player_width:parseInt(U(_,"width")),player_height:parseInt(U(_,"height")),player_autoplay_on:_.autoplay,player_preload_on:_.preload,player_language_code:_.lang,player_is_fullscreen:Ht()&&!!(Ht().fullscreenElement||Ht().webkitFullscreenElement||Ht().mozFullScreenElement||Ht().msFullscreenElement),video_poster_url:_.poster,video_source_url:te||me||_.currentSrc,video_source_duration:se(_.duration),video_source_height:_.videoHeight,video_source_width:_.videoWidth,view_dropped_frame_count:(Z=_)===null||Z===void 0||(z=Z.getVideoPlaybackQuality)===null||z===void 0?void 0:z.call(Z).droppedVideoFrames},Oe=x.getPlayheadTime();if(_.getStartDate&&Oe>0){var je=_.getStartDate();if(je&&typeof je.getTime=="function"&&je.getTime()){var it=je.getTime();if(Pe.player_program_time=it+Oe,_.seekable.length>0){var fe=it+_.seekable.end(_.seekable.length-1);Pe.player_live_edge_program_time=fe}}}return Pe},_.mux=_.mux||{},_.mux.deleted=!1,_.mux.emit=function(Z,z){g.emit(R,Z,z)};var Q=function(){I.error("The monitor for this video element has already been destroyed.")};_.mux.destroy=function(){Object.keys(_.mux.listeners).forEach(function(Z){_.removeEventListener(Z,_.mux.listeners[Z],!1)}),delete _.mux.listeners,_.mux.destroy=Q,_.mux.swapElement=Q,_.mux.emit=Q,_.mux.addHLSJS=Q,_.mux.addDashJS=Q,_.mux.removeHLSJS=Q,_.mux.removeDashJS=Q,_.mux.deleted=!0,g.emit(R,"destroy")},_.mux.swapElement=function(Z){var z=En(m(Z),3),te=z[0],me=z[1],Pe=z[2];return te?Pe!=="video"&&Pe!=="audio"?g.log.error("The element of `"+me+"` was not a media element."):(te.muxId=_.muxId,delete _.muxId,te.mux=te.mux||{},te.mux.listeners=Object.assign({},_.mux.listeners),delete _.mux.listeners,Object.keys(te.mux.listeners).forEach(function(Oe){_.removeEventListener(Oe,te.mux.listeners[Oe],!1),te.addEventListener(Oe,te.mux.listeners[Oe],!1)}),te.mux.swapElement=_.mux.swapElement,te.mux.destroy=_.mux.destroy,delete _.mux,void(_=te)):g.log.error("No element was found with the `"+me+"` query selector.")},_.mux.addHLSJS=function(Z){g.addHLSJS(R,Z)},_.mux.addDashJS=function(Z){g.addDashJS(R,Z)},_.mux.removeHLSJS=function(){g.removeHLSJS(R)},_.mux.removeDashJS=function(){g.removeDashJS(R)},g.init(R,x),g.emit(R,"playerready"),_.paused||(g.emit(R,"play"),_.readyState>2&&g.emit(R,"playing")),_.mux.listeners={},El.forEach(function(Z){(Z!=="error"||x.automaticErrorTracking)&&(_.mux.listeners[Z]=function(){var z={};if(Z==="error"){if(!_.error||_.error.code===1)return;z.player_error_code=_.error.code,z.player_error_message=xl[_.error.code]||_.error.message}g.emit(R,Z,z)},_.addEventListener(Z,_.mux.listeners[Z],!1))})}(Kt,p,f)},destroyMonitor:function(p){var f=Nl(m(p),1)[0];f&&f.mux&&typeof f.mux.destroy=="function"?f.mux.destroy():A.error("A video element monitor for `"+p+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(p,f){var g=h(p);tt[g]?tt[g].addHLSJS(f):A.error("A monitor for `"+g+"` has not been initialized.")},addDashJS:function(p,f){var g=h(p);tt[g]?tt[g].addDashJS(f):A.error("A monitor for `"+g+"` has not been initialized.")},removeHLSJS:function(p){var f=h(p);tt[f]?tt[f].removeHLSJS():A.error("A monitor for `"+f+"` has not been initialized.")},removeDashJS:function(p){var f=h(p);tt[f]?tt[f].removeDashJS():A.error("A monitor for `"+f+"` has not been initialized.")},init:function(p,f){D()&&f&&f.respectDoNotTrack&&A.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var g=h(p);tt[g]=new vl(Kt,g,f)},emit:function(p,f,g){var T=h(p);tt[T]?(tt[T].emit(f,g),f==="destroy"&&delete tt[T]):A.error("A monitor for `"+T+"` has not been initialized.")},checkDoNotTrack:D,log:A,utils:Ml,events:Fl,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Kt,Ul),c()!==void 0&&typeof c().addEventListener=="function"&&c().addEventListener("pagehide",function(p){p.persisted||(Kt.WINDOW_UNLOADING=!0)},!1);var Bl=Kt},655:function(s,n,o){var l,c;function u(d){return u=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},u(d);}(function(d){var h=!1;if((c=typeof(l=d)=="function"?l.call(n,o,n,s):l)===void 0||(s.exports=c),h=!0,u(n)==="object"&&(s.exports=d(),h=!0),!h){var m=window.Cookies,y=window.Cookies=d();y.noConflict=function(){return window.Cookies=m,y}}})(function(){var d=function(){for(var h=0,m={};h<arguments.length;h++){var y=arguments[h];for(var E in y)m[E]=y[E]}return m};return function h(m){function y(E,b,A){var D;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(A=d({path:"/"},y.defaults,A)).expires=="number"){var L=new Date;L.setMilliseconds(L.getMilliseconds()+864e5*A.expires),A.expires=L}try{D=JSON.stringify(b),/^[\{\[]/.test(D)&&(b=D)}catch{}return b=m.write?m.write(b,E):encodeURIComponent(String(b)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),E=(E=(E=encodeURIComponent(String(E))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[E,"=",b,A.expires?"; expires="+A.expires.toUTCString():"",A.path?"; path="+A.path:"",A.domain?"; domain="+A.domain:"",A.secure?"; secure":""].join("")}E||(D={});for(var F=document.cookie?document.cookie.split("; "):[],k=/(%[0-9A-Z]{2})+/g,G=0;G<F.length;G++){var M=F[G].split("="),$=M.slice(1).join("=");$.charAt(0)==='"'&&($=$.slice(1,-1));try{var K=M[0].replace(k,decodeURIComponent);if($=m.read?m.read($,K):m($,K)||$.replace(k,decodeURIComponent),this.json)try{$=JSON.parse($)}catch{}if(E===K){D=$;break}E||(D[K]=$)}catch{}}return D}}return y.set=y,y.get=function(E){return y.call(y,E)},y.getJSON=function(){return y.apply({json:!0},[].slice.call(arguments))},y.defaults={},y.remove=function(E,b){y(E,"",d(b,{expires:-1}))},y.withConverter=h,y}(function(){})})},153:function(s,n,o){var l,c=o.g!==void 0?o.g:typeof window!="undefined"?window:{},u=o(558);typeof document!="undefined"?l=document:(l=c["__GLOBAL_DOCUMENT_CACHE@4"])||(l=c["__GLOBAL_DOCUMENT_CACHE@4"]=u),s.exports=l},48:function(s,n,o){var l;l=typeof window!="undefined"?window:o.g!==void 0?o.g:typeof self!="undefined"?self:{},s.exports=l},640:function(s,n,o){var l,c;(function(u,d){"use strict";l=function(){var h=function(){},m="undefined",y=typeof window!==m&&typeof window.navigator!==m&&/Trident\/|MSIE /.test(window.navigator.userAgent),E=["trace","debug","info","warn","error"];function b(P,q){var H=P[q];if(typeof H.bind=="function")return H.bind(P);try{return Function.prototype.bind.call(H,P)}catch{return function(){return Function.prototype.apply.apply(H,[P,arguments])}}}function A(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function D(P){return P==="debug"&&(P="log"),typeof console!==m&&(P==="trace"&&y?A:console[P]!==void 0?b(console,P):console.log!==void 0?b(console,"log"):h)}function L(P,q){for(var H=0;H<E.length;H++){var ce=E[H];this[ce]=H<P?h:this.methodFactory(ce,P,q)}this.log=this.debug}function F(P,q,H){return function(){typeof console!==m&&(L.call(this,q,H),this[P].apply(this,arguments))}}function k(P,q,H){return D(P)||F.apply(this,arguments)}function G(P,q,H){var ce,oe=this;q=q==null?"WARN":q;var le="loglevel";function Te(Y){var de=(E[Y]||"silent").toUpperCase();if(typeof window!==m&&le){try{return void(window.localStorage[le]=de)}catch{}try{window.document.cookie=encodeURIComponent(le)+"="+de+";"}catch{}}}function ge(){var Y;if(typeof window!==m&&le){try{Y=window.localStorage[le]}catch{}if(typeof Y===m)try{var de=window.document.cookie,he=de.indexOf(encodeURIComponent(le)+"=");he!==-1&&(Y=/^([^;]+)/.exec(de.slice(he))[1])}catch{}return oe.levels[Y]===void 0&&(Y=void 0),Y}}function j(){if(typeof window!==m&&le){try{return void window.localStorage.removeItem(le)}catch{}try{window.document.cookie=encodeURIComponent(le)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof P=="string"?le+=":"+P:typeof P=="symbol"&&(le=void 0),oe.name=P,oe.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},oe.methodFactory=H||k,oe.getLevel=function(){return ce},oe.setLevel=function(Y,de){if(typeof Y=="string"&&oe.levels[Y.toUpperCase()]!==void 0&&(Y=oe.levels[Y.toUpperCase()]),!(typeof Y=="number"&&Y>=0&&Y<=oe.levels.SILENT))throw"log.setLevel() called with invalid level: "+Y;if(ce=Y,de!==!1&&Te(Y),L.call(oe,Y,P),typeof console===m&&Y<oe.levels.SILENT)return"No console available for logging"},oe.setDefaultLevel=function(Y){q=Y,ge()||oe.setLevel(Y,!1)},oe.resetLevel=function(){oe.setLevel(q,!1),j()},oe.enableAll=function(Y){oe.setLevel(oe.levels.TRACE,Y)},oe.disableAll=function(Y){oe.setLevel(oe.levels.SILENT,Y)};var X=ge();X==null&&(X=q),oe.setLevel(X,!1)}var M=new G,$={};M.getLogger=function(P){if(typeof P!="symbol"&&typeof P!="string"||P==="")throw new TypeError("You must supply a name when creating a logger.");var q=$[P];return q||(q=$[P]=new G(P,M.getLevel(),M.methodFactory)),q};var K=typeof window!==m?window.log:void 0;return M.noConflict=function(){return typeof window!==m&&window.log===M&&(window.log=K),M},M.getLoggers=function(){return $},M.default=M,M},(c=typeof l=="function"?l.call(n,o,n,s):l)===void 0||(s.exports=c)})()},375:function(s,n){"use strict";var o=Object.prototype.hasOwnProperty;function l(u){try{return decodeURIComponent(u.replace(/\+/g," "))}catch{return null}}function c(u){try{return encodeURIComponent(u)}catch{return null}}n.stringify=function(u,d){d=d||"";var h,m,y=[];for(m in typeof d!="string"&&(d="?"),u)if(o.call(u,m)){if((h=u[m])||h!=null&&!isNaN(h)||(h=""),m=c(m),h=c(h),m===null||h===null)continue;y.push(m+"="+h)}return y.length?d+y.join("&"):""},n.parse=function(u){for(var d,h=/([^=?#&]+)=?([^&]*)/g,m={};d=h.exec(u);){var y=l(d[1]),E=l(d[2]);y===null||E===null||y in m||(m[y]=E)}return m}},558:function(){}},i={};function r(s){var n=i[s];if(n!==void 0)return n.exports;var o=i[s]={exports:{}};return t[s].call(o.exports,o,o.exports,r),o.exports}return r.n=function(s){var n=s&&s.__esModule?function(){return s.default}:function(){return s};return r.d(n,{a:n}),n},r.d=function(s,n){for(var o in n)r.o(n,o)&&!r.o(s,o)&&Object.defineProperty(s,o,{enumerable:!0,get:n[o]})},r.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),r.o=function(s,n){return Object.prototype.hasOwnProperty.call(s,n)},r(80)}()},typeof ci=="object"&&typeof er=="object"?er.exports=e():typeof ci=="object"?ci.mux=e():a.mux=e()})()});var ji=Xl(An());function Ql(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var ha={exports:{}};(function(a,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,s=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,c,u){if(u=u||{},l=l.trim(),c=c.trim(),!c){if(!u.alwaysNormalize)return l;var d=o.parseURL(l);if(!d)throw new Error("Error trying to parse base URL.");return d.path=o.normalizePath(d.path),o.buildURLFromParts(d)}var h=o.parseURL(c);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):c;var m=o.parseURL(l);if(!m)throw new Error("Error trying to parse base URL.");if(!m.netLoc&&m.path&&m.path[0]!=="/"){var y=r.exec(m.path);m.netLoc=y[1],m.path=y[2]}m.netLoc&&!m.path&&(m.path="/");var E={scheme:m.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(E.netLoc=m.netLoc,h.path[0]!=="/"))if(!h.path)E.path=m.path,h.params||(E.params=m.params,h.query||(E.query=m.query));else{var b=m.path,A=b.substring(0,b.lastIndexOf("/")+1)+h.path;E.path=o.normalizePath(A)}return E.path===null&&(E.path=u.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(E)},parseURL:function(l){var c=i.exec(l);return c?{scheme:c[1]||"",netLoc:c[2]||"",path:c[3]||"",params:c[4]||"",query:c[5]||"",fragment:c[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(s,"");l.length!==(l=l.replace(n,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};a.exports=o})()})(ha);var xs=ha.exports;function Ln(a,e){var t=Object.keys(a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(a);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(a,r).enumerable})),t.push.apply(t,i)}return t}function Ze(a){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ln(Object(t),!0).forEach(function(i){Jl(a,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(t)):Ln(Object(t)).forEach(function(i){Object.defineProperty(a,i,Object.getOwnPropertyDescriptor(t,i))})}return a}function Jl(a,e,t){return e=ec(e),e in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}function Ie(){return Ie=Object.assign?Object.assign.bind():function(a){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(a[i]=t[i])}return a},Ie.apply(this,arguments)}function Zl(a,e){if(typeof a!="object"||a===null)return a;var t=a[Symbol.toPrimitive];if(t!==void 0){var i=t.call(a,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function ec(a){var e=Zl(a,"string");return typeof e=="symbol"?e:String(e)}var J=Number.isFinite||function(a){return typeof a=="number"&&isFinite(a)},v=function(a){return a.MEDIA_ATTACHING="hlsMediaAttaching",a.MEDIA_ATTACHED="hlsMediaAttached",a.MEDIA_DETACHING="hlsMediaDetaching",a.MEDIA_DETACHED="hlsMediaDetached",a.BUFFER_RESET="hlsBufferReset",a.BUFFER_CODECS="hlsBufferCodecs",a.BUFFER_CREATED="hlsBufferCreated",a.BUFFER_APPENDING="hlsBufferAppending",a.BUFFER_APPENDED="hlsBufferAppended",a.BUFFER_EOS="hlsBufferEos",a.BUFFER_FLUSHING="hlsBufferFlushing",a.BUFFER_FLUSHED="hlsBufferFlushed",a.MANIFEST_LOADING="hlsManifestLoading",a.MANIFEST_LOADED="hlsManifestLoaded",a.MANIFEST_PARSED="hlsManifestParsed",a.LEVEL_SWITCHING="hlsLevelSwitching",a.LEVEL_SWITCHED="hlsLevelSwitched",a.LEVEL_LOADING="hlsLevelLoading",a.LEVEL_LOADED="hlsLevelLoaded",a.LEVEL_UPDATED="hlsLevelUpdated",a.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",a.LEVELS_UPDATED="hlsLevelsUpdated",a.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",a.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",a.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",a.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",a.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",a.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",a.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",a.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",a.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",a.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",a.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",a.CUES_PARSED="hlsCuesParsed",a.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",a.INIT_PTS_FOUND="hlsInitPtsFound",a.FRAG_LOADING="hlsFragLoading",a.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",a.FRAG_LOADED="hlsFragLoaded",a.FRAG_DECRYPTED="hlsFragDecrypted",a.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",a.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",a.FRAG_PARSING_METADATA="hlsFragParsingMetadata",a.FRAG_PARSED="hlsFragParsed",a.FRAG_BUFFERED="hlsFragBuffered",a.FRAG_CHANGED="hlsFragChanged",a.FPS_DROP="hlsFpsDrop",a.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",a.ERROR="hlsError",a.DESTROYING="hlsDestroying",a.KEY_LOADING="hlsKeyLoading",a.KEY_LOADED="hlsKeyLoaded",a.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",a.BACK_BUFFER_REACHED="hlsBackBufferReached",a}({}),ie=function(a){return a.NETWORK_ERROR="networkError",a.MEDIA_ERROR="mediaError",a.KEY_SYSTEM_ERROR="keySystemError",a.MUX_ERROR="muxError",a.OTHER_ERROR="otherError",a}({}),N=function(a){return a.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",a.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",a.KEY_SYSTEM_NO_SESSION="keySystemNoSession",a.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",a.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",a.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",a.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",a.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",a.MANIFEST_LOAD_ERROR="manifestLoadError",a.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",a.MANIFEST_PARSING_ERROR="manifestParsingError",a.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",a.LEVEL_EMPTY_ERROR="levelEmptyError",a.LEVEL_LOAD_ERROR="levelLoadError",a.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",a.LEVEL_PARSING_ERROR="levelParsingError",a.LEVEL_SWITCH_ERROR="levelSwitchError",a.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",a.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",a.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",a.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",a.FRAG_LOAD_ERROR="fragLoadError",a.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",a.FRAG_DECRYPT_ERROR="fragDecryptError",a.FRAG_PARSING_ERROR="fragParsingError",a.FRAG_GAP="fragGap",a.REMUX_ALLOC_ERROR="remuxAllocError",a.KEY_LOAD_ERROR="keyLoadError",a.KEY_LOAD_TIMEOUT="keyLoadTimeOut",a.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",a.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",a.BUFFER_APPEND_ERROR="bufferAppendError",a.BUFFER_APPENDING_ERROR="bufferAppendingError",a.BUFFER_STALLED_ERROR="bufferStalledError",a.BUFFER_FULL_ERROR="bufferFullError",a.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",a.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",a.INTERNAL_EXCEPTION="internalException",a.INTERNAL_ABORTED="aborted",a.UNKNOWN="unknown",a}({}),Lt=function(){},br={trace:Lt,debug:Lt,log:Lt,warn:Lt,info:Lt,error:Lt},jt=br;function tc(a){let e=self.console[a];return e?e.bind(self.console,`[${a}] >`):Lt}function ic(a,...e){e.forEach(function(t){jt[t]=a[t]?a[t].bind(a):tc(t)})}function rc(a,e){if(self.console&&a===!0||typeof a=="object"){ic(a,"debug","log","info","warn","error");try{jt.log(`Debug logs enabled for "${e}" in hls.js version 1.4.8`)}catch{jt=br}}else jt=br}var w=jt,sc=/^(\d+)x(\d+)$/,Rn=/(.+?)=(".*?"|.*?)(?:,|$)/g,be=class{constructor(e){typeof e=="string"&&(e=be.parseAttrList(e));for(let t in e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let i=new Uint8Array(t.length/2);for(let r=0;r<t.length/2;r++)i[r]=parseInt(t.slice(r*2,r*2+2),16);return i}else return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=sc.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,i={},r='"';for(Rn.lastIndex=0;(t=Rn.exec(e))!==null;){let s=t[2];s.indexOf(r)===0&&s.lastIndexOf(r)===s.length-1&&(s=s.slice(1,-1));let n=t[1].trim();i[n]=s}return i}};function nc(a){return a!=="ID"&&a!=="CLASS"&&a!=="START-DATE"&&a!=="DURATION"&&a!=="END-DATE"&&a!=="END-ON-NEXT"}function ac(a){return a==="SCTE35-OUT"||a==="SCTE35-IN"}var Ei=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let i=t.attr;for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==i[r]){w.warn(`DATERANGE tag attribute: "${r}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=r;break}e=Ie(new be({}),i,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let i=new Date(this.attr["END-DATE"]);J(i.getTime())&&(this._endDate=i)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(J(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&J(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},Bt=class{constructor(){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}}},Ee={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},xi=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Ee.AUDIO]:null,[Ee.VIDEO]:null,[Ee.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let i=e.split("@",2),r=[];i.length===1?r[0]=t?t.byteRangeEndOffset:0:r[0]=parseInt(i[1]),r[1]=parseInt(i[0])+r[0],this._byteRange=r}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=xs.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},Yt=class extends xi{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Bt,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{let i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!J(this.programDateTime))return null;let e=J(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){let t=Object.keys(this.levelkeys),i=t.length;if(i>1||i===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,r,s,n=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:i,startDTS:r,endDTS:s,partial:n};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,r),l.endDTS=Math.max(l.endDTS,s)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[Ee.AUDIO]=null,e[Ee.VIDEO]=null,e[Ee.AUDIOVIDEO]=null}},_r=class extends xi{constructor(e,t,i,r,s){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new Bt,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=r;let n=e.enumeratedString("BYTERANGE");n&&this.setByteRange(n,s),s&&(this.fragOffset=s.fragOffset+s.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}},oc=10,Sr=class{constructor(e){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=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?J(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||oc}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}};function bs(a){return Uint8Array.from(atob(a),e=>e.charCodeAt(0))}function lc(a){let e=fa(a).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function cc(a){let e=function(i,r,s){let n=i[r];i[r]=i[s],i[s]=n};e(a,0,3),e(a,1,2),e(a,4,5),e(a,6,7)}function uc(a){let e=a.split(":"),t=null;if(e[0]==="data"&&e.length===2){let i=e[1].split(";"),r=i[i.length-1].split(",");if(r.length===2){let s=r[0]==="base64",n=r[1];s?(i.splice(-1,1),t=bs(n)):t=lc(n)}}return t}function fa(a){return Uint8Array.from(unescape(encodeURIComponent(a)),e=>e.charCodeAt(0))}var Se={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Je={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function In(a){switch(a){case Je.FAIRPLAY:return Se.FAIRPLAY;case Je.PLAYREADY:return Se.PLAYREADY;case Je.WIDEVINE:return Se.WIDEVINE;case Je.CLEARKEY:return Se.CLEARKEY}}var ga={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function dc(a){if(a===ga.WIDEVINE)return Se.WIDEVINE}function Dn(a){switch(a){case Se.FAIRPLAY:return Je.FAIRPLAY;case Se.PLAYREADY:return Je.PLAYREADY;case Se.WIDEVINE:return Je.WIDEVINE;case Se.CLEARKEY:return Je.CLEARKEY}}function tr(a){let{drmSystems:e,widevineLicenseUrl:t}=a,i=e?[Se.FAIRPLAY,Se.WIDEVINE,Se.PLAYREADY,Se.CLEARKEY].filter(r=>!!e[r]):[];return!i[Se.WIDEVINE]&&t&&i.push(Se.WIDEVINE),i}var ma=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function hc(a,e,t,i){let r;switch(a){case Se.FAIRPLAY:r=["cenc","sinf"];break;case Se.WIDEVINE:case Se.PLAYREADY:r=["cenc"];break;case Se.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${a}`)}return fc(r,e,t,i)}function fc(a,e,t,i){return[{initDataTypes:a,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(s=>({contentType:`audio/mp4; codecs="${s}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(s=>({contentType:`video/mp4; codecs="${s}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function Rt(a,e,t){return Uint8Array.prototype.slice?a.slice(e,t):new Uint8Array(Array.prototype.slice.call(a,e,t))}var _s=(a,e)=>e+10<=a.length&&a[e]===73&&a[e+1]===68&&a[e+2]===51&&a[e+3]<255&&a[e+4]<255&&a[e+6]<128&&a[e+7]<128&&a[e+8]<128&&a[e+9]<128,pa=(a,e)=>e+10<=a.length&&a[e]===51&&a[e+1]===68&&a[e+2]===73&&a[e+3]<255&&a[e+4]<255&&a[e+6]<128&&a[e+7]<128&&a[e+8]<128&&a[e+9]<128,bi=(a,e)=>{let t=e,i=0;for(;_s(a,e);){i+=10;let r=Gi(a,e+6);i+=r,pa(a,e+10)&&(i+=10),e+=i}if(i>0)return a.subarray(t,t+i)},Gi=(a,e)=>{let t=0;return t=(a[e]&127)<<21,t|=(a[e+1]&127)<<14,t|=(a[e+2]&127)<<7,t|=a[e+3]&127,t},gc=(a,e)=>_s(a,e)&&Gi(a,e+6)+10<=a.length-e,mc=a=>{let e=va(a);for(let t=0;t<e.length;t++){let i=e[t];if(ya(i))return xc(i)}},ya=a=>a&&a.key==="PRIV"&&a.info==="com.apple.streaming.transportStreamTimestamp",pc=a=>{let e=String.fromCharCode(a[0],a[1],a[2],a[3]),t=Gi(a,4),i=10;return{type:e,size:t,data:a.subarray(i,i+t)}},va=a=>{let e=0,t=[];for(;_s(a,e);){let i=Gi(a,e+6);e+=10;let r=e+i;for(;e+8<r;){let s=pc(a.subarray(e)),n=yc(s);n&&t.push(n),e+=s.size+10}pa(a,e)&&(e+=10)}return t},yc=a=>a.type==="PRIV"?vc(a):a.type[0]==="W"?Ec(a):Tc(a),vc=a=>{if(a.size<2)return;let e=ft(a.data,!0),t=new Uint8Array(a.data.subarray(e.length+1));return{key:a.type,info:e,data:t.buffer}},Tc=a=>{if(a.size<2)return;if(a.type==="TXXX"){let t=1,i=ft(a.data.subarray(t),!0);t+=i.length+1;let r=ft(a.data.subarray(t));return{key:a.type,info:i,data:r}}let e=ft(a.data.subarray(1));return{key:a.type,data:e}},Ec=a=>{if(a.type==="WXXX"){if(a.size<2)return;let t=1,i=ft(a.data.subarray(t),!0);t+=i.length+1;let r=ft(a.data.subarray(t));return{key:a.type,info:i,data:r}}let e=ft(a.data);return{key:a.type,data:e}},xc=a=>{if(a.data.byteLength===8){let e=new Uint8Array(a.data),t=e[3]&1,i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}},ft=(a,e=!1)=>{let t=bc();if(t){let c=t.decode(a);if(e){let u=c.indexOf("\0");return u!==-1?c.substring(0,u):c}return c.replace(/\0/g,"")}let i=a.length,r,s,n,o="",l=0;for(;l<i;){if(r=a[l++],r===0&&e)return o;if(r===0||r===3)continue;switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(r);break;case 12:case 13:s=a[l++],o+=String.fromCharCode((r&31)<<6|s&63);break;case 14:s=a[l++],n=a[l++],o+=String.fromCharCode((r&15)<<12|(s&63)<<6|(n&63)<<0);break}}return o},ir;function bc(){return!ir&&typeof self.TextDecoder!="undefined"&&(ir=new self.TextDecoder("utf-8")),ir}var lt={hexDump:function(a){let e="";for(let t=0;t<a.length;t++){let i=a[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}},_i=Math.pow(2,32)-1,_c=[].push,Ta={video:1,audio:2,id3:3,text:4};function Fe(a){return String.fromCharCode.apply(null,a)}function Ea(a,e){let t=a[e]<<8|a[e+1];return t<0?65536+t:t}function ne(a,e){let t=xa(a,e);return t<0?4294967296+t:t}function xa(a,e){return a[e]<<24|a[e+1]<<16|a[e+2]<<8|a[e+3]}function rr(a,e,t){a[e]=t>>24,a[e+1]=t>>16&255,a[e+2]=t>>8&255,a[e+3]=t&255}function ye(a,e){let t=[];if(!e.length)return t;let i=a.byteLength;for(let r=0;r<i;){let s=ne(a,r),n=Fe(a.subarray(r+4,r+8)),o=s>1?r+s:i;if(n===e[0])if(e.length===1)t.push(a.subarray(r+8,o));else{let l=ye(a.subarray(r+8,o),e.slice(1));l.length&&_c.apply(t,l)}r=o}return t}function Sc(a){let e=[],t=a[0],i=8,r=ne(a,i);i+=4;let s=0,n=0;t===0?i+=8:i+=16,i+=2;let o=a.length+n,l=Ea(a,i);i+=2;for(let c=0;c<l;c++){let u=i,d=ne(a,u);u+=4;let h=d&2147483647;if((d&2147483648)>>>31===1)return w.warn("SIDX has hierarchical references (not supported)"),null;let y=ne(a,u);u+=4,e.push({referenceSize:h,subsegmentDuration:y,info:{duration:y/r,start:o,end:o+h-1}}),o+=h,u+=4,i=u}return{earliestPresentationTime:s,timescale:r,version:t,referencesCount:l,references:e}}function ba(a){let e=[],t=ye(a,["moov","trak"]);for(let r=0;r<t.length;r++){let s=t[r],n=ye(s,["tkhd"])[0];if(n){let o=n[0],l=o===0?12:20,c=ne(n,l),u=ye(s,["mdia","mdhd"])[0];if(u){o=u[0],l=o===0?12:20;let d=ne(u,l),h=ye(s,["mdia","hdlr"])[0];if(h){let m=Fe(h.subarray(8,12)),y={soun:Ee.AUDIO,vide:Ee.VIDEO}[m];if(y){let E=ye(s,["mdia","minf","stbl","stsd"])[0],b;E&&(b=Fe(E.subarray(12,16))),e[c]={timescale:d,type:y},e[y]={timescale:d,id:c,codec:b}}}}}}return ye(a,["moov","mvex","trex"]).forEach(r=>{let s=ne(r,4),n=e[s];n&&(n.default={duration:ne(r,12),flags:ne(r,20)})}),e}function Ac(a,e){if(!a||!e)return a;let t=e.keyId;return t&&e.isCommonEncryption&&ye(a,["moov","trak"]).forEach(r=>{let n=ye(r,["mdia","minf","stbl","stsd"])[0].subarray(8),o=ye(n,["enca"]),l=o.length>0;l||(o=ye(n,["encv"])),o.forEach(c=>{let u=l?c.subarray(28):c.subarray(78);ye(u,["sinf"]).forEach(h=>{let m=_a(h);if(m){let y=m.subarray(8,24);y.some(E=>E!==0)||(w.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${lt.hexDump(y)} -> ${lt.hexDump(t)}`),m.set(t,8))}})})}),a}function _a(a){let e=ye(a,["schm"])[0];if(e){let t=Fe(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return ye(a,["schi","tenc"])[0]}return w.error("[eme] missing 'schm' box"),null}function Lc(a,e){return ye(e,["moof","traf"]).reduce((t,i)=>{let r=ye(i,["tfdt"])[0],s=r[0],n=ye(i,["tfhd"]).reduce((o,l)=>{let c=ne(l,4),u=a[c];if(u){let d=ne(r,4);if(s===1){if(d===_i)return w.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;d*=_i+1,d+=ne(r,8)}let h=u.timescale||9e4,m=d/h;if(isFinite(m)&&(o===null||m<o))return m}return o},null);return n!==null&&isFinite(n)&&(t===null||n<t)?n:t},null)}function Rc(a,e){let t=0,i=0,r=0,s=ye(a,["moof","traf"]);for(let n=0;n<s.length;n++){let o=s[n],l=ye(o,["tfhd"])[0],c=ne(l,4),u=e[c];if(!u)continue;let d=u.default,h=ne(l,0)|(d==null?void 0:d.flags),m=d==null?void 0:d.duration;h&8&&(h&2?m=ne(l,12):m=ne(l,8));let y=u.timescale||9e4,E=ye(o,["trun"]);for(let b=0;b<E.length;b++){if(t=Ic(E[b]),!t&&m){let A=ne(E[b],4);t=m*A}u.type===Ee.VIDEO?i+=t/y:u.type===Ee.AUDIO&&(r+=t/y)}}if(i===0&&r===0){let n=0,o=ye(a,["sidx"]);for(let l=0;l<o.length;l++){let c=Sc(o[l]);c!=null&&c.references&&(n+=c.references.reduce((u,d)=>u+d.info.duration||0,0))}return n}return i||r}function Ic(a){let e=ne(a,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let i=0,r=ne(a,4);for(let s=0;s<r;s++){if(e&256){let n=ne(a,t);i+=n,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return i}function Dc(a,e,t){ye(e,["moof","traf"]).forEach(i=>{ye(i,["tfhd"]).forEach(r=>{let s=ne(r,4),n=a[s];if(!n)return;let o=n.timescale||9e4;ye(i,["tfdt"]).forEach(l=>{let c=l[0],u=ne(l,4);if(c===0)u-=t*o,u=Math.max(u,0),rr(l,4,u);else{u*=Math.pow(2,32),u+=ne(l,8),u-=t*o,u=Math.max(u,0);let d=Math.floor(u/(_i+1)),h=Math.floor(u%(_i+1));rr(l,4,d),rr(l,8,h)}})})})}function wc(a){let e={valid:null,remainder:null},t=ye(a,["moof"]);if(t){if(t.length<2)return e.remainder=a,e}else return e;let i=t[t.length-1];return e.valid=Rt(a,0,i.byteOffset-8),e.remainder=Rt(a,i.byteOffset-8),e}function It(a,e){let t=new Uint8Array(a.length+e.length);return t.set(a),t.set(e,a.length),t}function wn(a,e){let t=[],i=e.samples,r=e.timescale,s=e.id,n=!1;return ye(i,["moof"]).map(l=>{let c=l.byteOffset-8;ye(l,["traf"]).map(d=>{let h=ye(d,["tfdt"]).map(m=>{let y=m[0],E=ne(m,4);return y===1&&(E*=Math.pow(2,32),E+=ne(m,8)),E/r})[0];return h!==void 0&&(a=h),ye(d,["tfhd"]).map(m=>{let y=ne(m,4),E=ne(m,0)&16777215,b=(E&1)!==0,A=(E&2)!==0,D=(E&8)!==0,L=0,F=(E&16)!==0,k=0,G=(E&32)!==0,M=8;y===s&&(b&&(M+=8),A&&(M+=4),D&&(L=ne(m,M),M+=4),F&&(k=ne(m,M),M+=4),G&&(M+=4),e.type==="video"&&(n=kc(e.codec)),ye(d,["trun"]).map($=>{let K=$[0],P=ne($,0)&16777215,q=(P&1)!==0,H=0,ce=(P&4)!==0,oe=(P&256)!==0,le=0,Te=(P&512)!==0,ge=0,j=(P&1024)!==0,X=(P&2048)!==0,Y=0,de=ne($,4),he=8;q&&(H=ne($,he),he+=4),ce&&(he+=4);let _e=H+c;for(let Ge=0;Ge<de;Ge++){if(oe?(le=ne($,he),he+=4):le=L,Te?(ge=ne($,he),he+=4):ge=k,j&&(he+=4),X&&(K===0?Y=ne($,he):Y=xa($,he),he+=4),e.type===Ee.VIDEO){let qe=0;for(;qe<ge;){let We=ne(i,_e);if(_e+=4,Cc(n,i[_e])){let pt=i.subarray(_e,_e+We);Sa(pt,n?2:1,a+Y/r,t)}_e+=We,qe+=We+4}}a+=le/r}}))})})}),t}function kc(a){if(!a)return!1;let e=a.indexOf("."),t=e<0?a:a.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function Cc(a,e){if(a){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Sa(a,e,t,i){let r=Aa(a),s=0;s+=e;let n=0,o=0,l=!1,c=0;for(;s<r.length;){n=0;do{if(s>=r.length)break;c=r[s++],n+=c}while(c===255);o=0;do{if(s>=r.length)break;c=r[s++],o+=c}while(c===255);let u=r.length-s;if(!l&&n===4&&s<r.length){if(l=!0,r[s++]===181){let h=Ea(r,s);if(s+=2,h===49){let m=ne(r,s);if(s+=4,m===1195456820){let y=r[s++];if(y===3){let E=r[s++],b=31&E,A=64&E,D=A?2+b*3:0,L=new Uint8Array(D);if(A){L[0]=E;for(let F=1;F<D;F++)L[F]=r[s++]}i.push({type:y,payloadType:n,pts:t,bytes:L})}}}}}else if(n===5&&o<u){if(l=!0,o>16){let d=[];for(let y=0;y<16;y++){let E=r[s++].toString(16);d.push(E.length==1?"0"+E:E),(y===3||y===5||y===7||y===9)&&d.push("-")}let h=o-16,m=new Uint8Array(h);for(let y=0;y<h;y++)m[y]=r[s++];i.push({payloadType:n,pts:t,uuid:d.join(""),userData:ft(m),userDataBytes:m})}}else if(o<u)s+=o;else if(o>u)break}}function Aa(a){let e=a.byteLength,t=[],i=1;for(;i<e-2;)a[i]===0&&a[i+1]===0&&a[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return a;let r=e-t.length,s=new Uint8Array(r),n=0;for(i=0;i<r;n++,i++)n===t[0]&&(n++,t.shift()),s[i]=a[n];return s}function Pc(a){let e=a[0],t="",i="",r=0,s=0,n=0,o=0,l=0,c=0;if(e===0){for(;Fe(a.subarray(c,c+1))!=="\0";)t+=Fe(a.subarray(c,c+1)),c+=1;for(t+=Fe(a.subarray(c,c+1)),c+=1;Fe(a.subarray(c,c+1))!=="\0";)i+=Fe(a.subarray(c,c+1)),c+=1;i+=Fe(a.subarray(c,c+1)),c+=1,r=ne(a,12),s=ne(a,16),o=ne(a,20),l=ne(a,24),c=28}else if(e===1){c+=4,r=ne(a,c),c+=4;let d=ne(a,c);c+=4;let h=ne(a,c);for(c+=4,n=2**32*d+h,Number.isSafeInteger(n)||(n=Number.MAX_SAFE_INTEGER,w.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ne(a,c),c+=4,l=ne(a,c),c+=4;Fe(a.subarray(c,c+1))!=="\0";)t+=Fe(a.subarray(c,c+1)),c+=1;for(t+=Fe(a.subarray(c,c+1)),c+=1;Fe(a.subarray(c,c+1))!=="\0";)i+=Fe(a.subarray(c,c+1)),c+=1;i+=Fe(a.subarray(c,c+1)),c+=1}let u=a.subarray(c,a.byteLength);return{schemeIdUri:t,value:i,timeScale:r,presentationTime:n,presentationTimeDelta:s,eventDuration:o,id:l,payload:u}}function Oc(a,...e){let t=e.length,i=8,r=t;for(;r--;)i+=e[r].byteLength;let s=new Uint8Array(i);for(s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=i&255,s.set(a,4),r=0,i=8;r<t;r++)s.set(e[r],i),i+=e[r].byteLength;return s}function Mc(a,e,t){if(a.byteLength!==16)throw new RangeError("Invalid system id");let i,r;if(e){i=1,r=new Uint8Array(e.length*16);for(let o=0;o<e.length;o++){let l=e[o];if(l.byteLength!==16)throw new RangeError("Invalid key");r.set(l,o*16)}}else i=0,r=new Uint8Array;let s;i>0?(s=new Uint8Array(4),e.length>0&&new DataView(s.buffer).setUint32(0,e.length,!1)):s=new Uint8Array;let n=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(n.buffer).setUint32(0,t.byteLength,!1),Oc([112,115,115,104],new Uint8Array([i,0,0,0]),a,s,r,n,t||new Uint8Array)}function Fc(a){if(!(a instanceof ArrayBuffer)||a.byteLength<32)return null;let e={version:0,systemId:"",kids:null,data:null},t=new DataView(a),i=t.getUint32(0);if(a.byteLength!==i&&i>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=lt.hexDump(new Uint8Array(a,12,16));let s=t.getUint32(28);if(e.version===0){if(i-32<s)return null;e.data=new Uint8Array(a,32,s)}else if(e.version===1){e.kids=[];for(let n=0;n<s;n++)e.kids.push(new Uint8Array(a,32+n*16,16))}return e}var ui={},Dt=class{static clearKeyUriToKeyIdMap(){ui={}}constructor(e,t,i,r=[1],s=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=i,this.keyFormatVersions=r,this.iv=s,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){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 Je.FAIRPLAY:case Je.WIDEVINE:case Je.PLAYREADY:case Je.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(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&&w.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let i=Nc(e);return new Dt(this.method,this.uri,"identity",this.keyFormatVersions,i)}let t=uc(this.uri);if(t)switch(this.keyFormat){case Je.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Je.PLAYREADY:{let i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Mc(i,null,t);let r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),s=String.fromCharCode.apply(null,Array.from(r)),n=s.substring(s.indexOf("<"),s.length),c=new DOMParser().parseFromString(n,"text/xml").getElementsByTagName("KID")[0];if(c){let u=c.childNodes[0]?c.childNodes[0].nodeValue:c.getAttribute("VALUE");if(u){let d=bs(u).subarray(0,16);cc(d),this.keyId=d}}break}default:{let i=t.subarray(0,16);if(i.length!==16){let r=new Uint8Array(16);r.set(i,16-i.length),i=r}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=ui[this.uri];if(!i){let r=Object.keys(ui).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,r),ui[this.uri]=i}this.keyId=i}return this}};function Nc(a){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=a>>8*(15-t)&255;return e}var La=/\{\$([a-zA-Z0-9-_]+)\}/g;function kn(a){return La.test(a)}function Xe(a,e,t){if(a.variableList!==null||a.hasVariableRefs)for(let i=t.length;i--;){let r=t[i],s=e[r];s&&(e[r]=Ar(a,s))}}function Ar(a,e){if(a.variableList!==null||a.hasVariableRefs){let t=a.variableList;return e.replace(La,i=>{let r=i.substring(2,i.length-1),s=t==null?void 0:t[r];return s===void 0?(a.playlistParsingError||(a.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),i):s})}return e}function Cn(a,e,t){let i=a.variableList;i||(a.variableList=i={});let r,s;if("QUERYPARAM"in e){r=e.QUERYPARAM;try{let n=new self.URL(t).searchParams;if(n.has(r))s=n.get(r);else throw new Error(`"${r}" does not match any query parameter in URI: "${t}"`)}catch(n){a.playlistParsingError||(a.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${n.message}`))}}else r=e.NAME,s=e.VALUE;r in i?a.playlistParsingError||(a.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):i[r]=s||""}function Uc(a,e,t){let i=e.IMPORT;if(t&&i in t){let r=a.variableList;r||(a.variableList=r={}),r[i]=t[i]}else a.playlistParsingError||(a.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function Hi(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var Bc={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}},Pn=Hi();function $c(a,e){let t=Bc[e];return!!t&&t[a.slice(0,4)]===!0}function sr(a,e){var t;return(t=Pn==null?void 0:Pn.isTypeSupported(`${e||"video"}/mp4;codecs="${a}"`))!=null?t:!1}var On=/#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,Mn=/#EXT-X-MEDIA:(.*)/g,Gc=/^#EXT(?:INF|-X-TARGETDURATION):/m,Fn=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Hc=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("|")),et=class{static findGroup(e,t){for(let i=0;i<e.length;i++){let r=e[i];if(r.id===t)return r}}static convertAVC1ToAVCOTI(e){let t=e.split(".");if(t.length>2){let i=t.shift()+".";return i+=parseInt(t.shift()).toString(16),i+=("000"+parseInt(t.shift()).toString(16)).slice(-4),i}return e}static resolve(e,t){return xs.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Gc.test(e)}static parseMasterPlaylist(e,t){let i=kn(e),r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},s=[];On.lastIndex=0;let n;for(;(n=On.exec(e))!=null;)if(n[1]){var o;let c=new be(n[1]);Xe(r,c,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let u=Ar(r,n[2]),d={attrs:c,bitrate:c.decimalInteger("AVERAGE-BANDWIDTH")||c.decimalInteger("BANDWIDTH"),name:c.NAME,url:et.resolve(u,t)},h=c.decimalResolution("RESOLUTION");h&&(d.width=h.width,d.height=h.height),Kc((c.CODECS||"").split(/[ ,]+/).filter(m=>m),d),d.videoCodec&&d.videoCodec.indexOf("avc1")!==-1&&(d.videoCodec=et.convertAVC1ToAVCOTI(d.videoCodec)),(o=d.unknownCodecs)!=null&&o.length||s.push(d),r.levels.push(d)}else if(n[3]){let c=n[3],u=n[4];switch(c){case"SESSION-DATA":{let d=new be(u);Xe(r,d,["DATA-ID","LANGUAGE","VALUE","URI"]);let h=d["DATA-ID"];h&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[h]=d);break}case"SESSION-KEY":{let d=Nn(u,t,r);d.encrypted&&d.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(d)):w.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{let d=new be(u);Xe(r,d,["NAME","VALUE","QUERYPARAM"]),Cn(r,d,t)}break}case"CONTENT-STEERING":{let d=new be(u);Xe(r,d,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:et.resolve(d["SERVER-URI"],t),pathwayId:d["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=Un(u);break}}}let l=s.length>0&&s.length<r.levels.length;return r.levels=l?s:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,i){let r,s={},n=i.levels,o={AUDIO:n.map(c=>({id:c.attrs.AUDIO,audioCodec:c.audioCodec})),SUBTITLES:n.map(c=>({id:c.attrs.SUBTITLES,textCodec:c.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(Mn.lastIndex=0;(r=Mn.exec(e))!==null;){let c=new be(r[1]),u=c.TYPE;if(u){let d=o[u],h=s[u]||[];s[u]=h,Xe(i,c,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let m={attrs:c,bitrate:0,id:l++,groupId:c["GROUP-ID"]||"",instreamId:c["INSTREAM-ID"],name:c.NAME||c.LANGUAGE||"",type:u,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:c.LANGUAGE,url:c.URI?et.resolve(c.URI,t):""};if(d!=null&&d.length){let y=et.findGroup(d,m.groupId)||d[0];Bn(m,y,"audioCodec"),Bn(m,y,"textCodec")}h.push(m)}}return s}static parseLevelPlaylist(e,t,i,r,s,n){let o=new Sr(t),l=o.fragments,c=null,u=0,d=0,h=0,m=0,y=null,E=new Yt(r,t),b,A,D,L=-1,F=!1;for(Fn.lastIndex=0,o.m3u8=e,o.hasVariableRefs=kn(e);(b=Fn.exec(e))!==null;){F&&(F=!1,E=new Yt(r,t),E.start=h,E.sn=u,E.cc=m,E.level=i,c&&(E.initSegment=c,E.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null));let $=b[1];if($){E.duration=parseFloat($);let K=(" "+b[2]).slice(1);E.title=K||null,E.tagList.push(K?["INF",$,K]:["INF",$])}else if(b[3]){if(J(E.duration)){E.start=h,D&&Hn(E,D,o),E.sn=u,E.level=i,E.cc=m,E.urlId=s,l.push(E);let K=(" "+b[3]).slice(1);E.relurl=Ar(o,K),$n(E,y),y=E,h+=E.duration,u++,d=0,F=!0}}else if(b[4]){let K=(" "+b[4]).slice(1);y?E.setByteRange(K,y):E.setByteRange(K)}else if(b[5])E.rawProgramDateTime=(" "+b[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),L===-1&&(L=l.length);else{if(b=b[0].match(Hc),!b){w.warn("No matches on slow regex match for level playlist!");continue}for(A=1;A<b.length&&typeof b[A]=="undefined";A++);let K=(" "+b[A]).slice(1),P=(" "+b[A+1]).slice(1),q=b[A+2]?(" "+b[A+2]).slice(1):"";switch(K){case"PLAYLIST-TYPE":o.type=P.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(P);break;case"SKIP":{let H=new be(P);Xe(o,H,["RECENTLY-REMOVED-DATERANGES"]);let ce=H.decimalInteger("SKIPPED-SEGMENTS");if(J(ce)){o.skippedSegments=ce;for(let le=ce;le--;)l.unshift(null);u+=ce}let oe=H.enumeratedString("RECENTLY-REMOVED-DATERANGES");oe&&(o.recentlyRemovedDateranges=oe.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(P),1);break;case"VERSION":o.version=parseInt(P);break;case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(P||q)&&E.tagList.push(q?[P,q]:[P]);break;case"DISCONTINUITY":m++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([K]);break;case"BITRATE":E.tagList.push([K,P]);break;case"DATERANGE":{let H=new be(P);Xe(o,H,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Xe(o,H,H.clientAttrs);let ce=new Ei(H,o.dateRanges[H.ID]);ce.isValid||o.skippedSegments?o.dateRanges[ce.id]=ce:w.warn(`Ignoring invalid DATERANGE tag: "${P}"`),E.tagList.push(["EXT-X-DATERANGE",P]);break}case"DEFINE":{{let H=new be(P);Xe(o,H,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in H?Uc(o,H,n):Cn(o,H,t)}break}case"DISCONTINUITY-SEQUENCE":m=parseInt(P);break;case"KEY":{let H=Nn(P,t,o);if(H.isSupported()){if(H.method==="NONE"){D=void 0;break}D||(D={}),D[H.keyFormat]&&(D=Ie({},D)),D[H.keyFormat]=H}else w.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${P}"`);break}case"START":o.startTimeOffset=Un(P);break;case"MAP":{let H=new be(P);if(Xe(o,H,["BYTERANGE","URI"]),E.duration){let ce=new Yt(r,t);Gn(ce,H,i,D),c=ce,E.initSegment=c,c.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=c.rawProgramDateTime)}else Gn(E,H,i,D),c=E,F=!0;break}case"SERVER-CONTROL":{let H=new be(P);o.canBlockReload=H.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=H.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&H.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=H.optionalFloat("PART-HOLD-BACK",0),o.holdBack=H.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let H=new be(P);o.partTarget=H.decimalFloatingPoint("PART-TARGET");break}case"PART":{let H=o.partList;H||(H=o.partList=[]);let ce=d>0?H[H.length-1]:void 0,oe=d++,le=new be(P);Xe(o,le,["BYTERANGE","URI"]);let Te=new _r(le,E,t,oe,ce);H.push(Te),E.duration+=Te.duration;break}case"PRELOAD-HINT":{let H=new be(P);Xe(o,H,["URI"]),o.preloadHint=H;break}case"RENDITION-REPORT":{let H=new be(P);Xe(o,H,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(H);break}default:w.warn(`line parsed but not handled: ${b}`);break}}}y&&!y.relurl?(l.pop(),h-=y.duration,o.partList&&(o.fragmentHint=y)):o.partList&&($n(E,y),E.cc=m,o.fragmentHint=E,D&&Hn(E,D,o));let k=l.length,G=l[0],M=l[k-1];if(h+=o.skippedSegments*o.targetduration,h>0&&k&&M){o.averagetargetduration=h/k;let $=M.sn;o.endSN=$!=="initSegment"?$:0,o.live||(M.endList=!0),G&&(o.startCC=G.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=m,L>0&&Vc(l,L),o}};function Nn(a,e,t){var i,r;let s=new be(a);Xe(t,s,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let n=(i=s.METHOD)!=null?i:"",o=s.URI,l=s.hexadecimalInteger("IV"),c=s.KEYFORMATVERSIONS,u=(r=s.KEYFORMAT)!=null?r:"identity";o&&s.IV&&!l&&w.error(`Invalid IV: ${s.IV}`);let d=o?et.resolve(o,e):"",h=(c||"1").split("/").map(Number).filter(Number.isFinite);return new Dt(n,d,u,h,l)}function Un(a){let t=new be(a).decimalFloatingPoint("TIME-OFFSET");return J(t)?t:null}function Kc(a,e){["video","audio","text"].forEach(t=>{let i=a.filter(r=>$c(r,t));if(i.length){let r=i.filter(s=>s.lastIndexOf("avc1",0)===0||s.lastIndexOf("mp4a",0)===0);e[`${t}Codec`]=r.length>0?r[0]:i[0],a=a.filter(s=>i.indexOf(s)===-1)}}),e.unknownCodecs=a}function Bn(a,e,t){let i=e[t];i&&(a[t]=i)}function Vc(a,e){let t=a[e];for(let i=e;i--;){let r=a[i];if(!r)return;r.programDateTime=t.programDateTime-r.duration*1e3,t=r}}function $n(a,e){a.rawProgramDateTime?a.programDateTime=Date.parse(a.rawProgramDateTime):e!=null&&e.programDateTime&&(a.programDateTime=e.endProgramDateTime),J(a.programDateTime)||(a.programDateTime=null,a.rawProgramDateTime=null)}function Gn(a,e,t,i){a.relurl=e.URI,e.BYTERANGE&&a.setByteRange(e.BYTERANGE),a.level=t,a.sn="initSegment",i&&(a.levelkeys=i),a.initSegment=null}function Hn(a,e,t){a.levelkeys=e;let{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(r=>e[r].isCommonEncryption)&&i.push(a)}var ve={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},re={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Kn(a){let{type:e}=a;switch(e){case ve.AUDIO_TRACK:return re.AUDIO;case ve.SUBTITLE_TRACK:return re.SUBTITLE;default:return re.MAIN}}function nr(a,e){let t=a.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var Lr=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,i=t.pLoader,r=t.loader,s=i||r,n=new s(t);return this.loaders[e.type]=n,n}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ve.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(e,t){let{id:i,level:r,url:s,deliveryDirectives:n}=t;this.load({id:i,level:r,responseType:"text",type:ve.LEVEL,url:s,deliveryDirectives:n})}onAudioTrackLoading(e,t){let{id:i,groupId:r,url:s,deliveryDirectives:n}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ve.AUDIO_TRACK,url:s,deliveryDirectives:n})}onSubtitleTrackLoading(e,t){let{id:i,groupId:r,url:s,deliveryDirectives:n}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ve.SUBTITLE_TRACK,url:s,deliveryDirectives:n})}load(e){var t;let i=this.hls.config,r=this.getInternalLoader(e);if(r){let c=r.context;if(c&&c.url===e.url){w.trace("[playlist-loader]: playlist request ongoing");return}w.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}let s;if(e.type===ve.MANIFEST?s=i.manifestLoadPolicy.default:s=Ie({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part){let c;if(e.type===ve.LEVEL&&e.level!==null?c=this.hls.levels[e.level].details:e.type===ve.AUDIO_TRACK&&e.id!==null?c=this.hls.audioTracks[e.id].details:e.type===ve.SUBTITLE_TRACK&&e.id!==null&&(c=this.hls.subtitleTracks[e.id].details),c){let u=c.partTarget,d=c.targetduration;if(u&&d){let h=Math.max(u*3,d*.8)*1e3;s=Ie({},s,{maxTimeToFirstByteMs:Math.min(h,s.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,s.maxTimeToFirstByteMs)})}}}let n=s.errorRetry||s.timeoutRetry||{},o={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0},l={onSuccess:(c,u,d,h)=>{let m=this.getInternalLoader(d);this.resetInternalLoader(d.type);let y=c.data;if(y.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(c,d,new Error("no EXTM3U delimiter"),h||null,u);return}u.parsing.start=performance.now(),et.isMediaPlaylist(y)?this.handleTrackOrLevelPlaylist(c,u,d,h||null,m):this.handleMasterPlaylist(c,u,d,h)},onError:(c,u,d,h)=>{this.handleNetworkError(u,d,!1,c,h)},onTimeout:(c,u,d)=>{this.handleNetworkError(u,d,!0,void 0,c)}};r.load(e,o,l)}handleMasterPlaylist(e,t,i,r){let s=this.hls,n=e.data,o=nr(e,i),l=et.parseMasterPlaylist(n,o);if(l.playlistParsingError){this.handleManifestParsingError(e,i,l.playlistParsingError,r,t);return}let{contentSteering:c,levels:u,sessionData:d,sessionKeys:h,startTimeOffset:m,variableList:y}=l;this.variableList=y;let{AUDIO:E=[],SUBTITLES:b,"CLOSED-CAPTIONS":A}=et.parseMasterPlaylistMedia(n,o,l);E.length&&!E.some(L=>!L.url)&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(w.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new be({}),bitrate:0,url:""})),s.trigger(v.MANIFEST_LOADED,{levels:u,audioTracks:E,subtitles:b,captions:A,contentSteering:c,url:o,stats:t,networkDetails:r,sessionData:d,sessionKeys:h,startTimeOffset:m,variableList:y})}handleTrackOrLevelPlaylist(e,t,i,r,s){let n=this.hls,{id:o,level:l,type:c}=i,u=nr(e,i),d=J(o)?o:0,h=J(l)?l:d,m=Kn(i),y=et.parseLevelPlaylist(e.data,u,h,m,d,this.variableList);if(c===ve.MANIFEST){let E={attrs:new be({}),bitrate:0,details:y,name:"",url:u};n.trigger(v.MANIFEST_LOADED,{levels:[E],audioTracks:[],url:u,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=y,this.handlePlaylistLoaded(y,e,t,i,r,s)}handleManifestParsingError(e,t,i,r,s){this.hls.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:N.MANIFEST_PARSING_ERROR,fatal:t.type===ve.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:r,stats:s})}handleNetworkError(e,t,i=!1,r,s){let n=`A network ${i?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===ve.LEVEL?n+=`: ${e.level} id: ${e.id}`:(e.type===ve.AUDIO_TRACK||e.type===ve.SUBTITLE_TRACK)&&(n+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(n);w.warn(`[playlist-loader]: ${n}`);let l=N.UNKNOWN,c=!1,u=this.getInternalLoader(e);switch(e.type){case ve.MANIFEST:l=i?N.MANIFEST_LOAD_TIMEOUT:N.MANIFEST_LOAD_ERROR,c=!0;break;case ve.LEVEL:l=i?N.LEVEL_LOAD_TIMEOUT:N.LEVEL_LOAD_ERROR,c=!1;break;case ve.AUDIO_TRACK:l=i?N.AUDIO_TRACK_LOAD_TIMEOUT:N.AUDIO_TRACK_LOAD_ERROR,c=!1;break;case ve.SUBTITLE_TRACK:l=i?N.SUBTITLE_TRACK_LOAD_TIMEOUT:N.SUBTITLE_LOAD_ERROR,c=!1;break}u&&this.resetInternalLoader(e.type);let d={type:ie.NETWORK_ERROR,details:l,fatal:c,url:e.url,loader:u,context:e,error:o,networkDetails:t,stats:s};if(r){let h=(t==null?void 0:t.url)||e.url;d.response=Ze({url:h,data:void 0},r)}this.hls.trigger(v.ERROR,d)}handlePlaylistLoaded(e,t,i,r,s,n){let o=this.hls,{type:l,level:c,id:u,groupId:d,deliveryDirectives:h}=r,m=nr(t,r),y=Kn(r),E=typeof r.level=="number"&&y===re.MAIN?c:void 0;if(!e.fragments.length){let A=new Error("No Segments found in Playlist");o.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:N.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:A,reason:A.message,response:t,context:r,level:E,parent:y,networkDetails:s,stats:i});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let b=e.playlistParsingError;if(b){o.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:N.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:b,reason:b.message,response:t,context:r,level:E,parent:y,networkDetails:s,stats:i});return}switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),(!n.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case ve.MANIFEST:case ve.LEVEL:o.trigger(v.LEVEL_LOADED,{details:e,level:E||0,id:u||0,stats:i,networkDetails:s,deliveryDirectives:h});break;case ve.AUDIO_TRACK:o.trigger(v.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:d||"",stats:i,networkDetails:s,deliveryDirectives:h});break;case ve.SUBTITLE_TRACK:o.trigger(v.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:d||"",stats:i,networkDetails:s,deliveryDirectives:h});break}}};function Ra(a,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=a,e.dispatchEvent(t)}function Ia(a,e){let t=a.mode;if(t==="disabled"&&(a.mode="hidden"),a.cues&&!a.cues.getCueById(e.id))try{if(a.addCue(e),!a.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){w.debug(`[texttrack-utils]: ${i}`);let r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,a.addCue(r)}t==="disabled"&&(a.mode=t)}function Nt(a){let e=a.mode;if(e==="disabled"&&(a.mode="hidden"),a.cues)for(let t=a.cues.length;t--;)a.removeCue(a.cues[t]);e==="disabled"&&(a.mode=e)}function Rr(a,e,t,i){let r=a.mode;if(r==="disabled"&&(a.mode="hidden"),a.cues&&a.cues.length>0){let s=Wc(a.cues,e,t);for(let n=0;n<s.length;n++)(!i||i(s[n]))&&a.removeCue(s[n])}r==="disabled"&&(a.mode=r)}function qc(a,e){if(e<a[0].startTime)return 0;let t=a.length-1;if(e>a[t].endTime)return-1;let i=0,r=t;for(;i<=r;){let s=Math.floor((r+i)/2);if(e<a[s].startTime)r=s-1;else if(e>a[s].startTime&&i<t)i=s+1;else return s}return a[i].startTime-e<e-a[r].startTime?i:r}function Wc(a,e,t){let i=[],r=qc(a,e);if(r>-1)for(let s=r,n=a.length;s<n;s++){let o=a[s];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}var ot={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},jc=.25;function Ir(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var di=(()=>{let a=Ir();try{new a(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function ar(a,e){return a.getTime()/1e3-e}function Yc(a){return Uint8Array.from(a.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Dr=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){!this.id3Track||(Nt(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(!!this.media){for(let t=0;t<e.length;t++){let i=e[t];if(i.kind==="metadata"&&i.label==="id3")return Ra(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:r}}}=this;if(!i&&!r)return;let{samples:s}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let n=Ir();for(let o=0;o<s.length;o++){let l=s[o].type;if(l===ot.emsg&&!i||!r)continue;let c=va(s[o].data);if(c){let u=s[o].pts,d=u+s[o].duration;d>di&&(d=di),d-u<=0&&(d=u+jc);for(let m=0;m<c.length;m++){let y=c[m];if(!ya(y)){this.updateId3CueEnds(u,l);let E=new n(u,d,"");E.value=y,l&&(E.type=l),this.id3Track.addCue(E)}}}}}updateId3CueEnds(e,t){var i;let r=(i=this.id3Track)==null?void 0:i.cues;if(r)for(let s=r.length;s--;){let n=r[s];n.type===t&&n.startTime<e&&n.endTime===di&&(n.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:r}){let{id3Track:s,hls:n}=this;if(!n)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=n;if(s&&(o||l)){let c;r==="audio"?c=u=>u.type===ot.audioId3&&l:r==="video"?c=u=>u.type===ot.emsg&&o:c=u=>u.type===ot.audioId3&&l||u.type===ot.emsg&&o,Rr(s,t,i,c)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:i,id3Track:r}=this,{dateRanges:s}=t,n=Object.keys(s);if(r){let u=Object.keys(i).filter(d=>!n.includes(d));for(let d=u.length;d--;){let h=u[d];Object.keys(i[h].cues).forEach(m=>{r.removeCue(i[h].cues[m])}),delete i[h]}}let o=t.fragments[t.fragments.length-1];if(n.length===0||!J(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,c=Ir();for(let u=0;u<n.length;u++){let d=n[u],h=s[d],m=i[d],y=(m==null?void 0:m.cues)||{},E=(m==null?void 0:m.durationKnown)||!1,b=ar(h.startDate,l),A=di,D=h.endDate;if(D)A=ar(D,l),E=!0;else if(h.endOnNext&&!E){let F=n.reduce((k,G)=>{let M=s[G];return M.class===h.class&&M.id!==G&&M.startDate>h.startDate&&k.push(M),k},[]).sort((k,G)=>k.startDate.getTime()-G.startDate.getTime())[0];F&&(A=ar(F.startDate,l),E=!0)}let L=Object.keys(h.attr);for(let F=0;F<L.length;F++){let k=L[F];if(!nc(k))continue;let G=y[k];if(G)E&&!m.durationKnown&&(G.endTime=A);else{let M=h.attr[k];G=new c(b,A,""),ac(k)&&(M=Yc(M)),G.value={key:k,data:M},G.type=ot.dateRange,G.id=d,this.id3Track.addCue(G),y[k]=G}}i[d]={cues:y,dateRange:h,durationKnown:E}}}},wr=class{constructor(e){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=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(e===null)return null;let{holdBack:t,partHoldBack:i,targetduration:r}=e,{liveSyncDuration:s,liveSyncDurationCount:n,lowLatencyMode:o}=this.config,l=this.hls.userConfig,c=o&&i||t;(l.liveSyncDuration||l.liveSyncDurationCount||c===0)&&(c=s!==void 0?s:n*r);let u=r,d=1;return c+Math.min(this.stallCount*d,u)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,i=this.levelDetails;if(e===null||t===null||i===null)return null;let r=i.edge,s=e-t-this.edgeStalled,n=r-i.totalduration,o=r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(n,s),o)}get drift(){let{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(v.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var i;t.details===N.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&w.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let i=this.computeLatency();if(i===null)return;this._latency=i;let{lowLatencyMode:r,maxLiveSyncPlaybackRate:s}=this.config;if(!r||s===1)return;let n=this.targetLatency;if(n===null)return;let o=i-n,l=Math.min(this.maxLatency,n+t.targetduration),c=o<l;if(t.live&&c&&o>.05&&this.forwardBufferLength>1){let u=Math.min(2,Math.max(1,s)),d=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,d))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){let{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},kr=["NONE","TYPE-0","TYPE-1",null],zt={No:"",Yes:"YES",v2:"v2"};function zc(a,e){let{canSkipUntil:t,canSkipDateRanges:i,endSN:r}=a,s=e!==void 0?e-r:0;return t&&s<t?i?zt.v2:zt.Yes:zt.No}var Si=class{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){let t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}},wt=class{constructor(e){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=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>t).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){let t=e%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var e;return(e=this.audioGroupIds)==null?void 0:e[this.urlId]}get textGroupId(){var e;return(e=this.textGroupIds)==null?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}};function or(a,e){let t=e.startPTS;if(J(t)){let i=0,r;e.sn>a.sn?(i=t-a.start,r=a):(i=a.start-t,r=e),r.duration!==i&&(r.duration=i)}else e.sn>a.sn?a.cc===e.cc&&a.minEndPTS?e.start=a.start+(a.minEndPTS-a.start):e.start=a.start+a.duration:e.start=Math.max(a.start-e.duration,0)}function Da(a,e,t,i,r,s){i-t<=0&&(w.warn("Fragment should have a positive duration",e),i=t+e.duration,s=r+e.duration);let o=t,l=i,c=e.startPTS,u=e.endPTS;if(J(c)){let b=Math.abs(c-t);J(e.deltaPTS)?e.deltaPTS=Math.max(b,e.deltaPTS):e.deltaPTS=b,o=Math.max(t,c),t=Math.min(t,c),r=Math.min(r,e.startDTS),l=Math.min(i,u),i=Math.max(i,u),s=Math.max(s,e.endDTS)}let d=t-e.start;e.start!==0&&(e.start=t),e.duration=i-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=r,e.endPTS=i,e.minEndPTS=l,e.endDTS=s;let h=e.sn;if(!a||h<a.startSN||h>a.endSN)return 0;let m,y=h-a.startSN,E=a.fragments;for(E[y]=e,m=y;m>0;m--)or(E[m],E[m-1]);for(m=y;m<E.length-1;m++)or(E[m],E[m+1]);return a.fragmentHint&&or(E[E.length-1],a.fragmentHint),a.PTSKnown=a.alignedSliding=!0,d}function Xc(a,e){let t=null,i=a.fragments;for(let l=i.length-1;l>=0;l--){let c=i[l].initSegment;if(c){t=c;break}}a.fragmentHint&&delete a.fragmentHint.endPTS;let r=0,s;if(Zc(a,e,(l,c)=>{l.relurl&&(r=l.cc-c.cc),J(l.startPTS)&&J(l.endPTS)&&(c.start=c.startPTS=l.startPTS,c.startDTS=l.startDTS,c.maxStartPTS=l.maxStartPTS,c.endPTS=l.endPTS,c.endDTS=l.endDTS,c.minEndPTS=l.minEndPTS,c.duration=l.endPTS-l.startPTS,c.duration&&(s=c),e.PTSKnown=e.alignedSliding=!0),c.elementaryStreams=l.elementaryStreams,c.loader=l.loader,c.stats=l.stats,c.urlId=l.urlId,l.initSegment&&(c.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(c=>{var u;(!c.initSegment||c.initSegment.relurl===((u=t)==null?void 0:u.relurl))&&(c.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){w.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=Qc(a.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));let n=e.fragments;if(r){w.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<n.length;l++)n[l].cc+=r}e.skippedSegments&&(e.startCC=e.fragments[0].cc),Jc(a.partList,e.partList,(l,c)=>{c.elementaryStreams=l.elementaryStreams,c.stats=l.stats}),s?Da(e,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):wa(a,e),n.length&&(e.totalduration=e.edge-n[0].start),e.driftStartTime=a.driftStartTime,e.driftStart=a.driftStart;let o=e.advancedDateTime;if(e.advanced&&o){let l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=a.driftEndTime,e.driftEnd=a.driftEnd,e.advancedDateTime=a.advancedDateTime}function Qc(a,e,t){let i=Ie({},a);return t&&t.forEach(r=>{delete i[r]}),Object.keys(e).forEach(r=>{let s=new Ei(e[r].attr,i[r]);s.isValid?i[r]=s:w.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[r].attr)}"`)}),i}function Jc(a,e,t){if(a&&e){let i=0;for(let r=0,s=a.length;r<=s;r++){let n=a[r],o=e[r+i];n&&o&&n.index===o.index&&n.fragment.sn===o.fragment.sn?t(n,o):i--}}}function Zc(a,e,t){let i=e.skippedSegments,r=Math.max(a.startSN,e.startSN)-e.startSN,s=(a.fragmentHint?1:0)+(i?e.endSN:Math.min(a.endSN,e.endSN))-e.startSN,n=e.startSN-a.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments;for(let c=r;c<=s;c++){let u=l[n+c],d=o[c];i&&!d&&c<i&&(d=e.fragments[c]=u),u&&d&&t(u,d)}}function wa(a,e){let t=e.startSN+e.skippedSegments-a.startSN,i=a.fragments;t<0||t>=i.length||Cr(e,i[t].start)}function Cr(a,e){if(e){let t=a.fragments;for(let i=a.skippedSegments;i<t.length;i++)t[i].start+=e;a.fragmentHint&&(a.fragmentHint.start+=e)}}function eu(a,e=1/0){let t=1e3*a.targetduration;if(a.updated){let i=a.fragments,r=4;if(i.length&&t*r>e){let s=i[i.length-1].duration*1e3;s<t&&(t=s)}}else t/=2;return Math.round(t)}function tu(a,e,t){if(!(a!=null&&a.details))return null;let i=a.details,r=i.fragments[e-i.startSN];return r||(r=i.fragmentHint,r&&r.sn===e)?r:e<i.startSN&&t&&t.sn===e?t:null}function Vn(a,e,t){var i;return a!=null&&a.details?ka((i=a.details)==null?void 0:i.partList,e,t):null}function ka(a,e,t){if(a)for(let i=a.length;i--;){let r=a[i];if(r.index===t&&r.fragment.sn===e)return r}return null}function Ai(a){switch(a.details){case N.FRAG_LOAD_TIMEOUT:case N.KEY_LOAD_TIMEOUT:case N.LEVEL_LOAD_TIMEOUT:case N.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function qn(a,e){let t=Ai(e);return a.default[`${t?"timeout":"error"}Retry`]}function Ss(a,e){let t=a.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*a.retryDelayMs,a.maxRetryDelayMs)}function Wn(a){return Ze(Ze({},a),{errorRetry:null,timeoutRetry:null})}function Li(a,e,t,i){return!!a&&e<a.maxNumRetry&&(iu(i)||!!t)}function iu(a){return a===0&&navigator.onLine===!1||!!a&&(a<400||a>499)}var Ca={search:function(a,e){let t=0,i=a.length-1,r=null,s=null;for(;t<=i;){r=(t+i)/2|0,s=a[r];let n=e(s);if(n>0)t=r+1;else if(n<0)i=r-1;else return s}return null}};function ru(a,e,t){if(e===null||!Array.isArray(a)||!a.length||!J(e))return null;let i=a[0].programDateTime;if(e<(i||0))return null;let r=a[a.length-1].endProgramDateTime;if(e>=(r||0))return null;t=t||0;for(let s=0;s<a.length;++s){let n=a[s];if(su(e,t,n))return n}return null}function Jt(a,e,t=0,i=0){let r=null;if(a?r=e[a.sn-e[0].sn+1]||null:t===0&&e[0].start===0&&(r=e[0]),r&&Pr(t,i,r)===0)return r;let s=Ca.search(e,Pr.bind(null,t,i));return s&&(s!==a||!r)?s:r}function Pr(a=0,e=0,t){if(t.start<=a&&t.start+t.duration>a)return 0;let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=a?1:t.start-i>a&&t.start?-1:0}function su(a,e,t){let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>a}function nu(a,e){return Ca.search(a,t=>t.cc<e?1:t.cc>e?-1:0)}var au=3e5,Ke={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},st={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},Or=class{constructor(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=w.log.bind(w,"[info]:"),this.warn=w.warn.bind(w,"[warning]:"),this.error=w.error.bind(w,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(v.ERROR,this.onError,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;!e||(e.off(v.ERROR,this.onError,this),e.off(v.ERROR,this.onErrorOut,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(e==null?void 0:e.type)===re.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var i;if(t.fatal)return;let r=this.hls,s=t.context;switch(t.details){case N.FRAG_LOAD_ERROR:case N.FRAG_LOAD_TIMEOUT:case N.KEY_LOAD_ERROR:case N.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case N.FRAG_GAP:case N.FRAG_PARSING_ERROR:case N.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Ke.SendAlternateToPenaltyBox;return}case N.LEVEL_EMPTY_ERROR:case N.LEVEL_PARSING_ERROR:{var n,o;let l=t.parent===re.MAIN?t.level:r.loadLevel;t.details===N.LEVEL_EMPTY_ERROR&&!!((n=t.context)!=null&&(o=n.levelDetails)!=null&&o.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,l))}return;case N.LEVEL_LOAD_ERROR:case N.LEVEL_LOAD_TIMEOUT:typeof(s==null?void 0:s.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.level));return;case N.AUDIO_TRACK_LOAD_ERROR:case N.AUDIO_TRACK_LOAD_TIMEOUT:case N.SUBTITLE_LOAD_ERROR:case N.SUBTITLE_TRACK_LOAD_TIMEOUT:if(s){let l=r.levels[r.loadLevel];if(l&&(s.type===ve.AUDIO_TRACK&&s.groupId===l.audioGroupId||s.type===ve.SUBTITLE_TRACK&&s.groupId===l.textGroupId)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.loadLevel),t.errorAction.action=Ke.SendAlternateToPenaltyBox,t.errorAction.flags=st.MoveAllAlternatesMatchingHost;return}}return;case N.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let l=r.levels[r.loadLevel],c=l==null?void 0:l.attrs["HDCP-LEVEL"];c&&(t.errorAction={action:Ke.SendAlternateToPenaltyBox,flags:st.MoveAllAlternatesMatchingHDCP,hdcpLevel:c})}return;case N.BUFFER_ADD_CODEC_ERROR:case N.REMUX_ALLOC_ERROR:t.errorAction=this.getLevelSwitchAction(t,(i=t.level)!=null?i:r.loadLevel);return;case N.INTERNAL_EXCEPTION:case N.BUFFER_APPENDING_ERROR:case N.BUFFER_APPEND_ERROR:case N.BUFFER_FULL_ERROR:case N.LEVEL_SWITCH_ERROR:case N.BUFFER_STALLED_ERROR:case N.BUFFER_SEEK_OVER_HOLE:case N.BUFFER_NUDGE_ON_STALL:t.errorAction={action:Ke.DoNothing,flags:st.None};return}if(t.type===ie.KEY_SYSTEM_ERROR){let l=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,l);return}}getPlaylistRetryOrSwitchAction(e,t){var i;let r=this.hls,s=qn(r.config.playlistLoadPolicy,e),n=this.playlistError++,o=(i=e.response)==null?void 0:i.code;if(Li(s,n,Ai(e),o))return{action:Ke.RetryRequest,flags:st.None,retryConfig:s,retryCount:n};let c=this.getLevelSwitchAction(e,t);return s&&(c.retryConfig=s,c.retryCount=n),c}getFragRetryOrSwitchAction(e){let t=this.hls,i=this.getVariantLevelIndex(e.frag),r=t.levels[i],{fragLoadPolicy:s,keyLoadPolicy:n}=t.config,o=qn(e.details.startsWith("key")?n:s,e),l=t.levels.reduce((d,h)=>d+h.fragmentError,0);if(r){var c;e.details!==N.FRAG_GAP&&r.fragmentError++;let d=(c=e.response)==null?void 0:c.code;if(Li(o,l,Ai(e),d))return{action:Ke.RetryRequest,flags:st.None,retryConfig:o,retryCount:l}}let u=this.getLevelSwitchAction(e,i);return o&&(u.retryConfig=o,u.retryCount=l),u}getLevelSwitchAction(e,t){let i=this.hls;t==null&&(t=i.loadLevel);let r=this.hls.levels[t];if(r&&(r.loadError++,i.autoLevelEnabled)){var s,n;let o=-1,{levels:l,loadLevel:c,minAutoLevel:u,maxAutoLevel:d}=i,h=(s=e.frag)==null?void 0:s.type,{type:m,groupId:y}=(n=e.context)!=null?n:{};for(let E=l.length;E--;){let b=(E+c)%l.length;if(b!==c&&b>=u&&b<=d&&l[b].loadError===0){let A=l[b];if(e.details===N.FRAG_GAP&&e.frag){let D=l[b].details;if(D){let L=Jt(e.frag,D.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(m===ve.AUDIO_TRACK&&y===A.audioGroupId||m===ve.SUBTITLE_TRACK&&y===A.textGroupId)continue;if(h===re.AUDIO&&r.audioGroupId===A.audioGroupId||h===re.SUBTITLE&&r.textGroupId===A.textGroupId)continue}o=b;break}}if(o>-1&&i.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:Ke.SendAlternateToPenaltyBox,flags:st.None,nextAutoLevel:o}}return{action:Ke.SendAlternateToPenaltyBox,flags:st.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Ke.DoNothing:break;case Ke.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==N.FRAG_GAP&&(t.fatal=!0);break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,i=e.errorAction;if(!i)return;let{flags:r,hdcpLevel:s,nextAutoLevel:n}=i;switch(r){case st.None:this.switchLevel(e,n);break;case st.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(e));break;case st.MoveAllAlternatesMatchingHDCP:s&&(t.maxHdcpLevel=kr[kr.indexOf(s)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(e,n)}switchLevel(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)}redundantFailover(e){let{hls:t,penalizedRenditions:i}=this,r=e.parent===re.MAIN?e.level:t.loadLevel,s=t.levels[r],n=s.url.length,o=e.frag?e.frag.urlId:s.urlId;s.urlId===o&&(!e.frag||s.details)&&this.penalizeRendition(s,e);for(let l=1;l<n;l++){let c=(o+l)%n,u=i[c];if(!u||ou(u,e,i[o]))return this.warn(`Switching to Redundant Stream ${c+1}/${n}: "${s.url[c]}" after ${e.details}`),this.playlistError=0,t.levels.forEach(d=>{d.urlId=c}),t.nextLoadLevel=r,!0}return!1}penalizeRendition(e,t){let{penalizedRenditions:i}=this,r=i[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};r.lastErrorPerfMs=performance.now(),r.errors.push(t),r.details=e.details,i[e.urlId]=r}};function ou(a,e,t){if(performance.now()-a.lastErrorPerfMs>au)return!0;let i=a.details;if(e.details===N.FRAG_GAP&&i&&e.frag){let r=e.frag.start,s=Jt(null,i.fragments,r);if(s&&!s.gap)return!0}if(t&&a.errors.length<t.errors.length){let r=a.errors[a.errors.length-1];if(i&&r.frag&&e.frag&&Math.abs(r.frag.start-e.frag.start)>i.targetduration*3)return!0}return!1}var Zt=class{constructor(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=w.log.bind(w,`${t}:`),this.warn=w.warn.bind(w,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t){let i=t==null?void 0:t.renditionReports;if(i){let r=-1;for(let s=0;s<i.length;s++){let n=i[s],o;try{o=new self.URL(n.URI,t.url).href}catch(l){w.warn(`Could not construct new URL for Rendition Report: ${l}`),o=n.URI||""}if(o===e){r=s;break}else o===e.substring(0,o.length)&&(r=s)}if(r!==-1){let s=i[r],n=parseInt(s["LAST-MSN"])||(t==null?void 0:t.lastPartSn),o=parseInt(s["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){let l=Math.min(t.age-t.partTarget,t.targetduration);o>=0&&l>t.partTarget&&(o+=1)}return new Si(n,o>=0?o:void 0,zt.No)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,i){let{details:r,stats:s}=t,n=self.performance.now(),o=s.loading.first?Math.max(0,n-s.loading.first):0;if(r.advancedDateTime=Date.now()-o,r.live||i!=null&&i.live){if(r.reloaded(i),i&&this.log(`live playlist ${e} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:"MISSED"}`),i&&r.fragments.length>0&&Xc(i,r),!this.canLoad||!r.live)return;let l,c,u;if(r.canBlockReload&&r.endSN&&r.advanced){let b=this.hls.config.lowLatencyMode,A=r.lastPartSn,D=r.endSN,L=r.lastPartIndex,F=L!==-1,k=A===D,G=b?0:L;F?(c=k?D+1:A,u=k?G:L+1):c=D+1;let M=r.age,$=M+r.ageHeader,K=Math.min($-r.partTarget,r.targetduration*1.5);if(K>0){if(i&&K>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${K} with playlist age: ${r.age}`),K=0;else{let P=Math.floor(K/r.targetduration);if(c+=P,u!==void 0){let q=Math.round(K%r.targetduration/r.partTarget);u+=q}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${M.toFixed(2)}s goal: ${K} skip sn ${P} to part ${u}`)}r.tuneInGoal=K}if(l=this.getDeliveryDirectives(r,t.deliveryDirectives,c,u),b||!k){this.loadPlaylist(l);return}}else r.canBlockReload&&(l=this.getDeliveryDirectives(r,t.deliveryDirectives,c,u));let d=this.hls.mainForwardBufferInfo,h=d?d.end-d.len:0,m=(r.edge-h)*1e3,y=eu(r,m);r.updated&&n>this.requestScheduled+y&&(this.requestScheduled=s.loading.start),c!==void 0&&r.canBlockReload?this.requestScheduled=s.loading.first+y-(r.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+y<n?this.requestScheduled=n:this.requestScheduled-n<=0&&(this.requestScheduled+=y);let E=this.requestScheduled-n;E=Math.max(0,E),this.log(`reload live playlist ${e} in ${Math.round(E)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),E)}else this.clearTimer()}getDeliveryDirectives(e,t,i,r){let s=zc(e,i);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,s=zt.No),new Si(i,r,s)}checkRetry(e){let t=e.details,i=Ai(e),r=e.errorAction,{action:s,retryCount:n=0,retryConfig:o}=r||{},l=!!r&&!!o&&(s===Ke.RetryRequest||!r.resolved&&s===Ke.SendAlternateToPenaltyBox);if(l){var c;if(this.requestScheduled=-1,n>=o.maxNumRetry)return!1;if(i&&(c=e.context)!=null&&c.deliveryDirectives)this.warn(`Retrying playlist loading ${n+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let u=Ss(o,n);this.timer=self.setTimeout(()=>this.loadPlaylist(),u),this.warn(`Retrying playlist loading ${n+1}/${o.maxNumRetry} after "${t}" in ${u}ms`)}e.levelRetry=!0,r.resolved=!0}return l}},lr,Mr=class extends Zt{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let i=[],r={},s;t.levels.forEach(n=>{var o;let l=n.attrs;((o=n.audioCodec)==null?void 0:o.indexOf("mp4a.40.34"))!==-1&&(lr||(lr=/chrome|firefox/i.test(navigator.userAgent)),lr&&(n.audioCodec=void 0));let{AUDIO:c,CODECS:u,"FRAME-RATE":d,"PATHWAY-ID":h,RESOLUTION:m,SUBTITLES:y}=l,b=`${`${h||"."}-`}${n.bitrate}-${m}-${d}-${u}`;s=r[b],s?s.addFallback(n):(s=new wt(n),r[b]=s,i.push(s)),Ri(s,"audio",c),Ri(s,"text",y)}),this.filterAndSortMediaOptions(i,t)}filterAndSortMediaOptions(e,t){let i=[],r=[],s=!1,n=!1,o=!1,l=e.filter(({audioCodec:m,videoCodec:y,width:E,height:b,unknownCodecs:A})=>(s||(s=!!(E&&b)),n||(n=!!y),o||(o=!!m),!(A!=null&&A.length)&&(!m||sr(m,"audio"))&&(!y||sr(y,"video"))));if((s||n)&&o&&(l=l.filter(({videoCodec:m,width:y,height:E})=>!!m||!!(y&&E))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}t.audioTracks&&(i=t.audioTracks.filter(m=>!m.audioCodec||sr(m.audioCodec,"audio")),jn(i)),t.subtitles&&(r=t.subtitles,jn(r));let c=l.slice(0);l.sort((m,y)=>m.attrs["HDCP-LEVEL"]!==y.attrs["HDCP-LEVEL"]?(m.attrs["HDCP-LEVEL"]||"")>(y.attrs["HDCP-LEVEL"]||"")?1:-1:m.bitrate!==y.bitrate?m.bitrate-y.bitrate:m.attrs["FRAME-RATE"]!==y.attrs["FRAME-RATE"]?m.attrs.decimalFloatingPoint("FRAME-RATE")-y.attrs.decimalFloatingPoint("FRAME-RATE"):m.attrs.SCORE!==y.attrs.SCORE?m.attrs.decimalFloatingPoint("SCORE")-y.attrs.decimalFloatingPoint("SCORE"):s&&m.height!==y.height?m.height-y.height:0);let u=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length)){for(let m=0;m<c.length;m++)if(c[m].pathwayId===l[0].pathwayId){u=c[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===u){this._firstLevel=m,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${u.bitrate}`);break}let d=o&&!n,h={levels:l,audioTracks:i,subtitleTracks:r,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:o,video:n,altAudio:!d&&i.some(m=>!!m.url)};this.hls.trigger(v.MANIFEST_PARSED,h),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let u=new Error("invalid level idx"),d=e<0;if(this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:N.LEVEL_SWITCH_ERROR,level:e,fatal:d,error:u,reason:u.message}),d)return;e=Math.min(e,t.length-1)}let i=this.currentLevelIndex,r=this.currentLevel,s=r?r.attrs["PATHWAY-ID"]:void 0,n=t[e],o=n.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=n,i===e&&n.details&&r&&s===o)return;this.log(`Switching to level ${e}${o?" with Pathway "+o:""} from level ${i}${s?" with Pathway "+s:""}`);let l=Ie({},n,{level:e,maxBitrate:n.maxBitrate,attrs:n.attrs,uri:n.uri,urlId:n.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(v.LEVEL_SWITCHING,l);let c=n.details;if(!c||c.live){let u=this.switchParams(n.uri,r==null?void 0:r.details);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){let e=this.hls.config.startLevel;return e!==void 0?e:this._firstLevel}else return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===ve.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(t!==void 0&&t.type===re.MAIN){let i=this._levels[t.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(e,t){var i;let{level:r,details:s}=t,n=this._levels[r];if(!n){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(s.deltaUpdateFailed=!0);return}r===this.currentLevelIndex?(n.fragmentError===0&&(n.loadError=0),this.playlistLoaded(r,t,n.details)):(i=t.deliveryDirectives)!=null&&i.skip&&(s.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){let i=this.currentLevel;if(!i)return;let r=this.hls.audioTracks[t.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==r){let s=-1;for(let n=0;n<i.audioGroupIds.length;n++)if(i.audioGroupIds[n]===r){s=n;break}s!==-1&&s!==i.urlId&&(i.urlId=s,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){let r=i.urlId,s=i.uri;if(e)try{s=e.addDirectives(s)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}let n=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} URI ${r+1}/${i.url.length} ${s}`),this.clearTimer(),this.hls.trigger(v.LEVEL_LOADING,{url:s,level:t,id:r,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e,t){let i=(s,n)=>n!==t,r=this._levels.filter((s,n)=>n!==e?!0:s.url.length>1&&t!==void 0?(s.url=s.url.filter(i),s.audioGroupIds&&(s.audioGroupIds=s.audioGroupIds.filter(i)),s.textGroupIds&&(s.textGroupIds=s.textGroupIds.filter(i)),s.urlId=0,!0):(this.steering&&this.steering.removeLevel(s),!1));this.hls.trigger(v.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){t.forEach((i,r)=>{let{details:s}=i;s!=null&&s.fragments&&s.fragments.forEach(n=>{n.level=r})}),this._levels=t}};function Ri(a,e,t){!t||(e==="audio"?(a.audioGroupIds||(a.audioGroupIds=[]),a.audioGroupIds[a.url.length-1]=t):e==="text"&&(a.textGroupIds||(a.textGroupIds=[]),a.textGroupIds[a.url.length-1]=t))}function jn(a){let e={};a.forEach(t=>{let i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}var Ce={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Fr=class{constructor(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()}_registerListeners(){let{hls:e}=this;e.on(v.BUFFER_APPENDED,this.onBufferAppended,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.BUFFER_APPENDED,this.onBufferAppended,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let i=this.activePartLists[t];if(i)for(let r=i.length;r--;){let s=i[r];if(!s)break;let n=s.end;if(s.start<=e&&n!==null&&e<=n)return s}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:i}=this,r=Object.keys(i);for(let s=r.length;s--;){let n=i[r[s]];if((n==null?void 0:n.body.type)===t&&n.buffered){let o=n.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,i,r){this.timeRanges&&(this.timeRanges[e]=t);let s=(r==null?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach(n=>{let o=this.fragments[n];if(!o||s>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===i&&this.removeFragment(o.body);return}let l=o.range[e];!l||l.time.some(c=>{let u=!this.isTimeBuffered(c.startPTS,c.endPTS,t);return u&&this.removeFragment(o.body),u})})}detectPartialFragments(e){let t=this.timeRanges,{frag:i,part:r}=e;if(!t||i.sn==="initSegment")return;let s=Ot(i),n=this.fragments[s];if(!n)return;let o=!i.relurl;Object.keys(t).forEach(l=>{let c=i.elementaryStreams[l];if(!c)return;let u=t[l],d=o||c.partial===!0;n.range[l]=this.getBufferedTimes(i,r,d,u)}),n.loaded=null,Object.keys(n.range).length?(n.buffered=!0,n.body.endList&&(this.endListFragments[n.body.type]=n),hi(n)||this.removeParts(i.sn-1,i.type)):this.removeFragment(n.body)}removeParts(e,t){let i=this.activePartLists[t];!i||(this.activePartLists[t]=i.filter(r=>r.fragment.sn>=e))}fragBuffered(e,t){let i=Ot(e),r=this.fragments[i];!r&&t&&(r=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)}getBufferedTimes(e,t,i,r){let s={time:[],partial:i},n=e.start,o=e.end,l=e.minEndPTS||o,c=e.maxStartPTS||n;for(let u=0;u<r.length;u++){let d=r.start(u)-this.bufferPadding,h=r.end(u)+this.bufferPadding;if(c>=d&&l<=h){s.time.push({startPTS:Math.max(n,r.start(u)),endPTS:Math.min(o,r.end(u))});break}else if(n<h&&o>d)s.partial=!0,s.time.push({startPTS:Math.max(n,r.start(u)),endPTS:Math.min(o,r.end(u))});else if(o<=d)break}return s}getPartialFragment(e){let t=null,i,r,s,n=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(c=>{let u=l[c];!u||hi(u)&&(r=u.body.start-o,s=u.body.end+o,e>=r&&e<=s&&(i=Math.min(e-r,s-e),n<=i&&(t=u.body,n=i)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||hi(t))}getState(e){let t=Ot(e),i=this.fragments[t];return i?i.buffered?hi(i)?Ce.PARTIAL:Ce.OK:Ce.APPENDING:Ce.NOT_LOADED}isTimeBuffered(e,t,i){let r,s;for(let n=0;n<i.length;n++){if(r=i.start(n)-this.bufferPadding,s=i.end(n)+this.bufferPadding,e>=r&&t<=s)return!0;if(t<=r)return!1}return!1}onFragLoaded(e,t){let{frag:i,part:r}=t;if(i.sn==="initSegment"||i.bitrateTest)return;let s=r?null:t,n=Ot(i);this.fragments[n]={body:i,appendedPTS:null,loaded:s,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:i,part:r,timeRanges:s}=t;if(i.sn==="initSegment")return;let n=i.type;if(r){let o=this.activePartLists[n];o||(this.activePartLists[n]=o=[]),o.push(r)}this.timeRanges=s,Object.keys(s).forEach(o=>{let l=s[o];this.detectEvictedFragments(o,l,n,r)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=Ot(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,r,s){r&&!this.hasGaps||Object.keys(this.fragments).forEach(n=>{let o=this.fragments[n];if(!o)return;let l=o.body;l.type!==i||r&&!l.gap||l.start<t&&l.end>e&&(o.buffered||s)&&this.removeFragment(l)})}removeFragment(e){let t=Ot(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let i=this.activePartLists[e.type];if(i){let r=e.sn;this.activePartLists[e.type]=i.filter(s=>s.fragment.sn!==r)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}};function hi(a){var e,t,i;return a.buffered&&(a.body.gap||((e=a.range.video)==null?void 0:e.partial)||((t=a.range.audio)==null?void 0:t.partial)||((i=a.range.audiovideo)==null?void 0:i.partial))}function Ot(a){return`${a.type}_${a.level}_${a.urlId}_${a.sn}`}var Yn=Math.pow(2,17),Nr=class{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let i=e.url;if(!i)return Promise.reject(new at({type:ie.NETWORK_ERROR,details:N.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();let r=this.config,s=r.fLoader,n=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap){l(Xn(e));return}let c=this.loader=e.loader=s?new s(r):new n(r),u=zn(e),d=Wn(r.fragLoadPolicy.default),h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Yn};e.stats=c.stats,c.load(u,h,{onSuccess:(m,y,E,b)=>{this.resetLoader(e,c);let A=m.data;E.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(A.slice(0,16)),A=A.slice(16)),o({frag:e,part:null,payload:A,networkDetails:b})},onError:(m,y,E,b)=>{this.resetLoader(e,c),l(new at({type:ie.NETWORK_ERROR,details:N.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Ze({url:i,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:E,stats:b}))},onAbort:(m,y,E)=>{this.resetLoader(e,c),l(new at({type:ie.NETWORK_ERROR,details:N.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:E,stats:m}))},onTimeout:(m,y,E)=>{this.resetLoader(e,c),l(new at({type:ie.NETWORK_ERROR,details:N.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:m}))},onProgress:(m,y,E,b)=>{t&&t({frag:e,part:null,payload:E,networkDetails:b})}})})}loadPart(e,t,i){this.abort();let r=this.config,s=r.fLoader,n=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(Xn(e,t));return}let c=this.loader=e.loader=s?new s(r):new n(r),u=zn(e,t),d=Wn(r.fragLoadPolicy.default),h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Yn};t.stats=c.stats,c.load(u,h,{onSuccess:(m,y,E,b)=>{this.resetLoader(e,c),this.updateStatsFromPart(e,t);let A={frag:e,part:t,payload:m.data,networkDetails:b};i(A),o(A)},onError:(m,y,E,b)=>{this.resetLoader(e,c),l(new at({type:ie.NETWORK_ERROR,details:N.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Ze({url:u.url,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:E,stats:b}))},onAbort:(m,y,E)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,c),l(new at({type:ie.NETWORK_ERROR,details:N.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:E,stats:m}))},onTimeout:(m,y,E)=>{this.resetLoader(e,c),l(new at({type:ie.NETWORK_ERROR,details:N.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:m}))}})})}updateStatsFromPart(e,t){let i=e.stats,r=t.stats,s=r.total;if(i.loaded+=r.loaded,s){let l=Math.round(e.duration/t.duration),c=Math.min(Math.round(i.loaded/s),l),d=(l-c)*Math.round(i.loaded/c);i.total=i.loaded+d}else i.total=Math.max(i.loaded,i.total);let n=i.loading,o=r.loading;n.start?n.first+=o.first-o.start:(n.start=o.start,n.first=o.first),n.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}};function zn(a,e=null){let t=e||a,i={frag:a,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},r=t.byteRangeStartOffset,s=t.byteRangeEndOffset;if(J(r)&&J(s)){var n;let o=r,l=s;if(a.sn==="initSegment"&&((n=a.decryptdata)==null?void 0:n.method)==="AES-128"){let c=s-r;c%16&&(l=s+(16-c%16)),r!==0&&(i.resetIV=!0,o=r-16)}i.rangeStart=o,i.rangeEnd=l}return i}function Xn(a,e){let t=new Error(`GAP ${a.gap?"tag":"attribute"} found`),i={type:ie.MEDIA_ERROR,details:N.FRAG_GAP,fatal:!1,frag:a,error:t,networkDetails:null};return e&&(i.part=e),(e||a).stats.aborted=!0,new at(i)}var at=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},Ur=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let t in this.keyUriToKeyInfo){let i=this.keyUriToKeyInfo[t].loader;if(i){if(e&&e!==i.context.frag.type)return;i.abort()}}}detach(){for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=N.KEY_LOAD_ERROR,i,r,s){return new at({type:ie.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:s,error:i,networkDetails:r})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:i,cc:r}=e;for(let s=0;s<t.length;s++){let n=t[s];if(r<=n.cc&&(i==="initSegment"||n.sn==="initSegment"||i<n.sn)){this.emeController.selectKeySystemFormat(n).then(o=>{n.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,r;t&&e.setKeyFormat(t);let s=e.decryptdata;if(!s){let c=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,N.KEY_LOAD_ERROR,c))}let n=s.uri;if(!n)return Promise.reject(this.createKeyLoadError(e,N.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${n}"`)));let o=this.keyUriToKeyInfo[n];if((i=o)!=null&&i.decryptdata.key)return s.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((r=o)!=null&&r.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(c=>(s.key=c.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[n]={decryptdata:s,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},s.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return s.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,N.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${s.method}"`)))}}loadKeyEME(e,t){let i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let r=this.emeController.loadKey(i);if(r)return(e.keyLoadPromise=r.then(s=>(e.mediaKeySessionContext=s,i))).catch(s=>{throw e.keyLoadPromise=null,s})}return Promise.resolve(i)}loadKeyHTTP(e,t){let i=this.config,r=i.loader,s=new r(i);return t.keyLoader=e.loader=s,e.keyLoadPromise=new Promise((n,o)=>{let l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},c=i.keyLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(h,m,y,E)=>{let{frag:b,keyInfo:A,url:D}=y;if(!b.decryptdata||A!==this.keyUriToKeyInfo[D])return o(this.createKeyLoadError(b,N.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),E));A.decryptdata.key=b.decryptdata.key=new Uint8Array(h.data),b.keyLoader=null,A.loader=null,n({frag:b,keyInfo:A})},onError:(h,m,y,E)=>{this.resetLoader(m),o(this.createKeyLoadError(t,N.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),y,Ze({url:l.url,data:void 0},h)))},onTimeout:(h,m,y)=>{this.resetLoader(m),o(this.createKeyLoadError(t,N.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),y))},onAbort:(h,m,y)=>{this.resetLoader(m),o(this.createKeyLoadError(t,N.INTERNAL_ABORTED,new Error("key loading aborted"),y))}};s.load(l,u,d)})}resetLoader(e){let{frag:t,keyInfo:i,url:r}=e,s=i.loader;t.keyLoader===s&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[r],s&&s.destroy()}},Br=class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}},lu={length:0,start:()=>0,end:()=>0},xe=class{static isBuffered(e,t){try{if(e){let i=xe.getBuffered(e);for(let r=0;r<i.length;r++)if(t>=i.start(r)&&t<=i.end(r))return!0}}catch{}return!1}static bufferInfo(e,t,i){try{if(e){let r=xe.getBuffered(e),s=[],n;for(n=0;n<r.length;n++)s.push({start:r.start(n),end:r.end(n)});return this.bufferedInfo(s,t,i)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.sort(function(c,u){let d=c.start-u.start;return d||u.end-c.end});let r=[];if(i)for(let c=0;c<e.length;c++){let u=r.length;if(u){let d=r[u-1].end;e[c].start-d<i?e[c].end>d&&(r[u-1].end=e[c].end):r.push(e[c])}else r.push(e[c])}else r=e;let s=0,n,o=t,l=t;for(let c=0;c<r.length;c++){let u=r[c].start,d=r[c].end;if(t+i>=u&&t<d)o=u,l=d,s=l-t;else if(t+i<u){n=u;break}}return{len:s,start:o||0,end:l||0,nextStart:n}}static getBuffered(e){try{return e.buffered}catch(t){return w.log("failed to get media.buffered",t),lu}}},ei=class{constructor(e,t,i,r=0,s=-1,n=!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=fi(),this.buffering={audio:fi(),video:fi(),audiovideo:fi()},this.level=e,this.sn=t,this.id=i,this.size=r,this.part=s,this.partial=n}};function fi(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Pa(a,e){let t=null;for(let i=0,r=a.length;i<r;i++){let s=a[i];if(s&&s.cc===e){t=s;break}}return t}function cu(a,e,t){return!!(e.details&&(t.endCC>t.startCC||a&&a.cc<t.startCC))}function uu(a,e,t=0){let i=a.fragments,r=e.fragments;if(!r.length||!i.length){w.log("No fragments to align");return}let s=Pa(i,r[0].cc);if(!s||s&&!s.startPTS){w.log("No frag in previous level to align on");return}return s}function Qn(a,e){if(a){let t=a.start+e;a.start=a.startPTS=t,a.endPTS=t+a.duration}}function As(a,e){let t=e.fragments;for(let i=0,r=t.length;i<r;i++)Qn(t[i],a);e.fragmentHint&&Qn(e.fragmentHint,a),e.alignedSliding=!0}function du(a,e,t){!e||(hu(a,t,e),!t.alignedSliding&&e.details&&fu(t,e.details),!t.alignedSliding&&e.details&&!t.skippedSegments&&wa(e.details,t))}function hu(a,e,t){if(cu(a,t,e)){let i=uu(t.details,e);i&&J(i.start)&&(w.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),As(i.start,e))}}function fu(a,e){if(!e.fragments.length||!a.hasProgramDateTime||!e.hasProgramDateTime)return;let t=e.fragments[0].programDateTime,i=a.fragments[0].programDateTime,r=(i-t)/1e3+e.fragments[0].start;r&&J(r)&&(w.log(`Adjusting PTS using programDateTime delta ${i-t}ms, sliding:${r.toFixed(3)} ${a.url} `),As(r,a))}function Oa(a,e){if(!a.hasProgramDateTime||!e.hasProgramDateTime)return;let t=a.fragments,i=e.fragments;if(!t.length||!i.length)return;let r=Math.round(i.length/2)-1,s=i[r],n=Pa(t,s.cc)||t[Math.round(t.length/2)-1],o=s.programDateTime,l=n.programDateTime;if(o===null||l===null)return;let c=(l-o)/1e3-(n.start-s.start);As(c,a)}var $r=class{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}},Gr=class{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}};function gu(a){let e=a.byteLength,t=e&&new DataView(a.buffer).getUint8(e-1);return t?Rt(a,0,e-t):a}var Hr=class{constructor(){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()}uint8ArrayToUint32Array_(e){let t=new DataView(e),i=new Uint32Array(4);for(let r=0;r<4;r++)i[r]=t.getUint32(r*4);return i}initTable(){let e=this.sBox,t=this.invSBox,i=this.subMix,r=i[0],s=i[1],n=i[2],o=i[3],l=this.invSubMix,c=l[0],u=l[1],d=l[2],h=l[3],m=new Uint32Array(256),y=0,E=0,b=0;for(b=0;b<256;b++)b<128?m[b]=b<<1:m[b]=b<<1^283;for(b=0;b<256;b++){let A=E^E<<1^E<<2^E<<3^E<<4;A=A>>>8^A&255^99,e[y]=A,t[A]=y;let D=m[y],L=m[D],F=m[L],k=m[A]*257^A*16843008;r[y]=k<<24|k>>>8,s[y]=k<<16|k>>>16,n[y]=k<<8|k>>>24,o[y]=k,k=F*16843009^L*65537^D*257^y*16843008,c[A]=k<<24|k>>>8,u[A]=k<<16|k>>>16,d[A]=k<<8|k>>>24,h[A]=k,y?(y=D^m[m[m[F^D]]],E^=m[m[E]]):y=E=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),i=!0,r=0;for(;r<t.length&&i;)i=t[r]===this.key[r],r++;if(i)return;this.key=t;let s=this.keySize=t.length;if(s!==4&&s!==6&&s!==8)throw new Error("Invalid aes key size="+s);let n=this.ksRows=(s+6+1)*4,o,l,c=this.keySchedule=new Uint32Array(n),u=this.invKeySchedule=new Uint32Array(n),d=this.sBox,h=this.rcon,m=this.invSubMix,y=m[0],E=m[1],b=m[2],A=m[3],D,L;for(o=0;o<n;o++){if(o<s){D=c[o]=t[o];continue}L=D,o%s===0?(L=L<<8|L>>>24,L=d[L>>>24]<<24|d[L>>>16&255]<<16|d[L>>>8&255]<<8|d[L&255],L^=h[o/s|0]<<24):s>6&&o%s===4&&(L=d[L>>>24]<<24|d[L>>>16&255]<<16|d[L>>>8&255]<<8|d[L&255]),c[o]=D=(c[o-s]^L)>>>0}for(l=0;l<n;l++)o=n-l,l&3?L=c[o]:L=c[o-4],l<4||o<=4?u[l]=L:u[l]=y[d[L>>>24]]^E[d[L>>>16&255]]^b[d[L>>>8&255]]^A[d[L&255]],u[l]=u[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){let r=this.keySize+6,s=this.invKeySchedule,n=this.invSBox,o=this.invSubMix,l=o[0],c=o[1],u=o[2],d=o[3],h=this.uint8ArrayToUint32Array_(i),m=h[0],y=h[1],E=h[2],b=h[3],A=new Int32Array(e),D=new Int32Array(A.length),L,F,k,G,M,$,K,P,q,H,ce,oe,le,Te,ge=this.networkToHostOrderSwap;for(;t<A.length;){for(q=ge(A[t]),H=ge(A[t+1]),ce=ge(A[t+2]),oe=ge(A[t+3]),M=q^s[0],$=oe^s[1],K=ce^s[2],P=H^s[3],le=4,Te=1;Te<r;Te++)L=l[M>>>24]^c[$>>16&255]^u[K>>8&255]^d[P&255]^s[le],F=l[$>>>24]^c[K>>16&255]^u[P>>8&255]^d[M&255]^s[le+1],k=l[K>>>24]^c[P>>16&255]^u[M>>8&255]^d[$&255]^s[le+2],G=l[P>>>24]^c[M>>16&255]^u[$>>8&255]^d[K&255]^s[le+3],M=L,$=F,K=k,P=G,le=le+4;L=n[M>>>24]<<24^n[$>>16&255]<<16^n[K>>8&255]<<8^n[P&255]^s[le],F=n[$>>>24]<<24^n[K>>16&255]<<16^n[P>>8&255]<<8^n[M&255]^s[le+1],k=n[K>>>24]<<24^n[P>>16&255]<<16^n[M>>8&255]<<8^n[$&255]^s[le+2],G=n[P>>>24]<<24^n[M>>16&255]<<16^n[$>>8&255]<<8^n[K&255]^s[le+3],D[t]=ge(L^m),D[t+1]=ge(G^y),D[t+2]=ge(k^E),D[t+3]=ge(F^b),m=q,y=H,E=ce,b=oe,t=t+4}return D.buffer}},mu=16,ti=class{constructor(e,{removePKCS7Padding:t=!0}={}){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=t,t)try{let i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?gu(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i){return this.useSoftware?new Promise((r,s)=>{this.softwareDecrypt(new Uint8Array(e),t,i);let n=this.flush();n?r(n.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i)}softwareDecrypt(e,t,i){let{currentIV:r,currentResult:s,remainderData:n}=this;this.logOnce("JS AES decrypt"),n&&(e=It(n,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;r&&(i=r);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Hr),l.expandKey(t);let c=s;return this.currentResult=l.decrypt(o.buffer,0,i),this.currentIV=Rt(o,-16).buffer,c||null}webCryptoDecrypt(e,t,i){let r=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new Gr(r,t)),this.fastAesKey.expandKey().then(s=>r?(this.logOnce("WebCrypto AES decrypt"),new $r(r,new Uint8Array(i)).decrypt(e.buffer,s)):Promise.reject(new Error("web crypto not initialized"))).catch(s=>(w.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,i)))}onWebCryptoError(e,t,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i);let r=this.flush();if(r)return r.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,i=e.length-e.length%mu;return i!==e.length&&(t=Rt(e,0,i),this.remainderData=Rt(e,i)),t}logOnce(e){!this.logEnabled||(w.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},pu={toString:function(a){let e="",t=a.length;for(let i=0;i<t;i++)e+=`[${a.start(i).toFixed(3)}-${a.end(i).toFixed(3)}]`;return e}},B={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},ii=class extends Br{constructor(e,t,i,r,s){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=B.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=s,this.logPrefix=r,this.log=w.log.bind(w,`${r}:`),this.warn=w.warn.bind(w,`${r}:`),this.hls=e,this.fragmentLoader=new Nr(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new ti(e.config),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=B.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;let i=t.partList;if(i!=null&&i.length){let s=i[i.length-1];return xe.isBuffered(this.media,s.start+s.duration/2)}let r=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(r)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levels[this.levelLastLoaded])==null?void 0:e.details}}onMediaAttached(e,t){let i=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);let r=this.config;this.levels&&r.autoStartLoad&&this.state===B.STOPPED&&this.startLoad(r.startPosition)}onMediaDetaching(){let e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.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()}onMediaSeeking(){let{config:e,fragCurrent:t,media:i,mediaBuffer:r,state:s}=this,n=i?i.currentTime:0,o=xe.bufferInfo(r||i,n,e.maxBufferHole);if(this.log(`media seeking to ${J(n)?n.toFixed(3):n}, state: ${s}`),this.state===B.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,c=t.start-l,u=t.start+t.duration+l;if(!o.len||u<o.start||c>o.end){let d=n>u;(n<c||d)&&(d&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(n,1/0,this.playlistType,!0),this.lastCurrentTime=n),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=n),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=B.STOPPED,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,super.onHandlerDestroyed()}loadFragment(e,t,i){this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){let r=s=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${s.part?" p: "+s.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(s)};this._doFragLoad(e,t,i,r).then(s=>{if(!s)return;let n=this.state;if(this.fragContextChanged(e)){(n===B.FRAG_LOADING||!this.fragCurrent&&n===B.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=B.IDLE);return}"payload"in s&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(v.FRAG_LOADED,s)),this._handleFragmentLoadComplete(s)}).catch(s=>{this.state===B.STOPPED||this.state===B.ERROR||(this.warn(s),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:i}=this;if(i.getState(e)===Ce.APPENDING){let s=e.type,n=this.getFwdBufferInfo(this.mediaBuffer,s),o=Math.max(e.duration,n?n.len:this.config.maxBufferLength);this.reduceMaxBufferLength(o)&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Ce.PARTIAL&&i.removeFragment(e))}flushMainBuffer(e,t,i=null){if(!(e-t))return;let r={startOffset:e,endOffset:t,type:i};this.hls.trigger(v.BUFFER_FLUSHING,r)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{if(!i||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{let{hls:r}=this,{payload:s}=i,n=e.decryptdata;if(s&&s.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){let o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(s),n.key.buffer,n.iv.buffer).catch(l=>{throw r.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{let c=self.performance.now();return r.trigger(v.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:c}}),i.payload=l,i})}return i}).then(i=>{let{fragCurrent:r,hls:s,levels:n}=this;if(!n)throw new Error("init load aborted, missing levels");let o=e.stats;this.state=B.IDLE,t.fragmentError=0,e.data=new Uint8Array(i.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),i.frag===r&&s.trigger(v.FRAG_BUFFERED,{stats:o,frag:r,part:null,id:e.type}),this.tick()}).catch(i=>{this.state===B.STOPPED||this.state===B.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var i,r,s,n;let o=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===re.MAIN?"level":"track"} ${e.level} (frag:[${((i=e.startPTS)!=null?i:NaN).toFixed(3)}-${((r=e.endPTS)!=null?r:NaN).toFixed(3)}] > buffer:${o?pu.toString(xe.getBuffered(o)):"(detached)"})`),this.state=B.IDLE,o&&(!this.loadedmetadata&&e.type==re.MAIN&&o.buffered.length&&((s=this.fragCurrent)==null?void 0:s.sn)===((n=this.fragPrevious)==null?void 0:n.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:i,part:r,partsLoaded:s}=e,n=!s||s.length===0||s.some(l=>!l),o=new ei(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!n);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,r){var s;let n=t==null?void 0:t.details;if(!this.levels||!n)throw new Error(`frag load aborted, missing level${n?"":" detail"}s`);let o=null;if(e.encrypted&&!((s=e.decryptdata)!=null&&s.key)?(this.log(`Loading key for ${e.sn} of [${n.startSN}-${n.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=B.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(v.KEY_LOADED,u),this.state===B.KEY_LOADING&&(this.state=B.IDLE),u}),this.hls.trigger(v.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&n.encryptedFragments.length&&this.keyLoader.loadClear(e,n.encryptedFragments),i=Math.max(e.start,i||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let u=n.partList;if(u&&r){i>e.end&&n.fragmentHint&&(e=n.fragmentHint);let d=this.getNextPart(u,e,i);if(d>-1){let h=u[d];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${n.startSN}-${n.endSN}] parts [0-${d}-${u.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=B.FRAG_LOADING;let m;return o?m=o.then(y=>!y||this.fragContextChanged(y.frag)?null:this.doFragPartsLoad(e,h,t,r)).catch(y=>this.handleFragLoadError(y)):m=this.doFragPartsLoad(e,h,t,r).catch(y=>this.handleFragLoadError(y)),this.hls.trigger(v.FRAG_LOADING,{frag:e,part:h,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):m}else if(!e.url||this.loadedEndOfParts(u,i))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${n?"of ["+n.startSN+"-"+n.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),J(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=B.FRAG_LOADING;let l=this.config.progressive,c;return l&&o?c=o.then(u=>!u||this.fragContextChanged(u==null?void 0:u.frag)?null:this.fragmentLoader.load(e,r)).catch(u=>this.handleFragLoadError(u)):c=Promise.all([this.fragmentLoader.load(e,l?r:void 0),o]).then(([u])=>(!l&&u&&r&&r(u),u)).catch(u=>this.handleFragLoadError(u)),this.hls.trigger(v.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c}doFragPartsLoad(e,t,i,r){return new Promise((s,n)=>{var o;let l=[],c=(o=i.details)==null?void 0:o.partList,u=d=>{this.fragmentLoader.loadPart(e,d,r).then(h=>{l[d.index]=h;let m=h.part;this.hls.trigger(v.FRAG_LOADED,h);let y=Vn(i,e.sn,d.index+1)||ka(c,e.sn,d.index+1);if(y)u(y);else return s({frag:e,part:m,partsLoaded:l})}).catch(n)};u(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===N.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(v.ERROR,t)}else this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:N.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==B.PARSING){!this.fragCurrent&&this.state!==B.STOPPED&&this.state!==B.ERROR&&(this.state=B.IDLE);return}let{frag:i,part:r,level:s}=t,n=self.performance.now();i.stats.parsing.end=n,r&&(r.stats.parsing.end=n),this.updateLevelTiming(i,r,s,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:i}=this,{level:r,sn:s,part:n}=e;if(!(t!=null&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${s} of level ${r}. The current chunk will not be buffered.`),null;let o=t[r],l=n>-1?Vn(o,s,n):null,c=l?l.fragment:tu(o,s,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:l,level:o}):null}bufferFragmentData(e,t,i,r){var s;if(!e||this.state!==B.PARSING)return;let{data1:n,data2:o}=e,l=n;if(n&&o&&(l=It(n,o)),!((s=l)!=null&&s.length))return;let c={type:e.type,frag:t,part:i,chunkMeta:r,parent:t.type,data:l};this.hls.trigger(v.BUFFER_APPENDING,c),e.dropped&&e.independent&&!i&&this.flushBufferGap(t)}flushBufferGap(e){let t=this.media;if(!t)return;if(!xe.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let i=t.currentTime,r=xe.bufferInfo(t,i,0),s=e.duration,n=Math.min(this.config.maxFragLookUpTolerance*2,s*.25),o=Math.max(Math.min(e.start-n,r.end-n),i+n);e.start-o>n&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let i=this.getLoadPosition();return J(i)?this.getFwdBufferInfoAtPos(e,i,t):null}getFwdBufferInfoAtPos(e,t,i){let{config:{maxBufferHole:r}}=this,s=xe.bufferInfo(e,t,r);if(s.len===0&&s.nextStart!==void 0){let n=this.fragmentTracker.getBufferedFrag(t,i);if(n&&s.nextStart<n.end)return xe.bufferInfo(e,t,Math.max(s.nextStart,r))}return s}getMaxBufferLength(e){let{config:t}=this,i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e){let t=this.config,i=e||t.maxBufferLength;return t.maxMaxBufferLength>=i?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=re.MAIN){let i=this.fragmentTracker.getAppendedFrag(e,re.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){let i=t.fragments,r=i.length;if(!r)return null;let{config:s}=this,n=i[0].start,o;if(t.live){let l=s.initialLiveManifestSize;if(r<l)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${l})`),null;!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(o=this.getInitialLiveFragment(t,i),this.startPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=n&&(o=i[0]);if(!o){let l=s.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){let i=this.fragmentTracker.getState(e);return(i===Ce.OK||i===Ce.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,r,s){let n=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,n&&e&&!e.gap&&i.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,r);if(l!==null&&i.len+l.len>=s)return this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let r=-1,s=!1,n=!0;for(let o=0,l=e.length;o<l;o++){let c=e[o];if(n=n&&!c.independent,r>-1&&i<c.start)break;let u=c.loaded;u?r=-1:(s||c.independent||n)&&c.fragment===t&&(r=o),s=u}return r}loadedEndOfParts(e,t){let i=e[e.length-1];return i&&t>i.start&&i.loaded}getInitialLiveFragment(e,t){let i=this.fragPrevious,r=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),r=ru(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){let s=i.sn+1;if(s>=e.startSN&&s<=e.endSN){let n=t[s-e.startSN];i.cc===n.cc&&(r=n,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=nu(t,i.cc),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{let s=this.hls.liveSyncPosition;s!==null&&(r=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r}getFragmentAtPosition(e,t,i){let{config:r}=this,{fragPrevious:s}=this,{fragments:n,endSN:o}=i,{fragmentHint:l}=i,c=r.maxFragLookUpTolerance,u=i.partList,d=!!(r.lowLatencyMode&&u!=null&&u.length&&l);d&&l&&!this.bitrateTest&&(n=n.concat(l),o=l.sn);let h;if(e<t){let m=e>t-c?0:c;h=Jt(s,n,e,m)}else h=n[n.length-1];if(h){let m=h.sn-i.startSN,y=this.fragmentTracker.getState(h);if((y===Ce.OK||y===Ce.PARTIAL&&h.gap)&&(s=h),s&&h.sn===s.sn&&(!d||u[0].fragment.sn>h.sn)&&s&&h.level===s.level){let b=n[m+1];h.sn<o&&this.fragmentTracker.getState(b)!==Ce.OK?h=b:h=null}}return h}synchronizeToLiveEdge(e){let{config:t,media:i}=this;if(!i)return;let r=this.hls.liveSyncPosition,s=i.currentTime,n=e.fragments[0].start,o=e.edge,l=s>=n-t.maxFragLookUpTolerance&&s<=o;if(r!==null&&i.duration>r&&(s<r||!l)){let c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&i.readyState<4||s<o-c)&&(this.loadedmetadata||(this.nextLoadPosition=r),i.readyState&&(this.warn(`Playback: ${s.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r.toFixed(3)}`),i.currentTime=r))}}alignPlaylists(e,t){let{levels:i,levelLastLoaded:r,fragPrevious:s}=this,n=r!==null?i[r]:null,o=e.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;let l=e.fragments[0].start,c=!t,u=e.alignedSliding&&J(l);if(c||!u&&!l){du(s,n,e);let d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${s?s.sn:"na"} fragments: ${o}`),d}return l}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;if(i<t&&(i=-1),i===-1||this.lastCurrentTime===-1){let r=this.startTimeOffset!==null,s=r?this.startTimeOffset:e.startTimeOffset;s!==null&&J(s)?(i=t+s,s<0&&(i+=e.totalduration),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Start time offset ${s} found in ${r?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):e.live?i=this.hls.liveSyncPosition||t:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==B.FRAG_LOADING_WAITING_RETRY)&&(this.state=B.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let d=this.getCurrentContext(t.chunkMeta);d&&(t.frag=d.frag)}let i=t.frag;if(!i||i.type!==e||!this.levels)return;if(this.fragContextChanged(i)){var r;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(r=this.fragCurrent)==null?void 0:r.url}`);return}let s=t.details===N.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(i,!0);let n=t.errorAction,{action:o,retryCount:l=0,retryConfig:c}=n||{};if(n&&o===Ke.RetryRequest&&c){var u;this.resetStartWhenNotLoaded((u=this.levelLastLoaded)!=null?u:i.level);let d=Ss(c,l);this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${l+1}/${c.maxNumRetry} in ${d}ms`),n.resolved=!0,this.retryDate=self.performance.now()+d,this.state=B.FRAG_LOADING_WAITING_RETRY}else c&&n?(this.resetFragmentErrors(e),l<c.maxNumRetry?s||(n.resolved=!0):w.warn(`${t.details} reached or exceeded max retry (${l})`)):(n==null?void 0:n.action)===Ke.SendAlternateToPenaltyBox?this.state=B.WAITING_LEVEL:this.state=B.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===B.PARSING||this.state===B.PARSED){let t=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,t),r=i&&i.len>.5;r&&this.reduceMaxBufferLength(i.len);let s=!r;return s&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),s}return!1}resetFragmentErrors(e){e===re.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==B.STOPPED&&(this.state=B.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;let r=xe.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,i),this.state===B.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=B.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;let t=this.levels?this.levels[e].details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){var t;this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((t=this.levelLastLoaded)!=null?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,r){var s;let n=i.details;if(!n){this.warn("level.details undefined");return}if(Object.keys(e.elementaryStreams).reduce((l,c)=>{let u=e.elementaryStreams[c];if(u){let d=u.endPTS-u.startPTS;if(d<=0)return this.warn(`Could not parse fragment ${e.sn} ${c} duration reliably (${d})`),l||!1;let h=r?0:Da(n,e,u.startPTS,u.endPTS,u.startDTS,u.endDTS);return this.hls.trigger(v.LEVEL_PTS_UPDATED,{details:n,level:i,drift:h,type:c,frag:e,start:u.startPTS,end:u.endPTS}),!0}return l},!1))i.fragmentError=0;else if(((s=this.transmuxer)==null?void 0:s.error)===null){let l=new Error(`Found no media in fragment ${e.sn} of level ${i.id} resetting transmuxer to fallback to playlist timing`);if(this.warn(l.message),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=B.PARSED,this.hls.trigger(v.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){if(e.event==="demuxerWorker"){var t,i,r;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((t=(i=this.levelLastLoaded)!=null?i:(r=this.fragCurrent)==null?void 0:r.level)!=null?t:0),this.resetLoadingState()}}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}};function Ma(){return self.SourceBuffer||self.WebKitSourceBuffer}function yu(){let a=Hi();if(!a)return!1;let e=Ma(),t=a&&typeof a.isTypeSupported=="function"&&a.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function";return!!t&&!!i}function vu(){var a;let e=Ma();return typeof(e==null||(a=e.prototype)==null?void 0:a.changeType)=="function"}function Tu(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Eu(){let a=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(a);return{worker:new self.Worker(e),objectURL:e}}function xu(a){let e=new self.URL(a,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function ct(a="",e=9e4){return{type:a,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var Ii=class{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=It(this.cachedData,e),this.cachedData=null);let i=bi(e,0),r=i?i.length:0,s,n=this._audioTrack,o=this._id3Track,l=i?mc(i):void 0,c=e.length;for((this.basePTS===null||this.frameIndex===0&&J(l))&&(this.basePTS=bu(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ot.audioId3,duration:Number.POSITIVE_INFINITY});r<c;){if(this.canParse(e,r)){let u=this.appendFrame(n,e,r);u?(this.frameIndex++,this.lastPTS=u.sample.pts,r+=u.length,s=r):r=c}else gc(e,r)?(i=bi(e,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ot.audioId3,duration:Number.POSITIVE_INFINITY}),r+=i.length,s=r):r++;if(r===c&&s!==c){let u=Rt(e,s);this.cachedData?this.cachedData=It(this.cachedData,u):this.cachedData=u}}return{audioTrack:n,videoTrack:ct(),id3Track:o,textTrack:ct()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:ct(),id3Track:this._id3Track,textTrack:ct()}}destroy(){}},bu=(a,e,t)=>{if(J(a))return a*90;let i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};function _u(a,e,t,i){let r,s,n,o,l=navigator.userAgent.toLowerCase(),c=i,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((e[t+2]&192)>>>6)+1;let d=(e[t+2]&60)>>>2;if(d>u.length-1){a.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${d}`});return}return n=(e[t+2]&1)<<2,n|=(e[t+3]&192)>>>6,w.log(`manifest codec:${i}, ADTS type:${r}, samplingIndex:${d}`),/firefox/i.test(l)?d>=6?(r=5,o=new Array(4),s=d-3):(r=2,o=new Array(2),s=d):l.indexOf("android")!==-1?(r=2,o=new Array(2),s=d):(r=5,o=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&d>=6?s=d-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(d>=6&&n===1||/vivaldi/i.test(l))||!i&&n===1)&&(r=2,o=new Array(2)),s=d)),o[0]=r<<3,o[0]|=(d&14)>>1,o[1]|=(d&1)<<7,o[1]|=n<<3,r===5&&(o[1]|=(s&14)>>1,o[2]=(s&1)<<7,o[2]|=2<<2,o[3]=0),{config:o,samplerate:u[d],channelCount:n,codec:"mp4a.40."+r,manifestCodec:c}}function Fa(a,e){return a[e]===255&&(a[e+1]&246)===240}function Na(a,e){return a[e+1]&1?7:9}function Ls(a,e){return(a[e+3]&3)<<11|a[e+4]<<3|(a[e+5]&224)>>>5}function Su(a,e){return e+5<a.length}function Di(a,e){return e+1<a.length&&Fa(a,e)}function Au(a,e){return Su(a,e)&&Fa(a,e)&&Ls(a,e)<=a.length-e}function Lu(a,e){if(Di(a,e)){let t=Na(a,e);if(e+t>=a.length)return!1;let i=Ls(a,e);if(i<=t)return!1;let r=e+i;return r===a.length||Di(a,r)}return!1}function Ua(a,e,t,i,r){if(!a.samplerate){let s=_u(e,t,i,r);if(!s)return;a.config=s.config,a.samplerate=s.samplerate,a.channelCount=s.channelCount,a.codec=s.codec,a.manifestCodec=s.manifestCodec,w.log(`parsed codec:${a.codec}, rate:${s.samplerate}, channels:${s.channelCount}`)}}function Ba(a){return 1024*9e4/a}function Ru(a,e){let t=Na(a,e);if(e+t<=a.length){let i=Ls(a,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function $a(a,e,t,i,r){let s=Ba(a.samplerate),n=i+r*s,o=Ru(e,t),l;if(o){let{frameLength:d,headerLength:h}=o,m=h+d,y=Math.max(0,t+m-e.length);y?(l=new Uint8Array(m-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+m);let E={unit:l,pts:n};return y||a.samples.push(E),{sample:E,length:m,missing:y}}let c=e.length-t;return l=new Uint8Array(c),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:n},length:c,missing:-1}}var Kr=class extends Ii{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let i=(bi(e,0)||[]).length;for(let r=e.length;i<r;i++)if(Lu(e,i))return w.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Au(e,t)}appendFrame(e,t,i){Ua(e,this.observer,t,i,e.manifestCodec);let r=$a(e,t,i,this.basePTS,this.frameIndex);if(r&&r.missing===0)return r}},Iu=/\/emsg[-/]ID3/i,Vr=class{constructor(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}resetTimeStamp(){}resetInitSegment(e,t,i,r){let s=this.videoTrack=ct("video",1),n=this.audioTrack=ct("audio",1),o=this.txtTrack=ct("text",1);if(this.id3Track=ct("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=ba(e);if(l.video){let{id:c,timescale:u,codec:d}=l.video;s.id=c,s.timescale=o.timescale=u,s.codec=d}if(l.audio){let{id:c,timescale:u,codec:d}=l.audio;n.id=c,n.timescale=u,n.codec=d}o.id=Ta.text,s.sampleDuration=0,s.duration=n.duration=r}resetContiguity(){this.remainderData=null}static probe(e){return e=e.length>16384?e.subarray(0,16384):e,ye(e,["moof"]).length>0}demux(e,t){this.timeOffset=t;let i=e,r=this.videoTrack,s=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=It(this.remainderData,e));let o=wc(i);this.remainderData=o.remainder,r.samples=o.valid||new Uint8Array}else r.samples=i;let n=this.extractID3Track(r,t);return s.samples=wn(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let r=this.extractID3Track(t,this.timeOffset);return i.samples=wn(e,t),{videoTrack:t,audioTrack:ct(),id3Track:r,textTrack:ct()}}extractID3Track(e,t){let i=this.id3Track;if(e.samples.length){let r=ye(e.samples,["emsg"]);r&&r.forEach(s=>{let n=Pc(s);if(Iu.test(n.schemeIdUri)){let o=J(n.presentationTime)?n.presentationTime/n.timeScale:t+n.presentationTimeDelta/n.timeScale,l=n.eventDuration===4294967295?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);let c=n.payload;i.samples.push({data:c,len:c.byteLength,dts:o,pts:o,type:ot.emsg,duration:l})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},gi=null,Du=[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],wu=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ku=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Cu=[0,1,1,4];function Ga(a,e,t,i,r){if(t+24>e.length)return;let s=Ha(e,t);if(s&&t+s.frameLength<=e.length){let n=s.samplesPerFrame*9e4/s.sampleRate,o=i+r*n,l={unit:e.subarray(t,t+s.frameLength),pts:o,dts:o};return a.config=[],a.channelCount=s.channelCount,a.samplerate=s.sampleRate,a.samples.push(l),{sample:l,length:s.frameLength,missing:0}}}function Ha(a,e){let t=a[e+1]>>3&3,i=a[e+1]>>1&3,r=a[e+2]>>4&15,s=a[e+2]>>2&3;if(t!==1&&r!==0&&r!==15&&s!==3){let n=a[e+2]>>1&1,o=a[e+3]>>6,l=t===3?3-i:i===3?3:4,c=Du[l*14+r-1]*1e3,d=wu[(t===3?0:t===2?1:2)*3+s],h=o===3?1:2,m=ku[t][i],y=Cu[i],E=m*8*y,b=Math.floor(m*c/d+n)*y;if(gi===null){let L=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);gi=L?parseInt(L[1]):0}return!!gi&&gi<=87&&i===2&&c>=224e3&&o===0&&(a[e+3]=a[e+3]|128),{sampleRate:d,channelCount:h,frameLength:b,samplesPerFrame:E}}}function Rs(a,e){return a[e]===255&&(a[e+1]&224)===224&&(a[e+1]&6)!==0}function Ka(a,e){return e+1<a.length&&Rs(a,e)}function Pu(a,e){return Rs(a,e)&&4<=a.length-e}function Ou(a,e){if(e+1<a.length&&Rs(a,e)){let i=Ha(a,e),r=4;i!=null&&i.frameLength&&(r=i.frameLength);let s=e+r;return s===a.length||Ka(a,s)}return!1}var wi=class{constructor(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}loadWord(){let e=this.data,t=this.bytesAvailable,i=e.byteLength-t,r=new Uint8Array(4),s=Math.min(4,t);if(s===0)throw new Error("no bytes available");r.set(e.subarray(i,i+s)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=s*8,this.bytesAvailable-=s}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&w.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let 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()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,i=8,r;for(let s=0;s<e;s++)i!==0&&(r=this.readEG(),i=(t+r+256)%256),t=i===0?t:i}readSPS(){let e=0,t=0,i=0,r=0,s,n,o,l=this.readUByte.bind(this),c=this.readBits.bind(this),u=this.readUEG.bind(this),d=this.readBoolean.bind(this),h=this.skipBits.bind(this),m=this.skipEG.bind(this),y=this.skipUEG.bind(this),E=this.skipScalingList.bind(this);l();let b=l();if(c(5),h(3),l(),y(),b===100||b===110||b===122||b===244||b===44||b===83||b===86||b===118||b===128){let G=u();if(G===3&&h(1),y(),y(),h(1),d())for(n=G!==3?8:12,o=0;o<n;o++)d()&&(o<6?E(16):E(64))}y();let A=u();if(A===0)u();else if(A===1)for(h(1),m(),m(),s=u(),o=0;o<s;o++)m();y(),h(1);let D=u(),L=u(),F=c(1);F===0&&h(1),h(1),d()&&(e=u(),t=u(),i=u(),r=u());let k=[1,1];if(d()&&d())switch(l()){case 1:k=[1,1];break;case 2:k=[12,11];break;case 3:k=[10,11];break;case 4:k=[16,11];break;case 5:k=[40,33];break;case 6:k=[24,11];break;case 7:k=[20,11];break;case 8:k=[32,11];break;case 9:k=[80,33];break;case 10:k=[18,11];break;case 11:k=[15,11];break;case 12:k=[64,33];break;case 13:k=[160,99];break;case 14:k=[4,3];break;case 15:k=[3,2];break;case 16:k=[2,1];break;case 255:{k=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((D+1)*16-e*2-t*2),height:(2-F)*(L+1)*16-(F?2:4)*(i+r),pixelRatio:k}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},qr=class{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new ti(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,i){let r=e[t].unit;if(r.length<=16)return;let s=r.subarray(16,r.length-r.length%16),n=s.buffer.slice(s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(n).then(o=>{let l=new Uint8Array(o);r.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)})}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t),r=0;for(let s=32;s<e.length-16;s+=160,r+=16)i.set(e.subarray(s,s+16),r);return i}getAvcDecryptedUnit(e,t){let i=new Uint8Array(t),r=0;for(let s=32;s<e.length-16;s+=160,r+=16)e.set(i.subarray(r,r+16),s);return e}decryptAvcSample(e,t,i,r,s){let n=Aa(s.data),o=this.getAvcEncryptedData(n);this.decryptBuffer(o.buffer).then(l=>{s.data=this.getAvcDecryptedUnit(n,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,r)})}decryptAvcSamples(e,t,i,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){r();return}let s=e[t].units;for(;!(i>=s.length);i++){let n=s[i];if(!(n.data.length<=48||n.type!==1&&n.type!==5)&&(this.decryptAvcSample(e,t,i,r,n),!this.decrypter.isSync()))return}}}},Be=188,ut=class{constructor(e,t,i){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=i}static probe(e){let t=ut.syncOffset(e);return t>0&&w.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,i=Math.min(Be*5,e.length-Be)+1,r=0;for(;r<i;){let s=!1,n=-1,o=0;for(let l=r;l<t;l+=Be)if(e[l]===71){if(o++,n===-1&&(n=l,n!==0&&(i=Math.min(n+Be*99,e.length-Be)+1)),s||(s=Wr(e,l)===0),s&&o>1&&(n===0&&o>2||l+Be>i))return n}else{if(o)return-1;break}r++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Ta[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,r){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=ut.createTrack("video"),this._audioTrack=ut.createTrack("audio",r),this._id3Track=ut.createTrack("id3"),this._txtTrack=ut.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=r}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_avcTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,i=!1,r=!1){i||(this.sampleAes=null);let s,n=this._avcTrack,o=this._audioTrack,l=this._id3Track,c=this._txtTrack,u=n.pid,d=n.pesData,h=o.pid,m=l.pid,y=o.pesData,E=l.pesData,b=null,A=this.pmtParsed,D=this._pmtId,L=e.length;if(this.remainderData&&(e=It(this.remainderData,e),L=e.length,this.remainderData=null),L<Be&&!r)return this.remainderData=e,{audioTrack:o,videoTrack:n,id3Track:l,textTrack:c};let F=Math.max(0,ut.syncOffset(e));L-=(L-F)%Be,L<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));let k=0;for(let M=F;M<L;M+=Be)if(e[M]===71){let $=!!(e[M+1]&64),K=Wr(e,M),P=(e[M+3]&48)>>4,q;if(P>1){if(q=M+5+e[M+4],q===M+Be)continue}else q=M+4;switch(K){case u:$&&(d&&(s=Mt(d))&&this.parseAVCPES(n,c,s,!1),d={data:[],size:0}),d&&(d.data.push(e.subarray(q,M+Be)),d.size+=M+Be-q);break;case h:if($){if(y&&(s=Mt(y)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,s);break;case"mp3":this.parseMPEGPES(o,s);break}y={data:[],size:0}}y&&(y.data.push(e.subarray(q,M+Be)),y.size+=M+Be-q);break;case m:$&&(E&&(s=Mt(E))&&this.parseID3PES(l,s),E={data:[],size:0}),E&&(E.data.push(e.subarray(q,M+Be)),E.size+=M+Be-q);break;case 0:$&&(q+=e[q]+1),D=this._pmtId=Mu(e,q);break;case D:{$&&(q+=e[q]+1);let H=Fu(e,q,this.typeSupported,i);u=H.avc,u>0&&(n.pid=u),h=H.audio,h>0&&(o.pid=h,o.segmentCodec=H.segmentCodec),m=H.id3,m>0&&(l.pid=m),b!==null&&!A&&(w.warn(`MPEG-TS PMT found at ${M} after unknown PID '${b}'. Backtracking to sync byte @${F} to parse all TS packets.`),b=null,M=F-188),A=this.pmtParsed=!0;break}case 17:case 8191:break;default:b=K;break}}else k++;if(k>0){let M=new Error(`Found ${k} TS packet/s that do not start with 0x47`);this.observer.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:N.FRAG_PARSING_ERROR,fatal:!1,error:M,reason:M.message})}n.pesData=d,o.pesData=y,l.pesData=E;let G={audioTrack:o,videoTrack:n,id3Track:l,textTrack:c};return r&&this.extractRemainingSamples(G),G}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){let{audioTrack:t,videoTrack:i,id3Track:r,textTrack:s}=e,n=i.pesData,o=t.pesData,l=r.pesData,c;if(n&&(c=Mt(n))?(this.parseAVCPES(i,s,c,!0),i.pesData=null):i.pesData=n,o&&(c=Mt(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,c);break;case"mp3":this.parseMPEGPES(t,c);break}t.pesData=null}else o!=null&&o.size&&w.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(c=Mt(l))?(this.parseID3PES(r,c),r.pesData=null):r.pesData=l}demuxSampleAes(e,t,i){let r=this.demux(e,i,!0,!this.config.progressive),s=this.sampleAes=new qr(this.observer,this.config,t);return this.decrypt(r,s)}decrypt(e,t){return new Promise(i=>{let{audioTrack:r,videoTrack:s}=e;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,()=>{s.samples?t.decryptAvcSamples(s.samples,0,0,()=>{i(e)}):i(e)}):s.samples&&t.decryptAvcSamples(s.samples,0,0,()=>{i(e)})})}destroy(){this._duration=0}parseAVCPES(e,t,i,r){let s=this.parseAVCNALu(e,i.data),n=this.avcSample,o,l=!1;i.data=null,n&&s.length&&!e.audFound&&(cr(n,e),n=this.avcSample=mi(!1,i.pts,i.dts,"")),s.forEach(c=>{switch(c.type){case 1:{o=!0,n||(n=this.avcSample=mi(!0,i.pts,i.dts,"")),n.frame=!0;let u=c.data;if(l&&u.length>4){let d=new wi(u).readSliceType();(d===2||d===4||d===7||d===9)&&(n.key=!0)}break}case 5:o=!0,n||(n=this.avcSample=mi(!0,i.pts,i.dts,"")),n.key=!0,n.frame=!0;break;case 6:{o=!0,Sa(c.data,1,i.pts,t.samples);break}case 7:if(o=!0,l=!0,!e.sps){let u=c.data,h=new wi(u).readSPS();e.width=h.width,e.height=h.height,e.pixelRatio=h.pixelRatio,e.sps=[u],e.duration=this._duration;let m=u.subarray(1,4),y="avc1.";for(let E=0;E<3;E++){let b=m[E].toString(16);b.length<2&&(b="0"+b),y+=b}e.codec=y}break;case 8:o=!0,e.pps||(e.pps=[c.data]);break;case 9:o=!1,e.audFound=!0,n&&cr(n,e),n=this.avcSample=mi(!1,i.pts,i.dts,"");break;case 12:o=!0;break;default:o=!1,n&&(n.debug+="unknown NAL "+c.type+" ");break}n&&o&&n.units.push(c)}),r&&n&&(cr(n,e),this.avcSample=null)}getLastNalUnit(e){var t;let i=this.avcSample,r;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){let s=i.units;r=s[s.length-1]}return r}parseAVCNALu(e,t){let i=t.byteLength,r=e.naluState||0,s=r,n=[],o=0,l,c,u,d=-1,h=0;for(r===-1&&(d=0,h=t[0]&31,r=0,o=1);o<i;){if(l=t[o++],!r){r=l?0:1;continue}if(r===1){r=l?0:2;continue}if(!l)r=3;else if(l===1){if(d>=0){let m={data:t.subarray(d,o-r-1),type:h};n.push(m)}else{let m=this.getLastNalUnit(e.samples);if(m&&(s&&o<=4-s&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-s)),c=o-r-1,c>0)){let y=new Uint8Array(m.data.byteLength+c);y.set(m.data,0),y.set(t.subarray(0,c),m.data.byteLength),m.data=y,m.state=0}}o<i?(u=t[o]&31,d=o,h=u,r=0):r=-1}else r=0}if(d>=0&&r>=0){let m={data:t.subarray(d,i),type:h,state:r};n.push(m)}if(n.length===0){let m=this.getLastNalUnit(e.samples);if(m){let y=new Uint8Array(m.data.byteLength+t.byteLength);y.set(m.data,0),y.set(t,m.data.byteLength),m.data=y}}return e.naluState=r,n}parseAACPES(e,t){let i=0,r=this.aacOverFlow,s=t.data;if(r){this.aacOverFlow=null;let d=r.missing,h=r.sample.unit.byteLength;if(d===-1){let m=new Uint8Array(h+s.byteLength);m.set(r.sample.unit,0),m.set(s,h),s=m}else{let m=h-d;r.sample.unit.set(s.subarray(0,d),m),e.samples.push(r.sample),i=r.missing}}let n,o;for(n=i,o=s.length;n<o-1&&!Di(s,n);n++);if(n!==i){let d,h=n<o-1;h?d=`AAC PES did not start with ADTS header,offset:${n}`:d="No ADTS header found in AAC PES";let m=new Error(d);if(w.warn(`parsing error: ${d}`),this.observer.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:N.FRAG_PARSING_ERROR,fatal:!1,levelRetry:h,error:m,reason:d}),!h)return}Ua(e,this.observer,s,n,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(r){let d=Ba(e.samplerate);l=r.sample.pts+d}else{w.warn("[tsdemuxer]: AAC PES unknown PTS");return}let c=0,u;for(;n<o;)if(u=$a(e,s,n,l,c),n+=u.length,u.missing){this.aacOverFlow=u;break}else for(c++;n<o-1&&!Di(s,n);n++);}parseMPEGPES(e,t){let i=t.data,r=i.length,s=0,n=0,o=t.pts;if(o===void 0){w.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;n<r;)if(Ka(i,n)){let l=Ga(e,i,n,o,s);if(l)n+=l.length,s++;else break}else n++}parseID3PES(e,t){if(t.pts===void 0){w.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let i=Ie({},t,{type:this._avcTrack?ot.emsg:ot.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}};function mi(a,e,t,i){return{key:a,frame:!1,pts:e,dts:t,units:[],debug:i,length:0}}function Wr(a,e){return((a[e+1]&31)<<8)+a[e+2]}function Mu(a,e){return(a[e+10]&31)<<8|a[e+11]}function Fu(a,e,t,i){let r={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},s=(a[e+1]&15)<<8|a[e+2],n=e+3+s-4,o=(a[e+10]&15)<<8|a[e+11];for(e+=12+o;e<n;){let l=Wr(a,e);switch(a[e]){case 207:if(!i){w.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:r.audio===-1&&(r.audio=l);break;case 21:r.id3===-1&&(r.id3=l);break;case 219:if(!i){w.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:r.avc===-1&&(r.avc=l);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?w.log("MPEG audio found, not supported in this browser"):r.audio===-1&&(r.audio=l,r.segmentCodec="mp3");break;case 36:w.warn("Unsupported HEVC stream type found");break}e+=((a[e+3]&15)<<8|a[e+4])+5}return r}function Mt(a){let e=0,t,i,r,s,n,o=a.data;if(!a||a.size===0)return null;for(;o[0].length<19&&o.length>1;){let c=new Uint8Array(o[0].length+o[1].length);c.set(o[0]),c.set(o[1],o[0].length),o[0]=c,o.splice(1,1)}if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(i=(t[4]<<8)+t[5],i&&i>a.size-6)return null;let c=t[7];c&192&&(s=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,c&64?(n=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,s-n>60*9e4&&(w.warn(`${Math.round((s-n)/9e4)}s delta between PTS and DTS, align them`),s=n)):n=s),r=t[8];let u=r+9;if(a.size<=u)return null;a.size-=u;let d=new Uint8Array(a.size);for(let h=0,m=o.length;h<m;h++){t=o[h];let y=t.byteLength;if(u)if(u>y){u-=y;continue}else t=t.subarray(u),y-=u,u=0;d.set(t,e),e+=y}return i&&(i-=r+3),{data:d,pts:s,dts:n,len:i}}return null}function cr(a,e){if(a.units.length&&a.frame){if(a.pts===void 0){let t=e.samples,i=t.length;if(i){let r=t[i-1];a.pts=r.pts,a.dts=r.dts}else{e.dropped++;return}}e.samples.push(a)}a.debug.length&&w.log(a.pts+"/"+a.dts+":"+a.debug)}var jr=class extends Ii{resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let i=(bi(e,0)||[]).length;for(let r=e.length;i<r;i++)if(Ou(e,i))return w.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Pu(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return Ga(e,t,i,this.basePTS,this.frameIndex)}},ki=class{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===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(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===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(t===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(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}},xt=Math.pow(2,32)-1,C=class{static init(){C.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:[]};let e;for(e in C.types)C.types.hasOwnProperty(e)&&(C.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=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]),i=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]);C.HDLR_TYPES={video:t,audio:i};let r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);C.STTS=C.STSC=C.STCO=s,C.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),C.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),C.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),C.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let n=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);C.FTYP=C.box(C.types.ftyp,n,l,n,o),C.DINF=C.box(C.types.dinf,C.box(C.types.dref,r))}static box(e,...t){let i=8,r=t.length,s=r;for(;r--;)i+=t[r].byteLength;let n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=i&255,n.set(e,4),r=0,i=8;r<s;r++)n.set(t[r],i),i+=t[r].byteLength;return n}static hdlr(e){return C.box(C.types.hdlr,C.HDLR_TYPES[e])}static mdat(e){return C.box(C.types.mdat,e)}static mdhd(e,t){t*=e;let i=Math.floor(t/(xt+1)),r=Math.floor(t%(xt+1));return C.box(C.types.mdhd,new Uint8Array([1,0,0,0,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,e&255,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}static mdia(e){return C.box(C.types.mdia,C.mdhd(e.timescale,e.duration),C.hdlr(e.type),C.minf(e))}static mfhd(e){return C.box(C.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?C.box(C.types.minf,C.box(C.types.smhd,C.SMHD),C.DINF,C.stbl(e)):C.box(C.types.minf,C.box(C.types.vmhd,C.VMHD),C.DINF,C.stbl(e))}static moof(e,t,i){return C.box(C.types.moof,C.mfhd(e),C.traf(i,t))}static moov(e){let t=e.length,i=[];for(;t--;)i[t]=C.trak(e[t]);return C.box.apply(null,[C.types.moov,C.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(C.mvex(e)))}static mvex(e){let t=e.length,i=[];for(;t--;)i[t]=C.trex(e[t]);return C.box.apply(null,[C.types.mvex,...i])}static mvhd(e,t){t*=e;let i=Math.floor(t/(xt+1)),r=Math.floor(t%(xt+1)),s=new Uint8Array([1,0,0,0,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,e&255,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return C.box(C.types.mvhd,s)}static sdtp(e){let t=e.samples||[],i=new Uint8Array(4+t.length),r,s;for(r=0;r<t.length;r++)s=t[r].flags,i[r+4]=s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy;return C.box(C.types.sdtp,i)}static stbl(e){return C.box(C.types.stbl,C.stsd(e),C.box(C.types.stts,C.STTS),C.box(C.types.stsc,C.STSC),C.box(C.types.stsz,C.STSZ),C.box(C.types.stco,C.STCO))}static avc1(e){let t=[],i=[],r,s,n;for(r=0;r<e.sps.length;r++)s=e.sps[r],n=s.byteLength,t.push(n>>>8&255),t.push(n&255),t=t.concat(Array.prototype.slice.call(s));for(r=0;r<e.pps.length;r++)s=e.pps[r],n=s.byteLength,i.push(n>>>8&255),i.push(n&255),i=i.concat(Array.prototype.slice.call(s));let o=C.box(C.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),l=e.width,c=e.height,u=e.pixelRatio[0],d=e.pixelRatio[1];return C.box(C.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,l&255,c>>8&255,c&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,C.box(C.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),C.box(C.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,d>>24,d>>16&255,d>>8&255,d&255])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){let t=e.samplerate;return C.box(C.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]),C.box(C.types.esds,C.esds(e)))}static mp3(e){let t=e.samplerate;return C.box(C.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?C.box(C.types.stsd,C.STSD,C.mp3(e)):C.box(C.types.stsd,C.STSD,C.mp4a(e)):C.box(C.types.stsd,C.STSD,C.avc1(e))}static tkhd(e){let t=e.id,i=e.duration*e.timescale,r=e.width,s=e.height,n=Math.floor(i/(xt+1)),o=Math.floor(i%(xt+1));return C.box(C.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,r&255,0,0,s>>8&255,s&255,0,0]))}static traf(e,t){let i=C.sdtp(e),r=e.id,s=Math.floor(t/(xt+1)),n=Math.floor(t%(xt+1));return C.box(C.types.traf,C.box(C.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),C.box(C.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,s&255,n>>24,n>>16&255,n>>8&255,n&255])),C.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,C.box(C.types.trak,C.tkhd(e),C.mdia(e))}static trex(e){let t=e.id;return C.box(C.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let i=e.samples||[],r=i.length,s=12+16*r,n=new Uint8Array(s),o,l,c,u,d,h;for(t+=8+s,n.set([e.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<r;o++)l=i[o],c=l.duration,u=l.size,d=l.flags,h=l.cts,n.set([c>>>24&255,c>>>16&255,c>>>8&255,c&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|d.isNonSync,d.degradPrio&240<<8,d.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return C.box(C.types.trun,n)}static initSegment(e){C.types||C.init();let t=C.moov(e),i=new Uint8Array(C.FTYP.byteLength+t.byteLength);return i.set(C.FTYP),i.set(t,C.FTYP.byteLength),i}};C.types=void 0;C.HDLR_TYPES=void 0;C.STTS=void 0;C.STSC=void 0;C.STCO=void 0;C.STSZ=void 0;C.VMHD=void 0;C.SMHD=void 0;C.STSD=void 0;C.FTYP=void 0;C.DINF=void 0;var Va=9e4;function Is(a,e,t=1,i=!1){let r=a*e*t;return i?Math.round(r):r}function Nu(a,e,t=1,i=!1){return Is(a,e,1/t,i)}function Wt(a,e=!1){return Is(a,1e3,1/Va,e)}function Uu(a,e=1){return Is(a,Va,1/e)}var Bu=10*1e3,Jn=1024,$u=1152,pi=null,ur=null,Xt=class{constructor(e,t,i,r=""){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=i,this.ISGenerated=!1,pi===null){let n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);pi=n?parseInt(n[1]):0}if(ur===null){let s=navigator.userAgent.match(/Safari\/(\d+)/i);ur=s?parseInt(s[1]):0}}destroy(){}resetTimeStamp(e){w.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){w.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){w.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let t=!1,i=e.reduce((r,s)=>{let n=s.pts-r;return n<-4294967296?(t=!0,rt(r,s.pts)):n>0?r:s.pts},e[0].pts);return t&&w.debug("PTS rollover detected"),i}remux(e,t,i,r,s,n,o,l){let c,u,d,h,m,y,E=s,b=s,A=e.pid>-1,D=t.pid>-1,L=t.samples.length,F=e.samples.length>0,k=o&&L>0||L>1;if((!A||F)&&(!D||k)||this.ISGenerated||o){this.ISGenerated||(d=this.generateIS(e,t,s,n));let M=this.isVideoContiguous,$=-1,K;if(k&&($=Gu(t.samples),!M&&this.config.forceKeyFrameOnDiscontinuity))if(y=!0,$>0){w.warn(`[mp4-remuxer]: Dropped ${$} out of ${L} video samples due to a missing keyframe`);let P=this.getVideoStartPts(t.samples);t.samples=t.samples.slice($),t.dropped+=$,b+=(t.samples[0].pts-P)/t.inputTimeScale,K=b}else $===-1&&(w.warn(`[mp4-remuxer]: No keyframe found out of ${L} video samples`),y=!1);if(this.ISGenerated){if(F&&k){let P=this.getVideoStartPts(t.samples),H=(rt(e.samples[0].pts,P)-P)/t.inputTimeScale;E+=Math.max(0,H),b+=Math.max(0,-H)}if(F){if(e.samplerate||(w.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(e,t,s,n)),u=this.remuxAudio(e,E,this.isAudioContiguous,n,D||k||l===re.AUDIO?b:void 0),k){let P=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(w.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(e,t,s,n)),c=this.remuxVideo(t,b,M,P)}}else k&&(c=this.remuxVideo(t,b,M,0));c&&(c.firstKeyFrame=$,c.independent=$!==-1,c.firstKeyFramePTS=K)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(m=qa(i,s,this._initPTS,this._initDTS)),r.samples.length&&(h=Wa(r,s,this._initPTS))),{audio:u,video:c,initSegment:d,independent:y,text:h,id3:m}}generateIS(e,t,i,r){let s=e.samples,n=t.samples,o=this.typeSupported,l={},c=this._initPTS,u=!c||r,d="audio/mp4",h,m,y;if(u&&(h=m=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(d="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break}l.audio={id:"audio",container:d,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):C.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(y=e.inputTimeScale,!c||y!==c.timescale?h=m=s[0].pts-Math.round(y*i):u=!1)}if(t.sps&&t.pps&&n.length&&(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:C.initSegment([t]),metadata:{width:t.width,height:t.height}},u))if(y=t.inputTimeScale,!c||y!==c.timescale){let E=this.getVideoStartPts(n),b=Math.round(y*i);m=Math.min(m,rt(n[0].dts,E)-b),h=Math.min(h,E-b)}else u=!1;if(Object.keys(l).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:h,timescale:y},this._initDTS={baseTime:m,timescale:y}):h=y=void 0,{tracks:l,initPTS:h,timescale:y}}remuxVideo(e,t,i,r){let s=e.inputTimeScale,n=e.samples,o=[],l=n.length,c=this._initPTS,u=this.nextAvcDts,d=8,h=this.videoSampleDuration,m,y,E=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,A=!1;if(!i||u===null){let j=t*s,X=n[0].pts-rt(n[0].dts,n[0].pts);u=j-X}let D=c.baseTime*s/c.timescale;for(let j=0;j<l;j++){let X=n[j];X.pts=rt(X.pts-D,u),X.dts=rt(X.dts-D,u),X.dts<n[j>0?j-1:j].dts&&(A=!0)}A&&n.sort(function(j,X){let Y=j.dts-X.dts,de=j.pts-X.pts;return Y||de}),m=n[0].dts,y=n[n.length-1].dts;let L=y-m,F=L?Math.round(L/(l-1)):h||e.inputTimeScale/30;if(i){let j=m-u,X=j>F,Y=j<-1;if((X||Y)&&(X?w.warn(`AVC: ${Wt(j,!0)} ms (${j}dts) hole between fragments detected, filling it`):w.warn(`AVC: ${Wt(-j,!0)} ms (${j}dts) overlapping between fragments detected`),!Y||u>=n[0].pts)){m=u;let de=n[0].pts-j;n[0].dts=m,n[0].pts=de,w.log(`Video: First PTS/DTS adjusted: ${Wt(de,!0)}/${Wt(m,!0)}, delta: ${Wt(j,!0)} ms`)}}m=Math.max(0,m);let k=0,G=0;for(let j=0;j<l;j++){let X=n[j],Y=X.units,de=Y.length,he=0;for(let _e=0;_e<de;_e++)he+=Y[_e].data.length;G+=he,k+=de,X.length=he,X.dts=Math.max(X.dts,m),E=Math.min(X.pts,E),b=Math.max(X.pts,b)}y=n[l-1].dts;let M=G+4*k+8,$;try{$=new Uint8Array(M)}catch(j){this.observer.emit(v.ERROR,v.ERROR,{type:ie.MUX_ERROR,details:N.REMUX_ALLOC_ERROR,fatal:!1,error:j,bytes:M,reason:`fail allocating video mdat ${M}`});return}let K=new DataView($.buffer);K.setUint32(0,M),$.set(C.types.mdat,4);let P=!1,q=Number.POSITIVE_INFINITY,H=Number.POSITIVE_INFINITY,ce=Number.NEGATIVE_INFINITY,oe=Number.NEGATIVE_INFINITY;for(let j=0;j<l;j++){let X=n[j],Y=X.units,de=0;for(let Ge=0,qe=Y.length;Ge<qe;Ge++){let We=Y[Ge],pt=We.data,kt=We.data.byteLength;K.setUint32(d,kt),d+=4,$.set(pt,d),d+=kt,de+=4+kt}let he;if(j<l-1)h=n[j+1].dts-X.dts,he=n[j+1].pts-X.pts;else{let Ge=this.config,qe=j>0?X.dts-n[j-1].dts:F;if(he=j>0?X.pts-n[j-1].pts:F,Ge.stretchShortVideoTrack&&this.nextAudioPts!==null){let We=Math.floor(Ge.maxBufferHole*s),pt=(r?E+r*s:this.nextAudioPts)-X.pts;pt>We?(h=pt-qe,h<0?h=qe:P=!0,w.log(`[mp4-remuxer]: It is approximately ${pt/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=qe}else h=qe}let _e=Math.round(X.pts-X.dts);q=Math.min(q,h),ce=Math.max(ce,h),H=Math.min(H,he),oe=Math.max(oe,he),o.push(new Ci(X.key,h,de,_e))}if(o.length){if(pi){if(pi<70){let j=o[0].flags;j.dependsOn=2,j.isNonSync=0}}else if(ur&&oe-H<ce-q&&F/ce<.025&&o[0].cts===0){w.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let j=m;for(let X=0,Y=o.length;X<Y;X++){let de=j+o[X].duration,he=j+o[X].cts;if(X<Y-1){let _e=de+o[X+1].cts;o[X].duration=_e-he}else o[X].duration=X?o[X-1].duration:F;o[X].cts=0,j=de}}}h=P||!h?F:h,this.nextAvcDts=u=y+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let le=C.moof(e.sequenceNumber++,m,Ie({},e,{samples:o})),Te="video",ge={data1:le,data2:$,startPTS:E/s,endPTS:(b+h)/s,startDTS:m/s,endDTS:u/s,type:Te,hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ge}remuxAudio(e,t,i,r,s){let n=e.inputTimeScale,o=e.samplerate?e.samplerate:n,l=n/o,c=e.segmentCodec==="aac"?Jn:$u,u=c*l,d=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,m=[],y=s!==void 0,E=e.samples,b=h?0:8,A=this.nextAudioPts||-1,D=t*n,L=d.baseTime*n/d.timescale;if(this.isAudioContiguous=i=i||E.length&&A>0&&(r&&Math.abs(D-A)<9e3||Math.abs(rt(E[0].pts-L,D)-A)<20*u),E.forEach(function(Te){Te.pts=rt(Te.pts-L,D)}),!i||A<0){if(E=E.filter(Te=>Te.pts>=0),!E.length)return;s===0?A=0:r&&!y?A=Math.max(0,D):A=E[0].pts}if(e.segmentCodec==="aac"){let Te=this.config.maxAudioFramesDrift;for(let ge=0,j=A;ge<E.length;ge++){let X=E[ge],Y=X.pts,de=Y-j,he=Math.abs(1e3*de/n);if(de<=-Te*u&&y)ge===0&&(w.warn(`Audio frame @ ${(Y/n).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*de/n)} ms.`),this.nextAudioPts=A=j=Y);else if(de>=Te*u&&he<Bu&&y){let _e=Math.round(de/u);j=Y-_e*u,j<0&&(_e--,j+=u),ge===0&&(this.nextAudioPts=A=j),w.warn(`[mp4-remuxer]: Injecting ${_e} audio frame @ ${(j/n).toFixed(3)}s due to ${Math.round(1e3*de/n)} ms gap.`);for(let Ge=0;Ge<_e;Ge++){let qe=Math.max(j,0),We=ki.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);We||(w.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),We=X.unit.subarray()),E.splice(ge,0,{unit:We,pts:qe}),j+=u,ge++}}X.pts=j,j+=u}}let F=null,k=null,G,M=0,$=E.length;for(;$--;)M+=E[$].unit.byteLength;for(let Te=0,ge=E.length;Te<ge;Te++){let j=E[Te],X=j.unit,Y=j.pts;if(k!==null){let he=m[Te-1];he.duration=Math.round((Y-k)/l)}else if(i&&e.segmentCodec==="aac"&&(Y=A),F=Y,M>0){M+=b;try{G=new Uint8Array(M)}catch(he){this.observer.emit(v.ERROR,v.ERROR,{type:ie.MUX_ERROR,details:N.REMUX_ALLOC_ERROR,fatal:!1,error:he,bytes:M,reason:`fail allocating audio mdat ${M}`});return}h||(new DataView(G.buffer).setUint32(0,M),G.set(C.types.mdat,4))}else return;G.set(X,b);let de=X.byteLength;b+=de,m.push(new Ci(!0,c,de,0)),k=Y}let K=m.length;if(!K)return;let P=m[m.length-1];this.nextAudioPts=A=k+l*P.duration;let q=h?new Uint8Array(0):C.moof(e.sequenceNumber++,F/l,Ie({},e,{samples:m}));e.samples=[];let H=F/n,ce=A/n,le={data1:q,data2:G,startPTS:H,endPTS:ce,startDTS:H,endDTS:ce,type:"audio",hasAudio:!0,hasVideo:!1,nb:K};return this.isAudioContiguous=!0,le}remuxEmptyAudio(e,t,i,r){let s=e.inputTimeScale,n=e.samplerate?e.samplerate:s,o=s/n,l=this.nextAudioPts,c=this._initDTS,u=c.baseTime*9e4/c.timescale,d=(l!==null?l:r.startDTS*s)+u,h=r.endDTS*s+u,m=o*Jn,y=Math.ceil((h-d)/m),E=ki.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(w.warn("[mp4-remuxer]: remux empty Audio"),!E){w.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let b=[];for(let A=0;A<y;A++){let D=d+A*m;b.push({unit:E,pts:D,dts:D})}return e.samples=b,this.remuxAudio(e,t,i,!1)}};function rt(a,e){let t;if(e===null)return a;for(e<a?t=-8589934592:t=8589934592;Math.abs(a-e)>4294967296;)a+=t;return a}function Gu(a){for(let e=0;e<a.length;e++)if(a[e].key)return e;return-1}function qa(a,e,t,i){let r=a.samples.length;if(!r)return;let s=a.inputTimeScale;for(let o=0;o<r;o++){let l=a.samples[o];l.pts=rt(l.pts-t.baseTime*s/t.timescale,e*s)/s,l.dts=rt(l.dts-i.baseTime*s/i.timescale,e*s)/s}let n=a.samples;return a.samples=[],{samples:n}}function Wa(a,e,t){let i=a.samples.length;if(!i)return;let r=a.inputTimeScale;for(let n=0;n<i;n++){let o=a.samples[n];o.pts=rt(o.pts-t.baseTime*9e4/t.timescale,e*r)/r}a.samples.sort((n,o)=>n.pts-o.pts);let s=a.samples;return a.samples=[],{samples:s}}var Ci=class{constructor(e,t,i,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=i,this.cts=r,this.flags=new Yr(e)}},Yr=class{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}},zr=class{constructor(){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}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,i,r){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(Ac(e,r)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:i}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let r=this.initData=ba(e);t||(t=Zn(r.audio,Ee.AUDIO)),i||(i=Zn(r.video,Ee.VIDEO));let s={};r.audio&&r.video?s.audiovideo={container:"video/mp4",codec:t+","+i,initSegment:e,id:"main"}:r.audio?s.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:r.video?s.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:w.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=s}remux(e,t,i,r,s,n){var o,l;let{initPTS:c,lastEndTime:u}=this,d={audio:void 0,video:void 0,text:r,id3:i,initSegment:void 0};J(u)||(u=this.lastEndTime=s||0);let h=t.samples;if(!(h!=null&&h.length))return d;let m={initPTS:void 0,timescale:1},y=this.initData;if((o=y)!=null&&o.length||(this.generateInitSegment(h),y=this.initData),!((l=y)!=null&&l.length))return w.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(m.tracks=this.initTracks,this.emitInitSegment=!1);let E=Rc(h,y),b=Lc(y,h),A=b===null?s:b;(Hu(c,A,s,E)||m.timescale!==c.timescale&&n)&&(m.initPTS=A-s,c&&c.timescale===1&&w.warn(`Adjusting initPTS by ${m.initPTS-c.baseTime}`),this.initPTS=c={baseTime:m.initPTS,timescale:1});let D=e?A-c.baseTime/c.timescale:u,L=D+E;Dc(y,h,c.baseTime/c.timescale),E>0?this.lastEndTime=L:(w.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let F=!!y.audio,k=!!y.video,G="";F&&(G+="audio"),k&&(G+="video");let M={data1:h,startPTS:D,startDTS:D,endPTS:L,endDTS:L,type:G,hasAudio:F,hasVideo:k,nb:1,dropped:0};return d.audio=M.type==="audio"?M:void 0,d.video=M.type!=="audio"?M:void 0,d.initSegment=m,d.id3=qa(i,s,c,c),r.samples.length&&(d.text=Wa(r,s,c)),d}};function Hu(a,e,t,i){if(a===null)return!0;let r=Math.max(i,1),s=e-a.baseTime/a.timescale;return Math.abs(s-t)>r}function Zn(a,e){let t=a==null?void 0:a.codec;return t&&t.length>4?t:t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":t==="avc1"||e===Ee.VIDEO?"avc1.42e01e":"mp4a.40.5"}var Tt;try{Tt=self.performance.now.bind(self.performance)}catch{w.debug("Unable to use Performance API on this environment"),Tt=typeof self!="undefined"&&self.Date.now}var dr=[{demux:Vr,remux:zr},{demux:ut,remux:Xt},{demux:Kr,remux:Xt},{demux:jr,remux:Xt}],Pi=class{constructor(e,t,i,r,s){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=i,this.vendor=r,this.id=s}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,r){let s=i.transmuxing;s.executeStart=Tt();let n=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;r&&(this.currentTransmuxState=r);let{contiguous:c,discontinuity:u,trackSwitch:d,accurateTimeOffset:h,timeOffset:m,initSegmentChange:y}=r||o,{audioCodec:E,videoCodec:b,defaultInitPts:A,duration:D,initSegmentData:L}=l,F=Ku(n,t);if(F&&F.method==="AES-128"){let $=this.getDecrypter();if($.isSync()){let K=$.softwareDecrypt(n,F.key.buffer,F.iv.buffer);if(i.part>-1&&(K=$.flush()),!K)return s.executeEnd=Tt(),hr(i);n=new Uint8Array(K)}else return this.decryptionPromise=$.webCryptoDecrypt(n,F.key.buffer,F.iv.buffer).then(K=>{let P=this.push(K,null,i);return this.decryptionPromise=null,P}),this.decryptionPromise}let k=this.needsProbing(u,d);if(k){let $=this.configureTransmuxer(n);if($)return w.warn(`[transmuxer] ${$.message}`),this.observer.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:N.FRAG_PARSING_ERROR,fatal:!1,error:$,reason:$.message}),s.executeEnd=Tt(),hr(i)}(u||d||y||k)&&this.resetInitSegment(L,E,b,D,t),(u||y||k)&&this.resetInitialTimestamp(A),c||this.resetContiguity();let G=this.transmux(n,F,m,h,i),M=this.currentTransmuxState;return M.contiguous=!0,M.discontinuity=!1,M.trackSwitch=!1,s.executeEnd=Tt(),G}flush(e){let t=e.transmuxing;t.executeStart=Tt();let{decrypter:i,currentTransmuxState:r,decryptionPromise:s}=this;if(s)return s.then(()=>this.flush(e));let n=[],{timeOffset:o}=r;if(i){let d=i.flush();d&&n.push(this.push(d,null,e))}let{demuxer:l,remuxer:c}=this;if(!l||!c)return t.executeEnd=Tt(),[hr(e)];let u=l.flush(o);return Ti(u)?u.then(d=>(this.flushRemux(n,d,e),n)):(this.flushRemux(n,u,e),n)}flushRemux(e,t,i){let{audioTrack:r,videoTrack:s,id3Track:n,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:c}=this.currentTransmuxState;w.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);let u=this.remuxer.remux(r,s,n,o,c,l,!0,this.id);e.push({remuxResult:u,chunkMeta:i}),i.transmuxing.executeEnd=Tt()}resetInitialTimestamp(e){let{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,r,s){let{demuxer:n,remuxer:o}=this;!n||!o||(n.resetInitSegment(e,t,i,r),o.resetInitSegment(e,t,i,s))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,r,s){let n;return t&&t.method==="SAMPLE-AES"?n=this.transmuxSampleAes(e,t,i,r,s):n=this.transmuxUnencrypted(e,i,r,s),n}transmuxUnencrypted(e,t,i,r){let{audioTrack:s,videoTrack:n,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(s,n,o,l,t,i,!1,this.id),chunkMeta:r}}transmuxSampleAes(e,t,i,r,s){return this.demuxer.demuxSampleAes(e,t,i).then(n=>({remuxResult:this.remuxer.remux(n.audioTrack,n.videoTrack,n.id3Track,n.textTrack,i,r,!1,this.id),chunkMeta:s}))}configureTransmuxer(e){let{config:t,observer:i,typeSupported:r,vendor:s}=this,n;for(let d=0,h=dr.length;d<h;d++)if(dr[d].demux.probe(e)){n=dr[d];break}if(!n)return new Error("Failed to find demuxer by probing fragment data");let o=this.demuxer,l=this.remuxer,c=n.remux,u=n.demux;(!l||!(l instanceof c))&&(this.remuxer=new c(i,t,r,s)),(!o||!(o instanceof u))&&(this.demuxer=new u(i,t,r),this.probe=u.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new ti(this.config)),e}};function Ku(a,e){let t=null;return a.byteLength>0&&e!=null&&e.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var hr=a=>({remuxResult:{},chunkMeta:a});function Ti(a){return"then"in a&&a.then instanceof Function}var Xr=class{constructor(e,t,i,r,s){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=r,this.defaultInitPts=s||null}},Qr=class{constructor(e,t,i,r,s,n){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=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=r,this.timeOffset=s,this.initSegmentChange=n}},ja={exports:{}};(function(a){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function r(l,c,u){this.fn=l,this.context=c,this.once=u||!1}function s(l,c,u,d,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var m=new r(u,d||l,h),y=t?t+c:c;return l._events[y]?l._events[y].fn?l._events[y]=[l._events[y],m]:l._events[y].push(m):(l._events[y]=m,l._eventsCount++),l}function n(l,c){--l._eventsCount===0?l._events=new i:delete l._events[c]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],u,d;if(this._eventsCount===0)return c;for(d in u=this._events)e.call(u,d)&&c.push(t?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},o.prototype.listeners=function(c){var u=t?t+c:c,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var h=0,m=d.length,y=new Array(m);h<m;h++)y[h]=d[h].fn;return y},o.prototype.listenerCount=function(c){var u=t?t+c:c,d=this._events[u];return d?d.fn?1:d.length:0},o.prototype.emit=function(c,u,d,h,m,y){var E=t?t+c:c;if(!this._events[E])return!1;var b=this._events[E],A=arguments.length,D,L;if(b.fn){switch(b.once&&this.removeListener(c,b.fn,void 0,!0),A){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,u),!0;case 3:return b.fn.call(b.context,u,d),!0;case 4:return b.fn.call(b.context,u,d,h),!0;case 5:return b.fn.call(b.context,u,d,h,m),!0;case 6:return b.fn.call(b.context,u,d,h,m,y),!0}for(L=1,D=new Array(A-1);L<A;L++)D[L-1]=arguments[L];b.fn.apply(b.context,D)}else{var F=b.length,k;for(L=0;L<F;L++)switch(b[L].once&&this.removeListener(c,b[L].fn,void 0,!0),A){case 1:b[L].fn.call(b[L].context);break;case 2:b[L].fn.call(b[L].context,u);break;case 3:b[L].fn.call(b[L].context,u,d);break;case 4:b[L].fn.call(b[L].context,u,d,h);break;default:if(!D)for(k=1,D=new Array(A-1);k<A;k++)D[k-1]=arguments[k];b[L].fn.apply(b[L].context,D)}}return!0},o.prototype.on=function(c,u,d){return s(this,c,u,d,!1)},o.prototype.once=function(c,u,d){return s(this,c,u,d,!0)},o.prototype.removeListener=function(c,u,d,h){var m=t?t+c:c;if(!this._events[m])return this;if(!u)return n(this,m),this;var y=this._events[m];if(y.fn)y.fn===u&&(!h||y.once)&&(!d||y.context===d)&&n(this,m);else{for(var E=0,b=[],A=y.length;E<A;E++)(y[E].fn!==u||h&&!y[E].once||d&&y[E].context!==d)&&b.push(y[E]);b.length?this._events[m]=b.length===1?b[0]:b:n(this,m)}return this},o.prototype.removeAllListeners=function(c){var u;return c?(u=t?t+c:c,this._events[u]&&n(this,u)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,a.exports=o})(ja);var Vu=ja.exports,Ds=Ql(Vu),fr=Hi()||{isTypeSupported:()=>!1},Oi=class{constructor(e,t,i,r){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;let s=e.config;this.hls=e,this.id=t,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=i,this.onFlush=r;let n=(c,u)=>{u=u||{},u.frag=this.frag,u.id=this.id,c===v.ERROR&&(this.error=u.error),this.hls.trigger(c,u)};this.observer=new Ds,this.observer.on(v.FRAG_DECRYPTED,n),this.observer.on(v.ERROR,n);let o={mp4:fr.isTypeSupported("video/mp4"),mpeg:fr.isTypeSupported("audio/mpeg"),mp3:fr.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"&&(s.workerPath||Tu())){try{s.workerPath?(w.log(`loading Web Worker ${s.workerPath} for "${t}"`),this.workerContext=xu(s.workerPath)):(w.log(`injecting Web Worker for "${t}"`),this.workerContext=Eu()),this.onwmsg=d=>this.onWorkerMessage(d);let{worker:u}=this.workerContext;u.addEventListener("message",this.onwmsg),u.onerror=d=>{let h=new Error(`${d.message} (${d.filename}:${d.lineno})`);s.enableWorker=!1,w.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:N.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},u.postMessage({cmd:"init",typeSupported:o,vendor:l,id:t,config:JSON.stringify(s)})}catch(u){w.warn(`Error setting up "${t}" Web Worker, fallback to inline`,u),this.resetWorker(),this.error=null,this.transmuxer=new Pi(this.observer,o,s,l,t)}return}this.transmuxer=new Pi(this.observer,o,s,l,t)}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,i,r,s,n,o,l,c,u){var d,h;c.transmuxing.start=self.performance.now();let{transmuxer:m}=this,y=n?n.start:s.start,E=s.decryptdata,b=this.frag,A=!(b&&s.cc===b.cc),D=!(b&&c.level===b.level),L=b?c.sn-b.sn:-1,F=this.part?c.part-this.part.index:-1,k=L===0&&c.id>1&&c.id===(b==null?void 0:b.stats.chunkCount),G=!D&&(L===1||L===0&&(F===1||k&&F<=0)),M=self.performance.now();(D||L||s.stats.parsing.start===0)&&(s.stats.parsing.start=M),n&&(F||!G)&&(n.stats.parsing.start=M);let $=!(b&&((d=s.initSegment)==null?void 0:d.url)===((h=b.initSegment)==null?void 0:h.url)),K=new Qr(A,G,l,D,y,$);if(!G||A||$){w.log(`[transmuxer-interface, ${s.type}]: Starting new transmux session for sn: ${c.sn} p: ${c.part} level: ${c.level} id: ${c.id}
|
|
20
|
+
discontinuity: ${A}
|
|
21
|
+
trackSwitch: ${D}
|
|
22
|
+
contiguous: ${G}
|
|
23
|
+
accurateTimeOffset: ${l}
|
|
24
|
+
timeOffset: ${y}
|
|
25
|
+
initSegmentChange: ${$}`);let P=new Xr(i,r,t,o,u);this.configureTransmuxer(P)}if(this.frag=s,this.part=n,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:E,chunkMeta:c,state:K},e instanceof ArrayBuffer?[e]:[]);else if(m){let P=m.push(e,E,c,K);Ti(P)?(m.async=!0,P.then(q=>{this.handleTransmuxComplete(q)}).catch(q=>{this.transmuxerError(q,c,"transmuxer-interface push error")})):(m.async=!1,this.handleTransmuxComplete(P))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let i=t.flush(e);Ti(i)||t.async?(Ti(i)||(i=Promise.resolve(i)),i.then(s=>{this.handleFlushResult(s,e)}).catch(s=>{this.transmuxerError(s,e,"transmuxer-interface flush error")})):this.handleFlushResult(i,e)}}transmuxerError(e,t,i){!this.hls||(this.error=e,this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data,i=this.hls;switch(t.event){case"init":{var r;let s=(r=this.workerContext)==null?void 0:r.objectURL;s&&self.URL.revokeObjectURL(s);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":w[t.data.logType]&&w[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,i.trigger(t.event,t.data);break}}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}},qu=250,gr=2,Wu=.1,ju=.05,Jr=class{constructor(e,t,i,r){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=i,this.hls=r}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:i,media:r,stalled:s}=this;if(r===null)return;let{currentTime:n,seeking:o}=r,l=this.seeking&&!o,c=!this.seeking&&o;if(this.seeking=o,n!==e){if(this.moved=!0,s!==null){if(this.stallReported){let A=self.performance.now()-s;w.warn(`playback not stuck anymore @${n}, after ${Math.round(A)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(c||l){this.stalled=null;return}if(r.paused&&!o||r.ended||r.playbackRate===0||!xe.getBuffered(r).length)return;let u=xe.bufferInfo(r,n,0),d=u.len>0,h=u.nextStart||0;if(!d&&!h)return;if(o){let A=u.len>gr,D=!h||t&&t.start<=n||h-n>gr&&!this.fragmentTracker.getPartialFragment(n);if(A||D)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var m;let A=Math.max(h,u.start||0)-n,D=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,F=(D==null||(m=D.details)==null?void 0:m.live)?D.details.targetduration*2:gr,k=this.fragmentTracker.getPartialFragment(n);if(A>0&&(A<=F||k)){this._trySkipBufferHole(k);return}}let y=self.performance.now();if(s===null){this.stalled=y;return}let E=y-s;if(!o&&E>=qu&&(this._reportStall(u),!this.media))return;let b=xe.bufferInfo(r,n,i.maxBufferHole);this._tryFixBufferStall(b,E)}_tryFixBufferStall(e,t){let{config:i,fragmentTracker:r,media:s}=this;if(s===null)return;let n=s.currentTime,o=r.getPartialFragment(n);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>i.maxBufferHole||e.nextStart&&e.nextStart-n<i.maxBufferHole)&&t>i.highBufferWatchdogPeriod*1e3&&(w.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:i,stallReported:r}=this;if(!r&&i){this.stallReported=!0;let s=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`);w.warn(s.message),t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.BUFFER_STALLED_ERROR,fatal:!1,error:s,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:i,media:r}=this;if(r===null)return 0;let s=r.currentTime,n=xe.bufferInfo(r,s,0),o=s<n.start?n.start:n.nextStart;if(o){let l=n.len<=t.maxBufferHole,c=n.len>0&&n.len<1&&r.readyState<3,u=o-s;if(u>0&&(l||c)){if(u>t.maxBufferHole){let{fragmentTracker:h}=this,m=!1;if(s===0){let y=h.getAppendedFrag(0,re.MAIN);y&&o<y.end&&(m=!0)}if(!m){let y=e||h.getAppendedFrag(s,re.MAIN);if(y){let E=!1,b=y.end;for(;b<o;){let A=h.getPartialFragment(b);if(A)b+=A.duration;else{E=!0;break}}if(E)return 0}}}let d=Math.max(o+ju,s+Wu);if(w.warn(`skipping hole, adjusting currentTime from ${s} to ${d}`),this.moved=!0,this.stalled=null,r.currentTime=d,e&&!e.gap){let h=new Error(`fragment loaded with buffer holes, seeking from ${s} to ${d}`);i.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return d}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:i,nudgeRetry:r}=this;if(i===null)return;let s=i.currentTime;if(this.nudgeRetry++,r<e.nudgeMaxRetry){let n=s+(r+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${s} to ${n}`);w.warn(o.message),i.currentTime=n,t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{let n=new Error(`Playhead still not moving while enough data buffered @${s} after ${e.nudgeMaxRetry} nudges`);w.error(n.message),t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.BUFFER_STALLED_ERROR,error:n,fatal:!0})}}},Yu=100,Zr=class extends ii{constructor(e,t,i){super(e,t,i,"[stream-controller]",re.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(v.ERROR,this.onError,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(v.ERROR,this.onError,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:i}=this;if(this.stopLoad(),this.setInterval(Yu),this.level=-1,!this.startFragRequested){let r=i.startLevel;r===-1&&(i.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=i.nextAutoLevel),this.level=i.nextLoadLevel=r,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=B.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=B.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case B.WAITING_LEVEL:{var e;let{levels:i,level:r}=this,s=i==null||(e=i[r])==null?void 0:e.details;if(s&&(!s.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(s))break;this.state=B.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=B.IDLE;break}break}case B.FRAG_LOADING_WAITING_RETRY:{var t;let i=self.performance.now(),r=this.retryDate;(!r||i>=r||(t=this.media)!=null&&t.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=B.IDLE)}break}this.state===B.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:i,media:r}=this,{config:s,nextLoadLevel:n}=e;if(t===null||!r&&(this.startFragRequested||!s.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[n]))return;let o=i[n],l=this.getMainFwdBufferInfo();if(l===null)return;let c=this.getLevelDetails();if(c&&this._streamEnded(l,c)){let b={};this.altAudio&&(b.type="video"),this.hls.trigger(v.BUFFER_EOS,b),this.state=B.ENDED;return}e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;let u=o.details;if(!u||this.state===B.WAITING_LEVEL||u.live&&this.levelLastLoaded!==n){this.level=n,this.state=B.WAITING_LEVEL;return}let d=l.len,h=this.getMaxBufferLength(o.maxBitrate);if(d>=h)return;this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);let m=this.backtrackFragment?this.backtrackFragment.start:l.end,y=this.getNextFragment(m,u);if(this.couldBacktrack&&!this.fragPrevious&&y&&y.sn!=="initSegment"&&this.fragmentTracker.getState(y)!==Ce.OK){var E;let A=((E=this.backtrackFragment)!=null?E:y).sn-u.startSN,D=u.fragments[A-1];D&&y.cc===D.cc&&(y=D,this.fragmentTracker.removeFragment(D))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(y&&this.isLoopLoading(y,m)){if(!y.gap){let A=this.audioOnly&&!this.altAudio?Ee.AUDIO:Ee.VIDEO,D=(A===Ee.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;D&&this.afterBufferFlushed(D,A,re.MAIN)}y=this.getNextFragmentLoopLoading(y,u,l,re.MAIN,h)}!y||(y.initSegment&&!y.initSegment.data&&!this.bitrateTest&&(y=y.initSegment),this.loadFragment(y,o,m))}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);this.fragCurrent=e,r===Ce.NOT_LOADED||r===Ce.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,i)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,re.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){let{levels:e,media:t}=this;if(t!=null&&t.readyState){let i,r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);let s=this.getLevelDetails();if(s!=null&&s.live){let o=this.getMainFwdBufferInfo();if(!o||o.len<s.targetduration*2)return}if(!t.paused&&e){let o=this.hls.nextLoadLevel,l=e[o],c=this.fragLastKbps;c&&this.fragCurrent?i=this.fragCurrent.duration*l.maxBitrate/(1e3*c)+1:i=0}else i=0;let n=this.getBufferedFrag(t.currentTime+i);if(n){let o=this.followingBufferedFrag(n);if(o){this.abortCurrentFrag();let l=o.maxStartPTS?o.maxStartPTS:o.start,c=o.duration,u=Math.max(n.end,l+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,c*.5),c*.75));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case B.KEY_LOADING:case B.FRAG_LOADING:case B.FRAG_LOADING_WAITING_RETRY:case B.PARSING:case B.PARSED:this.state=B.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let i=t.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 Jr(this.config,i,this.fragmentTracker,this.hls)}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;J(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let i=this.getMainFwdBufferInfo();if(i===null||i.len===0){this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(v.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}onManifestParsed(e,t){let i=!1,r=!1,s;t.levels.forEach(n=>{s=n.audioCodec,s&&(s.indexOf("mp4a.40.2")!==-1&&(i=!0),s.indexOf("mp4a.40.5")!==-1&&(r=!0))}),this.audioCodecSwitch=i&&r&&!vu(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:i}=this;if(!i||this.state!==B.IDLE)return;let r=i[t.level];(!r.details||r.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(r.details))&&(this.state=B.WAITING_LEVEL)}onLevelLoaded(e,t){var i;let{levels:r}=this,s=t.level,n=t.details,o=n.totalduration;if(!r){this.warn(`Levels were reset while loading level ${s}`);return}this.log(`Level ${s} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""}, cc [${n.startCC}, ${n.endCC}] duration:${o}`);let l=r[s],c=this.fragCurrent;c&&(this.state===B.FRAG_LOADING||this.state===B.FRAG_LOADING_WAITING_RETRY)&&(c.level!==t.level||c.urlId!==l.urlId)&&c.loader&&this.abortCurrentFrag();let u=0;if(n.live||(i=l.details)!=null&&i.live){if(n.fragments[0]||(n.deltaUpdateFailed=!0),n.deltaUpdateFailed)return;u=this.alignPlaylists(n,l.details)}if(l.details=n,this.levelLastLoaded=s,this.hls.trigger(v.LEVEL_UPDATED,{details:n,level:s}),this.state===B.WAITING_LEVEL){if(this.waitForCdnTuneIn(n))return;this.state=B.IDLE}this.startFragRequested?n.live&&this.synchronizeToLiveEdge(n):this.setStartPosition(n,u),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:i,part:r,payload:s}=e,{levels:n}=this;if(!n){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}let o=n[i.level],l=o.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}let c=o.videoCodec,u=l.PTSKnown||!l.live,d=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),m=this.transmuxer=this.transmuxer||new Oi(this.hls,re.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),y=r?r.index:-1,E=y!==-1,b=new ei(i.level,i.sn,i.stats.chunkCount,s.byteLength,y,E),A=this.initPTS[i.cc];m.push(s,d,h,c,i,r,l.totalduration,u,b,A)}onAudioTrackSwitching(e,t){let i=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();let s=this.hls;i&&(s.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),s.trigger(v.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let i=t.id,r=!!this.hls.audioTracks[i].url;if(r){let s=this.videoBuffer;s&&this.mediaBuffer!==s&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=s)}this.altAudio=r,this.tick()}onBufferCreated(e,t){let i=t.tracks,r,s,n=!1;for(let o in i){let l=i[o];if(l.id==="main"){if(s=o,r=l,o==="video"){let c=i[o];c&&(this.videoBuffer=c.buffer)}}else n=!0}n&&r?(this.log(`Alternate track found, use ${s}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:i,part:r}=t;if(i&&i.type!==re.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===B.PARSED&&(this.state=B.IDLE);return}let s=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*s.total/(s.buffering.end-s.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,r)}onError(e,t){var i;if(t.fatal){this.state=B.ERROR;return}switch(t.details){case N.FRAG_GAP:case N.FRAG_PARSING_ERROR:case N.FRAG_DECRYPT_ERROR:case N.FRAG_LOAD_ERROR:case N.FRAG_LOAD_TIMEOUT:case N.KEY_LOAD_ERROR:case N.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(re.MAIN,t);break;case N.LEVEL_LOAD_ERROR:case N.LEVEL_LOAD_TIMEOUT:case N.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===B.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===ve.LEVEL&&(this.state=B.IDLE);break;case N.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case N.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){let{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!xe.getBuffered(e).length){let i=this.state!==B.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,i)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=B.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Ee.AUDIO||this.audioOnly&&!this.altAudio){let i=(t===Ee.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,t,re.MAIN)}}onLevelsUpdated(e,t){this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}let r=xe.getBuffered(e),n=(r.length?r.start(0):0)-i;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${n} to match buffer start`),i+=n,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${t}`),e.currentTime=i}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{let{hls:r}=this;if(!i||this.fragContextChanged(e))return;t.fragmentError=0,this.state=B.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;let s=e.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),r.trigger(v.FRAG_LOADED,i),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let i="main",{hls:r}=this,{remuxResult:s,chunkMeta:n}=e,o=this.getCurrentContext(n);if(!o){this.resetWhenMissingContext(n);return}let{frag:l,part:c,level:u}=o,{video:d,text:h,id3:m,initSegment:y}=s,{details:E}=u,b=this.altAudio?void 0:s.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=B.PARSING,y){if(y!=null&&y.tracks){let F=l.initSegment||l;this._bufferInitSegment(u,y.tracks,F,n),r.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:F,id:i,tracks:y.tracks})}let D=y.initPTS,L=y.timescale;J(D)&&(this.initPTS[l.cc]={baseTime:D,timescale:L},r.trigger(v.INIT_PTS_FOUND,{frag:l,id:i,initPTS:D,timescale:L}))}let A=l.sn!==(E==null?void 0:E.startSN);if(d&&s.independent!==!1){if(E){let{startPTS:D,endPTS:L,startDTS:F,endDTS:k}=d;if(c)c.elementaryStreams[d.type]={startPTS:D,endPTS:L,startDTS:F,endDTS:k};else if(d.firstKeyFrame&&d.independent&&n.id===1&&(this.couldBacktrack=!0),d.dropped&&d.independent){let G=this.getMainFwdBufferInfo(),M=(G?G.end:this.getLoadPosition())+this.config.maxBufferHole,$=d.firstKeyFramePTS?d.firstKeyFramePTS:D;if(A&&M<$-this.config.maxBufferHole){this.backtrack(l);return}l.setElementaryStreamInfo(d.type,l.start,L,l.start,k,!0)}l.setElementaryStreamInfo(d.type,D,L,F,k),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(d,l,c,n)}}else if(A&&s.independent===!1){this.backtrack(l);return}if(b){let{startPTS:D,endPTS:L,startDTS:F,endDTS:k}=b;c&&(c.elementaryStreams[Ee.AUDIO]={startPTS:D,endPTS:L,startDTS:F,endDTS:k}),l.setElementaryStreamInfo(Ee.AUDIO,D,L,F,k),this.bufferFragmentData(b,l,c,n)}if(E&&m!=null&&(t=m.samples)!=null&&t.length){let D={id:i,frag:l,details:E,samples:m.samples};r.trigger(v.FRAG_PARSING_METADATA,D)}if(E&&h){let D={id:i,frag:l,details:E,samples:h.samples};r.trigger(v.FRAG_PARSING_USERDATA,D)}}_bufferInitSegment(e,t,i,r){if(this.state!==B.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:s,video:n,audiovideo:o}=t;if(s){let l=e.audioCodec,c=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),s.metadata.channelCount!==1&&c.indexOf("firefox")===-1&&(l="mp4a.40.5")),c.indexOf("android")!==-1&&s.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),s.levelCodec=l,s.id="main",this.log(`Init audio buffer, container:${s.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${s.codec}]`)}n&&(n.levelCodec=e.videoCodec,n.id="main",this.log(`Init video buffer, container:${n.container}, codecs[level/parsed]=[${e.videoCodec||""}/${n.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.attrs.CODECS||""}/${o.codec}]`),this.hls.trigger(v.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(v.BUFFER_APPENDING,{type:l,data:u,frag:i,part:null,chunkMeta:r,parent:i.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,re.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=B.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===!1){let i=e.currentTime;if(xe.isBuffered(e,i)?t=this.getAppendedFrag(i):xe.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;let r=this.fragPlaying,s=t.level;(!r||t.sn!==r.sn||r.level!==s||t.urlId!==r.urlId)&&(this.fragPlaying=t,this.hls.trigger(v.FRAG_CHANGED,{frag:t}),(!r||r.level!==s)&&this.hls.trigger(v.LEVEL_SWITCHED,{level:s}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,i=this.currentFrag;if(i&&J(t)&&J(i.programDateTime)){let r=i.programDateTime+(t-i.start)*1e3;return new Date(r)}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},bt=class{constructor(e,t=0,i=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_=i}sample(e,t){let i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}},es=class{constructor(e,t,i,r=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_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new bt(e),this.fast_=new bt(t),this.defaultTTFB_=r,this.ttfb_=new bt(e)}update(e,t){let{slow_:i,fast_:r,ttfb_:s}=this;i.halfLife!==e&&(this.slow_=new bt(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.fast_=new bt(t,r.getEstimate(),r.getTotalWeight())),s.halfLife!==e&&(this.ttfb_=new bt(e,s.getEstimate(),s.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);let i=8*t,r=e/1e3,s=i/r;this.fast_.sample(r,s),this.slow_.sample(r,s)}sampleTTFB(e){let t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}},ts=class{constructor(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;let t=e.config;this.bwEstimator=new es(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){let{hls:e}=this;e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var i;let r=t.frag;this.ignoreFragment(r)||(this.fragCurrent=r,this.partCurrent=(i=t.part)!=null?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,i,r){let s=e+i/t,n=r?this.lastLevelLoadSec:0;return s+n}onLevelLoaded(e,t){let i=this.hls.config,{total:r,bwEstimate:s}=t.stats;J(r)&&J(s)&&(this.lastLevelLoadSec=8*r/s),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}_abandonRulesCheck(){let{fragCurrent:e,partCurrent:t,hls:i}=this,{autoLevelEnabled:r,media:s}=i;if(!e||!s)return;let n=performance.now(),o=t?t.stats:e.stats,l=t?t.duration:e.duration,c=n-o.loading.start;if(o.aborted||o.loaded&&o.loaded===o.total||e.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!r||s.paused||!s.playbackRate||!s.readyState)return;let u=i.mainForwardBufferInfo;if(u===null)return;let d=this.bwEstimator.getEstimateTTFB(),h=Math.abs(s.playbackRate);if(c<=Math.max(d,1e3*(l/(h*2))))return;let m=u.len/h;if(m>=2*l/h)return;let y=o.loading.first?o.loading.first-o.loading.start:-1,E=o.loaded&&y>-1,b=this.bwEstimator.getEstimate(),{levels:A,minAutoLevel:D}=i,L=A[e.level],F=o.total||Math.max(o.loaded,Math.round(l*L.maxBitrate/8)),k=c-y;k<1&&E&&(k=Math.min(c,o.loaded*8/b));let G=E?o.loaded*1e3/k:0,M=G?(F-o.loaded)/G:F*8/b+d/1e3;if(M<=m)return;let $=G?G*8:b,K=Number.POSITIVE_INFINITY,P;for(P=e.level-1;P>D;P--){let q=A[P].maxBitrate;if(K=this.getTimeToLoadFrag(d/1e3,$,l*q,!A[P].details),K<m)break}K>=M||K>l*10||(i.nextLoadLevel=P,E?this.bwEstimator.sample(c-Math.min(d,y),o.loaded):this.bwEstimator.sampleTTFB(c),this.clearTimer(),w.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;
|
|
26
|
+
Time to underbuffer: ${m.toFixed(3)} s
|
|
27
|
+
Estimated load time for current fragment: ${M.toFixed(3)} s
|
|
28
|
+
Estimated load time for down switch fragment: ${K.toFixed(3)} s
|
|
29
|
+
TTFB estimate: ${y}
|
|
30
|
+
Current BW estimate: ${J(b)?(b/1024).toFixed(3):"Unknown"} Kb/s
|
|
31
|
+
New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
|
|
32
|
+
Aborting and switching to level ${P}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),i.trigger(v.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}onFragLoaded(e,{frag:t,part:i}){let r=i?i.stats:t.stats;if(t.type===re.MAIN&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){let s=i?i.duration:t.duration,n=this.hls.levels[t.level],o=(n.loaded?n.loaded.bytes:0)+r.loaded,l=(n.loaded?n.loaded.duration:0)+s;n.loaded={bytes:o,duration:l},n.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){let s={stats:r,frag:t,part:i,id:t.type};this.onFragBuffered(v.FRAG_BUFFERED,s),t.bitrateTest=!1}}}onFragBuffered(e,t){let{frag:i,part:r}=t,s=r!=null&&r.stats.loaded?r.stats:i.stats;if(s.aborted||this.ignoreFragment(i))return;let n=s.parsing.end-s.loading.start-Math.min(s.loading.first-s.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,s.loaded),s.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==re.MAIN||e.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){let e=this._nextAutoLevel,t=this.bwEstimator;if(e!==-1&&!t.canEstimate())return e;let i=this.getNextABRAutoLevel();if(e!==-1){let r=this.hls.levels;if(r.length>Math.max(e,i)&&r[e].loadError<=r[i].loadError)return e}return e!==-1&&(i=Math.min(e,i)),i}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:i}=this,{maxAutoLevel:r,config:s,minAutoLevel:n,media:o}=i,l=t?t.duration:e?e.duration:0,c=o&&o.playbackRate!==0?Math.abs(o.playbackRate):1,u=this.bwEstimator?this.bwEstimator.getEstimate():s.abrEwmaDefaultEstimate,d=i.mainForwardBufferInfo,h=(d?d.len:0)/c,m=this.findBestLevel(u,n,r,h,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(m>=0)return m;w.trace(`[abr] ${h?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let y=l?Math.min(l,s.maxStarvationDelay):s.maxStarvationDelay,E=s.abrBandWidthFactor,b=s.abrBandWidthUpFactor;if(!h){let A=this.bitrateTestDelay;A&&(y=(l?Math.min(l,s.maxLoadingDelay):s.maxLoadingDelay)-A,w.trace(`[abr] bitrate test took ${Math.round(1e3*A)}ms, set first fragment max fetchDuration to ${Math.round(1e3*y)} ms`),E=b=1)}return m=this.findBestLevel(u,n,r,h+y,E,b),Math.max(m,0)}findBestLevel(e,t,i,r,s,n){var o;let{fragCurrent:l,partCurrent:c,lastLoadedFragLevel:u}=this,{levels:d}=this.hls,h=d[u],m=!!(h!=null&&(o=h.details)!=null&&o.live),y=h==null?void 0:h.codecSet,E=c?c.duration:l?l.duration:0,b=this.bwEstimator.getEstimateTTFB()/1e3,A=t,D=-1;for(let L=i;L>=t;L--){let F=d[L];if(!F||y&&F.codecSet!==y){F&&(A=Math.min(L,A),D=Math.max(L,D));continue}D!==-1&&w.trace(`[abr] Skipped level(s) ${A}-${D} with CODECS:"${d[D].attrs.CODECS}"; not compatible with "${h.attrs.CODECS}"`);let k=F.details,G=(c?k==null?void 0:k.partTarget:k==null?void 0:k.averagetargetduration)||E,M;L<=u?M=s*e:M=n*e;let $=d[L].maxBitrate,K=this.getTimeToLoadFrag(b,M,$*G,k===void 0);if(w.trace(`[abr] level:${L} adjustedbw-bitrate:${Math.round(M-$)} avgDuration:${G.toFixed(1)} maxFetchDuration:${r.toFixed(1)} fetchDuration:${K.toFixed(1)}`),M>$&&(K===0||!J(K)||m&&!this.bitrateTestDelay||K<r))return L}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}},Mi=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,i;if(e.length)e.length===1?i=e[0]:i=zu(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}};function zu(a,e){let t=new Uint8Array(e),i=0;for(let r=0;r<a.length;r++){let s=a[r];t.set(s,i),i+=s.length}return t}var ea=100,is=class extends ii{constructor(e,t,i){super(e,t,i,"[audio-stream-controller]",re.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:s}){if(i==="main"){let n=t.cc;this.initPTS[t.cc]={baseTime:r,timescale:s},this.log(`InitPTS for cc: ${n} found from main: ${r}`),this.videoTrackCC=n,this.state===B.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=B.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(ea),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=B.IDLE):(this.loadedmetadata=!1,this.state=B.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case B.IDLE:this.doTickIdle();break;case B.WAITING_TRACK:{var e;let{levels:i,trackId:r}=this,s=i==null||(e=i[r])==null?void 0:e.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=B.WAITING_INIT_PTS}break}case B.FRAG_LOADING_WAITING_RETRY:{var t;let i=performance.now(),r=this.retryDate;(!r||i>=r||(t=this.media)!=null&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=B.IDLE);break}case B.WAITING_INIT_PTS:{let i=this.waitingData;if(i){let{frag:r,part:s,cache:n,complete:o}=i;if(this.initPTS[r.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=B.FRAG_LOADING;let l=n.flush(),c={frag:r,part:s,payload:l,networkDetails:null};this._handleFragmentLoadProgress(c),o&&super._handleFragmentLoadComplete(c)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${r.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{let l=this.getLoadPosition(),c=xe.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);Pr(c.end,this.config.maxFragLookUpTolerance,r)<0&&(this.log(`Waiting fragment cc (${r.cc}) @ ${r.start} cancelled because another fragment at ${c.end} is needed`),this.clearWaitingFragment())}}else this.state=B.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=B.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){let{media:e}=this;!(e!=null&&e.readyState)||(this.lastCurrentTime=e.currentTime)}doTickIdle(){let{hls:e,levels:t,media:i,trackId:r}=this,s=e.config;if(!(t!=null&&t[r])||!i&&(this.startFragRequested||!s.startFragPrefetch))return;let n=t[r],o=n.details;if(!o||o.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(o)){this.state=B.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Ee.AUDIO,re.AUDIO));let c=this.getFwdBufferInfo(l,re.AUDIO);if(c===null)return;let{bufferedTrack:u,switchingTrack:d}=this;if(!d&&this._streamEnded(c,o)){e.trigger(v.BUFFER_EOS,{type:"audio"}),this.state=B.ENDED;return}let h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,re.MAIN),m=c.len,y=this.getMaxBufferLength(h==null?void 0:h.len);if(m>=y&&!d)return;let b=o.fragments[0].start,A=c.end;if(d&&i){let k=this.getLoadPosition();u&&d.attrs!==u.attrs&&(A=k),o.PTSKnown&&k<b&&(c.end>b||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=b+.05)}let D=this.getNextFragment(A,o),L=!1;if(D&&this.isLoopLoading(D,A)&&(L=!!D.gap,D=this.getNextFragmentLoopLoading(D,o,c,re.MAIN,y)),!D){this.bufferFlushed=!0;return}let F=h&&D.start>h.end+o.targetduration;if(F||!(h!=null&&h.len)&&c.len){let k=this.getAppendedFrag(D.start,re.MAIN);if(k===null||(L||(L=!!k.gap||!!F&&h.len===0),F&&!L||L&&c.nextStart&&c.nextStart<k.end))return}this.loadFragment(D,n,A)}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new wt(i))}onAudioTrackSwitching(e,t){let i=!!t.url;this.trackId=t.id;let{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),i?this.setInterval(ea):this.resetTransmuxer(),i?(this.switchingTrack=t,this.state=B.IDLE):(this.switchingTrack=null,this.bufferedTrack=t,this.state=B.STOPPED),this.tick()}onManifestLoading(){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}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(v.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var i;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}let{levels:r}=this,{details:s,id:n}=t;if(!r){this.warn(`Audio tracks were reset while loading level ${n}`);return}this.log(`Track ${n} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""},duration:${s.totalduration}`);let o=r[n],l=0;if(s.live||(i=o.details)!=null&&i.live){let c=this.mainDetails;if(s.fragments[0]||(s.deltaUpdateFailed=!0),s.deltaUpdateFailed||!c)return;!o.details&&s.hasProgramDateTime&&c.hasProgramDateTime?(Oa(s,c),l=s.fragments[0].start):l=this.alignPlaylists(s,o.details)}o.details=s,this.levelLastLoaded=n,!this.startFragRequested&&(this.mainDetails||!s.live)&&this.setStartPosition(o.details,l),this.state===B.WAITING_TRACK&&!this.waitForCdnTuneIn(s)&&(this.state=B.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:i,part:r,payload:s}=e,{config:n,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}let c=l[o];if(!c){this.warn("Audio track is undefined on fragment load progress");return}let u=c.details;if(!u){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}let d=n.defaultAudioCodec||c.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new Oi(this.hls,re.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let m=this.initPTS[i.cc],y=(t=i.initSegment)==null?void 0:t.data;if(m!==void 0){let b=r?r.index:-1,A=b!==-1,D=new ei(i.level,i.sn,i.stats.chunkCount,s.byteLength,b,A);h.push(s,y,d,"",i,r,u.totalduration,!1,D,m)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${u.startSN} ,${u.endSN}],track ${o}`);let{cache:E}=this.waitingData=this.waitingData||{frag:i,part:r,cache:new Mi,complete:!1};E.push(new Uint8Array(s)),this.waitingVideoCC=this.videoTrackCC,this.state=B.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){let i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:i,part:r}=t;if(i.type!==re.AUDIO){if(!this.loadedmetadata&&i.type===re.MAIN){let s=this.videoBuffer||this.media;s&&xe.getBuffered(s).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(i.sn!=="initSegment"){this.fragPrevious=i;let s=this.switchingTrack;s&&(this.bufferedTrack=s,this.switchingTrack=null,this.hls.trigger(v.AUDIO_TRACK_SWITCHED,Ze({},s)))}this.fragBufferedComplete(i,r)}onError(e,t){var i;if(t.fatal){this.state=B.ERROR;return}switch(t.details){case N.FRAG_GAP:case N.FRAG_PARSING_ERROR:case N.FRAG_DECRYPT_ERROR:case N.FRAG_LOAD_ERROR:case N.FRAG_LOAD_TIMEOUT:case N.KEY_LOAD_ERROR:case N.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(re.AUDIO,t);break;case N.AUDIO_TRACK_LOAD_ERROR:case N.AUDIO_TRACK_LOAD_TIMEOUT:case N.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===B.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===ve.AUDIO_TRACK&&(this.state=B.IDLE);break;case N.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case N.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushed(e,{type:t}){t===Ee.AUDIO&&(this.bufferFlushed=!0,this.state===B.ENDED&&(this.state=B.IDLE))}_handleTransmuxComplete(e){var t;let i="audio",{hls:r}=this,{remuxResult:s,chunkMeta:n}=e,o=this.getCurrentContext(n);if(!o){this.resetWhenMissingContext(n);return}let{frag:l,part:c,level:u}=o,{details:d}=u,{audio:h,text:m,id3:y,initSegment:E}=s;if(this.fragContextChanged(l)||!d){this.fragmentTracker.removeFragment(l);return}if(this.state=B.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),E!=null&&E.tracks){let b=l.initSegment||l;this._bufferInitSegment(E.tracks,b,n),r.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:i,tracks:E.tracks})}if(h){let{startPTS:b,endPTS:A,startDTS:D,endDTS:L}=h;c&&(c.elementaryStreams[Ee.AUDIO]={startPTS:b,endPTS:A,startDTS:D,endDTS:L}),l.setElementaryStreamInfo(Ee.AUDIO,b,A,D,L),this.bufferFragmentData(h,l,c,n)}if(y!=null&&(t=y.samples)!=null&&t.length){let b=Ie({id:i,frag:l,details:d},y);r.trigger(v.FRAG_PARSING_METADATA,b)}if(m){let b=Ie({id:i,frag:l,details:d},m);r.trigger(v.FRAG_PARSING_USERDATA,b)}}_bufferInitSegment(e,t,i){if(this.state!==B.PARSING)return;e.video&&delete e.video;let r=e.audio;if(!r)return;r.levelCodec=r.codec,r.id="audio",this.log(`Init audio buffer, container:${r.container}, codecs[parsed]=[${r.codec}]`),this.hls.trigger(v.BUFFER_CODECS,e);let s=r.initSegment;if(s!=null&&s.byteLength){let n={type:"audio",frag:t,part:null,chunkMeta:i,parent:t.type,data:s};this.hls.trigger(v.BUFFER_APPENDING,n)}this.tick()}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||r===Ce.NOT_LOADED||r===Ce.PARTIAL){var s;e.sn==="initSegment"?this._loadInitSegment(e,t):(s=t.details)!=null&&s.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=B.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(e,t,i))}else this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){let{hls:t,media:i,bufferedTrack:r}=this,s=r==null?void 0:r.attrs,n=e.attrs;i&&s&&(s.CHANNELS!==n.CHANNELS||s.NAME!==n.NAME||s.LANGUAGE!==n.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(v.AUDIO_TRACK_SWITCHED,Ze({},e))}},rs=class extends Zt{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:i,groupId:r,details:s}=t,n=this.tracksInGroup[i];if(!n||n.groupId!==r){this.warn(`Track with id:${i} and group:${r} not found in active group ${n.groupId}`);return}let o=n.details;n.details=t.details,this.log(`audio-track ${i} "${n.name}" lang:${n.lang} group:${r} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!(t!=null&&t.audioGroupIds))return;let i=t.audioGroupIds[t.urlId];if(this.groupId!==i){this.groupId=i||null;let r=this.tracks.filter(n=>!i||n.groupId===i);this.selectDefaultTrack&&!r.some(n=>n.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=r;let s={audioTracks:r};this.log(`Updating audio tracks, ${r.length} track(s) found in group:${i}`),this.hls.trigger(v.AUDIO_TRACKS_UPDATED,s),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===ve.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();let i=this.currentTrack;t[this.trackId];let r=t[e],{groupId:s,name:n}=r;if(this.log(`Switching to audio-track ${e} "${n}" lang:${r.lang} group:${s}`),this.trackId=e,this.currentTrack=r,this.selectDefaultTrack=!1,this.hls.trigger(v.AUDIO_TRACK_SWITCHING,Ze({},r)),r.details&&!r.details.live)return;let o=this.switchParams(r.url,i==null?void 0:i.details);this.loadPlaylist(o)}selectInitialTrack(){let e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(t!==-1)this.setAudioTrack(t);else{let i=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(i.message),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++){let r=t[i];if((!this.selectDefaultTrack||r.default)&&(!e||e.attrs["STABLE-RENDITION-ID"]!==void 0&&e.attrs["STABLE-RENDITION-ID"]===r.attrs["STABLE-RENDITION-ID"]||e.name===r.name&&e.lang===r.lang))return r.id}return-1}loadPlaylist(e){super.loadPlaylist();let t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){let i=t.id,r=t.groupId,s=t.url;if(e)try{s=e.addDirectives(s)}catch(n){this.warn(`Could not construct new URL with HLS Delivery Directives: ${n}`)}this.log(`loading audio-track playlist ${i} "${t.name}" lang:${t.lang} group:${r}`),this.clearTimer(),this.hls.trigger(v.AUDIO_TRACK_LOADING,{url:s,id:i,groupId:r,deliveryDirectives:e||null})}}};function Ya(a,e){if(a.length!==e.length)return!1;for(let t=0;t<a.length;t++)if(!Xu(a[t].attrs,e[t].attrs))return!1;return!0}function Xu(a,e){let t=a["STABLE-RENDITION-ID"];return t?t===e["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>a[i]!==e[i])}var ta=500,ss=class extends ii{constructor(e,t,i){super(e,t,i,"[subtitle-stream-controller]",re.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=B.IDLE,this.setInterval(ta),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let{frag:i,success:r}=t;if(this.fragPrevious=i,this.state=B.IDLE,!r)return;let s=this.tracksBuffered[this.currentTrackId];if(!s)return;let n,o=i.start;for(let c=0;c<s.length;c++)if(o>=s[c].start&&o<=s[c].end){n=s[c];break}let l=i.start+i.duration;n?n.end=l:(n={start:o,end:l},s.push(n)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(e,t){let{startOffset:i,endOffset:r}=t;if(i===0&&r!==Number.POSITIVE_INFINITY){let s=r-1;if(s<=0)return;t.endOffsetSubtitles=Math.max(0,s),this.tracksBuffered.forEach(n=>{for(let o=0;o<n.length;){if(n[o].end<=s){n.shift();continue}else if(n[o].start<s)n[o].start=s;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(i,s,re.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===re.MAIN){var i;(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let i=t.frag;(i==null?void 0:i.type)===re.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==B.STOPPED&&(this.state=B.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(Ya(this.levels,t)){this.levels=t.map(i=>new wt(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{let r=new wt(i);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,re.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){if(this.currentTrackId=t.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}let i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(ta)}onSubtitleTrackLoaded(e,t){var i;let{details:r,id:s}=t,{currentTrackId:n,levels:o}=this;if(!o.length)return;let l=o[n];if(s>=o.length||s!==n||!l)return;this.mediaBuffer=this.mediaBufferTimeRanges;let c=0;if(r.live||(i=l.details)!=null&&i.live){let u=this.mainDetails;if(r.deltaUpdateFailed||!u)return;let d=u.fragments[0];l.details?(c=this.alignPlaylists(r,l.details),c===0&&d&&(c=d.start,Cr(r,c))):r.hasProgramDateTime&&u.hasProgramDateTime?(Oa(r,u),c=r.fragments[0].start):d&&(c=d.start,Cr(r,c))}l.details=r,this.levelLastLoaded=s,!this.startFragRequested&&(this.mainDetails||!r.live)&&this.setStartPosition(l.details,c),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===B.IDLE&&(Jt(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0))}_handleFragmentLoadComplete(e){let{frag:t,payload:i}=e,r=t.decryptdata,s=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&r&&r.key&&r.iv&&r.method==="AES-128"){let n=performance.now();this.decrypter.decrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer).catch(o=>{throw s.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{let l=performance.now();s.trigger(v.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:n,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=B.IDLE})}}doTick(){if(!this.media){this.state=B.IDLE;return}if(this.state===B.IDLE){let{currentTrackId:e,levels:t}=this,i=t[e];if(!t.length||!i||!i.details)return;let{config:r}=this,s=this.getLoadPosition(),n=xe.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s,r.maxBufferHole),{end:o,len:l}=n,c=this.getFwdBufferInfo(this.media,re.MAIN),u=i.details,d=this.getMaxBufferLength(c==null?void 0:c.len)+u.levelTargetDuration;if(l>d)return;let h=u.fragments,m=h.length,y=u.edge,E=null,b=this.fragPrevious;if(o<y){let A=r.maxFragLookUpTolerance,D=o>y-A?0:A;E=Jt(b,h,Math.max(h[0].start,o),D),!E&&b&&b.start<h[0].start&&(E=h[0])}else E=h[m-1];if(!E)return;if(E=this.mapToInitFragWhenRequired(E),E.sn!=="initSegment"){let A=E.sn-u.startSN,D=h[A-1];D&&D.cc===E.cc&&this.fragmentTracker.getState(D)===Ce.NOT_LOADED&&(E=D)}this.fragmentTracker.getState(E)===Ce.NOT_LOADED&&this.loadFragment(E,i,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,i){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,i))}get mediaBufferTimeRanges(){return new ns(this.tracksBuffered[this.currentTrackId]||[])}},ns=class{constructor(e){this.buffered=void 0;let t=(i,r,s)=>{if(r=r>>>0,r>s-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${s})`);return e[r][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}},as=class extends Zt{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.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))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),mr(this.media.textTracks).forEach(t=>{Nt(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:i,details:r}=t,{trackId:s}=this,n=this.tracksInGroup[s];if(!n){this.warn(`Invalid subtitle track id ${i}`);return}let o=n.details;n.details=t.details,this.log(`subtitle track ${i} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!(t!=null&&t.textGroupIds))return;let i=t.textGroupIds[t.urlId],r=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){let s=this.tracks.filter(l=>!i||l.groupId===i);this.tracksInGroup=s;let n=this.findTrackId(r==null?void 0:r.name)||this.findTrackId();this.groupId=i||null;let o={subtitleTracks:s};this.log(`Updating subtitle tracks, ${s.length} track(s) found in "${i}" group-id`),this.hls.trigger(v.SUBTITLE_TRACKS_UPDATED,o),n!==-1&&this.setSubtitleTrack(n,r)}else this.shouldReloadPlaylist(r)&&this.setSubtitleTrack(this.trackId,r)}findTrackId(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++){let r=t[i];if((!this.selectDefaultTrack||r.default)&&(!e||e===r.name))return r.id}return-1}onError(e,t){t.fatal||!t.context||t.context.type===ve.SUBTITLE_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.checkRetry(t)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;let t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}loadPlaylist(e){super.loadPlaylist();let t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){let i=t.id,r=t.groupId,s=t.url;if(e)try{s=e.addDirectives(s)}catch(n){this.warn(`Could not construct new URL with HLS Delivery Directives: ${n}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(v.SUBTITLE_TRACK_LOADING,{url:s,id:i,groupId:r,deliveryDirectives:e||null})}}toggleTrackModes(e){let{media:t,trackId:i}=this;if(!t)return;let r=mr(t.textTracks),s=r.filter(o=>o.groupId===this.groupId);if(e===-1)[].slice.call(r).forEach(o=>{o.mode="disabled"});else{let o=s[i];o&&(o.mode="disabled")}let n=s[e];n&&(n.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var i;let r=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(i=r[e])!=null&&i.details)||e<-1||e>=r.length)return;this.clearTimer();let s=r[e];if(this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:"")),this.trackId=e,s){let{id:n,groupId:o="",name:l,type:c,url:u}=s;this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:n,groupId:o,name:l,type:c,url:u});let d=this.switchParams(s.url,t==null?void 0:t.details);this.loadPlaylist(d)}else this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1,t=mr(this.media.textTracks);for(let i=0;i<t.length;i++)if(t[i].mode==="hidden")e=i;else if(t[i].mode==="showing"){e=i;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}};function mr(a){let e=[];for(let t=0;t<a.length;t++){let i=a[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(a[t])}return e}var os=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t){let i=this.queues[t];i.push(e),i.length===1&&this.buffers[t]&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,i=new Promise(s=>{t=s}),r={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(r,e),i}executeNext(e){let{buffers:t,queues:i}=this,r=t[e],s=i[e];if(s.length){let n=s[0];try{n.execute()}catch(o){w.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),n.onError(o),r!=null&&r.updating||(s.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}},ia=Hi(),ra=/([ha]vc.)(?:\.[^.,]+)+/,ls=class{constructor(e){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=()=>{let{media:t,mediaSource:i}=this;w.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(v.MEDIA_ATTACHED,{media:t})),i&&i.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{w.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{w.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{let{media:t,_objectUrl:i}=this;t&&t.src!==i&&w.error(`Media element src was set while attaching MediaSource (${i} > ${t.src})`)},this.hls=e,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_APPENDING,this.onBufferAppending,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.BUFFER_EOS,this.onBufferEos,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.FRAG_PARSED,this.onFragParsed,this),e.on(v.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_APPENDING,this.onBufferAppending,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.BUFFER_EOS,this.onBufferEos,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.FRAG_PARSED,this.onFragParsed,this),e.off(v.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new os(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,w.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let i=this.media=t.media;if(i&&ia){let r=this.mediaSource=new ia;r.addEventListener("sourceopen",this._onMediaSourceOpen),r.addEventListener("sourceended",this._onMediaSourceEnded),r.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(r),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:i}=this;if(t){if(w.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(r){w.warn(`[buffer-controller]: onMediaDetaching: ${r.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),i&&self.URL.revokeObjectURL(i),e.src===i?(e.removeAttribute("src"),e.load()):w.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(v.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{let t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(i){w.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(e,t){let i=this.getSourceBufferTypes().length;Object.keys(t).forEach(r=>{if(i){let s=this.tracks[r];if(s&&typeof s.buffer.changeType=="function"){let{id:n,codec:o,levelCodec:l,container:c,metadata:u}=t[r],d=(s.levelCodec||s.codec).replace(ra,"$1"),h=(l||o).replace(ra,"$1");if(d!==h){let m=`${c};codecs=${l||o}`;this.appendChangeType(r,m),w.log(`[buffer-controller]: switching codec ${d} to ${h}`),this.tracks[r]={buffer:s.buffer,codec:o,container:c,levelCodec:l,metadata:u,id:n}}}}else this.pendingTracks[r]=t[r]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(e,t){let{operationQueue:i}=this,r={execute:()=>{let s=this.sourceBuffer[e];s&&(w.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),s.changeType(t)),i.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:s=>{w.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,s)}};i.append(r,e)}onBufferAppending(e,t){let{hls:i,operationQueue:r,tracks:s}=this,{data:n,type:o,frag:l,part:c,chunkMeta:u}=t,d=u.buffering[o],h=self.performance.now();d.start=h;let m=l.stats.buffering,y=c?c.stats.buffering:null;m.start===0&&(m.start=h),y&&y.start===0&&(y.start=h);let E=s.audio,b=!1;o==="audio"&&(E==null?void 0:E.container)==="audio/mpeg"&&(b=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);let A=l.start,D={execute:()=>{if(d.executeStart=self.performance.now(),b){let L=this.sourceBuffer[o];if(L){let F=A-L.timestampOffset;Math.abs(F)>=.1&&(w.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${A} (delta: ${F}) sn: ${l.sn})`),L.timestampOffset=A)}}this.appendExecutor(n,o)},onStart:()=>{},onComplete:()=>{let L=self.performance.now();d.executeEnd=d.end=L,m.first===0&&(m.first=L),y&&y.first===0&&(y.first=L);let{sourceBuffer:F}=this,k={};for(let G in F)k[G]=xe.getBuffered(F[G]);this.appendError=0,this.hls.trigger(v.BUFFER_APPENDED,{type:o,frag:l,part:c,chunkMeta:u,parent:l.type,timeRanges:k})},onError:L=>{w.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,L);let F={type:ie.MEDIA_ERROR,parent:l.type,details:N.BUFFER_APPEND_ERROR,frag:l,part:c,chunkMeta:u,error:L,err:L,fatal:!1};L.code===DOMException.QUOTA_EXCEEDED_ERR?F.details=N.BUFFER_FULL_ERROR:(this.appendError++,F.details=N.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(w.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),F.fatal=!0)),i.trigger(v.ERROR,F)}};r.append(D,o)}onBufferFlushing(e,t){let{operationQueue:i}=this,r=s=>({execute:this.removeExecutor.bind(this,s,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(v.BUFFER_FLUSHED,{type:s})},onError:n=>{w.warn(`[buffer-controller]: Failed to remove from ${s} SourceBuffer`,n)}});t.type?i.append(r(t.type),t.type):this.getSourceBufferTypes().forEach(s=>{i.append(r(s),s)})}onFragParsed(e,t){let{frag:i,part:r}=t,s=[],n=r?r.elementaryStreams:i.elementaryStreams;n[Ee.AUDIOVIDEO]?s.push("audiovideo"):(n[Ee.AUDIO]&&s.push("audio"),n[Ee.VIDEO]&&s.push("video"));let o=()=>{let l=self.performance.now();i.stats.buffering.end=l,r&&(r.stats.buffering.end=l);let c=r?r.stats:i.stats;this.hls.trigger(v.FRAG_BUFFERED,{frag:i,part:r,stats:c,id:i.type})};s.length===0&&w.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(o,s)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((r,s)=>{let n=this.sourceBuffer[s];return n&&(!t.type||t.type===s)&&(n.ending=!0,n.ended||(n.ended=!0,w.log(`[buffer-controller]: ${s} sourceBuffer now EOS`))),r&&!!(!n||n.ended)},!0)&&(w.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(s=>{let n=this.sourceBuffer[s];n&&(n.ending=!1)});let{mediaSource:r}=this;if(!r||r.readyState!=="open"){r&&w.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${r.readyState}`);return}w.log("[buffer-controller]: Calling mediaSource.endOfStream()"),r.endOfStream()}))}onLevelUpdated(e,{details:t}){!t.fragments.length||(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){let{hls:e,details:t,media:i,sourceBuffer:r}=this;if(!i||t===null)return;let s=this.getSourceBufferTypes();if(!s.length)return;let n=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!J(n)||n<0)return;let o=i.currentTime,l=t.levelTargetDuration,c=Math.max(n,l),u=Math.floor(o/l)*l-c;s.forEach(d=>{let h=r[d];if(h){let m=xe.getBuffered(h);if(m.length>0&&u>m.start(0)){if(e.trigger(v.BACK_BUFFER_REACHED,{bufferEnd:u}),t.live)e.trigger(v.LIVE_BACK_BUFFER_REACHED,{bufferEnd:u});else if(h.ended&&m.end(m.length-1)-o<l*2){w.info(`[buffer-controller]: Cannot flush ${d} back buffer while SourceBuffer is in ended state`);return}e.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:u,type:d})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;let{details:e,hls:t,media:i,mediaSource:r}=this,s=e.fragments[0].start+e.totalduration,n=i.duration,o=J(r.duration)?r.duration:0;e.live&&t.config.liveDurationInfinity?(w.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(e)):(s>o&&s>n||!J(n))&&(w.log(`[buffer-controller]: Updating Media Source duration to ${s.toFixed(3)}`),r.duration=s)}updateSeekableRange(e){let t=this.mediaSource,i=e.fragments;if(i.length&&e.live&&t!=null&&t.setLiveSeekableRange){let s=Math.max(0,i[0].start),n=Math.max(s,s+e.totalduration);t.setLiveSeekableRange(s,n)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:i}=this,r=Object.keys(i).length;if(r&&!e||r===2){this.createSourceBuffers(i),this.pendingTracks={};let s=this.getSourceBufferTypes();if(s.length)this.hls.trigger(v.BUFFER_CREATED,{tracks:this.tracks}),s.forEach(n=>{t.executeNext(n)});else{let n=new Error("could not create source buffer for media codec(s)");this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:n,reason:n.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(let r in e)if(!t[r]){let s=e[r];if(!s)throw Error(`source buffer exists for track ${r}, however track does not`);let n=s.levelCodec||s.codec,o=`${s.container};codecs=${n}`;w.log(`[buffer-controller]: creating sourceBuffer(${o})`);try{let l=t[r]=i.addSourceBuffer(o),c=r;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[r]={buffer:l,codec:n,container:s.container,levelCodec:s.levelCodec,metadata:s.metadata,id:s.id}}catch(l){w.error(`[buffer-controller]: error while trying to add sourceBuffer: ${l.message}`),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:o})}}}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){let{operationQueue:t}=this;t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){let i=new Error(`${e} SourceBuffer error`);w.error(`[buffer-controller]: ${i}`,t),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:N.BUFFER_APPENDING_ERROR,error:i,fatal:!1});let r=this.operationQueue.current(e);r&&r.onError(t)}removeExecutor(e,t,i){let{media:r,mediaSource:s,operationQueue:n,sourceBuffer:o}=this,l=o[e];if(!r||!s||!l){w.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),n.shiftAndExecuteNext(e);return}let c=J(r.duration)?r.duration:1/0,u=J(s.duration)?s.duration:1/0,d=Math.max(0,t),h=Math.min(i,c,u);h>d&&!l.ending?(l.ended=!1,w.log(`[buffer-controller]: Removing [${d},${h}] from the ${e} SourceBuffer`),l.remove(d,h)):n.shiftAndExecuteNext(e)}appendExecutor(e,t){let{operationQueue:i,sourceBuffer:r}=this,s=r[t];if(!s){w.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),i.shiftAndExecuteNext(t);return}s.ended=!1,s.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){w.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:i}=this,r=t.map(s=>i.appendBlocker(s));Promise.all(r).then(()=>{e(),t.forEach(s=>{let n=this.sourceBuffer[s];n!=null&&n.updating||i.shiftAndExecuteNext(s)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,i){let r=this.sourceBuffer[e];if(!r)return;let s=i.bind(this,e);this.listeners[e].push({event:t,listener:s}),r.addEventListener(t,s)}removeBufferListeners(e){let t=this.sourceBuffer[e];!t||this.listeners[e].forEach(i=>{t.removeEventListener(i.event,i.listener)})}},sa={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},za=function(e){let t=e;return sa.hasOwnProperty(e)&&(t=sa[e]),String.fromCharCode(t)},nt=15,vt=100,Qu={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Ju={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Zu={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},ed={25:2,26:4,29:6,30:8,31:10,27:13,28:15},td=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],cs=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let i=typeof t=="function"?t():t;w.log(`${this.time} [${e}] ${i}`)}}},At=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t},Fi=class{constructor(e,t,i,r,s){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=i||!1,this.background=r||"black",this.flash=s||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){let r=t[i];e.hasOwnProperty(r)&&(this[r]=e[r])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},us=class{constructor(e,t,i,r,s,n){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new Fi(t,i,r,s,n)}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}},ds=class{constructor(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let t=0;t<vt;t++)this.chars.push(new us);this.logger=e,this.pos=0,this.currPenState=new Fi}equals(e){let t=!0;for(let i=0;i<vt;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t}copy(e){for(let t=0;t<vt;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<vt;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>vt&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=vt)}moveCursor(e){let t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=za(e);if(this.pos>=vt){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<vt;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let i=0;i<vt;i++){let r=this.chars[i].uchar;r!==" "&&(t=!1),e.push(r)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},Qt=class{constructor(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let t=0;t<nt;t++)this.rows.push(new ds(e));this.logger=e,this.currRow=nt-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<nt;e++)this.rows[e].clear();this.currRow=nt-1}equals(e){let t=!0;for(let i=0;i<nt;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<nt;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<nt;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<nt;o++)this.rows[o].clear();let s=this.currRow+1-this.nrRollUpRows,n=this.lastOutputScreen;if(n){let o=n.rows[s].cueStartTime,l=this.logger.time;if(o&&l!==null&&o<l)for(let c=0;c<this.nrRollUpRows;c++)this.rows[t-this.nrRollUpRows+c+1].copy(n.rows[s+c])}}this.currRow=t;let i=this.rows[this.currRow];if(e.indent!==null){let s=e.indent,n=Math.max(s-1,0);i.setCursor(e.indent),e.color=i.chars[n].penState.foreground}let r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(r)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],i="",r=-1;for(let s=0;s<nt;s++){let n=this.rows[s].getTextString();n&&(r=s+1,e?t.push("Row "+r+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
|
|
33
|
+
`)),i}getTextAndFormat(){return this.rows}},Ni=class{constructor(e,t,i){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 Qt(i),this.nonDisplayedMemory=new Qt(i),this.lastOutputScreen=new Qt(i),this.currRollUpRow=this.displayedMemory.rows[nt-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[nt-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"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)}insertChars(e){for(let i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{let i=Math.floor(e/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=r[i]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t: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.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}},Ui=class{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;let r=new cs;this.channels=[null,new Ni(e,t,r),new Ni(e+1,i,r)],this.cmdHistory=aa(),this.logger=r}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let i,r,s,n=!1;this.logger.time=e;for(let o=0;o<t.length;o+=2)if(r=t[o]&127,s=t[o+1]&127,!(r===0&&s===0)){if(this.logger.log(3,"["+At([t[o],t[o+1]])+"] -> ("+At([r,s])+")"),i=this.parseCmd(r,s),i||(i=this.parseMidrow(r,s)),i||(i=this.parsePAC(r,s)),i||(i=this.parseBackgroundAttributes(r,s)),!i&&(n=this.parseChars(r,s),n)){let l=this.currentChannel;l&&l>0?this.channels[l].insertChars(n):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!i&&!n&&this.logger.log(2,"Couldn't parse cleaned data "+At([r,s])+" orig: "+At([t[o],t[o+1]]))}}parseCmd(e,t){let{cmdHistory:i}=this,r=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=33&&t<=35;if(!(r||s))return!1;if(na(e,t,i))return Ft(null,null,i),this.logger.log(3,"Repeated command ("+At([e,t])+") is dropped"),!0;let n=e===20||e===21||e===23?1:2,o=this.channels[n];return e===20||e===21||e===28||e===29?t===32?o.ccRCL():t===33?o.ccBS():t===34?o.ccAOF():t===35?o.ccAON():t===36?o.ccDER():t===37?o.ccRU(2):t===38?o.ccRU(3):t===39?o.ccRU(4):t===40?o.ccFON():t===41?o.ccRDC():t===42?o.ccTR():t===43?o.ccRTD():t===44?o.ccEDM():t===45?o.ccCR():t===46?o.ccENM():t===47&&o.ccEOC():o.ccTO(t-32),Ft(e,t,i),this.currentChannel=n,!0}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let r=this.channels[i];return r?(r.ccMIDROW(t),this.logger.log(3,"MIDROW ("+At([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i,r=this.cmdHistory,s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(s||n))return!1;if(na(e,t,r))return Ft(null,null,r),!0;let o=e<=23?1:2;t>=64&&t<=95?i=o===1?Qu[e]:Zu[e]:i=o===1?Ju[e]:ed[e];let l=this.channels[o];return l?(l.setPAC(this.interpretPAC(i,t)),Ft(e,t,r),this.currentChannel=o,!0):!1}interpretPAC(e,t){let i,r={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-64,r.underline=(i&1)===1,i<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(r.italics=!0,r.color="white"):r.indent=Math.floor((i-16)/2)*4,r}parseChars(e,t){let i,r=null,s=null;if(e>=25?(i=2,s=e-8):(i=1,s=e),s>=17&&s<=19){let n;s===17?n=t+80:s===18?n=t+112:n=t+144,this.logger.log(2,"Special char '"+za(n)+"' in channel "+i),r=[n]}else e>=32&&e<=127&&(r=t===0?[e]:[e,t]);if(r){let n=At(r);this.logger.log(3,"Char codes = "+n.join(",")),Ft(e,t,this.cmdHistory)}return r}parseBackgroundAttributes(e,t){let i=(e===16||e===24)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=45&&t<=47;if(!(i||r))return!1;let s,n={};e===16||e===24?(s=Math.floor((t-32)/2),n.background=td[s],t%2===1&&(n.background=n.background+"_semi")):t===45?n.background="transparent":(n.foreground="black",t===47&&(n.underline=!0));let o=e<=23?1:2;return this.channels[o].setBkgData(n),Ft(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}this.cmdHistory=aa()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let i=this.channels[t];i&&i.cueSplitAtTime(e)}}};function Ft(a,e,t){t.a=a,t.b=e}function na(a,e,t){return t.a===a&&t.b===e}function aa(){return{a:null,b:null}}var Ut=class{constructor(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}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},ws=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;let a=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;let c=l.toLowerCase();return~o.indexOf(c)?c:!1}function i(o){return t(a,o)}function r(o){return t(e,o)}function s(o,...l){let c=1;for(;c<arguments.length;c++){let u=arguments[c];for(let d in u)o[d]=u[d]}return o}function n(o,l,c){let u=this,d={enumerable:!0};u.hasBeenReset=!1;let h="",m=!1,y=o,E=l,b=c,A=null,D="",L=!0,F="auto",k="start",G=50,M="middle",$=50,K="middle";Object.defineProperty(u,"id",s({},d,{get:function(){return h},set:function(P){h=""+P}})),Object.defineProperty(u,"pauseOnExit",s({},d,{get:function(){return m},set:function(P){m=!!P}})),Object.defineProperty(u,"startTime",s({},d,{get:function(){return y},set:function(P){if(typeof P!="number")throw new TypeError("Start time must be set to a number.");y=P,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",s({},d,{get:function(){return E},set:function(P){if(typeof P!="number")throw new TypeError("End time must be set to a number.");E=P,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",s({},d,{get:function(){return b},set:function(P){b=""+P,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",s({},d,{get:function(){return A},set:function(P){A=P,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",s({},d,{get:function(){return D},set:function(P){let q=i(P);if(q===!1)throw new SyntaxError("An invalid or illegal string was specified.");D=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",s({},d,{get:function(){return L},set:function(P){L=!!P,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",s({},d,{get:function(){return F},set:function(P){if(typeof P!="number"&&P!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");F=P,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",s({},d,{get:function(){return k},set:function(P){let q=r(P);if(!q)throw new SyntaxError("An invalid or illegal string was specified.");k=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",s({},d,{get:function(){return G},set:function(P){if(P<0||P>100)throw new Error("Position must be between 0 and 100.");G=P,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",s({},d,{get:function(){return M},set:function(P){let q=r(P);if(!q)throw new SyntaxError("An invalid or illegal string was specified.");M=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",s({},d,{get:function(){return $},set:function(P){if(P<0||P>100)throw new Error("Size must be between 0 and 100.");$=P,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",s({},d,{get:function(){return K},set:function(P){let q=r(P);if(!q)throw new SyntaxError("An invalid or illegal string was specified.");K=q,this.hasBeenReset=!0}})),u.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}(),hs=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function Xa(a){function e(i,r,s,n){return(i|0)*3600+(r|0)*60+(s|0)+parseFloat(n||0)}let t=a.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}var fs=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let r=0;r<i.length;++r)if(t===i[r]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}};function Qa(a,e,t,i){let r=i?a.split(i):[a];for(let s in r){if(typeof r[s]!="string")continue;let n=r[s].split(t);if(n.length!==2)continue;let o=n[0],l=n[1];e(o,l)}}var gs=new ws(0,0,""),yi=gs.align==="middle"?"middle":"center";function id(a,e,t){let i=a;function r(){let o=Xa(a);if(o===null)throw new Error("Malformed timestamp: "+i);return a=a.replace(/^[^\sa-zA-Z-]+/,""),o}function s(o,l){let c=new fs;Qa(o,function(h,m){let y;switch(h){case"region":for(let E=t.length-1;E>=0;E--)if(t[E].id===m){c.set(h,t[E].region);break}break;case"vertical":c.alt(h,m,["rl","lr"]);break;case"line":y=m.split(","),c.integer(h,y[0]),c.percent(h,y[0])&&c.set("snapToLines",!1),c.alt(h,y[0],["auto"]),y.length===2&&c.alt("lineAlign",y[1],["start",yi,"end"]);break;case"position":y=m.split(","),c.percent(h,y[0]),y.length===2&&c.alt("positionAlign",y[1],["start",yi,"end","line-left","line-right","auto"]);break;case"size":c.percent(h,m);break;case"align":c.alt(h,m,["start",yi,"end","left","right"]);break}},/:/,/\s/),l.region=c.get("region",null),l.vertical=c.get("vertical","");let u=c.get("line","auto");u==="auto"&&gs.line===-1&&(u=-1),l.line=u,l.lineAlign=c.get("lineAlign","start"),l.snapToLines=c.get("snapToLines",!0),l.size=c.get("size",100),l.align=c.get("align",yi);let d=c.get("position","auto");d==="auto"&&gs.position===50&&(d=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=d}function n(){a=a.replace(/^\s+/,"")}if(n(),e.startTime=r(),n(),a.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);a=a.slice(3),n(),e.endTime=r(),n(),s(a,e)}function Ja(a){return a.replace(/<br(?: \/)?>/gi,`
|
|
34
|
+
`)}var ms=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new hs,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){let t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function i(){let s=t.buffer,n=0;for(s=Ja(s);n<s.length&&s[n]!=="\r"&&s[n]!==`
|
|
35
|
+
`;)++n;let o=s.slice(0,n);return s[n]==="\r"&&++n,s[n]===`
|
|
36
|
+
`&&++n,t.buffer=s.slice(n),o}function r(s){Qa(s,function(n,o){},/:/)}try{let s="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;s=i();let o=s.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let n=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(n?n=!1:s=i(),t.state){case"HEADER":/:/.test(s)?r(s):s||(t.state="ID");continue;case"NOTE":s||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(s)){t.state="NOTE";break}if(!s)continue;if(t.cue=new ws(0,0,""),t.state="CUE",s.indexOf("-->")===-1){t.cue.id=s;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{id(s,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let o=s.indexOf("-->")!==-1;if(!s||o&&(n=!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+=`
|
|
37
|
+
`),t.cue.text+=s}continue;case"BADCUE":s||(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}flush(){let e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
|
|
39
38
|
|
|
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}
|
|
39
|
+
`,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}},rd=/\r\n|\n\r|\n|\r/g,pr=function(e,t,i=0){return e.slice(i,i+t.length)===t},sd=function(e){let t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),s=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!J(t)||!J(i)||!J(r)||!J(s))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*r,t+=60*60*1e3*s,t},yr=function(e){let t=5381,i=e.length;for(;i;)t=t*33^e.charCodeAt(--i);return(t>>>0).toString()};function ks(a,e,t){return yr(a.toString())+yr(e.toString())+yr(t)}var nd=function(e,t,i){let r=e[t],s=e[r.prevCC];if(!s||!s.new&&r.new){e.ccOffset=e.presentationOffset=r.start,r.new=!1;return}for(;(n=s)!=null&&n.new;){var n;e.ccOffset+=r.start-s.start,r.new=!1,r=s,s=e[r.prevCC]}e.presentationOffset=i};function ad(a,e,t,i,r,s,n){let o=new ms,l=ft(new Uint8Array(a)).trim().replace(rd,`
|
|
41
40
|
`).split(`
|
|
42
|
-
`),
|
|
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 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},q(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)},q(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)},q(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 V=u.onErrorOut;typeof V=="function"&&this.on(E.ERROR,V,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=yt.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)},q(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 mt=(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||mt(D,"playing",()=>{H=!0},{once:!0})};if(Q(),mt(D,"loadstart",()=>{H=!1,Q(),ka(D,K)},{once:!0}),mt(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&&mt(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,q=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=q,H.config.maxBufferSize=re),ne())},ne=()=>{!K&&D&&(K=!0,H.loadSource(D))};return mt(M,"play",()=>{Q=!0,H.config.maxBufferLength=q,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 q=(z=Q.subtitleTrack)!=null?z:Q.closedCaptions,re=D.subtitleTracks.findIndex(({lang:ne,name:ye,type:oe})=>ne==(q==null?void 0:q.lang)&&ye===Q.label&&oe.toLowerCase()===Q.kind);wa(I,Q.kind,Q.label,q==null?void 0:q.lang,`${Q.kind}${re}`)})});let M=()=>{var Q;if(!D.subtitleTracks.length)return;let j=Array.from(I.textTracks).find(q=>q.id&&q.mode==="showing"&&["subtitles","captions"].includes(q.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 q=D.subtitleTracks.findIndex(({lang:re,name:z,type:ne})=>re==j.language&&z===j.label&&ne.toLowerCase()===j.kind);D.subtitleTrack=q}j&&(j==null?void 0:j.id)===K&&j.cues&&Array.from(j.cues).forEach(q=>{j.addCue(q)})};I.textTracks.addEventListener("change",M),D.on(lt.Events.CUES_PARSED,(j,{track:K,cues:Q})=>{let q=I.textTracks.getTrackById(K);if(!q)return;let re=q.mode==="disabled";re&&(q.mode="hidden"),Q.forEach(z=>{var ne;(ne=q.cues)!=null&&ne.getCueById(z.id)||q.addCue(z)}),re&&(q.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 q=I.querySelector('track[label="thumbnails"]'),re=(Q=q==null?void 0:q.getAttribute("src"))!=null?Q:"";q==null||q.removeAttribute("src"),setTimeout(()=>{q==null||q.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),q=(ye=H==null?void 0:H.cues)==null?void 0:ye[Q],re=q?q.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:q,endTime:re})=>q<=H&&re>H);return Bs(j)}async function Gs(I,D=Aa){return new Promise(M=>{mt(I,"loadstart",async()=>{let H=await Us(I,[],D);mt(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
|
-
`).find((
|
|
47
|
-
`))}),
|
|
41
|
+
`),c=[],u=e?Uu(e.baseTime,e.timescale):0,d="00:00.000",h=0,m=0,y,E=!0;o.oncue=function(b){let A=t[i],D=t.ccOffset,L=(h-u)/9e4;if(A!=null&&A.new&&(m!==void 0?D=t.ccOffset=A.start:nd(t,i,L)),L){if(!e){y=new Error("Missing initPTS for VTT MPEGTS");return}D=L-t.presentationOffset}let F=b.endTime-b.startTime,k=rt((b.startTime+D-m)*9e4,r*9e4)/9e4;b.startTime=Math.max(k,0),b.endTime=Math.max(k+F,0);let G=b.text.trim();b.text=decodeURIComponent(encodeURIComponent(G)),b.id||(b.id=ks(b.startTime,b.endTime,G)),b.endTime>0&&c.push(b)},o.onparsingerror=function(b){y=b},o.onflush=function(){if(y){n(y);return}s(c)},l.forEach(b=>{if(E)if(pr(b,"X-TIMESTAMP-MAP=")){E=!1,b.slice(16).split(",").forEach(A=>{pr(A,"LOCAL:")?d=A.slice(6):pr(A,"MPEGTS:")&&(h=parseInt(A.slice(7)))});try{m=sd(d)/1e3}catch(A){y=A}return}else b===""&&(E=!1);o.parse(b+`
|
|
42
|
+
`)}),o.flush()}var vr="stpp.ttml.im1t",Za=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,eo=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,od={left:"start",center:"center",right:"end",start:"start",end:"end"};function oa(a,e,t,i){let r=ye(new Uint8Array(a),["mdat"]);if(r.length===0){i(new Error("Could not parse IMSC1 mdat"));return}let s=r.map(o=>ft(o)),n=Nu(e.baseTime,1,e.timescale);try{s.forEach(o=>t(ld(o,n)))}catch(o){i(o)}}function ld(a,e){let r=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");let s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(s).reduce((d,h)=>(d[h]=r.getAttribute(`ttp:${h}`)||s[h],d),{}),o=r.getAttribute("xml:space")!=="preserve",l=la(Tr(r,"styling","style")),c=la(Tr(r,"layout","region")),u=Tr(r,"body","[begin]");return[].map.call(u,d=>{let h=to(d,o);if(!h||!d.hasAttribute("begin"))return null;let m=xr(d.getAttribute("begin"),n),y=xr(d.getAttribute("dur"),n),E=xr(d.getAttribute("end"),n);if(m===null)throw ca(d);if(E===null){if(y===null)throw ca(d);E=m+y}let b=new ws(m-e,E-e,h);b.id=ks(b.startTime,b.endTime,b.text);let A=c[d.getAttribute("region")],D=l[d.getAttribute("style")],L=cd(A,D,l),{textAlign:F}=L;if(F){let k=od[F];k&&(b.lineAlign=k),b.align=F}return Ie(b,L),b}).filter(d=>d!==null)}function Tr(a,e,t){let i=a.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function la(a){return a.reduce((e,t)=>{let i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function to(a,e){return[].slice.call(a.childNodes).reduce((t,i,r)=>{var s;return i.nodeName==="br"&&r?t+`
|
|
43
|
+
`:(s=i.childNodes)!=null&&s.length?to(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function cd(a,e,t){let i="http://www.w3.org/ns/ttml#styling",r=null,s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],n=a!=null&&a.hasAttribute("style")?a.getAttribute("style"):null;return n&&t.hasOwnProperty(n)&&(r=t[n]),s.reduce((o,l)=>{let c=Er(e,i,l)||Er(a,i,l)||Er(r,i,l);return c&&(o[l]=c),o},{})}function Er(a,e,t){return a&&a.hasAttributeNS(e,t)?a.getAttributeNS(e,t):null}function ca(a){return new Error(`Could not parse ttml timestamp ${a}`)}function xr(a,e){if(!a)return null;let t=Xa(a);return t===null&&(Za.test(a)?t=ud(a,e):eo.test(a)&&(t=dd(a,e))),t}function ud(a,e){let t=Za.exec(a),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function dd(a,e){let t=eo.exec(a),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}var ps=class{constructor(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=ua(),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){let t=new Ut(this,"textTrack1"),i=new Ut(this,"textTrack2"),r=new Ut(this,"textTrack3"),s=new Ut(this,"textTrack4");this.cea608Parser1=new Ui(1,t,i),this.cea608Parser2=new Ui(3,r,s)}e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,i,r,s){let n=!1;for(let o=s.length;o--;){let l=s[o],c=fd(l[0],l[1],t,i);if(c>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],i),n=!0,c/(i-t)>.5))return}if(n||s.push([t,i]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,i,r)}else{let o=this.Cues.newCue(null,t,i,r);this.hls.trigger(v.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:s}){let{unparsedVttFrags:n}=this;i==="main"&&(this.initPTS[t.cc]={baseTime:r,timescale:s}),n.length&&(this.unparsedVttFrags=[],n.forEach(o=>{this.onFragLoaded(v.FRAG_LOADED,o)}))}getExistingTrack(e){let{media:t}=this;if(t)for(let i=0;i<t.textTracks.length;i++){let r=t.textTracks[i];if(r[e])return r}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:i,media:r}=this,{label:s,languageCode:n}=t[e],o=this.getExistingTrack(e);if(o)i[e]=o,Nt(i[e]),Ra(i[e],r);else{let l=this.createTextTrack("captions",s,n);l&&(l[e]=!0,i[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let i=t.label,r={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,i){let r=this.media;if(!!r)return r.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{Nt(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=ua(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let i=0;i<t.length;i++)Nt(t[i])}onSubtitleTracksUpdated(e,t){let i=t.subtitleTracks||[],r=i.some(s=>s.textCodec===vr);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(Ya(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){let n=this.media?this.media.textTracks:null;this.tracks.forEach((o,l)=>{let c;if(n&&l<n.length){let u=null;for(let d=0;d<n.length;d++)if(hd(n[d],o)){u=n[d];break}u&&(c=u)}if(c)Nt(c);else{let u=this._captionsOrSubtitlesFromCharacteristics(o);c=this.createTextTrack(u,o.name,o.lang),c&&(c.mode="disabled")}c&&(c.groupId=o.groupId,this.textTracks.push(c))})}else if(this.tracks.length){let n=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:n})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){let t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&i)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{let r=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!r)return;let s=`textTrack${r[1]}`,n=this.captionsProperties[s];!n||(n.label=i.name,i.lang&&(n.languageCode=i.lang),n.media=i)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){let{cea608Parser1:i,cea608Parser2:r,lastSn:s,lastPartIndex:n}=this;if(!(!this.enabled||!(i&&r))&&t.frag.type===re.MAIN){var o,l;let c=t.frag.sn,u=(o=t==null||(l=t.part)==null?void 0:l.index)!=null?o:-1;c===s+1||c===s&&u===n+1||(i.reset(),r.reset()),this.lastSn=c,this.lastPartIndex=u}}onFragLoaded(e,t){let{frag:i,payload:r}=t;if(i.type===re.SUBTITLE)if(r.byteLength){let s=i.decryptdata,n="stats"in t;if(s==null||!s.encrypted||n){let o=this.tracks[i.level],l=this.vttCCs;l[i.cc]||(l[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===vr?this._parseIMSC1(i,r):this._parseVTTs(t)}}else this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let i=this.hls;oa(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),i.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},r=>{w.log(`Failed to parse IMSC1: ${r}`),i.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})})}_parseVTTs(e){var t;let{frag:i,payload:r}=e,{initPTS:s,unparsedVttFrags:n}=this,o=s.length-1;if(!s[i.cc]&&o===-1){n.push(e);return}let l=this.hls,c=(t=i.initSegment)!=null&&t.data?It(i.initSegment.data,new Uint8Array(r)):r;ad(c,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,u=>{this._appendCues(u,i.level),l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},u=>{let d=u.message==="Missing initPTS for VTT MPEGTS";d?n.push(e):this._fallbackToIMSC1(i,r),w.log(`Failed to parse VTT cue: ${u}`),!(d&&o>i.cc)&&l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:u})})}_fallbackToIMSC1(e,t){let i=this.tracks[e.level];i.textCodec||oa(t,this.initPTS[e.cc],()=>{i.textCodec=vr,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){let i=this.hls;if(this.config.renderTextTracksNatively){let r=this.textTracks[t];if(!r||r.mode==="disabled")return;e.forEach(s=>Ia(r,s))}else{let r=this.tracks[t];if(!r)return;let s=r.default?"default":"subtitles"+t;i.trigger(v.CUES_PARSED,{type:"subtitles",cues:e,track:s})}}onFragDecrypted(e,t){let{frag:i}=t;i.type===re.SUBTITLE&&this.onFragLoaded(v.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){let{cea608Parser1:i,cea608Parser2:r}=this;if(!this.enabled||!(i&&r))return;let{frag:s,samples:n}=t;if(!(s.type===re.MAIN&&this.closedCaptionsForLevel(s)==="NONE"))for(let o=0;o<n.length;o++){let l=n[o].bytes;if(l){let c=this.extractCea608Data(l);i.addData(n[o].pts,c[0]),r.addData(n[o].pts,c[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:r,type:s}){let{media:n}=this;if(!(!n||n.currentTime<i)){if(!s||s==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>Rr(o[l],t,i))}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>Rr(o[l],t,r))}}}extractCea608Data(e){let t=[[],[]],i=e[0]&31,r=2;for(let s=0;s<i;s++){let n=e[r++],o=127&e[r++],l=127&e[r++];if(o===0&&l===0)continue;if((4&n)!==0){let u=3&n;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}};function hd(a,e){return!!a&&a.label===e.name&&!(a.textTrack1||a.textTrack2)}function fd(a,e,t,i){return Math.min(e,i)-Math.max(a,t)}function ua(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var ri=class{constructor(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()}setStreamController(e){this.streamController=e}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){let i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){let e=this.hls.levels;if(e.length){let t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return-1;let i=t.filter((r,s)=>this.isLevelAllowed(r)&&s<=e);return this.clientRect=null,ri.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;let r=(n,o)=>o?n.width!==o.width||n.height!==o.height:!0,s=e.length-1;for(let n=0;n<e.length;n+=1){let o=e[n];if((o.width>=t||o.height>=i)&&r(o,e[n+1])){s=n;break}}return s}},ys=class{constructor(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()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let i=this.hls.config;if(i.capLevelOnFPSDrop){let r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,i){let r=performance.now();if(t){if(this.lastTime){let s=r-this.lastTime,n=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*n/s,c=this.hls;if(c.trigger(v.FPS_DROP,{currentDropped:n,currentDecoded:o,totalDroppedFrames:i}),l>0&&n>c.config.fpsDroppedMonitoringThreshold*o){let u=c.currentLevel;w.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(c.autoLevelCapping===-1||c.autoLevelCapping>=u)&&(u=u-1,c.trigger(v.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:c.currentLevel}),c.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},vi="[eme]",_t=class{constructor(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=_t.CDMCleanupPromise?[_t.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=w.debug.bind(w,vi),this.log=w.log.bind(w,vi),this.warn=w.warn.bind(w,vi),this.error=w.error.bind(w,vi),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();let 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}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:i}=this.config,r=t[e];if(r)return r.licenseUrl;if(e===Se.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){let{drmSystems:t}=this.config,i=t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,i=(n,o,l)=>!!n&&l.indexOf(n)===o,r=t.map(n=>n.audioCodec).filter(i),s=t.map(n=>n.videoCodec).filter(i);return r.length+s.length===0&&s.push("avc1.42e01e"),new Promise((n,o)=>{let l=c=>{let u=c.shift();this.getMediaKeysPromise(u,r,s).then(d=>n({keySystem:u,mediaKeys:d})).catch(d=>{c.length?l(c):d instanceof Qe?o(d):o(new Qe({type:ie.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_NO_ACCESS,error:d,fatal:!0},d.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${i}`;return ma===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return i(e,t)}getMediaKeysPromise(e,t,i){let r=hc(e,t,i,this.config.drmSystemOptions),s=this.keySystemAccessPromises[e],n=s==null?void 0:s.keySystemAccess;if(!n){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(r)}`),n=this.requestMediaKeySystemAccess(e,r);let o=this.keySystemAccessPromises[e]={keySystemAccess:n};return n.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),n.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let c=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),c.then(d=>d?this.setMediaKeysServerCertificate(u,e,d):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return n.then(()=>s.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${lt.hexDump(e.keyId||[])}`);let r=i.createSession(),s={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let i=this.createMediaKeySessionContext(e),r=this.getKeyIdString(t),s="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(i,s,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return lt.hexDump(e.keyId)}updateKeySession(e,t){var i;let r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${lt.hexDump(((i=e.decryptdata)==null?void 0:i.keyId)||[])}
|
|
44
|
+
} (data length: ${t&&t.byteLength})`),r.update(t)}selectKeySystemFormat(e){let 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}getKeyFormatPromise(e){return new Promise((t,i)=>{let r=tr(this.config),s=e.map(In).filter(n=>!!n&&r.indexOf(n)!==-1);return this.getKeySystemSelectionPromise(s).then(({keySystem:n})=>{let o=Dn(n);o?t(o):i(new Error(`Unable to find format for key-system "${n}"`))}).catch(i)})}loadKey(e){let t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);let s=this.keyIdToKeySessionPromise[i];return s||(s=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(t).then(({keySystem:n,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(n,o).then(()=>{this.throwIfDestroyed();let l=this.createMediaKeySessionContext({keySystem:n,mediaKeys:o,decryptdata:t}),c="cenc";return this.generateRequestWithPreferredKeySession(l,c,t.pssh,"playlist-key")}))),s.catch(n=>this.handleError(n))),s}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){!this.hls||(this.error(e.message),e instanceof Qe?this.hls.trigger(v.ERROR,e.data):this.hls.trigger(v.ERROR,{type:ie.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){let r=In(e.keyFormat),s=r?[r]:tr(this.config);return this.attemptKeySystemAccess(s)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=tr(this.config)),e.length===0)throw new Qe({type:ie.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){let{initDataType:t,initData:i}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),i===null)return;let r,s;if(t==="sinf"&&this.config.drmSystems[Se.FAIRPLAY]){let u=Fe(new Uint8Array(i));try{let d=bs(JSON.parse(u).sinf),h=_a(new Uint8Array(d));if(!h)return;r=h.subarray(8,24),s=Se.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{let u=Fc(i);if(u===null)return;u.version===0&&u.systemId===ga.WIDEVINE&&u.data&&(r=u.data.subarray(8,24)),s=dc(u.systemId)}if(!s||!r)return;let n=lt.hexDump(r),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this,c=o[n];for(let u=0;u<l.length;u++){let d=l[u],h=d.decryptdata;if(h.pssh||!h.keyId)continue;let m=lt.hexDump(h.keyId);if(n===m||h.uri.replace(/-/g,"").indexOf(n)!==-1){c=o[m],delete o[m],h.pssh=new Uint8Array(i),h.keyId=r,c=o[n]=c.then(()=>this.generateRequestWithPreferredKeySession(d,t,i,"encrypted-event-key-match"));break}}c||(c=o[n]=this.getKeySystemSelectionPromise([s]).then(({keySystem:u,mediaKeys:d})=>{var h;this.throwIfDestroyed();let m=new Dt("ISO-23001-7",n,(h=Dn(u))!=null?h:"");return m.pssh=new Uint8Array(i),m.keyId=r,this.attemptSetMediaKeys(u,d).then(()=>{this.throwIfDestroyed();let y=this.createMediaKeySessionContext({decryptdata:m,keySystem:u,mediaKeys:d});return this.generateRequestWithPreferredKeySession(y,t,i,"encrypted-event-no-match")})})),c.catch(u=>this.handleError(u))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){let i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let r=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(s=>i.indexOf(s)===-1)})}generateRequestWithPreferredKeySession(e,t,i,r){var s,n;let o=(s=this.config.drmSystems)==null||(n=s[e.keySystem])==null?void 0:n.generateRequest;if(o)try{let h=o.call(this.hls,t,i,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,i=e.decryptdata.pssh=h.initData?new Uint8Array(h.initData):null}catch(h){var l;if(this.warn(h.message),(l=this.hls)!=null&&l.config.debug)throw h}if(i===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);let c=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${r}": ${c} (init data type: ${t} length: ${i?i.byteLength:null})`);let u=new Ds;e.mediaKeysSession.onmessage=h=>{let m=e.mediaKeysSession;if(!m){u.emit("error",new Error("invalid state"));return}let{messageType:y,message:E}=h;this.log(`"${y}" message event for session "${m.sessionId}" message size: ${E.byteLength}`),y==="license-request"||y==="license-renewal"?this.renewLicense(e,E).catch(b=>{this.handleError(b),u.emit("error",b)}):y==="license-release"?e.keySystem===Se.FAIRPLAY&&(this.updateKeySession(e,fa("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${y}"`)},e.mediaKeysSession.onkeystatuseschange=h=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let y=e.keyStatus;u.emit("keyStatus",y),y==="expired"&&(this.warn(`${e.keySystem} expired for key ${c}`),this.renewKeySession(e))};let d=new Promise((h,m)=>{u.on("error",m),u.on("keyStatus",y=>{y.startsWith("usable")?h():y==="output-restricted"?m(new Qe({type:ie.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):y==="internal-error"?m(new Qe({type:ie.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${y}"`)):y==="expired"?m(new Error("key expired while generating request")):this.warn(`unhandled key status change "${y}"`)})});return e.mediaKeysSession.generateRequest(t,i).then(()=>{var h;this.log(`Request generated for key-session "${(h=e.mediaKeysSession)==null?void 0:h.sessionId}" keyId: ${c}`)}).catch(h=>{throw new Qe({type:ie.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_NO_SESSION,error:h,fatal:!1},`Error generating key-session request: ${h}`)}).then(()=>d).catch(h=>{throw u.removeAllListeners(),this.removeSession(e),h}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,i)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${lt.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${lt.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,i=t.loader,r=new i(t),s=this.getServerCertificateUrl(e);return s?(this.log(`Fetching serverCertificate for "${e}"`),new Promise((n,o)=>{let l={responseType:"arraybuffer",url:s},c=t.certLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(h,m,y,E)=>{n(h.data)},onError:(h,m,y,E)=>{o(new Qe({type:ie.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:y,response:Ze({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${s}). Status: ${h.code} (${h.text})`))},onTimeout:(h,m,y)=>{o(new Qe({type:ie.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:y,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${s})`))},onAbort:(h,m,y)=>{o(new Error("aborted"))}};r.load(l,u,d)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((r,s)=>{e.setServerCertificate(i).then(n=>{this.log(`setServerCertificate ${n?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${t}"`),r(e)}).catch(n=>{s(new Qe({type:ie.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:n,fatal:!0},n.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(r=>{throw new Qe({type:ie.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:r,fatal:!0},r.message)}))}setupLicenseXHR(e,t,i,r){let s=this.config.licenseXhrSetup;return s?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return s.call(this.hls,e,t,i,r)}).catch(n=>{if(!i.decryptdata)throw n;return e.open("POST",t,!0),s.call(this.hls,e,t,i,r)}).then(n=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:n||r})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){let i=this.config.keyLoadPolicy.default;return new Promise((r,s)=>{let n=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${n}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return s(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let c=this.config.licenseResponseCallback;if(c)try{l=c.call(this.hls,o,n,e)}catch(u){this.error(u)}r(l)}else{let l=i.errorRetry,c=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>c||o.status>=400&&o.status<500)s(new Qe({type:ie.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:n,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${n}). Status: ${o.status} (${o.statusText})`));else{let u=c-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(r,s)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,n,e,t).then(({xhr:l,licenseChallenge:c})=>{l.send(c)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Dt.clearKeyUriToKeyIdMap();let i=t.length;_t.CDMCleanupPromise=Promise.all(t.map(r=>this.removeSession(r)).concat(e==null?void 0:e.setMediaKeys(null).catch(r=>{this.log(`Could not clear media keys: ${r}. media.src: ${e==null?void 0:e.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}. media.src: ${e==null?void 0:e.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let i=t.reduce((r,s)=>(r.indexOf(s.keyFormat)===-1&&r.push(s.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:i}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),t.onmessage=null,t.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let r=this.mediaKeySessions.indexOf(e);return r>-1&&this.mediaKeySessions.splice(r,1),t.remove().catch(s=>{this.log(`Could not remove session: ${s}`)}).then(()=>t.close()).catch(s=>{this.log(`Could not close session: ${s}`)})}}};_t.CDMCleanupPromise=void 0;var Qe=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},gd=1,ze={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},md="h",dt=class{constructor(e){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=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=r=>{try{this.apply(r,{ot:ze.MANIFEST,su:!this.initialized})}catch(s){w.warn("Could not generate manifest CMCD data.",s)}},this.applyFragmentData=r=>{try{let s=r.frag,n=this.hls.levels[s.level],o=this.getObjectType(s),l={d:s.duration*1e3,ot:o};(o===ze.VIDEO||o===ze.AUDIO||o==ze.MUXED)&&(l.br=n.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(r,l)}catch(s){w.warn("Could not generate segment CMCD data.",s)}},this.hls=e;let t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||dt.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){let e=this.hls;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHED,this.onMediaDetached,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHED,this.onMediaDetached,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,r;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer}createData(){var e;return{v:gd,sf:md,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Ie(t,this.createData());let i=t.ot===ze.INIT||t.ot===ze.VIDEO||t.ot===ze.MUXED;if(this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){let r=dt.toHeaders(t);if(!Object.keys(r).length)return;e.headers||(e.headers={}),Ie(e.headers,r)}else{let r=dt.toQuery(t);if(!r)return;e.url=dt.appendQueryToUri(e.url,r)}}getObjectType(e){let{type:t}=e;if(t==="subtitle")return ze.TIMED_TEXT;if(e.sn==="initSegment")return ze.INIT;if(t==="audio")return ze.AUDIO;if(t==="main")return this.hls.audioTracks.length?ze.VIDEO:ze.MUXED}getTopBandwidth(e){let t=0,i,r=this.hls;if(e===ze.AUDIO)i=r.audioTracks;else{let s=r.maxAutoLevel,n=s>-1?s+1:r.levels.length;i=r.levels.slice(0,n)}for(let s of i)s.bitrate>t&&(t=s.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,i=e===ze.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:xe.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(s){this.loader=void 0,this.loader=new i(s)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(s,n,o){t(s),this.loader.load(s,n,o)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(s){this.loader=void 0,this.loader=new i(s)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(s,n,o){t(s),this.loader.load(s,n,o)}}}static uuid(){let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}static serialize(e){let t=[],i=c=>!Number.isNaN(c)&&c!=null&&c!==""&&c!==!1,r=c=>Math.round(c),s=c=>r(c/100)*100,o={br:r,d:r,bl:s,dl:s,mtp:s,nor:c=>encodeURIComponent(c),rtp:s,tb:r},l=Object.keys(e||{}).sort();for(let c of l){let u=e[c];if(!i(u)||c==="v"&&u===1||c=="pr"&&u===1)continue;let d=o[c];d&&(u=d(u));let h=typeof u,m;c==="ot"||c==="sf"||c==="st"?m=`${c}=${u}`:h==="boolean"?m=c:h==="number"?m=`${c}=${u}`:m=`${c}=${JSON.stringify(u)}`,t.push(m)}return t.join(",")}static toHeaders(e){let t=Object.keys(e),i={},r=["Object","Request","Session","Status"],s=[{},{},{},{}],n={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};for(let o of t){let l=n[o]!=null?n[o]:1;s[l][o]=e[o]}for(let o=0;o<s.length;o++){let l=dt.serialize(s[o]);l&&(i[`CMCD-${r[o]}`]=l)}return i}static toQuery(e){return`CMCD=${encodeURIComponent(dt.serialize(e))}`}static appendQueryToUri(e,t){if(!t)return e;let i=e.includes("?")?"&":"?";return`${e}${i}${t}`}},pd=3e5,vs=class{constructor(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=w.log.bind(w,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;!e||(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){let e=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(i=>i!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:i}=t;if((i==null?void 0:i.action)===Ke.SendAlternateToPenaltyBox&&i.flags===st.MoveAllAlternatesMatchingHost){let r=this.pathwayPriority,s=this.pathwayId;this.penalizedPathways[s]||(this.penalizedPathways[s]=performance.now()),!r&&this.levels&&(r=this.levels.reduce((n,o)=>(n.indexOf(o.pathwayId)===-1&&n.push(o.pathwayId),n),[])),r&&r.length>1&&(this.updatePathwayPriority(r),i.resolved=this.pathwayId!==s)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t,i=this.penalizedPathways,r=performance.now();Object.keys(i).forEach(s=>{r-i[s]>pd&&delete i[s]});for(let s=0;s<e.length;s++){let n=e[s];if(i[n])continue;if(n===this.pathwayId)return;let o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(n),t.length>0){this.log(`Setting Pathway to "${n}"`),this.pathwayId=n,this.hls.trigger(v.LEVELS_UPDATED,{levels:t});let c=this.hls.levels[o];l&&c&&this.levels&&(c.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&c.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${c.bitrate}`),this.hls.nextLoadLevel=o);break}}}clonePathways(e){let t=this.levels;if(!t)return;let i={},r={};e.forEach(s=>{let{ID:n,"BASE-ID":o,"URI-REPLACEMENT":l}=s;if(t.some(u=>u.pathwayId===n))return;let c=this.getLevelsForPathway(o).map(u=>{let d=Ie({},u);d.details=void 0,d.url=io(u.uri,u.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);let h=new be(u.attrs);h["PATHWAY-ID"]=n;let m=h.AUDIO&&`${h.AUDIO}_clone_${n}`,y=h.SUBTITLES&&`${h.SUBTITLES}_clone_${n}`;m&&(i[h.AUDIO]=m,h.AUDIO=m),y&&(r[h.SUBTITLES]=y,h.SUBTITLES=y),d.attrs=h;let E=new wt(d);return Ri(E,"audio",m),Ri(E,"text",y),E});t.push(...c),da(this.audioTracks,i,l,n),da(this.subtitleTracks,r,l,n)})}loadSteeringManifest(e){let t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let r;try{r=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){let u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+u)}let s={responseType:"json",url:r.href},n=t.steeringManifestLoadPolicy.default,o=n.errorRetry||n.timeoutRetry||{},l={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},c={onSuccess:(u,d,h,m)=>{this.log(`Loaded steering manifest: "${r}"`);let y=u.data;if(y.VERSION!==1){this.log(`Steering VERSION ${y.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=y.TTL;let{"RELOAD-URI":E,"PATHWAY-CLONES":b,"PATHWAY-PRIORITY":A}=y;if(E)try{this.uri=new self.URL(E,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${E}`);return}this.scheduleRefresh(this.uri||h.url),b&&this.clonePathways(b),A&&this.updatePathwayPriority(A)},onError:(u,d,h,m)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${d.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${d.url} no longer available`);return}let y=this.timeToLoad*1e3;if(u.code===429){let E=this.loader;if(typeof(E==null?void 0:E.getResponseHeader)=="function"){let b=E.getResponseHeader("Retry-After");b&&(y=parseFloat(b)*1e3)}this.log(`Steering manifest ${d.url} rate limited`);return}this.scheduleRefresh(this.uri||d.url,y)},onTimeout:(u,d,h)=>{this.log(`Timeout loading steering manifest (${d.url})`),this.scheduleRefresh(this.uri||d.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(s,l,c)}scheduleRefresh(e,t=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}};function da(a,e,t,i){!a||Object.keys(e).forEach(r=>{let s=a.filter(n=>n.groupId===r).map(n=>{let o=Ie({},n);return o.details=void 0,o.attrs=new be(o.attrs),o.url=o.attrs.URI=io(n.url,n.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[r],o.attrs["PATHWAY-ID"]=i,o});a.push(...s)})}function io(a,e,t,i){let{HOST:r,PARAMS:s,[t]:n}=i,o;e&&(o=n==null?void 0:n[e],o&&(a=o));let l=new self.URL(a);return r&&!o&&(l.host=r),s&&Object.keys(s).sort().forEach(c=>{c&&l.searchParams.set(c,s[c])}),l.href}var yd=/^age:\s*[\d.]+\s*$/im,Bi=class{constructor(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 Bt,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){let 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()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){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=i,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e)return;let i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;let s=this.xhrSetup;s?Promise.resolve().then(()=>{if(!this.stats.aborted)return s(i,t.url)}).catch(n=>(i.open("GET",t.url,!0),s(i,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(n=>{this.callbacks.onError({code:i.status,text:n.message},t,i,r)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);let r=this.context.headers,{maxTimeToFirstByteMs:s,maxLoadTimeMs:n}=i.loadPolicy;if(r)for(let o in r)e.setRequestHeader(o,r[o]);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),i.timeout=s&&J(s)?s:n,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:i}=this;if(!e||!t)return;let r=t.readyState,s=this.config;if(!i.aborted&&r>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),s.timeout!==s.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),s.timeout=s.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let n=t.status,o=t.responseType!=="text";if(n>=200&&n<300&&(o&&t.response||t.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);let l=o?t.response:t.responseText,c=t.responseType==="arraybuffer"?l.byteLength:l.length;if(i.loaded=i.total=c,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;let u=this.callbacks.onProgress;if(u&&u(i,e,l,t),!this.callbacks)return;let d={url:t.responseURL,data:l,code:n};this.callbacks.onSuccess(d,i,e,t)}else{let l=s.loadPolicy.errorRetry,c=i.retry;Li(l,c,!1,n)?this.retry(l):(w.error(`${n} while loading ${e.url}`),this.callbacks.onError({code:n,text:t.statusText},e,t,i))}}}loadtimeout(){var e;let t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,i=this.stats.retry;if(Li(t,i,!0))this.retry(t);else{w.warn(`timeout while loading ${this.context.url}`);let r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:i}=this;this.retryDelay=Ss(e,i.retry),i.retry++,w.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t.url}, retrying ${i.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)}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&yd.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}};function vd(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var Td=/(\d+)-(\d+)\/(\d+)/,$i=class{constructor(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||_d,this.controller=new self.AbortController,this.stats=new Bt}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){let e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){let r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();let s=Ed(e,this.controller.signal),n=i.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),t.timeout=c&&J(c)?c:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(r,e,this.response)},t.timeout),self.fetch(this.request).then(d=>{this.response=this.loader=d;let h=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(r,e,this.response)},u-(h-r.loading.start)),!d.ok){let{status:m,statusText:y}=d;throw new Ts(y||"fetch, bad network response",m,d)}return r.loading.first=h,r.total=bd(d.headers)||r.total,n&&J(t.highWaterMark)?this.loadProgressively(d,r,e,t.highWaterMark,n):o?d.arrayBuffer():e.responseType==="json"?d.json():d.text()}).then(d=>{let{response:h}=this;self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);let m=d[l];m&&(r.loaded=r.total=m);let y={url:h.url,data:d,code:h.status};n&&!J(t.highWaterMark)&&n(r,e,d,h),i.onSuccess(y,r,e,h)}).catch(d=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;let h=d&&d.code||0,m=d?d.message:null;i.onError({code:h,text:m},e,d?d.details:null,r)})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,r=0,s){let n=new Mi,o=e.body.getReader(),l=()=>o.read().then(c=>{if(c.done)return n.dataLength&&s(t,i,n.flush(),e),Promise.resolve(new ArrayBuffer(0));let u=c.value,d=u.length;return t.loaded+=d,d<r||n.dataLength?(n.push(u),n.dataLength>=r&&s(t,i,n.flush(),e)):s(t,i,u,e),l()}).catch(()=>Promise.reject());return l()}};function Ed(a,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Ie({},a.headers))};return a.rangeEnd&&t.headers.set("Range","bytes="+a.rangeStart+"-"+String(a.rangeEnd-1)),t}function xd(a){let e=Td.exec(a);if(e)return parseInt(e[2])-parseInt(e[1])+1}function bd(a){let e=a.get("Content-Range");if(e){let i=xd(e);if(J(i))return i}let t=a.get("Content-Length");if(t)return parseInt(t)}function _d(a,e){return new self.Request(a.url,e)}var Ts=class extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}},Sd=/\s/,Ad={newCue(a,e,t,i){let r=[],s,n,o,l,c,u=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(s=i.rows[h],o=!0,l=0,c="",!s.isEmpty()){var d;for(let E=0;E<s.chars.length;E++)Sd.test(s.chars[E].uchar)&&o?l++:(c+=s.chars[E].uchar,o=!1);s.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;let m=Ja(c.trim()),y=ks(e,t,m);a!=null&&(d=a.cues)!=null&&d.getCueById(y)||(n=new u(e,t,m),n.id=y,n.line=h+1,n.align="left",n.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(n))}return a&&r.length&&(r.sort((h,m)=>h.line==="auto"||m.line==="auto"?0:h.line>8&&m.line>8?m.line-h.line:h.line-m.line),r.forEach(h=>Ia(a,h))),r}},Ld={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Rd=Ze(Ze({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Bi,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:ts,bufferController:ls,capLevelController:ri,errorController:Or,fpsController:ys,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:ma,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:Ld},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},Id()),{},{subtitleStreamController:ss,subtitleTrackController:as,timelineController:ps,audioStreamController:is,audioTrackController:rs,emeController:_t,cmcdController:dt,contentSteeringController:vs});function Id(){return{cueHandler:Ad,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Dd(a,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let t=Es(a),i=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(s=>{let n=`${s==="level"?"playlist":s}LoadPolicy`,o=e[n]===void 0,l=[];r.forEach(c=>{let u=`${s}Loading${c}`,d=e[u];if(d!==void 0&&o){l.push(u);let h=t[n].default;switch(e[n]={default:h},c){case"TimeOut":h.maxLoadTimeMs=d,h.maxTimeToFirstByteMs=d;break;case"MaxRetry":h.errorRetry.maxNumRetry=d,h.timeoutRetry.maxNumRetry=d;break;case"RetryDelay":h.errorRetry.retryDelayMs=d,h.timeoutRetry.retryDelayMs=d;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=d,h.timeoutRetry.maxRetryDelayMs=d;break}}}),l.length&&w.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${n}": ${JSON.stringify(e[n])}`)}),Ze(Ze({},t),e)}function Es(a){return a&&typeof a=="object"?Array.isArray(a)?a.map(Es):Object.keys(a).reduce((e,t)=>(e[t]=Es(a[t]),e),{}):a}function wd(a){let e=a.loader;e!==$i&&e!==Bi?(w.log("[config]: Custom loader detected, cannot enable progressive streaming"),a.progressive=!1):vd()&&(a.loader=$i,a.progressive=!0,a.enableSoftwareAES=!0,w.log("[config]: Progressive streaming enabled, using FetchLoader"))}var ht=class{static get version(){return"1.4.8"}static isSupported(){return yu()}static get Events(){return v}static get ErrorTypes(){return ie}static get ErrorDetails(){return N}static get DefaultConfig(){return ht.defaultConfig?ht.defaultConfig:Rd}static set DefaultConfig(e){ht.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Ds,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,rc(e.debug||!1,"Hls instance");let t=this.config=Dd(ht.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&wd(t);let{abrController:i,bufferController:r,capLevelController:s,errorController:n,fpsController:o}=t,l=new n(this),c=this.abrController=new i(this),u=this.bufferController=new r(this),d=this.capLevelController=new s(this),h=new o(this),m=new Lr(this),y=new Dr(this),E=t.contentSteeringController,b=E?new E(this):null,A=this.levelController=new Mr(this,b),D=new Fr(this),L=new Ur(this.config),F=this.streamController=new Zr(this,D,L);d.setStreamController(F),h.setStreamController(F);let k=[m,A,F];b&&k.splice(1,0,b),this.networkControllers=k;let G=[c,u,d,h,y,D];this.audioTrackController=this.createController(t.audioTrackController,k);let M=t.audioStreamController;M&&k.push(new M(this,D,L)),this.subtitleTrackController=this.createController(t.subtitleTrackController,k);let $=t.subtitleStreamController;$&&k.push(new $(this,D,L)),this.createController(t.timelineController,G),L.emeController=this.emeController=this.createController(t.emeController,G),this.cmcdController=this.createController(t.cmcdController,G),this.latencyController=this.createController(wr,G),this.coreComponents=G,k.push(l);let K=l.onErrorOut;typeof K=="function"&&this.on(v.ERROR,K,l)}createController(e,t){if(e){let i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,r){this._emitter.off(e,t,i,r)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){w.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:N.INTERNAL_EXCEPTION,fatal:!1,event:e,error:i})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){w.log("destroy"),this.trigger(v.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){w.log("attachMedia"),this._media=e,this.trigger(v.MEDIA_ATTACHING,{media:e})}detachMedia(){w.log("detachMedia"),this.trigger(v.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,i=this.url,r=this.url=xs.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});w.log(`loadSource:${r}`),t&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(v.MANIFEST_LOADING,{url:e})}startLoad(e=-1){w.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){w.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){w.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){w.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){w.log(`set currentLevel:${e}`),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){w.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){w.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){w.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){w.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(w.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){kr.indexOf(e)>-1&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let i=e.length;for(let r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this,r;if(t===-1&&e&&e.length?r=e.length-1:r=t,i)for(let s=r;s--;){let n=e[s].attrs["HDCP-LEVEL"];if(n&&n<=i)return s}return r}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}};ht.defaultConfig=void 0;var Ne=ht;var $t=class extends Error{constructor(t,i=$t.MEDIA_ERR_CUSTOM,r,s){var n;super(t);this.name="MediaError",this.code=i,this.context=s,this.fatal=r!=null?r:i>=$t.MEDIA_ERR_NETWORK&&i<=$t.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(n=$t.defaultMessages[this.code])!=null?n:"")}},$e=$t;$e.MEDIA_ERR_ABORTED=1,$e.MEDIA_ERR_NETWORK=2,$e.MEDIA_ERR_DECODE=3,$e.MEDIA_ERR_SRC_NOT_SUPPORTED=4,$e.MEDIA_ERR_ENCRYPTED=5,$e.MEDIA_ERR_CUSTOM=100,$e.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var kd=a=>a==null,Cs=(a,e)=>kd(e)?!1:a in e,Ki={ANY:"any",MUTED:"muted"},gt={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},Ps={MSE:"mse",NATIVE:"native"},Vi={HEADER:"header",QUERY:"query",NONE:"none"},hh=Object.values(Vi),mt={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},qi={HLS:mt.M3U8},fh=Object.keys(qi),gh=[...Object.values(mt),"hls","HLS"];var Ve=(a,e,t,i,r=a)=>{r.addEventListener(e,t,i),a.addEventListener("teardown",()=>{r.removeEventListener(e,t)},{once:!0})};function ro(a,e,t){e&&t>e&&(t=e);for(let i=0;i<a.length;i++)if(a.start(i)<=t&&a.end(i)>=t)return!0;return!1}var so=a=>{let e=a.indexOf("?");if(e<0)return[a];let t=a.slice(0,e),i=a.slice(e);return[t,i]},si=a=>{let e=a.type;if(e){let i=e.toUpperCase();return Cs(i,qi)?qi[i]:e}let{src:t}=a;return t?Cd(t):""},Os=a=>a==="VOD"?gt.ON_DEMAND:gt.LIVE,Ms=a=>a==="EVENT"?Number.POSITIVE_INFINITY:a==="VOD"?Number.NaN:0,Cd=a=>{let e="";try{e=new URL(a).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let r=e.slice(t+1).toUpperCase();return Cs(r,mt)?mt[r]:""};var Pd=Object.values(Ki),no=a=>typeof a=="boolean"||typeof a=="string"&&Pd.includes(a),ao=({autoplay:a},e,t)=>{let i=!1,r=!1,s=no(a)?a:!!a,n=()=>{i||Ve(e,"playing",()=>{i=!0},{once:!0})};if(n(),Ve(e,"loadstart",()=>{i=!1,n(),Fs(e,s)},{once:!0}),Ve(e,"loadstart",()=>{t||(r=!Number.isFinite(e.duration)),Fs(e,s)},{once:!0}),t&&t.once(Ne.Events.LEVEL_LOADED,(l,c)=>{var u;r=(u=c.details.live)!=null?u:!1}),!s){let l=()=>{!r||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&Ve(e,"play",()=>{e.preload==="metadata"?t.once(Ne.Events.LEVEL_UPDATED,l):l()},{once:!0})}return l=>{i||(s=no(l)?l:!!l,Fs(e,s))}},Fs=(a,e)=>{if(!e)return;let t=a.muted,i=()=>a.muted=t;switch(e){case Ki.ANY:a.play().catch(()=>{a.muted=!0,a.play().catch(i)});break;case Ki.MUTED:a.muted=!0,a.play().catch(i);break;default:a.play().catch(()=>{});break}};var oo=({preload:a,src:e},t,i)=>{let r=d=>{d!=null&&["","none","metadata","auto"].includes(d)?t.setAttribute("preload",d):t.removeAttribute("preload")};if(!i)return r(a),r;let s=!1,n=!1,o=i.config.maxBufferLength,l=i.config.maxBufferSize,c=d=>{r(d);let h=d!=null?d:t.preload;n||h==="none"||(h==="metadata"?(i.config.maxBufferLength=1,i.config.maxBufferSize=1):(i.config.maxBufferLength=o,i.config.maxBufferSize=l),u())},u=()=>{!s&&e&&(s=!0,i.loadSource(e))};return Ve(t,"play",()=>{n=!0,i.config.maxBufferLength=o,i.config.maxBufferSize=l,u()},{once:!0}),c(a),c};function lo(a,e){e.on(Ne.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(r,{tracks:s})=>{s.forEach(n=>{var c;let o=(c=n.subtitleTrack)!=null?c:n.closedCaptions,l=e.subtitleTracks.findIndex(({lang:u,name:d,type:h})=>u==(o==null?void 0:o.lang)&&d===n.label&&h.toLowerCase()===n.kind);Ns(a,n.kind,n.label,o==null?void 0:o.lang,`${n.kind}${l}`)})});let t=()=>{var n;if(!e.subtitleTracks.length)return;let r=Array.from(a.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind)),s=`${(n=e.subtitleTracks[e.subtitleTrack])==null?void 0:n.type.toLowerCase()}${e.subtitleTrack}`;if(r&&(e.subtitleTrack<0||(r==null?void 0:r.id)!==s)){let o=e.subtitleTracks.findIndex(({lang:l,name:c,type:u})=>l==r.language&&c===r.label&&u.toLowerCase()===r.kind);e.subtitleTrack=o}r&&(r==null?void 0:r.id)===s&&r.cues&&Array.from(r.cues).forEach(o=>{r.addCue(o)})};a.textTracks.addEventListener("change",t),e.on(Ne.Events.CUES_PARSED,(r,{track:s,cues:n})=>{let o=a.textTracks.getTrackById(s);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),n.forEach(c=>{var u;(u=o.cues)!=null&&u.getCueById(c.id)||o.addCue(c)}),l&&(o.mode="disabled")}),e.once(Ne.Events.DESTROYING,()=>{a.textTracks.removeEventListener("change",t),a.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let i=()=>{Array.from(a.textTracks).forEach(r=>{var s,n;if(!["subtitles","caption"].includes(r.kind)&&r.label==="thumbnails"){if(!((s=r.cues)!=null&&s.length)){let o=a.querySelector('track[label="thumbnails"]'),l=(n=o==null?void 0:o.getAttribute("src"))!=null?n:"";o==null||o.removeAttribute("src"),setTimeout(()=>{o==null||o.setAttribute("src",l)},0)}r.mode!=="hidden"&&(r.mode="hidden")}})};e.once(Ne.Events.MANIFEST_LOADED,i),e.once(Ne.Events.MEDIA_ATTACHED,i)}function Ns(a,e,t,i,r){let s=document.createElement("track");return s.kind=e,s.label=t,i&&(s.srclang=i),r&&(s.id=r),s.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",s.setAttribute("data-removeondestroy",""),a.append(s),s.track}function Od(a,e){let t=Array.prototype.find.call(a.querySelectorAll("track"),i=>i.track===e);t==null||t.remove()}var ni="cuepoints",Us=Object.freeze({label:ni}),Wi=(a,{label:e=ni}=Us)=>{var t;return(t=Array.from(a.querySelectorAll("track")).find(i=>i.track.label===e&&i.track.kind==="metadata"))==null?void 0:t.track};async function co(a,e,t=Us){let i=Wi(a,t);if(!i){let{label:r=ni}=t;i=Ns(a,"metadata",r),i.mode="hidden",await new Promise(s=>setTimeout(()=>s(void 0),0))}return i.mode!=="hidden"&&(i.mode="hidden"),[...e].sort(({time:r},{time:s})=>s-r).forEach(({time:r,value:s})=>{var d,h;let n=Array.prototype.findIndex.call(i==null?void 0:i.cues,m=>m.startTime>=r),o=(d=i==null?void 0:i.cues)==null?void 0:d[n],l=o?o.startTime:Number.isFinite(a.duration)?a.duration:Number.MAX_SAFE_INTEGER,c=(h=i==null?void 0:i.cues)==null?void 0:h[n-1];c&&(c.endTime=r);let u=new VTTCue(r,l,JSON.stringify(s!=null?s:null));i.addCue(u)}),i}var uo=a=>({time:a.startTime,value:JSON.parse(a.text)});function Md(a,e={label:ni}){let t=Wi(a,e);return t!=null&&t.cues?Array.from(t.cues,i=>uo(i)):[]}function ho(a,e={label:ni}){var s,n;let t=Wi(a,e);if(!((s=t==null?void 0:t.activeCues)!=null&&s.length))return;let{currentTime:i}=a,r=Array.prototype.find.call((n=t.activeCues)!=null?n:[],({startTime:o,endTime:l})=>o<=i&&l>i);return uo(r)}async function fo(a,e=Us){return new Promise(t=>{Ve(a,"loadstart",async()=>{let i=await co(a,[],e);Ve(a,"cuechange",()=>{let r=ho(a);if(r){let s=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:r});a.dispatchEvent(s)}},{},i),t(i)})})}function Fd(a,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-a.currentTime*1e3)}return typeof a.getStartDate=="function"?a.getStartDate():new Date(NaN)}function Nd(a,e){if(e&&e.playingDate)return e.playingDate;if(typeof a.getStartDate=="function"){let t=a.getStartDate();return new Date(t.getTime()+a.currentTime*1e3)}return new Date(NaN)}var Ud=async a=>fetch(a).then(e=>e.text()).then(e=>{let t=e.split(`
|
|
45
|
+
`).find((i,r,s)=>r&&s[r-1].startsWith("#EXT-X-STREAM-INF"));return fetch(t).then(i=>i.text()).then(i=>i.split(`
|
|
46
|
+
`))}),Bd=a=>{var n,o;let t=(o=((n=a.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?n:"").split(":")[1])==null?void 0:o.trim(),i=Os(t),r=Ms(t),s;if(i===gt.LIVE){let l=a.find(u=>u.startsWith("#EXT-X-PART-INF"));!!l?s=+l.split(":")[1].split("=")[1]*2:s=+a.find(h=>h.startsWith("#EXT-X-TARGETDURATION")).split(":")[1]*3}return{streamType:i,targetLiveWindow:r,liveEdgeStartOffset:s}},$d=async(a,e)=>{if(e===mt.MP4)return{streamType:gt.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===mt.M3U8){let t=await Ud(a);return Bd(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${a}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},go=async(a,e,t=si({src:a}))=>{var n,o,l;let{streamType:i,targetLiveWindow:r,liveEdgeStartOffset:s}=await $d(a,t);((n=Ue.get(e))!=null?n:{}).liveEdgeStartOffset=s,((o=Ue.get(e))!=null?o:{}).targetLiveWindow=r,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((l=Ue.get(e))!=null?l:{}).streamType=i,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Gd=a=>{var n;let e=a.type,t=Os(e),i=Ms(e),r,s=!!((n=a.partList)!=null&&n.length);return t===gt.LIVE&&(r=s?a.partTarget*2:a.targetduration*3),{streamType:t,targetLiveWindow:i,liveEdgeStartOffset:r,lowLatency:s}},Hd=(a,e,t)=>{var o,l,c,u,d,h,m,y;let{streamType:i,targetLiveWindow:r,liveEdgeStartOffset:s,lowLatency:n}=Gd(a);if(i===gt.LIVE){n?(t.config.backBufferLength=(o=t.userConfig.backBufferLength)!=null?o:4,t.config.maxFragLookUpTolerance=(l=t.userConfig.maxFragLookUpTolerance)!=null?l:.001,t.config.abrBandWidthUpFactor=(c=t.userConfig.abrBandWidthUpFactor)!=null?c:t.config.abrBandWidthFactor):t.config.backBufferLength=(u=t.userConfig.backBufferLength)!=null?u:8;let E=Object.freeze({get length(){return e.seekable.length},start(b){return e.seekable.start(b)},end(b){var A;return b>this.length?e.seekable.end(b):(A=t.liveSyncPosition)!=null?A:e.seekable.end(b)}});((d=Ue.get(e))!=null?d:{}).seekable=E}((h=Ue.get(e))!=null?h:{}).liveEdgeStartOffset=s,((m=Ue.get(e))!=null?m:{}).targetLiveWindow=r,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((y=Ue.get(e))!=null?y:{}).streamType=i,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},mo,po,Kd=(po=(mo=globalThis==null?void 0:globalThis.navigator)==null?void 0:mo.userAgent)!=null?po:"",Vd=Kd.toLowerCase().indexOf("android")!==-1,Ue=new WeakMap,To="mux.com",yo,vo,Eo=(vo=(yo=Ne).isSupported)==null?void 0:vo.call(yo),qd=Vd,Gh=()=>ji.default.utils.now(),Wd=ji.default.utils.generateUUID,Hh=(a,{domain:e=To,maxResolution:t=""}={})=>{if(!a)return;let[i,r=""]=so(a),s=new URL(`https://stream.${e}/${i}.m3u8${r}`);return t&&s.searchParams.set("max_resolution",t),s.toString()},jd=a=>{if(!a)return;let[e]=a.split("?");return e||void 0},Yd=a=>{if(!a||!a.startsWith("https://stream."))return;let[e]=new URL(a).pathname.slice(1).split(".m3u8");return e||void 0},zd=a=>{var e,t,i;return(e=a==null?void 0:a.metadata)!=null&&e.video_id?a.metadata.video_id:_o(a)&&(i=(t=jd(a.playbackId))!=null?t:Yd(a.src))!=null?i:a.src},Kh=a=>{var e;return(e=Ue.get(a))==null?void 0:e.error},Vh=a=>{var e,t;return(t=(e=Ue.get(a))==null?void 0:e.streamType)!=null?t:gt.UNKNOWN},qh=a=>{var e,t;return(t=(e=Ue.get(a))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},Xd=a=>{var e,t;return(t=(e=Ue.get(a))==null?void 0:e.seekable)!=null?t:a.seekable},Wh=a=>{var i;let e=(i=Ue.get(a))==null?void 0:i.liveEdgeStartOffset;if(typeof e!="number")return Number.NaN;let t=Xd(a);return t.length?t.end(t.length-1)-e:Number.NaN},Qd=(a,e,t=.001)=>Math.abs(a-e)<=t,xo=(a,e,t=.001)=>a>e||Qd(a,e,t),Jd=a=>a.paused&&xo(a.currentTime,a.duration),Zd=(a,e)=>a.loop||!!e?a.ended:a.ended||Jd(a),jh=(a,e,t)=>{eh(e,t);let{metadata:i={}}=a,{view_session_id:r=Wd()}=i,s=zd(a);i.view_session_id=r,i.video_id=s,a.metadata=i,Ue.set(e,{});let n=th(a,e);rh(a,e,n),sh(a,e,n),fo(e);let o=ao(a,e,n),l=oo(a,e,n);return{engine:n,setAutoplay:o,setPreload:l}},eh=(a,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),(a==null?void 0:a.mux)&&!a.mux.deleted&&(a.mux.destroy(),delete a.mux),a&&(a.removeAttribute("src"),a.load(),a.removeEventListener("error",Ao),a.removeEventListener("error",Bs),a.removeEventListener("durationchange",So),Ue.delete(a),a.dispatchEvent(new Event("teardown")))};function bo(a,e){var c;let t=si(a);if(!(t===mt.M3U8))return!0;let r=!t||((c=e.canPlayType(t))!=null?c:!0),{preferPlayback:s}=a,n=s===Ps.MSE,o=s===Ps.NATIVE;return r&&(o||!(Eo&&(n||qd)))}var th=(a,e)=>{let{debug:t,streamType:i,startTime:r=-1,metadata:s,preferCmcd:n}=a,l=si(a)===mt.M3U8,c=bo(a,e);if(l&&!c&&Eo){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},d=ih(i),h=n!==Vi.NONE?{useHeaders:n===Vi.HEADER,sessionId:s==null?void 0:s.view_session_id,contentId:s==null?void 0:s.video_id}:void 0;return new Ne({debug:t,startPosition:r,cmcd:h,...u,...d})}},ih=a=>a===gt.LIVE?{backBufferLength:8}:{},_o=({playbackId:a,src:e,customDomain:t})=>{if(a)return!0;if(typeof e!="string")return!1;let i=window==null?void 0:window.location.href,r=new URL(e,i).hostname.toLocaleLowerCase();return r.includes(To)||!!t&&r.includes(t.toLocaleLowerCase())},rh=(a,e,t)=>{var s;let{envKey:i}=a,r=_o(a);if(i||r){let{playerInitTime:n,playerSoftwareName:o,playerSoftwareVersion:l,beaconCollectionDomain:c,debug:u,disableCookies:d}=a,h={...a.metadata,video_title:((s=a==null?void 0:a.metadata)==null?void 0:s.video_title)||void 0},m=y=>typeof y.player_error_code=="string"?!1:typeof a.errorTranslator=="function"?a.errorTranslator(y):y;ji.default.monitor(e,{debug:u,beaconCollectionDomain:c,hlsjs:t,Hls:t?Ne:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:d,data:{...i?{env_key:i}:{},player_software_name:o,player_software:o,player_software_version:l,player_init_time:n,...h}})}},sh=(a,e,t)=>{var s;let i=bo(a,e),{src:r}=a;if(e&&i){let n=si(a);typeof r=="string"?(e.preload==="none"?Ve(e,"loadstart",()=>go(r,e,n)):go(r,e,n),e.setAttribute("src",r),a.startTime&&(((s=Ue.get(e))!=null?s:{}).startTime=a.startTime,e.addEventListener("durationchange",So,{once:!0}))):e.removeAttribute("src"),e.addEventListener("error",Ao),e.addEventListener("error",Bs),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(c=>{c.remove()})},{once:!0});let o=()=>{e.ended||!Zd(e)||e.dispatchEvent(new Event("ended"))};Ve(e,"pause",o),Ve(e,"seeked",o),Ve(e,"play",()=>{e.ended||!xo(e.currentTime,e.duration)||(e.currentTime=e.seekable.start(0))})}else t&&r?(t.once(Ne.Events.LEVEL_LOADED,(n,o)=>{Hd(o.details,e,t)}),t.on(Ne.Events.ERROR,(n,o)=>{let l={[Ne.ErrorTypes.NETWORK_ERROR]:$e.MEDIA_ERR_NETWORK,[Ne.ErrorTypes.MEDIA_ERROR]:$e.MEDIA_ERR_DECODE},c=new $e("",l[o.type]);c.fatal=o.fatal,c.data=o,e.dispatchEvent(new CustomEvent("error",{detail:c}))}),e.addEventListener("error",Bs),lo(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function So(a){var i;let e=a.target,t=(i=Ue.get(e))==null?void 0:i.startTime;if(!!t&&ro(e.seekable,e.duration,t)){let r=e.preload==="auto";r&&(e.preload="none"),e.currentTime=t,r&&(e.preload="auto")}}async function Ao(a){if(!a.isTrusted)return;a.stopImmediatePropagation();let e=a.target;if(!(e!=null&&e.error))return;let{message:t,code:i}=e.error,r=new $e(t,i);if(e.src&&(i!==$e.MEDIA_ERR_DECODE||i!==void 0))try{let{status:s}=await fetch(e.src);r.data={response:{code:s}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:r}))}function Bs(a){var i,r;if(!(a instanceof CustomEvent)||!(a.detail instanceof $e))return;let e=a.target,t=a.detail;!t||!t.fatal||(((i=Ue.get(e))!=null?i:{}).error=t,(r=e.mux)==null||r.emit("error",{player_error_code:t.code,player_error_message:t.message,player_error_context:t.context}))}})();
|
|
48
47
|
/*!
|
|
49
48
|
* JavaScript Cookie v2.1.3
|
|
50
49
|
* https://github.com/js-cookie/js-cookie
|