@mux/mux-video 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +4 -4
- package/dist/mux-video.js +47 -32
- package/dist/mux-video.js.map +4 -4
- package/dist/mux-video.mjs +47 -32
- package/dist/mux-video.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +13 -3
- package/dist/types/polyfills/index.d.ts +4 -0
- package/dist/types-ts3.4/index.d.ts +10 -2
- package/dist/types-ts3.4/polyfills/index.d.ts +4 -0
- package/package.json +7 -6
package/dist/mux-video.mjs
CHANGED
|
@@ -1,35 +1,50 @@
|
|
|
1
|
-
var Ks=Object.create;var $n=Object.defineProperty;var Hs=Object.getOwnPropertyDescriptor;var qs=Object.getOwnPropertyNames;var Vs=Object.getPrototypeOf,Ys=Object.prototype.hasOwnProperty;var Ws=(x,w,A)=>w in x?$n(x,w,{enumerable:!0,configurable:!0,writable:!0,value:A}):x[w]=A;var Ga=(x,w)=>()=>(w||x((w={exports:{}}).exports,w),w.exports);var Xs=(x,w,A,le)=>{if(w&&typeof w=="object"||typeof w=="function")for(let ae of qs(w))!Ys.call(x,ae)&&ae!==A&&$n(x,ae,{get:()=>w[ae],enumerable:!(le=Hs(w,ae))||le.enumerable});return x};var Ka=(x,w,A)=>(A=x!=null?Ks(Vs(x)):{},Xs(w||!x||!x.__esModule?$n(A,"default",{value:x,enumerable:!0}):A,x));var Ki=(x,w,A)=>(Ws(x,typeof w!="symbol"?w+"":w,A),A),Zn=(x,w,A)=>{if(!w.has(x))throw TypeError("Cannot "+A)};var Ye=(x,w,A)=>(Zn(x,w,"read from private field"),A?A.call(x):w.get(x)),_t=(x,w,A)=>{if(w.has(x))throw TypeError("Cannot add the same private member more than once");w instanceof WeakSet?w.add(x):w.set(x,A)},Nt=(x,w,A,le)=>(Zn(x,w,"write to private field"),le?le.call(x,A):w.set(x,A),A);var zt=(x,w,A)=>(Zn(x,w,"access private method"),A);var Va=Ga((En,ia)=>{(function(){var x,w;x=this,w=function(){return function(){var A={80:function(W,B,j){W.exports=j(728).default},728:function(W,B,j){"use strict";j.d(B,{default:function(){return Un}});var re=j(48),R=j.n(re),g=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)})},k=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},L=function(p){return p&&p.nodeName!==void 0?(p.muxId||(p.muxId=p.id||k()),p.muxId):p},me=function(p){var h;p&&p.nodeName!==void 0?p=L(h=p):h=document.querySelector(p);var f=h&&h.nodeName?h.nodeName.toLowerCase():"";return[h,p,f]},ne=j(640),ce=j.n(ne),we=ce().methodFactory;ce().methodFactory=function(p,h,f){var y=we(p,h,f);return function(){for(var b=["[mux]"],M=0;M<arguments.length;M++)b.push(arguments[M]);y.apply(void 0,b)}},ce().setLevel(ce().getLevel());var q=ce();function ye(){return(R().doNotTrack||R().navigator&&R().navigator.doNotTrack)==="1"}var J={now:function(){var p=R().performance,h=p&&p.timing,f=h&&h.navigationStart,y=typeof f=="number"&&typeof p.now=="function"?f+p.now():Date.now();return Math.round(y)}},oe=j(678),K=j.n(oe),Ee=function(p){return ke(p)[0]},ke=function(p){if(typeof p!="string"||p==="")return["localhost"];var h,f=(p.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return f&&(h=(f.match(/[^\.]+\.[^\.]+$/)||[])[0]),[f,h]},Ne={exists:function(){var p=R().performance;return(p&&p.timing)!==void 0},domContentLoadedEventEnd:function(){var p=R().performance,h=p&&p.timing;return h&&h.domContentLoadedEventEnd},navigationStart:function(){var p=R().performance,h=p&&p.timing;return h&&h.navigationStart}};function V(p,h,f){f=f===void 0?1:f,p[h]=p[h]||0,p[h]+=f}var E=["x-cdn","content-type","x-request-id"];function U(p){var h={};return(p=p||"").trim().split(/[\r\n]+/).forEach(function(f){if(f){var y=f.split(": "),b=y.shift();b&&(E.indexOf(b.toLowerCase())>=0||b.toLowerCase().indexOf("x-litix-")===0)&&(h[b]=y.join(": "))}}),h}var D=function(p){var h={};for(var f in p){var y=p[f];y["DATA-ID"].search("io.litix.data.")!==-1&&(h[y["DATA-ID"].replace("io.litix.data.","")]=y.VALUE)}return h};function de(p,h){var f=Object.keys(p);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(p);h&&(y=y.filter(function(b){return Object.getOwnPropertyDescriptor(p,b).enumerable})),f.push.apply(f,y)}return f}function Se(p){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?de(Object(f),!0).forEach(function(y){z(p,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(f)):de(Object(f)).forEach(function(y){Object.defineProperty(p,y,Object.getOwnPropertyDescriptor(f,y))})}return p}function z(p,h,f){return h in p?Object.defineProperty(p,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):p[h]=f,p}var $=function(p){if(!p)return{};var h=Ne.navigationStart(),f=p.loading,y=f?f.start:p.trequest,b=f?f.first:p.tfirst,M=f?f.end:p.tload;return{bytesLoaded:p.total,requestStart:Math.round(h+y),responseStart:Math.round(h+b),responseEnd:Math.round(h+M)}},Le=function(p){if(p&&typeof p.getAllResponseHeaders=="function")return U(p.getAllResponseHeaders())};function Oe(p,h){var f=Object.keys(p);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(p);h&&(y=y.filter(function(b){return Object.getOwnPropertyDescriptor(p,b).enumerable})),f.push.apply(f,y)}return f}function xe(p){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?Oe(Object(f),!0).forEach(function(y){be(p,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(f)):Oe(Object(f)).forEach(function(y){Object.defineProperty(p,y,Object.getOwnPropertyDescriptor(f,y))})}return p}function be(p,h,f){return h in p?Object.defineProperty(p,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):p[h]=f,p}var qe=function(p,h){if(!p||typeof p.getRequests!="function")return{};var f=p.getRequests({state:"executed"});if(f.length===0)return{};var y,b=f[f.length-1],M=Ee(b.url),I=b.url,Y=b.bytesLoaded,he=new Date(b.requestStartDate).getTime(),ee=new Date(b.firstByteDate).getTime(),Me=new Date(b.requestEndDate).getTime(),ut=isNaN(b.duration)?0:b.duration,Ze=typeof h.getMetricsFor=="function"?h.getMetricsFor(b.mediaType).HttpList:h.getDashMetrics().getHttpRequests(b.mediaType);return Ze.length>0&&(y=U(Ze[Ze.length-1]._responseHeaders||"")),{requestStart:he,requestResponseStart:ee,requestResponseEnd:Me,requestBytesLoaded:Y,requestResponseHeaders:y,requestMediaDuration:ut,requestHostname:M,requestUrl:I}},at=function(p,h){var f=h.getQualityFor(p),y=h.getCurrentTrackFor(p).bitrateList;return y?{currentLevel:f,renditionWidth:y[f].width||null,renditionHeight:y[f].height||null,renditionBitrate:y[f].bandwidth}:{}},ie=function(p){var h;return(h=p.match(/.*codecs\*?="(.*)"/))===null||h===void 0?void 0:h[1]};function pe(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}var se=0,Ue=function(){function p(){(function(b,M){if(!(b instanceof M))throw new TypeError("Cannot call a class as a function")})(this,p)}var h,f,y;return h=p,f=[{key:"on",value:function(b,M,I){return M._eventEmitterGuid=M._eventEmitterGuid||++se,this._listeners=this._listeners||{},this._listeners[b]=this._listeners[b]||[],I&&(M=M.bind(I)),this._listeners[b].push(M),M}},{key:"off",value:function(b,M){var I=this._listeners&&this._listeners[b];I&&I.forEach(function(Y,he){Y._eventEmitterGuid===M._eventEmitterGuid&&I.splice(he,1)})}},{key:"one",value:function(b,M,I){var Y=this;M._eventEmitterGuid=M._eventEmitterGuid||++se;var he=function ee(){Y.off(b,ee),M.apply(I||this,arguments)};he._eventEmitterGuid=M._eventEmitterGuid,this.on(b,he)}},{key:"emit",value:function(b,M){var I=this;if(this._listeners){M=M||{};var Y=this._listeners["before*"]||[],he=this._listeners[b]||[],ee=this._listeners["after"+b]||[],Me=function(ut,Ze){(ut=ut.slice()).forEach(function(st){st.call(I,{type:b},Ze)})};Me(Y,M),Me(he,M),Me(ee,M)}}}],f&&pe(h.prototype,f),y&&pe(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}(),H=Ue;function ve(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}var Ie=function(){function p(b){var M=this;(function(I,Y){if(!(I instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=b,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,b.on("playing",function(){M._playheadShouldBeProgressing=!0}),b.on("play",this._startPlaybackHeartbeatInterval.bind(this)),b.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),b.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),b.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),b.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),b.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),b.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),b.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),b.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),b.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("seeked",function(){b.data.player_is_paused?M._stopPlaybackHeartbeatInterval():M._startPlaybackHeartbeatInterval()}),b.on("timeupdate",function(){M._playbackHeartbeatInterval!==null&&b.emit("playbackheartbeat")}),b.on("devicesleep",function(I,Y){M._playbackHeartbeatInterval!==null&&(R().clearInterval(M._playbackHeartbeatInterval),b.emit("playbackheartbeatend",{viewer_time:Y.viewer_time}),M._playbackHeartbeatInterval=null)})}var h,f,y;return h=p,(f=[{key:"_startPlaybackHeartbeatInterval",value:function(){var b=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=R().setInterval(function(){b.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(R().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&ve(h.prototype,f),y&&ve(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Fe(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}function fe(p,h,f){return h&&Fe(p.prototype,h),f&&Fe(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var Ce=fe(function p(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,p),h.on("viewinit",function(){f.viewErrored=!1}),h.on("error",function(y,b){try{var M=h.errorTranslator({player_error_code:b.player_error_code,player_error_message:b.player_error_message,player_error_context:b.player_error_context});M?(h.data.player_error_code=M.player_error_code||b.player_error_code,h.data.player_error_message=M.player_error_message||b.player_error_message,h.data.player_error_context=M.player_error_context||b.player_error_context,f.viewErrored=!0):(delete h.data.player_error_code,delete h.data.player_error_message,delete h.data.player_error_context)}catch(I){h.mux.log.warn("Exception in error translator callback.",I),f.viewErrored=!0}})});function Ve(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}var Xe=function(){function p(b){(function(M,I){if(!(M instanceof I))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=b,this._watchTimeTrackerLastCheckedTime=null,b.on("playbackheartbeat",this._updateWatchTime.bind(this)),b.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var h,f,y;return h=p,(f=[{key:"_updateWatchTime",value:function(b,M){var I=M.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=I),V(this.pm.data,"view_watch_time",I-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=I}},{key:"_clearWatchTimeState",value:function(b,M){this._updateWatchTime(b,M),this._watchTimeTrackerLastCheckedTime=null}}])&&Ve(h.prototype,f),y&&Ve(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function it(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}var lt=function(){function p(b){(function(M,I){if(!(M instanceof I))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=b,this._playbackTimeTrackerLastPlayheadPosition=-1,b.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),b.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),b.on("seeking",this._clearPlaybackTimeState.bind(this))}var h,f,y;return h=p,(f=[{key:"_updatePlaybackTime",value:function(){var b=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&b>this._playbackTimeTrackerLastPlayheadPosition){var M=b-this._playbackTimeTrackerLastPlayheadPosition;M<=1e3&&V(this.pm.data,"view_content_playback_time",M)}this._playbackTimeTrackerLastPlayheadPosition=b}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&it(h.prototype,f),y&&it(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Ct(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}var Rt=function(){function p(b){(function(I,Y){if(!(I instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=b;var M=this._updatePlayheadTime.bind(this);b.on("playbackheartbeat",M),b.on("playbackheartbeatend",M),b.on("timeupdate",M),b.on("destroy",function(){b.off("timeupdate",M)})}var h,f,y;return h=p,(f=[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=this.pm.data.view_max_playhead_position===void 0?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(b,M){var I=this,Y=function(){I.pm.currentFragmentPDT&&I.pm.currentFragmentStart&&(I.pm.data.player_program_time=I.pm.currentFragmentPDT+I.pm.data.player_playhead_time-I.pm.currentFragmentStart)};if(M&&M.player_playhead_time)this.pm.data.player_playhead_time=M.player_playhead_time,Y(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var he=this.pm.getPlayheadTime();he!==void 0&&(this.pm.data.player_playhead_time=he,Y(),this._updateMaxPlayheadPosition())}}}])&&Ct(h.prototype,f),y&&Ct(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function St(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}function wt(p,h,f){return h&&St(p.prototype,h),f&&St(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var gt=wt(function p(h){if(function(M,I){if(!(M instanceof I))throw new TypeError("Cannot call a class as a function")}(this,p),!h.disableRebufferTracking){var f,y=function(M,I){b(I),f=void 0},b=function(M){if(f){var I=M.viewer_time-f;V(h.data,"view_rebuffer_duration",I),f=M.viewer_time}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(M,I){return b(I)}),h.on("rebufferstart",function(M,I){f||(V(h.data,"view_rebuffer_count",1),f=I.viewer_time,h.one("rebufferend",y))}),h.on("viewinit",function(){f=void 0,h.off("rebufferend",y)})}});function dt(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}var tt=function(){function p(b){var M=this;(function(I,Y){if(!(I instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=b,b.disableRebufferTracking||b.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,b.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),b.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),b.on("seeking",function(){M._cleanupRebufferTracker(null,{viewer_time:J.now()})}))}var h,f,y;return h=p,f=[{key:"_checkIfRebuffering",value:function(b,M){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(b,M);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var I=M.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&I>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=M.viewer_time}else this._cleanupRebufferTracker(b,M,!0);else this._prepareRebufferTrackerState(M.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(b){this._lastCheckedTime=b,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=b}},{key:"_cleanupRebufferTracker",value:function(b,M){var I=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:M.viewer_time});else{if(this._lastCheckedTime===null)return;var Y=this.pm.data.player_playhead_time-this._lastPlayheadTime,he=M.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&Y>0&&he-Y>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+he-Y}))}I?this._prepareRebufferTrackerState(M.viewer_time):this._clearRebufferTrackerState()}}],f&&dt(h.prototype,f),y&&dt(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}(),It=tt;function Ut(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}var Wt=function(){function p(b){var M=this;(function(I,Y){if(!(I instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=b,b.on("viewinit",function(){var I=b.data,Y=I.view_id;if(!I.view_program_changed){var he=function(ee,Me){var ut=Me.viewer_time;ee.type==="playing"&&b.data.view_time_to_first_frame===void 0?M.calculateTimeToFirstFrame(ut||J.now(),Y):ee.type!=="adplaying"||b.data.view_time_to_first_frame!==void 0&&!M._inPrerollPosition()||M.calculateTimeToFirstFrame(ut||J.now(),Y)};b.one("playing",he),b.one("adplaying",he),b.one("viewend",function(){b.off("playing",he),b.off("adplaying",he)})}})}var h,f,y;return h=p,(f=[{key:"_inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(b,M){M===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:b}),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))}}])&&Ut(h.prototype,f),y&&Ut(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Bt(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}function ar(p,h,f){return h&&Bt(p.prototype,h),f&&Bt(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var te=ar(function p(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,p),h.on("viewinit",function(){f._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(y){h.on(y,function(){if(f._lastPlayheadPosition>=0&&h.data.player_playhead_time>=0&&f._lastPlayerWidth>=0&&f._lastSourceWidth>0&&f._lastPlayerHeight>=0&&f._lastSourceHeight>0){var b=h.data.player_playhead_time-f._lastPlayheadPosition;if(b<0)return void(f._lastPlayheadPosition=-1);var M=Math.min(f._lastPlayerWidth/f._lastSourceWidth,f._lastPlayerHeight/f._lastSourceHeight),I=Math.max(0,M-1),Y=Math.max(0,1-M);h.data.view_max_upscale_percentage=Math.max(h.data.view_max_upscale_percentage||0,I),h.data.view_max_downscale_percentage=Math.max(h.data.view_max_downscale_percentage||0,Y),V(h.data,"view_total_content_playback_time",b),V(h.data,"view_total_upscaling",I*b),V(h.data,"view_total_downscaling",Y*b)}f._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(y){h.on(y,function(){f._lastPlayheadPosition=h.data.player_playhead_time,f._lastPlayerWidth=h.data.player_width,f._lastPlayerHeight=h.data.player_height,f._lastSourceWidth=h.data.video_source_width,f._lastSourceHeight=h.data.video_source_height})})});function N(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}function T(p,h,f){return h&&N(p.prototype,h),f&&N(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var O=T(function p(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,p),this.isSeeking=!1,h.on("seeking",function(y,b){K()(h.data,b),f._lastSeekingTime=J.now(),f.isSeeking===!1&&(f.isSeeking=!0,h.send("seeking"))}),h.on("seeked",function(){f.isSeeking=!1;var y=f._lastSeekingTime||J.now(),b=J.now()-y;V(h.data,"view_seek_count",1),V(h.data,"view_seek_duration",b);var M=h.data.view_max_seek_time||0;h.data.view_max_seek_time=Math.max(M,b)}),h.on("viewend",function(){f.isSeeking=!1})});function C(p,h){return function(f){if(Array.isArray(f))return f}(p)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var M,I,Y=[],he=!0,ee=!1;try{for(b=b.call(f);!(he=(M=b.next()).done)&&(Y.push(M.value),!y||Y.length!==y);he=!0);}catch(Me){ee=!0,I=Me}finally{try{he||b.return==null||b.return()}finally{if(ee)throw I}}return Y}}(p,h)||function(f,y){if(f){if(typeof f=="string")return G(f,y);var b=Object.prototype.toString.call(f).slice(8,-1);return b==="Object"&&f.constructor&&(b=f.constructor.name),b==="Map"||b==="Set"?Array.from(f):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?G(f,y):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 G(p,h){(h==null||h>p.length)&&(h=p.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=p[f];return y}function Q(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}var Z=function(p,h){p.push(h),p.sort(function(f,y){return f.viewer_time-y.viewer_time})},Te=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Re=function(){function p(b){var M=this;(function(Y,he){if(!(Y instanceof he))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=b,b.on("viewinit",function(){M.isAdBreak=!1,M._currentAdRequestNumber=0,M._currentAdResponseNumber=0,M._adRequests=[],M._adResponses=[],M._adHasPlayed=!1,M._wouldBeNewAdPlay=!0,M._prerollPlayTime=void 0}),Te.forEach(function(Y){return b.on(Y,M._updateAdData.bind(M))});var I=function(){M.isAdBreak=!1};b.on("adbreakstart",function(){M.isAdBreak=!0}),b.on("play",I),b.on("playing",I),b.on("viewend",I),b.on("adrequest",function(Y,he){he=K()({ad_request_id:"generatedAdRequestId"+M._currentAdRequestNumber++},he),Z(M._adRequests,he),V(b.data,"view_ad_request_count"),M.inPrerollPosition()&&(b.data.view_preroll_requested=!0,M._adHasPlayed||V(b.data,"view_preroll_request_count"))}),b.on("adresponse",function(Y,he){he=K()({ad_request_id:"generatedAdRequestId"+M._currentAdResponseNumber++},he),Z(M._adResponses,he);var ee=M.findAdRequest(he.ad_request_id);ee&&V(b.data,"view_ad_request_time",Math.max(0,he.viewer_time-ee.viewer_time))}),b.on("adplay",function(Y,he){M._adHasPlayed=!0,M._wouldBeNewAdPlay&&(M._wouldBeNewAdPlay=!1,V(b.data,"view_ad_played_count")),M.inPrerollPosition()&&!b.data.view_preroll_played&&(b.data.view_preroll_played=!0,M._adRequests.length>0&&(b.data.view_preroll_request_time=Math.max(0,he.viewer_time-M._adRequests[0].viewer_time)),b.data.view_start&&(b.data.view_startup_preroll_request_time=Math.max(0,he.viewer_time-b.data.view_start)),M._prerollPlayTime=he.viewer_time)}),b.on("adplaying",function(Y,he){M.inPrerollPosition()&&b.data.view_preroll_load_time===void 0&&M._prerollPlayTime!==void 0&&(b.data.view_preroll_load_time=he.viewer_time-M._prerollPlayTime,b.data.view_startup_preroll_load_time=he.viewer_time-M._prerollPlayTime)}),b.on("adended",function(){M._wouldBeNewAdPlay=!0}),b.on("aderror",function(){M._wouldBeNewAdPlay=!0})}var h,f,y;return h=p,(f=[{key:"inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(b){for(var M=0;M<this._adRequests.length;M++)if(this._adRequests[M].ad_request_id===b)return this._adRequests[M]}},{key:"_updateAdData",value:function(b,M){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&M.ad_tag_url){var I=C(ke(M.ad_tag_url),2),Y=I[0],he=I[1];this.pm.data.view_preroll_ad_tag_domain=he,this.pm.data.view_preroll_ad_tag_hostname=Y}if(!this.pm.data.view_preroll_ad_asset_hostname&&M.ad_asset_url){var ee=C(ke(M.ad_asset_url),2),Me=ee[0],ut=ee[1];this.pm.data.view_preroll_ad_asset_domain=ut,this.pm.data.view_preroll_ad_asset_hostname=Me}}}}])&&Q(h.prototype,f),y&&Q(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Pe(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}function Be(p,h,f){return h&&Pe(p.prototype,h),f&&Pe(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var We=Be(function p(h){var f,y;(function(Y,he){if(!(Y instanceof he))throw new TypeError("Cannot call a class as a function")})(this,p);var b=function(){h.disableRebufferTracking||f&&(V(h.data,"view_waiting_rebuffer_duration",J.now()-f),f=!1,R().clearInterval(y))},M=!1,I=function(){M=!1,b()};h.on("waiting",function(){M&&(h.disableRebufferTracking||(V(h.data,"view_waiting_rebuffer_count",1),f=J.now(),y=R().setInterval(function(){if(f){var Y=J.now();V(h.data,"view_waiting_rebuffer_duration",Y-f),f=Y}},250)))}),h.on("playing",function(){b(),M=!0}),h.on("pause",I),h.on("seeking",I)});function Ge(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}function $e(p,h,f){return h&&Ge(p.prototype,h),f&&Ge(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var ht=$e(function p(h){var f=this;(function(M,I){if(!(M instanceof I))throw new TypeError("Cannot call a class as a function")})(this,p);var y=function(){f.lastWallClockTime=J.now(),h.on("before*",b)},b=function(M){var I=J.now(),Y=f.lastWallClockTime;f.lastWallClockTime=I,I-Y>3e4&&(h.emit("devicesleep",{viewer_time:Y}),K()(h.data,{viewer_time:Y}),h.send("devicesleep"),h.emit("devicewake",{viewer_time:I}),K()(h.data,{viewer_time:I}),h.send("devicewake"))};h.one("playbackheartbeat",y),h.on("playbackheartbeatend",function(){h.off("before*",b),h.one("playbackheartbeat",y)})}),Dt=j(375),ze=j(655),Pt=j.n(ze),tr="muxData",jt=function(){var p;try{p=Dt.parse(Pt().get(tr)||"")}catch{p={}}return p},Ft=function(p){try{Pt().set(tr,Dt.stringify(p),{expires:7300})}catch{}},Ht=function(){var p=jt();return p.mux_viewer_id=p.mux_viewer_id||g(),p.msn=p.msn||Math.random(),Ft(p),{mux_viewer_id:p.mux_viewer_id,mux_sample_number:p.msn}};function rt(p,h){var f=h.beaconCollectionDomain,y=h.beaconDomain;if(f)return"https://"+f;var b=y||"litix.io";return(p=p||"inferred").match(/^[a-z0-9]+$/)?"https://"+p+"."+b:"https://img.litix.io/a.gif"}var lr=function(){var p;switch(Ar()){case"cellular":p="cellular";break;case"ethernet":p="wired";break;case"wifi":p="wifi";break;case void 0:break;default:p="other"}return p},Ar=function(){var p=R().navigator,h=p&&(p.connection||p.mozConnection||p.webkitConnection);return h&&h.type};lr.getConnectionFromAPI=Ar;var Kt=lr,Jt=Cr({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"}),pr=Cr({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function Cr(p){var h={};for(var f in p)p.hasOwnProperty(f)&&(h[p[f]]=f);return h}function vr(p){var h={},f={};return Object.keys(p).forEach(function(y){var b=!1;if(p.hasOwnProperty(y)&&p[y]!==void 0){var M=y.split("_"),I=M[0],Y=Jt[I];Y||(q.info("Data key word `"+M[0]+"` not expected in "+y),Y=I+"_"),M.splice(1).forEach(function(he){he==="url"&&(b=!0),pr[he]?Y+=pr[he]:Number(he)&&Math.floor(Number(he))===Number(he)?Y+=he:(q.info("Data key word `"+he+"` not expected in "+y),Y+="_"+he+"_")}),b?f[Y]=p[y]:h[Y]=p[y]}}),K()(h,f)}var Gt={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Di=["hb","requestcompleted","requestfailed","requestcanceled"],nn="https://img.litix.io",kr=function(p){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=p||nn,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=K()({},Gt,h)};kr.prototype.queueEvent=function(p,h){var f=K()({},h);return(this._eventQueue.length<=this._options.maxQueueLength||p==="eventrateexceeded")&&(this._eventQueue.push(f),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},kr.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())},kr.prototype.destroy=function(){var p=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,p?this._clearBeaconQueue():this.flushEvents(),R().clearTimeout(this._sendTimeout)},kr.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&&K()(h[h.length-1],vr({mux_view_message:"event queue truncated"}));var f=this._createPayload(h);li(this._beaconUrl,f,!0,function(){})},kr.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 f=this._createPayload(h),y=J.now();li(this._beaconUrl,f,!1,function(b,M){M?(p._eventQueue=h.concat(p._eventQueue),p._failureCount+=1,q.info("Error sending beacon: "+M)):p._failureCount=0,p._roundTripTime=J.now()-y,p._postInFlight=!1})}},kr.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},kr.prototype._startBeaconSending=function(){var p=this;R().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=R().setTimeout(function(){p._eventQueue.length&&p._sendBeaconQueue(),p._startBeaconSending()},this._getNextBeaconTime()))},kr.prototype._createPayload=function(p){var h,f,y,b=this,M={transmission_timestamp:Math.round(J.now())};this._roundTripTime&&(M.rtt_ms=Math.round(this._roundTripTime));var I=function(){h=JSON.stringify({metadata:M,events:f||p}),y=h.length/1024},Y=function(){return y<=b._options.maxPayloadKBSize};return I(),Y()||(q.info("Payload size is too big ("+y+" kb). Removing unnecessary events."),f=p.filter(function(he){return Di.indexOf(he.e)===-1}),I()),Y()||(q.info("Payload size still too big ("+y+" kb). Cropping fields.."),f.forEach(function(he){for(var ee in he){var Me=he[ee];typeof Me=="string"&&Me.length>51200&&(he[ee]=Me.substring(0,51200))}}),I()),h};var li=function(p,h,f,y){if(f&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(p,h))y();else if(R().fetch)R().fetch(p,{method:"POST",body:h,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(M){return y(null,M.ok?null:"Error")}).catch(function(M){return y(null,M)});else{if(R().XMLHttpRequest){var b=new(R()).XMLHttpRequest;return b.onreadystatechange=function(){if(b.readyState===4)return y(null,b.status!==200?"error":void 0)},b.open("POST",p),b.setRequestHeader("Content-Type","text/plain"),void b.send(h)}y()}},an=kr;function sn(p,h){return function(f){if(Array.isArray(f))return f}(p)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var M,I,Y=[],he=!0,ee=!1;try{for(b=b.call(f);!(he=(M=b.next()).done)&&(Y.push(M.value),!y||Y.length!==y);he=!0);}catch(Me){ee=!0,I=Me}finally{try{he||b.return==null||b.return()}finally{if(ee)throw I}}return Y}}(p,h)||function(f,y){if(f){if(typeof f=="string")return ui(f,y);var b=Object.prototype.toString.call(f).slice(8,-1);return b==="Object"&&f.constructor&&(b=f.constructor.name),b==="Map"||b==="Set"?Array.from(f):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?ui(f,y):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 hi(p,h){(h==null||h>p.length)&&(h=p.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=p[f];return y}function fi(p,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(p,y.key,y)}}function vi(p,h){return vi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,y){return f.__proto__=y,f},vi(p,h)}function Li(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 f,y=pi(p);if(h){var b=pi(this).constructor;f=Reflect.construct(y,arguments,b)}else f=y.apply(this,arguments);return un(this,f)}}function un(p,h){if(h&&(Ur(h)==="object"||typeof h=="function"))return h;if(h!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return $t(p)}function $t(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function pi(p){return pi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},pi(p)}var Dn=["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"],dn=function(p){(function(I,Y){if(typeof Y!="function"&&Y!==null)throw new TypeError("Super expression must either be null or a function");I.prototype=Object.create(Y&&Y.prototype,{constructor:{value:I,writable:!0,configurable:!0}}),Object.defineProperty(I,"prototype",{writable:!1}),Y&&vi(I,Y)})(M,p);var h,f,y,b=Li(M);function M(I,Y,he){var ee;(function(Qe,ot){if(!(Qe instanceof ot))throw new TypeError("Cannot call a class as a function")})(this,M),(ee=b.call(this)).DOM_CONTENT_LOADED_EVENT_END=Ne.domContentLoadedEventEnd(),ee.NAVIGATION_START=Ne.navigationStart(),ee.mux=I,ee.id=Y,(he=K()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(Qe){return Qe}},he)).data=he.data||{},he.data.property_key&&(he.data.env_key=he.data.property_key,delete he.data.property_key),q.setLevel(he.debug?"debug":"warn"),ee.getPlayheadTime=he.getPlayheadTime,ee.getStateData=he.getStateData||function(){return{}},ee.getAdData=he.getAdData||function(){},ee.minimumRebufferDuration=he.minimumRebufferDuration,ee.sustainedRebufferThreshold=he.sustainedRebufferThreshold,ee.playbackHeartbeatTime=he.playbackHeartbeatTime,ee.disableRebufferTracking=he.disableRebufferTracking,ee.disableRebufferTracking&&ee.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."),ee.disablePlayheadRebufferTracking=he.disablePlayheadRebufferTracking,ee.errorTranslator=he.errorTranslator,ee.playbackEventDispatcher=new qr(I,he.data.env_key,he),ee.data={player_instance_id:g(),mux_sample_rate:he.sampleRate,beacon_domain:he.beaconCollectionDomain?he.beaconCollectionDomain:he.beaconDomain},ee.data.view_sequence_number=1,ee.data.player_sequence_number=1,ee.oldEmit=ee.emit,ee.emit=function(Qe,ot){ot=K()({viewer_time:this.mux.utils.now()},ot),this.oldEmit(Qe,ot)};var Me=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind($t(ee));ee.on("viewinit",function(Qe,ot){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),K()(this.data,ot),this._initializeViewData(),this.one("play",Me),this.one("adbreakstart",Me)});var ut=function(Qe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",Qe)}.bind($t(ee));if(ee.on("videochange",function(Qe,ot){ut(ot)}),ee.on("programchange",function(Qe,ot){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."),ut(K()(ot,{view_program_changed:!0})),Me(),this.emit("play"),this.emit("playing")}),ee.on("fragmentchange",function(Qe,ot){this.currentFragmentPDT=ot.currentFragmentPDT,this.currentFragmentStart=ot.currentFragmentStart}),ee.on("destroy",ee.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var Ze=function(){var Qe=ee.data.view_start!==void 0;ee.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",Qe&&ee.mux.WINDOW_HIDDEN&&(ee.data.player_is_paused||ee.emit("hb"))};window.addEventListener("visibilitychange",Ze,!1);var st=function(Qe){Qe.persisted||ee.destroy()};window.addEventListener("pagehide",st,!1),ee.on("destroy",function(){window.removeEventListener("visibilitychange",Ze),window.removeEventListener("pagehide",st)})}return ee.on("playerready",function(Qe,ot){K()(this.data,ot)}),Dn.forEach(function(Qe){ee.on(Qe,function(ot,Ot){Qe.indexOf("ad")!==0&&this._updateStateData(),K()(this.data,Ot),this._sanitizeData()}),ee.on("after"+Qe,function(){(Qe!=="error"||this.errorTracker.viewErrored)&&this.send(Qe)})}),ee.on("viewend",function(Qe,ot){K()(ee.data,ot)}),ee.one("playerready",function(Qe){var ot=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ot-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}),ee.longResumeTracker=new Lr($t(ee)),ee.errorTracker=new Ce($t(ee)),new ht($t(ee)),ee.seekingTracker=new O($t(ee)),ee.playheadTime=new Rt($t(ee)),ee.playbackHeartbeat=new Ie($t(ee)),new te($t(ee)),ee.watchTimeTracker=new Xe($t(ee)),new lt($t(ee)),ee.adTracker=new Re($t(ee)),new It($t(ee)),new gt($t(ee)),new Wt($t(ee)),new We($t(ee)),new wr($t(ee)),he.hlsjs&&ee.addHLSJS(he),he.dashjs&&ee.addDashJS(he),ee.emit("viewinit",he.data),ee}return h=M,f=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(I){var Y=K()({},this.data);if(Y.video_source_is_live===void 0&&(Y.player_source_duration===1/0||Y.video_source_duration===1/0?Y.video_source_is_live=!0:(Y.player_source_duration>0||Y.video_source_duration>0)&&(Y.video_source_is_live=!1)),Y.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(ut){Y[ut]=void 0}),Y.video_source_url=Y.video_source_url||Y.player_source_url,Y.video_source_url){var he=Yr(ke(Y.video_source_url),2),ee=he[0],Me=he[1];Y.video_source_domain=Me,Y.video_source_hostname=ee}delete Y.ad_request_id,this.playbackEventDispatcher.send(I,Y),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){K()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var I=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Y){var he=parseInt(I.data[Y],10);I.data[Y]=isNaN(he)?void 0:he}),["player_source_url","video_source_url"].forEach(function(Y){if(I.data[Y]){var he=I.data[Y].toLowerCase();he.indexOf("data:")!==0&&he.indexOf("blob:")!==0||(I.data[Y]="MSE style URL")}})}},{key:"_resetVideoData",value:function(I,Y){var he=this;Object.keys(this.data).forEach(function(ee){ee.indexOf("video_")===0&&delete he.data[ee]})}},{key:"_resetViewData",value:function(){var I=this;Object.keys(this.data).forEach(function(Y){Y.indexOf("view_")===0&&delete I.data[Y]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(I,Y){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var I=this,Y=this.data.view_id=g(),he=function(){Y===I.data.view_id&&V(I.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",he):he()}},{key:"_restartHeartBeat",value:function(){var I=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){I.data.player_is_paused||I.emit("hb")},1e4))}},{key:"addHLSJS",value:function(I){I.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=I.hlsjs,function(Y,he,ee){var Me=arguments.length>4?arguments[4]:void 0,ut=Y.log,Ze=Y.utils.secondsToMs,st=function(Lt){var nt,vt=parseInt(Me.version);return vt===1&&Lt.programDateTime!==null&&(nt=Lt.programDateTime),vt===0&&Lt.pdt!==null&&(nt=Lt.pdt),nt};if(Ne.exists()){var Qe=function(Lt,nt){return Y.emit(he,Lt,nt)},ot=function(Lt,nt){var vt=nt.levels,et=nt.audioTracks,ft=nt.url,Vt=nt.stats,Xt=nt.networkDetails,dr=nt.sessionData,or={},mr={};vt.forEach(function(Er,zr){or[zr]={width:Er.width,height:Er.height,bitrate:Er.bitrate,attrs:Er.attrs}}),et.forEach(function(Er,zr){mr[zr]={name:Er.name,language:Er.lang,bitrate:Er.bitrate}});var cr=$(Vt),yr=cr.bytesLoaded,Qt=cr.requestStart,hr=cr.responseStart,ni=cr.responseEnd;Qe("requestcompleted",Se(Se({},D(dr)),{},{request_event_type:Lt,request_bytes_loaded:yr,request_start:Qt,request_response_start:hr,request_response_end:ni,request_type:"manifest",request_hostname:Ee(ft),request_response_headers:Le(Xt),request_rendition_lists:{media:or,audio:mr,video:{}}}))};ee.on(Me.Events.MANIFEST_LOADED,ot);var Ot=function(Lt,nt){var vt=nt.details,et=nt.level,ft=nt.networkDetails,Vt=nt.stats,Xt=$(Vt),dr=Xt.bytesLoaded,or=Xt.requestStart,mr=Xt.responseStart,cr=Xt.responseEnd,yr=vt.fragments[vt.fragments.length-1],Qt=st(yr)+Ze(yr.duration);Qe("requestcompleted",{request_event_type:Lt,request_bytes_loaded:dr,request_start:or,request_response_start:mr,request_response_end:cr,request_current_level:et,request_type:"manifest",request_hostname:Ee(vt.url),request_response_headers:Le(ft),video_holdback:vt.holdBack&&Ze(vt.holdBack),video_part_holdback:vt.partHoldBack&&Ze(vt.partHoldBack),video_part_target_duration:vt.partTarget&&Ze(vt.partTarget),video_target_duration:vt.targetduration&&Ze(vt.targetduration),video_source_is_live:vt.live,player_manifest_newest_program_time:isNaN(Qt)?void 0:Qt})};ee.on(Me.Events.LEVEL_LOADED,Ot);var qt=function(Lt,nt){var vt=nt.details,et=nt.networkDetails,ft=nt.stats,Vt=$(ft),Xt=Vt.bytesLoaded,dr=Vt.requestStart,or=Vt.responseStart,mr=Vt.responseEnd;Qe("requestcompleted",{request_event_type:Lt,request_bytes_loaded:Xt,request_start:dr,request_response_start:or,request_response_end:mr,request_type:"manifest",request_hostname:Ee(vt.url),request_response_headers:Le(et)})};ee.on(Me.Events.AUDIO_TRACK_LOADED,qt);var rr=function(Lt,nt){var vt=nt.stats,et=nt.networkDetails,ft=nt.frag;vt=vt||ft.stats;var Vt=$(vt),Xt=Vt.bytesLoaded,dr=Vt.requestStart,or=Vt.responseStart,mr=Vt.responseEnd,cr=Le(et),yr=cr==null?void 0:cr["x-request-id"],Qt={request_event_type:Lt,request_bytes_loaded:Xt,request_start:dr,request_response_start:or,request_response_end:mr,request_hostname:et?Ee(et.responseURL):void 0,request_id:yr,request_response_headers:cr,request_media_duration:ft.duration,request_url:et==null?void 0:et.responseURL};ft.type==="main"?(Qt.request_type="media",Qt.request_current_level=ft.level,Qt.request_video_width=(ee.levels[ft.level]||{}).width,Qt.request_video_height=(ee.levels[ft.level]||{}).height,Qt.request_labeled_bitrate=(ee.levels[ft.level]||{}).bitrate):Qt.request_type=ft.type,Qe("requestcompleted",Qt)};ee.on(Me.Events.FRAG_LOADED,rr);var ur=function(Lt,nt){var vt=nt.frag,et=vt.start,ft={currentFragmentPDT:st(vt),currentFragmentStart:Ze(et)};Qe("fragmentchange",ft)};ee.on(Me.Events.FRAG_CHANGED,ur);var bt=function(Lt,nt){var vt=nt.type,et=nt.details,ft=nt.response,Vt=nt.fatal,Xt=nt.context,dr=nt.frag;if(et===Me.ErrorDetails.MANIFEST_LOAD_ERROR||et===Me.ErrorDetails.MANIFEST_LOAD_TIMEOUT||et===Me.ErrorDetails.FRAG_LOAD_ERROR||et===Me.ErrorDetails.FRAG_LOAD_TIMEOUT||et===Me.ErrorDetails.LEVEL_LOAD_ERROR||et===Me.ErrorDetails.LEVEL_LOAD_TIMEOUT){var or=dr&&dr.url||Xt&&Xt.url||"";Qe("requestfailed",{request_error:et,request_url:or,request_hostname:Ee(or),request_type:et===Me.ErrorDetails.FRAG_LOAD_ERROR||et===Me.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:ft&&ft.code,request_error_text:ft&&ft.text})}Vt&&Qe("error",{player_error_code:vt,player_error_message:et})};ee.on(Me.Events.ERROR,bt);var Zt=function(Lt,nt){var vt=nt.frag,et=vt&&vt._url||"";Qe("requestcanceled",{request_event_type:Lt,request_url:et,request_type:"media",request_hostname:Ee(et)})};ee.on(Me.Events.FRAG_LOAD_EMERGENCY_ABORTED,Zt);var sr=function(Lt,nt){var vt=nt.level,et=ee.levels[vt];if(et&&et.attrs&&et.attrs.BANDWIDTH){var ft,Vt=et.attrs.BANDWIDTH,Xt=parseFloat(et.attrs["FRAME-RATE"]);isNaN(Xt)||(ft=Xt),Vt?Qe("renditionchange",{video_source_fps:ft,video_source_bitrate:Vt,video_source_width:et.width,video_source_height:et.height,video_source_rendition_name:et.name,video_source_codec:et==null?void 0:et.videoCodec}):ut.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};ee.on(Me.Events.LEVEL_SWITCHED,sr),ee._stopMuxMonitor=function(){ee.off(Me.Events.MANIFEST_LOADED,ot),ee.off(Me.Events.LEVEL_LOADED,Ot),ee.off(Me.Events.AUDIO_TRACK_LOADED,qt),ee.off(Me.Events.FRAG_LOADED,rr),ee.off(Me.Events.FRAG_CHANGED,ur),ee.off(Me.Events.ERROR,bt),ee.off(Me.Events.FRAG_LOAD_EMERGENCY_ABORTED,Zt),ee.off(Me.Events.LEVEL_SWITCHED,sr),ee.off(Me.Events.DESTROYING,ee._stopMuxMonitor),delete ee._stopMuxMonitor},ee.on(Me.Events.DESTROYING,ee._stopMuxMonitor)}else ut.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,I.hlsjs,{},I.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var I;this.hlsjs&&((I=this.hlsjs)&&typeof I._stopMuxMonitor=="function"&&I._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(I){I.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=I.dashjs,function(Y,he,ee){var Me=Y.log;if(ee&&ee.on){var ut=function(bt,Zt){return Y.emit(he,bt,Zt)},Ze=function(bt){var Zt=bt.type,sr=(bt.data||{}).url;ut("requestcompleted",{request_event_type:Zt,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:Ee(sr),request_url:sr})};ee.on("manifestLoaded",Ze);var st={},Qe=function(bt){var Zt=bt.type,sr=bt.fragmentModel,Lt=(bt.chunk||{}).mediaInfo||{},nt=Lt.type,vt=Lt.bitrateList,et={};(vt=vt||[]).forEach(function(Qt,hr){et[hr]={},et[hr].width=Qt.width,et[hr].height=Qt.height,et[hr].bitrate=Qt.bandwidth,et[hr].attrs={}}),nt==="video"?st.video=et:nt==="audio"?st.audio=et:st.media=et;var ft=qe(sr,ee),Vt=ft.requestStart,Xt=ft.requestResponseStart,dr=ft.requestResponseEnd,or=ft.requestResponseHeaders,mr=ft.requestMediaDuration,cr=ft.requestHostname,yr=ft.requestUrl;ut("requestcompleted",{request_event_type:Zt,request_start:Vt,request_response_start:Xt,request_response_end:dr,request_bytes_loaded:-1,request_type:nt+"_init",request_response_headers:or,request_hostname:cr,request_url:yr,request_media_duration:mr,request_rendition_lists:st})};ee.on("initFragmentLoaded",Qe);var ot=function(bt){var Zt=bt.type,sr=bt.fragmentModel,Lt=bt.chunk||{},nt=Lt.mediaInfo,vt=Lt.start,et=(nt||{}).type,ft=qe(sr,ee),Vt=ft.requestStart,Xt=ft.requestResponseStart,dr=ft.requestResponseEnd,or=ft.requestBytesLoaded,mr=ft.requestResponseHeaders,cr=ft.requestMediaDuration,yr=ft.requestHostname,Qt=ft.requestUrl,hr=at(et,ee),ni=hr.currentLevel,Er=hr.renditionWidth,zr=hr.renditionHeight,pn=hr.renditionBitrate;ut("requestcompleted",{request_event_type:Zt,request_start:Vt,request_response_start:Xt,request_response_end:dr,request_bytes_loaded:or,request_type:et,request_response_headers:mr,request_hostname:yr,request_url:Qt,request_media_start_time:vt,request_media_duration:cr,request_current_level:ni,request_labeled_bitrate:pn,request_video_width:Er,request_video_height:zr})};ee.on("mediaFragmentLoaded",ot);var Ot={video:void 0,audio:void 0,totalBitrate:void 0},qt=function(){if(Ot.video&&typeof Ot.video.bitrate=="number"){if(Ot.video.width&&Ot.video.height){var bt=Ot.video.bitrate;return Ot.audio&&typeof Ot.audio.bitrate=="number"&&(bt+=Ot.audio.bitrate),bt!==Ot.totalBitrate?(Ot.totalBitrate=bt,{video_source_bitrate:bt,video_source_height:Ot.video.height,video_source_width:Ot.video.width,video_source_codec:ie(Ot.video.codec)}):void 0}Me.warn("have bitrate info for video but missing width/height")}},rr=function(bt,Zt,sr){if(typeof bt.newQuality=="number"){var Lt=bt.mediaType;if(Lt==="audio"||Lt==="video"){var nt=ee.getBitrateInfoListFor(Lt).find(function(et){return et.qualityIndex===bt.newQuality});if(nt&&typeof nt.bitrate=="number"){Ot[Lt]=xe(xe({},nt),{},{codec:ee.getCurrentTrackFor(Lt).codec});var vt=qt();vt&&ut("renditionchange",vt)}else Me.warn("missing bitrate info for ".concat(Lt))}}else Me.warn("missing evt.newQuality in qualityChangeRendered event",bt)};ee.on("qualityChangeRendered",rr);var ur=function(bt){var Zt=bt.error,sr=bt.event,Lt=(sr=sr||{}).request||{},nt=R().event&&R().event.currentTarget||{};ut("requestfailed",{request_error:Zt+"_"+sr.id+"_"+Lt.type,request_url:sr.url,request_hostname:Ee(sr.url),request_type:Lt.mediaType,request_error_code:nt.status,request_error_type:nt.statusText})};ee.on("error",ur),ee._stopMuxMonitor=function(){ee.off("manifestLoaded",Ze),ee.off("initFragmentLoaded",Qe),ee.off("mediaFragmentLoaded",ot),ee.off("qualityChangeRendered",rr),ee.off("error",ur),delete ee._stopMuxMonitor}}else Me.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,I.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var I;this.dashjs&&((I=this.dashjs)&&typeof I._stopMuxMonitor=="function"&&I._stopMuxMonitor(),this.dashjs=void 0)}}],f&&fi(h.prototype,f),y&&fi(h,y),Object.defineProperty(h,"prototype",{writable:!1}),M}(H),Br=dn,Ri=j(153),ti=j.n(Ri);function ri(p){return ri=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},ri(p)}function Ii(p,h){return function(f){if(Array.isArray(f))return f}(p)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var M,I,Y=[],he=!0,ee=!1;try{for(b=b.call(f);!(he=(M=b.next()).done)&&(Y.push(M.value),!y||Y.length!==y);he=!0);}catch(Me){ee=!0,I=Me}finally{try{he||b.return==null||b.return()}finally{if(ee)throw I}}return Y}}(p,h)||function(f,y){if(f){if(typeof f=="string")return cn(f,y);var b=Object.prototype.toString.call(f).slice(8,-1);return b==="Object"&&f.constructor&&(b=f.constructor.name),b==="Map"||b==="Set"?Array.from(f):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?cn(f,y):void 0}}(p,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
-
|
|
1
|
+
var Eu=Object.create;var Ka=Object.defineProperty;var Tu=Object.getOwnPropertyDescriptor;var bu=Object.getOwnPropertyNames;var _u=Object.getPrototypeOf,Su=Object.prototype.hasOwnProperty;var Au=(R,L,S)=>L in R?Ka(R,L,{enumerable:!0,configurable:!0,writable:!0,value:S}):R[L]=S;var co=(R,L)=>()=>(L||R((L={exports:{}}).exports,L),L.exports);var ku=(R,L,S,F)=>{if(L&&typeof L=="object"||typeof L=="function")for(let U of bu(L))!Su.call(R,U)&&U!==S&&Ka(R,U,{get:()=>L[U],enumerable:!(F=Tu(L,U))||F.enumerable});return R};var ho=(R,L,S)=>(S=R!=null?Eu(_u(R)):{},ku(L||!R||!R.__esModule?Ka(S,"default",{value:R,enumerable:!0}):S,R));var Vi=(R,L,S)=>(Au(R,typeof L!="symbol"?L+"":L,S),S),qa=(R,L,S)=>{if(!L.has(R))throw TypeError("Cannot "+S)};var re=(R,L,S)=>(qa(R,L,"read from private field"),S?S.call(R):L.get(R)),Oe=(R,L,S)=>{if(L.has(R))throw TypeError("Cannot add the same private member more than once");L instanceof WeakSet?L.add(R):L.set(R,S)},Xe=(R,L,S,F)=>(qa(R,L,"write to private field"),F?F.call(R,S):L.set(R,S),S);var rt=(R,L,S)=>(qa(R,L,"access private method"),S);var go=co((Vn,Wa)=>{(function(){var R,L;R=this,L=function(){return function(){var S={80:function(H,Q,q){H.exports=q(728).default},728:function(H,Q,q){"use strict";q.d(Q,{default:function(){return ci}});var ne=q(48),W=q.n(ne),de=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(m){var h=16*Math.random()|0;return(m==="x"?h:3&h|8).toString(16)})},ve=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},ge=function(m){return m&&m.nodeName!==void 0?(m.muxId||(m.muxId=m.id||ve()),m.muxId):m},Ee=function(m){var h;m&&m.nodeName!==void 0?m=ge(h=m):h=document.querySelector(m);var g=h&&h.nodeName?h.nodeName.toLowerCase():"";return[h,m,g]},xe=q(640),Pe=q.n(xe),it=Pe().methodFactory;Pe().methodFactory=function(m,h,g){var _=it(m,h,g);return function(){for(var k=["[mux]"],D=0;D<arguments.length;D++)k.push(arguments[D]);_.apply(void 0,k)}},Pe().setLevel(Pe().getLevel());var Le=Pe();function St(){return(W().doNotTrack||W().navigator&&W().navigator.doNotTrack)==="1"}var Ne={now:function(){var m=W().performance,h=m&&m.timing,g=h&&h.navigationStart,_=typeof g=="number"&&typeof m.now=="function"?g+m.now():Date.now();return Math.round(_)}},ie=function(m){return T(m)[0]},T=function(m){if(typeof m!="string"||m==="")return["localhost"];var h,g=(m.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return g&&(h=(g.match(/[^\.]+\.[^\.]+$/)||[])[0]),[g,h]},Z={exists:function(){var m=W().performance;return(m&&m.timing)!==void 0},domContentLoadedEventEnd:function(){var m=W().performance,h=m&&m.timing;return h&&h.domContentLoadedEventEnd},navigationStart:function(){var m=W().performance,h=m&&m.timing;return h&&h.navigationStart}};function N(m,h,g){g=g===void 0?1:g,m[h]=m[h]||0,m[h]+=g}var Ke=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],ot=["x-cdn","content-type"].concat(Ke);function _e(m){var h={};return(m=m||"").trim().split(/[\r\n]+/).forEach(function(g){if(g){var _=g.split(": "),k=_.shift();k&&(ot.indexOf(k.toLowerCase())>=0||k.toLowerCase().indexOf("x-litix-")===0)&&(h[k]=_.join(": "))}}),h}function je(m){if(m){var h=Ke.find(function(g){return m[g]!==void 0});return h?m[h]:void 0}}var ut=function(m){var h={};for(var g in m){var _=m[g];_["DATA-ID"].search("io.litix.data.")!==-1&&(h[_["DATA-ID"].replace("io.litix.data.","")]=_.VALUE)}return h};function P(m,h){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(m);h&&(_=_.filter(function(k){return Object.getOwnPropertyDescriptor(m,k).enumerable})),g.push.apply(g,_)}return g}function Qe(m){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?P(Object(g),!0).forEach(function(_){nt(m,_,g[_])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):P(Object(g)).forEach(function(_){Object.defineProperty(m,_,Object.getOwnPropertyDescriptor(g,_))})}return m}function nt(m,h,g){return h in m?Object.defineProperty(m,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[h]=g,m}var ze=function(m){if(!m)return{};var h=Z.navigationStart(),g=m.loading,_=g?g.start:m.trequest,k=g?g.first:m.tfirst,D=g?g.end:m.tload;return{bytesLoaded:m.total,requestStart:Math.round(h+_),responseStart:Math.round(h+k),responseEnd:Math.round(h+D)}},wt=function(m){if(m&&typeof m.getAllResponseHeaders=="function")return _e(m.getAllResponseHeaders())};function Or(m,h){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(m);h&&(_=_.filter(function(k){return Object.getOwnPropertyDescriptor(m,k).enumerable})),g.push.apply(g,_)}return g}function yt(m){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?Or(Object(g),!0).forEach(function(_){De(m,_,g[_])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):Or(Object(g)).forEach(function(_){Object.defineProperty(m,_,Object.getOwnPropertyDescriptor(g,_))})}return m}function De(m,h,g){return h in m?Object.defineProperty(m,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[h]=g,m}var Je=function(m,h){if(!m||typeof m.getRequests!="function")return{};var g=m.getRequests({state:"executed"});if(g.length===0)return{};var _,k=g[g.length-1],D=ie(k.url),w=k.url,x=k.bytesLoaded,G=new Date(k.requestStartDate).getTime(),M=new Date(k.firstByteDate).getTime(),Y=new Date(k.requestEndDate).getTime(),Se=isNaN(k.duration)?0:k.duration,ae=typeof h.getMetricsFor=="function"?h.getMetricsFor(k.mediaType).HttpList:h.getDashMetrics().getHttpRequests(k.mediaType);return ae.length>0&&(_=_e(ae[ae.length-1]._responseHeaders||"")),{requestStart:G,requestResponseStart:M,requestResponseEnd:Y,requestBytesLoaded:x,requestResponseHeaders:_,requestMediaDuration:Se,requestHostname:D,requestUrl:w,requestId:_?je(_):void 0}},nr=function(m,h){var g=h.getQualityFor(m),_=h.getCurrentTrackFor(m).bitrateList;return _?{currentLevel:g,renditionWidth:_[g].width||null,renditionHeight:_[g].height||null,renditionBitrate:_[g].bandwidth}:{}},Gt=function(m){var h;return(h=m.match(/.*codecs\*?="(.*)"/))===null||h===void 0?void 0:h[1]};function Qr(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var sn=0,on=function(){function m(){(function(k,D){if(!(k instanceof D))throw new TypeError("Cannot call a class as a function")})(this,m)}var h,g,_;return h=m,g=[{key:"on",value:function(k,D,w){return D._eventEmitterGuid=D._eventEmitterGuid||++sn,this._listeners=this._listeners||{},this._listeners[k]=this._listeners[k]||[],w&&(D=D.bind(w)),this._listeners[k].push(D),D}},{key:"off",value:function(k,D){var w=this._listeners&&this._listeners[k];w&&w.forEach(function(x,G){x._eventEmitterGuid===D._eventEmitterGuid&&w.splice(G,1)})}},{key:"one",value:function(k,D,w){var x=this;D._eventEmitterGuid=D._eventEmitterGuid||++sn;var G=function M(){x.off(k,M),D.apply(w||this,arguments)};G._eventEmitterGuid=D._eventEmitterGuid,this.on(k,G)}},{key:"emit",value:function(k,D){var w=this;if(this._listeners){D=D||{};var x=this._listeners["before*"]||[],G=this._listeners[k]||[],M=this._listeners["after"+k]||[],Y=function(Se,ae){(Se=Se.slice()).forEach(function(me){me.call(w,{type:k},ae)})};Y(x,D),Y(G,D),Y(M,D)}}}],g&&Qr(h.prototype,g),_&&Qr(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}(),z=on;function se(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var Ye=function(){function m(k){var D=this;(function(w,x){if(!(w instanceof x))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=k,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,k.on("playing",function(){D._playheadShouldBeProgressing=!0}),k.on("play",this._startPlaybackHeartbeatInterval.bind(this)),k.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),k.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),k.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),k.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),k.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),k.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),k.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),k.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),k.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),k.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),k.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),k.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),k.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),k.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),k.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),k.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),k.on("seeked",function(){k.data.player_is_paused?D._stopPlaybackHeartbeatInterval():D._startPlaybackHeartbeatInterval()}),k.on("timeupdate",function(){D._playbackHeartbeatInterval!==null&&k.emit("playbackheartbeat")}),k.on("devicesleep",function(w,x){D._playbackHeartbeatInterval!==null&&(W().clearInterval(D._playbackHeartbeatInterval),k.emit("playbackheartbeatend",{viewer_time:x.viewer_time}),D._playbackHeartbeatInterval=null)})}var h,g,_;return h=m,(g=[{key:"_startPlaybackHeartbeatInterval",value:function(){var k=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=W().setInterval(function(){k.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(W().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&se(h.prototype,g),_&&se(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function Ce(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function dt(m,h,g){return h&&Ce(m.prototype,h),g&&Ce(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var At=dt(function m(h){var g=this;(function(_,k){if(!(_ instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m),h.on("viewinit",function(){g.viewErrored=!1}),h.on("error",function(_,k){try{var D=h.errorTranslator({player_error_code:k.player_error_code,player_error_message:k.player_error_message,player_error_context:k.player_error_context});D?(h.data.player_error_code=D.player_error_code||k.player_error_code,h.data.player_error_message=D.player_error_message||k.player_error_message,h.data.player_error_context=D.player_error_context||k.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(w){h.mux.log.warn("Exception in error translator callback.",w),g.viewErrored=!0}})});function Dt(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var ht=function(){function m(k){(function(D,w){if(!(D instanceof w))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=k,this._watchTimeTrackerLastCheckedTime=null,k.on("playbackheartbeat",this._updateWatchTime.bind(this)),k.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var h,g,_;return h=m,(g=[{key:"_updateWatchTime",value:function(k,D){var w=D.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=w),N(this.pm.data,"view_watch_time",w-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=w}},{key:"_clearWatchTimeState",value:function(k,D){this._updateWatchTime(k,D),this._watchTimeTrackerLastCheckedTime=null}}])&&Dt(h.prototype,g),_&&Dt(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function ft(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var Ht=function(){function m(k){(function(D,w){if(!(D instanceof w))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=k,this._playbackTimeTrackerLastPlayheadPosition=-1,k.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),k.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),k.on("seeking",this._clearPlaybackTimeState.bind(this))}var h,g,_;return h=m,(g=[{key:"_updatePlaybackTime",value:function(){var k=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&k>this._playbackTimeTrackerLastPlayheadPosition){var D=k-this._playbackTimeTrackerLastPlayheadPosition;D<=1e3&&N(this.pm.data,"view_content_playback_time",D)}this._playbackTimeTrackerLastPlayheadPosition=k}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&ft(h.prototype,g),_&&ft(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function _r(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var Sr=function(){function m(k){(function(w,x){if(!(w instanceof x))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=k;var D=this._updatePlayheadTime.bind(this);k.on("playbackheartbeat",D),k.on("playbackheartbeatend",D),k.on("timeupdate",D),k.on("destroy",function(){k.off("timeupdate",D)})}var h,g,_;return h=m,(g=[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=this.pm.data.view_max_playhead_position===void 0?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(k,D){var w=this,x=function(){w.pm.currentFragmentPDT&&w.pm.currentFragmentStart&&(w.pm.data.player_program_time=w.pm.currentFragmentPDT+w.pm.data.player_playhead_time-w.pm.currentFragmentStart)};if(D&&D.player_playhead_time)this.pm.data.player_playhead_time=D.player_playhead_time,x(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var G=this.pm.getPlayheadTime();G!==void 0&&(this.pm.data.player_playhead_time=G,x(),this._updateMaxPlayheadPosition())}}}])&&_r(h.prototype,g),_&&_r(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function Ar(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function Kt(m,h,g){return h&&Ar(m.prototype,h),g&&Ar(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var gr=3e5,kr=Kt(function m(h){if(function(D,w){if(!(D instanceof w))throw new TypeError("Cannot call a class as a function")}(this,m),!h.disableRebufferTracking){var g,_=function(D,w){k(w),g=void 0},k=function(D){if(g){var w=D.viewer_time-g;N(h.data,"view_rebuffer_duration",w),g=D.viewer_time,h.data.view_rebuffer_duration>gr&&(h.emit("viewend"),h.send("viewend"),h.mux.log.warn("Ending view after rebuffering for longer than ".concat(gr,"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(D,w){return k(w)}),h.on("rebufferstart",function(D,w){g||(N(h.data,"view_rebuffer_count",1),g=w.viewer_time,h.one("rebufferend",_))}),h.on("viewinit",function(){g=void 0,h.off("rebufferend",_)})}});function $e(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var Zt=function(){function m(k){var D=this;(function(w,x){if(!(w instanceof x))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=k,k.disableRebufferTracking||k.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,k.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),k.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),k.on("seeking",function(){D._cleanupRebufferTracker(null,{viewer_time:Ne.now()})}))}var h,g,_;return h=m,g=[{key:"_checkIfRebuffering",value:function(k,D){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(k,D);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var w=D.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&w>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=D.viewer_time}else this._cleanupRebufferTracker(k,D,!0);else this._prepareRebufferTrackerState(D.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(k){this._lastCheckedTime=k,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=k}},{key:"_cleanupRebufferTracker",value:function(k,D){var w=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:D.viewer_time});else{if(this._lastCheckedTime===null)return;var x=this.pm.data.player_playhead_time-this._lastPlayheadTime,G=D.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&x>0&&G-x>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+G-x}))}w?this._prepareRebufferTrackerState(D.viewer_time):this._clearRebufferTrackerState()}}],g&&$e(h.prototype,g),_&&$e(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}(),ar=Zt;function Mr(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var Fr=function(){function m(k){var D=this;(function(w,x){if(!(w instanceof x))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=k,k.on("viewinit",function(){var w=k.data,x=w.view_id;if(!w.view_program_changed){var G=function(M,Y){var Se=Y.viewer_time;M.type==="playing"&&k.data.view_time_to_first_frame===void 0?D.calculateTimeToFirstFrame(Se||Ne.now(),x):M.type!=="adplaying"||k.data.view_time_to_first_frame!==void 0&&!D._inPrerollPosition()||D.calculateTimeToFirstFrame(Se||Ne.now(),x)};k.one("playing",G),k.one("adplaying",G),k.one("viewend",function(){k.off("playing",G),k.off("adplaying",G)})}})}var h,g,_;return h=m,(g=[{key:"_inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(k,D){D===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:k}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&Mr(h.prototype,g),_&&Mr(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function Nr(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function ln(m,h,g){return h&&Nr(m.prototype,h),g&&Nr(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Jn=ln(function m(h){var g=this;(function(_,k){if(!(_ instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m),h.on("viewinit",function(){g._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(_){h.on(_,function(){if(g._lastPlayheadPosition>=0&&h.data.player_playhead_time>=0&&g._lastPlayerWidth>=0&&g._lastSourceWidth>0&&g._lastPlayerHeight>=0&&g._lastSourceHeight>0){var k=h.data.player_playhead_time-g._lastPlayheadPosition;if(k<0)return void(g._lastPlayheadPosition=-1);var D=Math.min(g._lastPlayerWidth/g._lastSourceWidth,g._lastPlayerHeight/g._lastSourceHeight),w=Math.max(0,D-1),x=Math.max(0,1-D);h.data.view_max_upscale_percentage=Math.max(h.data.view_max_upscale_percentage||0,w),h.data.view_max_downscale_percentage=Math.max(h.data.view_max_downscale_percentage||0,x),N(h.data,"view_total_content_playback_time",k),N(h.data,"view_total_upscaling",w*k),N(h.data,"view_total_downscaling",x*k)}g._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(_){h.on(_,function(){g._lastPlayheadPosition=h.data.player_playhead_time,g._lastPlayerWidth=h.data.player_width,g._lastPlayerHeight=h.data.player_height,g._lastSourceWidth=h.data.video_source_width,g._lastSourceHeight=h.data.video_source_height})})});function un(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function $n(m,h,g){return h&&un(m.prototype,h),g&&un(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Zn=$n(function m(h){var g=this;(function(_,k){if(!(_ instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m),this.isSeeking=!1,h.on("seeking",function(_,k){Object.assign(h.data,k),g._lastSeekingTime=Ne.now(),g.isSeeking===!1&&(g.isSeeking=!0,h.send("seeking"))}),h.on("seeked",function(){g.isSeeking=!1;var _=g._lastSeekingTime||Ne.now(),k=Ne.now()-_;N(h.data,"view_seek_count",1),N(h.data,"view_seek_duration",k);var D=h.data.view_max_seek_time||0;h.data.view_max_seek_time=Math.max(D,k)}),h.on("viewend",function(){g.isSeeking=!1})});function dn(m,h){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var k=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(k!=null){var D,w,x=[],G=!0,M=!1;try{for(k=k.call(g);!(G=(D=k.next()).done)&&(x.push(D.value),!_||x.length!==_);G=!0);}catch(Y){M=!0,w=Y}finally{try{G||k.return==null||k.return()}finally{if(M)throw w}}return x}}(m,h)||function(g,_){if(g){if(typeof g=="string")return Ft(g,_);var k=Object.prototype.toString.call(g).slice(8,-1);return k==="Object"&&g.constructor&&(k=g.constructor.name),k==="Map"||k==="Set"?Array.from(g):k==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(k)?Ft(g,_):void 0}}(m,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Ft(m,h){(h==null||h>m.length)&&(h=m.length);for(var g=0,_=new Array(h);g<h;g++)_[g]=m[g];return _}function cn(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}var Nt=function(m,h){m.push(h),m.sort(function(g,_){return g.viewer_time-_.viewer_time})},Jr=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],ea=function(){function m(k){var D=this;(function(x,G){if(!(x instanceof G))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=k,k.on("viewinit",function(){D.isAdBreak=!1,D._currentAdRequestNumber=0,D._currentAdResponseNumber=0,D._adRequests=[],D._adResponses=[],D._adHasPlayed=!1,D._wouldBeNewAdPlay=!0,D._prerollPlayTime=void 0}),Jr.forEach(function(x){return k.on(x,D._updateAdData.bind(D))});var w=function(){D.isAdBreak=!1};k.on("adbreakstart",function(){D.isAdBreak=!0}),k.on("play",w),k.on("playing",w),k.on("viewend",w),k.on("adrequest",function(x,G){G=Object.assign({ad_request_id:"generatedAdRequestId"+D._currentAdRequestNumber++},G),Nt(D._adRequests,G),N(k.data,"view_ad_request_count"),D.inPrerollPosition()&&(k.data.view_preroll_requested=!0,D._adHasPlayed||N(k.data,"view_preroll_request_count"))}),k.on("adresponse",function(x,G){G=Object.assign({ad_request_id:"generatedAdRequestId"+D._currentAdResponseNumber++},G),Nt(D._adResponses,G);var M=D.findAdRequest(G.ad_request_id);M&&N(k.data,"view_ad_request_time",Math.max(0,G.viewer_time-M.viewer_time))}),k.on("adplay",function(x,G){D._adHasPlayed=!0,D._wouldBeNewAdPlay&&(D._wouldBeNewAdPlay=!1,N(k.data,"view_ad_played_count")),D.inPrerollPosition()&&!k.data.view_preroll_played&&(k.data.view_preroll_played=!0,D._adRequests.length>0&&(k.data.view_preroll_request_time=Math.max(0,G.viewer_time-D._adRequests[0].viewer_time)),k.data.view_start&&(k.data.view_startup_preroll_request_time=Math.max(0,G.viewer_time-k.data.view_start)),D._prerollPlayTime=G.viewer_time)}),k.on("adplaying",function(x,G){D.inPrerollPosition()&&k.data.view_preroll_load_time===void 0&&D._prerollPlayTime!==void 0&&(k.data.view_preroll_load_time=G.viewer_time-D._prerollPlayTime,k.data.view_startup_preroll_load_time=G.viewer_time-D._prerollPlayTime)}),k.on("adended",function(){D._wouldBeNewAdPlay=!0}),k.on("aderror",function(){D._wouldBeNewAdPlay=!0})}var h,g,_;return h=m,(g=[{key:"inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(k){for(var D=0;D<this._adRequests.length;D++)if(this._adRequests[D].ad_request_id===k)return this._adRequests[D]}},{key:"_updateAdData",value:function(k,D){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&D.ad_tag_url){var w=dn(T(D.ad_tag_url),2),x=w[0],G=w[1];this.pm.data.view_preroll_ad_tag_domain=G,this.pm.data.view_preroll_ad_tag_hostname=x}if(!this.pm.data.view_preroll_ad_asset_hostname&&D.ad_asset_url){var M=dn(T(D.ad_asset_url),2),Y=M[0],Se=M[1];this.pm.data.view_preroll_ad_asset_domain=Se,this.pm.data.view_preroll_ad_asset_hostname=Y}}this.pm.data.ad_asset_url=D==null?void 0:D.ad_asset_url,this.pm.data.ad_tag_url=D==null?void 0:D.ad_tag_url,this.pm.data.ad_creative_id=D==null?void 0:D.ad_creative_id,this.pm.data.ad_id=D==null?void 0:D.ad_id,this.pm.data.ad_universal_id=D==null?void 0:D.ad_universal_id}}])&&cn(h.prototype,g),_&&cn(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function Si(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function vt(m,h,g){return h&&Si(m.prototype,h),g&&Si(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var hn=vt(function m(h){var g,_;(function(x,G){if(!(x instanceof G))throw new TypeError("Cannot call a class as a function")})(this,m);var k=function(){h.disableRebufferTracking||g&&(N(h.data,"view_waiting_rebuffer_duration",Ne.now()-g),g=!1,W().clearInterval(_))},D=!1,w=function(){D=!1,k()};h.on("waiting",function(){D&&(h.disableRebufferTracking||(N(h.data,"view_waiting_rebuffer_count",1),g=Ne.now(),_=W().setInterval(function(){if(g){var x=Ne.now();N(h.data,"view_waiting_rebuffer_duration",x-g),g=x}},250)))}),h.on("playing",function(){k(),D=!0}),h.on("pause",w),h.on("seeking",w)});function Re(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function fn(m,h,g){return h&&Re(m.prototype,h),g&&Re(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Ai=fn(function m(h){var g=this;(function(D,w){if(!(D instanceof w))throw new TypeError("Cannot call a class as a function")})(this,m);var _=function(){g.lastWallClockTime=Ne.now(),h.on("before*",k)},k=function(D){var w=Ne.now(),x=g.lastWallClockTime;g.lastWallClockTime=w,w-x>3e4&&(h.emit("devicesleep",{viewer_time:x}),Object.assign(h.data,{viewer_time:x}),h.send("devicesleep"),h.emit("devicewake",{viewer_time:w}),Object.assign(h.data,{viewer_time:w}),h.send("devicewake"))};h.one("playbackheartbeat",_),h.on("playbackheartbeatend",function(){h.off("before*",k),h.one("playbackheartbeat",_)})}),Ue=q(375),ta=q(655),ki=q.n(ta),Li="muxData",vn=function(){var m;try{m=Ue.parse(ki().get(Li)||"")}catch{m={}}return m},sr=function(m){try{ki().set(Li,Ue.stringify(m),{expires:7300})}catch{}},gn=function(){var m=vn();return m.mux_viewer_id=m.mux_viewer_id||de(),m.msn=m.msn||Math.random(),sr(m),{mux_viewer_id:m.mux_viewer_id,mux_sample_number:m.msn}};function ra(m,h){var g=h.beaconCollectionDomain,_=h.beaconDomain;if(g)return"https://"+g;var k=_||"litix.io";return(m=m||"inferred").match(/^[a-z0-9]+$/)?"https://"+m+"."+k:"https://img.litix.io/a.gif"}var Ri=function(){var m;switch(wi()){case"cellular":m="cellular";break;case"ethernet":m="wired";break;case"wifi":m="wifi";break;case void 0:break;default:m="other"}return m},wi=function(){var m=W().navigator,h=m&&(m.connection||m.mozConnection||m.webkitConnection);return h&&h.type};Ri.getConnectionFromAPI=wi;var ia=Ri,$r=Di({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"}),Zr=Di({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 Di(m){var h={};for(var g in m)m.hasOwnProperty(g)&&(h[m[g]]=g);return h}function ei(m){var h={},g={};return Object.keys(m).forEach(function(_){var k=!1;if(m.hasOwnProperty(_)&&m[_]!==void 0){var D=_.split("_"),w=D[0],x=$r[w];x||(Le.info("Data key word `"+D[0]+"` not expected in "+_),x=w+"_"),D.splice(1).forEach(function(G){G==="url"&&(k=!0),Zr[G]?x+=Zr[G]:Number(G)&&Math.floor(Number(G))===Number(G)?x+=G:(Le.info("Data key word `"+G+"` not expected in "+_),x+="_"+G+"_")}),k?g[x]=m[_]:h[x]=m[_]}}),Object.assign(h,g)}var kt={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Ii=["hb","requestcompleted","requestfailed","requestcanceled"],mn="https://img.litix.io",er=function(m){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=m||mn,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},kt,h)};er.prototype.queueEvent=function(m,h){var g=Object.assign({},h);return(this._eventQueue.length<=this._options.maxQueueLength||m==="eventrateexceeded")&&(this._eventQueue.push(g),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},er.prototype.flushEvents=function(){var m=arguments.length>0&&arguments[0]!==void 0&&arguments[0];m&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},er.prototype.destroy=function(){var m=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,m?this._clearBeaconQueue():this.flushEvents(),W().clearTimeout(this._sendTimeout)},er.prototype._clearBeaconQueue=function(){var m=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,h=this._eventQueue.slice(m);m>0&&Object.assign(h[h.length-1],ei({mux_view_message:"event queue truncated"}));var g=this._createPayload(h);ti(this._beaconUrl,g,!0,function(){})},er.prototype._sendBeaconQueue=function(){var m=this;if(!this._postInFlight){var h=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var g=this._createPayload(h),_=Ne.now();ti(this._beaconUrl,g,!1,function(k,D){D?(m._eventQueue=h.concat(m._eventQueue),m._failureCount+=1,Le.info("Error sending beacon: "+D)):m._failureCount=0,m._roundTripTime=Ne.now()-_,m._postInFlight=!1})}},er.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var m=Math.pow(2,this._failureCount-1);return(1+(m*=Math.random()))*this._options.baseTimeBetweenBeacons},er.prototype._startBeaconSending=function(){var m=this;W().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=W().setTimeout(function(){m._eventQueue.length&&m._sendBeaconQueue(),m._startBeaconSending()},this._getNextBeaconTime()))},er.prototype._createPayload=function(m){var h,g,_,k=this,D={transmission_timestamp:Math.round(Ne.now())};this._roundTripTime&&(D.rtt_ms=Math.round(this._roundTripTime));var w=function(){h=JSON.stringify({metadata:D,events:g||m}),_=h.length/1024},x=function(){return _<=k._options.maxPayloadKBSize};return w(),x()||(Le.info("Payload size is too big ("+_+" kb). Removing unnecessary events."),g=m.filter(function(G){return Ii.indexOf(G.e)===-1}),w()),x()||(Le.info("Payload size still too big ("+_+" kb). Cropping fields.."),g.forEach(function(G){for(var M in G){var Y=G[M];typeof Y=="string"&&Y.length>51200&&(G[M]=Y.substring(0,51200))}}),w()),h};var na=function(m){return m.length<=57344},ti=function(m,h,g,_){if(g&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(m,h))_();else if(W().fetch)W().fetch(m,{method:"POST",body:h,headers:{"Content-Type":"text/plain"},keepalive:na(h)}).then(function(D){return _(null,D.ok?null:"Error")}).catch(function(D){return _(null,D)});else{if(W().XMLHttpRequest){var k=new(W()).XMLHttpRequest;return k.onreadystatechange=function(){if(k.readyState===4)return _(null,k.status!==200?"error":void 0)},k.open("POST",m),k.setRequestHeader("Content-Type","text/plain"),void k.send(h)}_()}},pn=er;function yn(m,h){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var k=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(k!=null){var D,w,x=[],G=!0,M=!1;try{for(k=k.call(g);!(G=(D=k.next()).done)&&(x.push(D.value),!_||x.length!==_);G=!0);}catch(Y){M=!0,w=Y}finally{try{G||k.return==null||k.return()}finally{if(M)throw w}}return x}}(m,h)||function(g,_){if(g){if(typeof g=="string")return En(g,_);var k=Object.prototype.toString.call(g).slice(8,-1);return k==="Object"&&g.constructor&&(k=g.constructor.name),k==="Map"||k==="Set"?Array.from(g):k==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(k)?En(g,_):void 0}}(m,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function En(m,h){(h==null||h>m.length)&&(h=m.length);for(var g=0,_=new Array(h);g<h;g++)_[g]=m[g];return _}function Ci(m,h){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(m);h&&(_=_.filter(function(k){return Object.getOwnPropertyDescriptor(m,k).enumerable})),g.push.apply(g,_)}return g}function Lr(m){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?Ci(Object(g),!0).forEach(function(_){ri(m,_,g[_])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):Ci(Object(g)).forEach(function(_){Object.defineProperty(m,_,Object.getOwnPropertyDescriptor(g,_))})}return m}function tr(m){return tr=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},tr(m)}function Tn(m,h){if(!(m instanceof h))throw new TypeError("Cannot call a class as a function")}function Pi(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function ri(m,h,g){return h in m?Object.defineProperty(m,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[h]=g,m}var bn=["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"],_n=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse"],Sn=["viewstart","error","ended","viewend"],An=function(){function m(k,D){var w,x,G,M,Y,Se,ae,me,oe,pe,Be,Ze,gt,Lt,Ct,ce=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Tn(this,m),ri(this,"previousBeaconData",null),ri(this,"lastEventTime",0),ri(this,"rateLimited",!1),this.mux=k,this.envKey=D,this.options=ce,this.eventQueue=new pn(ra(this.envKey,this.options)),this.sampleRate=(w=this.options.sampleRate)!==null&&w!==void 0?w:1,this.disableCookies=(x=this.options.disableCookies)!==null&&x!==void 0&&x,this.respectDoNotTrack=(G=this.options.respectDoNotTrack)!==null&&G!==void 0&&G,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(M=this.options.platform)===null||M===void 0?void 0:M.name,viewer_application_version:(Y=this.options.platform)===null||Y===void 0?void 0:Y.version,viewer_application_engine:(Se=this.options.platform)===null||Se===void 0?void 0:Se.layout,viewer_device_name:(ae=this.options.platform)===null||ae===void 0?void 0:ae.product,viewer_device_category:"",viewer_device_manufacturer:(me=this.options.platform)===null||me===void 0?void 0:me.manufacturer,viewer_os_family:(oe=this.options.platform)===null||oe===void 0||(pe=oe.os)===null||pe===void 0?void 0:pe.family,viewer_os_architecture:(Be=this.options.platform)===null||Be===void 0||(Ze=Be.os)===null||Ze===void 0?void 0:Ze.architecture,viewer_os_version:(gt=this.options.platform)===null||gt===void 0||(Lt=gt.os)===null||Lt===void 0?void 0:Lt.version,viewer_connection_type:ia(),page_url:W()===null||W()===void 0||(Ct=W().location)===null||Ct===void 0?void 0:Ct.href},this.viewerData=this.disableCookies?{}:gn()}var h,g,_;return h=m,(g=[{key:"send",value:function(k,D){var w;if(k&&D!=null&&D.view_id){if(this.respectDoNotTrack&&St())return Le.info("Not sending `"+k+"` because Do Not Track is enabled");if(!D||tr(D)!=="object")return Le.error("A data object was expected in send() but was not provided");var x,G,M=this.disableCookies?{}:(x=vn(),G=Ne.now(),x.session_start&&(x.sst=x.session_start,delete x.session_start),x.session_id&&(x.sid=x.session_id,delete x.session_id),x.session_expires&&(x.sex=x.session_expires,delete x.session_expires),(!x.sex||x.sex<G)&&(x.sid=de(),x.sst=G),x.sex=G+15e5,sr(x),{session_id:x.sid,session_start:x.sst,session_expires:x.sex}),Y=Lr(Lr(Lr(Lr(Lr({},this.pageLevelData),D),M),this.viewerData),{},{event:k,env_key:this.envKey});Y.user_id&&(Y.viewer_user_id=Y.user_id,delete Y.user_id);var Se=((w=Y.mux_sample_number)!==null&&w!==void 0?w:0)>=this.sampleRate,ae=ei(this._deduplicateBeaconData(k,Y));if(this.lastEventTime=this.mux.utils.now(),Se)return Le.info("Not sending event due to sample rate restriction",k,Y,ae);if(this.envKey||Le.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",k,Y,ae),!this.rateLimited){if(Le.info("Sending event",k,Y,ae),this.rateLimited=!this.eventQueue.queueEvent(k,ae),this.mux.WINDOW_UNLOADING&&k==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&k==="hb"?this.eventQueue.flushEvents(!0):Sn.indexOf(k)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return Y.event="eventrateexceeded",ae=ei(Y),this.eventQueue.queueEvent(Y.event,ae),Le.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(k,D){var w=this,x={},G=D.view_id;if(G==="-1"||k==="viewstart"||k==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)x=Lr({},D),G&&(this.previousBeaconData=x),G&&k==="viewend"&&(this.previousBeaconData=null);else{var M=k.indexOf("request")===0;Object.entries(D).forEach(function(Y){var Se=yn(Y,2),ae=Se[0],me=Se[1];w.previousBeaconData&&(me!==w.previousBeaconData[ae]||bn.indexOf(ae)>-1||w.objectHasChanged(M,ae,me,w.previousBeaconData[ae])||w.eventRequiresKey(k,ae))&&(x[ae]=me,w.previousBeaconData[ae]=me)})}return x}},{key:"objectHasChanged",value:function(k,D,w,x){return!(!k||D.indexOf("request_")!==0||D!=="request_response_headers"&&tr(w)==="object"&&tr(x)==="object"&&Object.keys(w||{}).length===Object.keys(x||{}).length)}},{key:"eventRequiresKey",value:function(k,D){return k==="renditionchange"&&D.indexOf("video_source_")===0||!(D.indexOf("ad_id")!==0||!_n.includes(k))}}])&&Pi(h.prototype,g),_&&Pi(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function mr(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function pr(m,h,g){return h&&mr(m.prototype,h),g&&mr(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var qt=pr(function m(h){(function(M,Y){if(!(M instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,m);var g=0,_=0,k=0,D=0,w=0,x=0,G=0;h.on("requestcompleted",function(M,Y){var Se,ae,me=Y.request_start,oe=Y.request_response_start,pe=Y.request_response_end,Be=Y.request_bytes_loaded;if(D++,oe?(Se=oe-(me!=null?me:0),ae=(pe!=null?pe:0)-oe):ae=(pe!=null?pe:0)-(me!=null?me:0),ae>0&&Be&&Be>0){var Ze=Be/ae*8e3;w++,_+=Be,k+=ae,h.data.view_min_request_throughput=Math.min(h.data.view_min_request_throughput||1/0,Ze),h.data.view_average_request_throughput=_/k*8e3,h.data.view_request_count=D,Se>0&&(g+=Se,h.data.view_max_request_latency=Math.max(h.data.view_max_request_latency||0,Se),h.data.view_average_request_latency=g/w)}}),h.on("requestfailed",function(M,Y){D++,x++,h.data.view_request_count=D,h.data.view_request_failed_count=x}),h.on("requestcanceled",function(M,Y){D++,G++,h.data.view_request_count=D,h.data.view_request_canceled_count=G})});function jt(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function qe(m,h,g){return h&&jt(m.prototype,h),g&&jt(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Vt=qe(function m(h){var g=this;(function(_,k){if(!(_ instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m),h.on("before*",function(_,k){var D=k.viewer_time,w=Ne.now(),x=g._lastEventTime;if(g._lastEventTime=w,x&&w-x>36e5){var G=Object.keys(h.data).reduce(function(M,Y){return Y.indexOf("video_")===0?Object.assign(M,function(Se,ae,me){return ae in Se?Object.defineProperty(Se,ae,{value:me,enumerable:!0,configurable:!0,writable:!0}):Se[ae]=me,Se}({},Y,h.data[Y])):M},{});h.mux.log.info("Received event after at least an hour inactivity, creating a new view"),h.emit("viewinit",Object.assign({viewer_time:D},G)),h.playbackHeartbeat._playheadShouldBeProgressing&&_.type!=="play"&&_.type!=="adbreakstart"&&(h.emit("play",{viewer_time:D}),_.type!=="playing"&&h.emit("playing",{viewer_time:D}))}})});function Yt(m){return Yt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},Yt(m)}function kn(m,h){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var k=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(k!=null){var D,w,x=[],G=!0,M=!1;try{for(k=k.call(g);!(G=(D=k.next()).done)&&(x.push(D.value),!_||x.length!==_);G=!0);}catch(Y){M=!0,w=Y}finally{try{G||k.return==null||k.return()}finally{if(M)throw w}}return x}}(m,h)||function(g,_){if(g){if(typeof g=="string")return ii(g,_);var k=Object.prototype.toString.call(g).slice(8,-1);return k==="Object"&&g.constructor&&(k=g.constructor.name),k==="Map"||k==="Set"?Array.from(g):k==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(k)?ii(g,_):void 0}}(m,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function ii(m,h){(h==null||h>m.length)&&(h=m.length);for(var g=0,_=new Array(h);g<h;g++)_[g]=m[g];return _}function Ln(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function ni(m,h){return ni=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,_){return g.__proto__=_,g},ni(m,h)}function Rn(m){var h=function(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var g,_=or(m);if(h){var k=or(this).constructor;g=Reflect.construct(_,arguments,k)}else g=_.apply(this,arguments);return Rr(this,g)}}function Rr(m,h){if(h&&(Yt(h)==="object"||typeof h=="function"))return h;if(h!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return at(m)}function at(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function or(m){return or=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},or(m)}var aa=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],Ur=function(m){(function(w,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function");w.prototype=Object.create(x&&x.prototype,{constructor:{value:w,writable:!0,configurable:!0}}),Object.defineProperty(w,"prototype",{writable:!1}),x&&ni(w,x)})(D,m);var h,g,_,k=Rn(D);function D(w,x,G){var M;(function(oe,pe){if(!(oe instanceof pe))throw new TypeError("Cannot call a class as a function")})(this,D),(M=k.call(this)).DOM_CONTENT_LOADED_EVENT_END=Z.domContentLoadedEventEnd(),M.NAVIGATION_START=Z.navigationStart(),M.mux=w,M.id=x,(G=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(oe){return oe}},G)).data=G.data||{},G.data.property_key&&(G.data.env_key=G.data.property_key,delete G.data.property_key),Le.setLevel(G.debug?"debug":"warn"),M.getPlayheadTime=G.getPlayheadTime,M.getStateData=G.getStateData||function(){return{}},M.getAdData=G.getAdData||function(){},M.minimumRebufferDuration=G.minimumRebufferDuration,M.sustainedRebufferThreshold=G.sustainedRebufferThreshold,M.playbackHeartbeatTime=G.playbackHeartbeatTime,M.disableRebufferTracking=G.disableRebufferTracking,M.disableRebufferTracking&&M.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),M.disablePlayheadRebufferTracking=G.disablePlayheadRebufferTracking,M.errorTranslator=G.errorTranslator,M.playbackEventDispatcher=new An(w,G.data.env_key,G),M.data={player_instance_id:de(),mux_sample_rate:G.sampleRate,beacon_domain:G.beaconCollectionDomain?G.beaconCollectionDomain:G.beaconDomain},M.data.view_sequence_number=1,M.data.player_sequence_number=1,M.oldEmit=M.emit,M.emit=function(oe,pe){pe=Object.assign({viewer_time:this.mux.utils.now()},pe),this.oldEmit(oe,pe)};var Y=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(at(M));M.on("viewinit",function(oe,pe){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,pe),this._initializeViewData(),this.one("play",Y),this.one("adbreakstart",Y)});var Se=function(oe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",oe)}.bind(at(M));if(M.on("videochange",function(oe,pe){Se(pe)}),M.on("programchange",function(oe,pe){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(pe,{view_program_changed:!0})),Y(),this.emit("play"),this.emit("playing")}),M.on("fragmentchange",function(oe,pe){this.currentFragmentPDT=pe.currentFragmentPDT,this.currentFragmentStart=pe.currentFragmentStart}),M.on("destroy",M.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ae=function(){var oe=M.data.view_start!==void 0;M.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",oe&&M.mux.WINDOW_HIDDEN&&(M.data.player_is_paused||M.emit("hb"))};window.addEventListener("visibilitychange",ae,!1);var me=function(oe){oe.persisted||M.destroy()};window.addEventListener("pagehide",me,!1),M.on("destroy",function(){window.removeEventListener("visibilitychange",ae),window.removeEventListener("pagehide",me)})}return M.on("playerready",function(oe,pe){Object.assign(this.data,pe)}),aa.forEach(function(oe){M.on(oe,function(pe,Be){oe.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,Be),this._sanitizeData()}),M.on("after"+oe,function(){(oe!=="error"||this.errorTracker.viewErrored)&&this.send(oe)})}),M.on("viewend",function(oe,pe){Object.assign(M.data,pe)}),M.one("playerready",function(oe){var pe=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=pe-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),M.longResumeTracker=new Vt(at(M)),M.errorTracker=new At(at(M)),new Ai(at(M)),M.seekingTracker=new Zn(at(M)),M.playheadTime=new Sr(at(M)),M.playbackHeartbeat=new Ye(at(M)),new Jn(at(M)),M.watchTimeTracker=new ht(at(M)),new Ht(at(M)),M.adTracker=new ea(at(M)),new ar(at(M)),new kr(at(M)),new Fr(at(M)),new hn(at(M)),new qt(at(M)),G.hlsjs&&M.addHLSJS(G),G.dashjs&&M.addDashJS(G),M.emit("viewinit",G.data),M}return h=D,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(w){if(this.data.view_id){var x=Object.assign({},this.data);if(x.video_source_is_live===void 0&&(x.player_source_duration===1/0||x.video_source_duration===1/0?x.video_source_is_live=!0:(x.player_source_duration>0||x.video_source_duration>0)&&(x.video_source_is_live=!1)),x.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){x[Se]=void 0}),x.video_source_url=x.video_source_url||x.player_source_url,x.video_source_url){var G=kn(T(x.video_source_url),2),M=G[0],Y=G[1];x.video_source_domain=Y,x.video_source_hostname=M}delete x.ad_request_id,this.playbackEventDispatcher.send(w,x),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),w==="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 w=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(x){var G=parseInt(w.data[x],10);w.data[x]=isNaN(G)?void 0:G}),["player_source_url","video_source_url"].forEach(function(x){if(w.data[x]){var G=w.data[x].toLowerCase();G.indexOf("data:")!==0&&G.indexOf("blob:")!==0||(w.data[x]="MSE style URL")}})}},{key:"_resetVideoData",value:function(w,x){var G=this;Object.keys(this.data).forEach(function(M){M.indexOf("video_")===0&&delete G.data[M]})}},{key:"_resetViewData",value:function(){var w=this;Object.keys(this.data).forEach(function(x){x.indexOf("view_")===0&&delete w.data[x]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(w,x){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var w=this,x=this.data.view_id=de(),G=function(){x===w.data.view_id&&N(w.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",G):G()}},{key:"_restartHeartBeat",value:function(){var w=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){w.data.player_is_paused||w.emit("hb")},1e4))}},{key:"addHLSJS",value:function(w){w.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=w.hlsjs,function(x,G,M){var Y=arguments.length>4?arguments[4]:void 0,Se=x.log,ae=x.utils.secondsToMs,me=function(Ge){var $,he=parseInt(Y.version);return he===1&&Ge.programDateTime!==null&&($=Ge.programDateTime),he===0&&Ge.pdt!==null&&($=Ge.pdt),$};if(Z.exists()){var oe=function(Ge,$){return x.emit(G,Ge,$)},pe=function(Ge,$){var he=$.levels,te=$.audioTracks,we=$.url,Me=$.stats,st=$.networkDetails,Rt=$.sessionData,lt={},Et={};he.forEach(function(tt,It){lt[It]={width:tt.width,height:tt.height,bitrate:tt.bitrate,attrs:tt.attrs}}),te.forEach(function(tt,It){Et[It]={name:tt.name,language:tt.lang,bitrate:tt.bitrate}});var Ve=ze(Me),fe=Ve.bytesLoaded,Wt=Ve.requestStart,zt=Ve.responseStart,Pt=Ve.responseEnd;oe("requestcompleted",Qe(Qe({},ut(Rt)),{},{request_event_type:Ge,request_bytes_loaded:fe,request_start:Wt,request_response_start:zt,request_response_end:Pt,request_type:"manifest",request_hostname:ie(we),request_response_headers:wt(st),request_rendition_lists:{media:lt,audio:Et,video:{}}}))};M.on(Y.Events.MANIFEST_LOADED,pe);var Be=function(Ge,$){var he=$.details,te=$.level,we=$.networkDetails,Me=$.stats,st=ze(Me),Rt=st.bytesLoaded,lt=st.requestStart,Et=st.responseStart,Ve=st.responseEnd,fe=he.fragments[he.fragments.length-1],Wt=me(fe)+ae(fe.duration);oe("requestcompleted",{request_event_type:Ge,request_bytes_loaded:Rt,request_start:lt,request_response_start:Et,request_response_end:Ve,request_current_level:te,request_type:"manifest",request_hostname:ie(he.url),request_response_headers:wt(we),video_holdback:he.holdBack&&ae(he.holdBack),video_part_holdback:he.partHoldBack&&ae(he.partHoldBack),video_part_target_duration:he.partTarget&&ae(he.partTarget),video_target_duration:he.targetduration&&ae(he.targetduration),video_source_is_live:he.live,player_manifest_newest_program_time:isNaN(Wt)?void 0:Wt})};M.on(Y.Events.LEVEL_LOADED,Be);var Ze=function(Ge,$){var he=$.details,te=$.networkDetails,we=$.stats,Me=ze(we),st=Me.bytesLoaded,Rt=Me.requestStart,lt=Me.responseStart,Et=Me.responseEnd;oe("requestcompleted",{request_event_type:Ge,request_bytes_loaded:st,request_start:Rt,request_response_start:lt,request_response_end:Et,request_type:"manifest",request_hostname:ie(he.url),request_response_headers:wt(te)})};M.on(Y.Events.AUDIO_TRACK_LOADED,Ze);var gt=function(Ge,$){var he=$.stats,te=$.networkDetails,we=$.frag;he=he||we.stats;var Me=ze(he),st=Me.bytesLoaded,Rt=Me.requestStart,lt=Me.responseStart,Et=Me.responseEnd,Ve=te?wt(te):void 0,fe={request_event_type:Ge,request_bytes_loaded:st,request_start:Rt,request_response_start:lt,request_response_end:Et,request_hostname:te?ie(te.responseURL):void 0,request_id:Ve?je(Ve):void 0,request_response_headers:Ve,request_media_duration:we.duration,request_url:te==null?void 0:te.responseURL};we.type==="main"?(fe.request_type="media",fe.request_current_level=we.level,fe.request_video_width=(M.levels[we.level]||{}).width,fe.request_video_height=(M.levels[we.level]||{}).height,fe.request_labeled_bitrate=(M.levels[we.level]||{}).bitrate):fe.request_type=we.type,oe("requestcompleted",fe)};M.on(Y.Events.FRAG_LOADED,gt);var Lt=function(Ge,$){var he=$.frag,te=he.start,we={currentFragmentPDT:me(he),currentFragmentStart:ae(te)};oe("fragmentchange",we)};M.on(Y.Events.FRAG_CHANGED,Lt);var Ct=function(Ge,$){var he=$.type,te=$.details,we=$.response,Me=$.fatal,st=$.frag,Rt=$.networkDetails,lt=(st==null?void 0:st.url)||$.url||"",Et=Rt?wt(Rt):void 0;if(te!==Y.ErrorDetails.MANIFEST_LOAD_ERROR&&te!==Y.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&te!==Y.ErrorDetails.FRAG_LOAD_ERROR&&te!==Y.ErrorDetails.FRAG_LOAD_TIMEOUT&&te!==Y.ErrorDetails.LEVEL_LOAD_ERROR&&te!==Y.ErrorDetails.LEVEL_LOAD_TIMEOUT&&te!==Y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&te!==Y.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&te!==Y.ErrorDetails.SUBTITLE_LOAD_ERROR&&te!==Y.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&te!==Y.ErrorDetails.KEY_LOAD_ERROR&&te!==Y.ErrorDetails.KEY_LOAD_TIMEOUT||oe("requestfailed",{request_error:te,request_url:lt,request_hostname:ie(lt),request_id:Et?je(Et):void 0,request_type:te===Y.ErrorDetails.FRAG_LOAD_ERROR||te===Y.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":te===Y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||te===Y.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":te===Y.ErrorDetails.SUBTITLE_LOAD_ERROR||te===Y.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":te===Y.ErrorDetails.KEY_LOAD_ERROR||te===Y.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:we==null?void 0:we.code,request_error_text:we==null?void 0:we.text}),Me){var Ve,fe="".concat(lt?"url: ".concat(lt,`
|
|
5
|
+
`):"")+"".concat(we&&(we.code||we.text)?"response: ".concat(we.code,", ").concat(we.text,`
|
|
6
|
+
`):"")+"".concat($.reason?"failure reason: ".concat($.reason,`
|
|
7
|
+
`):"")+"".concat($.level?"level: ".concat($.level,`
|
|
8
|
+
`):"")+"".concat($.parent?"parent stream controller: ".concat($.parent,`
|
|
9
|
+
`):"")+"".concat($.buffer?"buffer length: ".concat($.buffer,`
|
|
10
|
+
`):"")+"".concat($.error?"error: ".concat($.error,`
|
|
11
|
+
`):"")+"".concat($.event?"event: ".concat($.event,`
|
|
12
|
+
`):"")+"".concat($.err?"error message: ".concat((Ve=$.err)===null||Ve===void 0?void 0:Ve.message,`
|
|
13
|
+
`):"");oe("error",{player_error_code:he,player_error_message:te,player_error_context:fe})}};M.on(Y.Events.ERROR,Ct);var ce=function(Ge,$){var he=$.frag,te=he&&he._url||"";oe("requestcanceled",{request_event_type:Ge,request_url:te,request_type:"media",request_hostname:ie(te)})};M.on(Y.Events.FRAG_LOAD_EMERGENCY_ABORTED,ce);var et=function(Ge,$){var he=$.level,te=M.levels[he];if(te&&te.attrs&&te.attrs.BANDWIDTH){var we,Me=te.attrs.BANDWIDTH,st=parseFloat(te.attrs["FRAME-RATE"]);isNaN(st)||(we=st),Me?oe("renditionchange",{video_source_fps:we,video_source_bitrate:Me,video_source_width:te.width,video_source_height:te.height,video_source_rendition_name:te.name,video_source_codec:te==null?void 0:te.videoCodec}):Se.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};M.on(Y.Events.LEVEL_SWITCHED,et),M._stopMuxMonitor=function(){M.off(Y.Events.MANIFEST_LOADED,pe),M.off(Y.Events.LEVEL_LOADED,Be),M.off(Y.Events.AUDIO_TRACK_LOADED,Ze),M.off(Y.Events.FRAG_LOADED,gt),M.off(Y.Events.FRAG_CHANGED,Lt),M.off(Y.Events.ERROR,Ct),M.off(Y.Events.FRAG_LOAD_EMERGENCY_ABORTED,ce),M.off(Y.Events.LEVEL_SWITCHED,et),M.off(Y.Events.DESTROYING,M._stopMuxMonitor),delete M._stopMuxMonitor},M.on(Y.Events.DESTROYING,M._stopMuxMonitor)}else Se.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,w.hlsjs,{},w.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var w;this.hlsjs&&((w=this.hlsjs)&&typeof w._stopMuxMonitor=="function"&&w._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(w){w.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=w.dashjs,function(x,G,M){var Y=x.log;if(M&&M.on){var Se=function(ce,et){return x.emit(G,ce,et)},ae=function(ce){var et=ce.type,Ge=(ce.data||{}).url;Se("requestcompleted",{request_event_type:et,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:ie(Ge),request_url:Ge})};M.on("manifestLoaded",ae);var me={},oe=function(ce){var et=ce.type,Ge=ce.fragmentModel,$=(ce.chunk||{}).mediaInfo||{},he=$.type,te=$.bitrateList,we={};(te=te||[]).forEach(function(Pt,tt){we[tt]={},we[tt].width=Pt.width,we[tt].height=Pt.height,we[tt].bitrate=Pt.bandwidth,we[tt].attrs={}}),he==="video"?me.video=we:he==="audio"?me.audio=we:me.media=we;var Me=Je(Ge,M),st=Me.requestStart,Rt=Me.requestResponseStart,lt=Me.requestResponseEnd,Et=Me.requestResponseHeaders,Ve=Me.requestMediaDuration,fe=Me.requestHostname,Wt=Me.requestUrl,zt=Me.requestId;Se("requestcompleted",{request_event_type:et,request_start:st,request_response_start:Rt,request_response_end:lt,request_bytes_loaded:-1,request_type:he+"_init",request_response_headers:Et,request_hostname:fe,request_id:zt,request_url:Wt,request_media_duration:Ve,request_rendition_lists:me})};M.on("initFragmentLoaded",oe);var pe=function(ce){var et=ce.type,Ge=ce.fragmentModel,$=ce.chunk||{},he=$.mediaInfo,te=$.start,we=(he||{}).type,Me=Je(Ge,M),st=Me.requestStart,Rt=Me.requestResponseStart,lt=Me.requestResponseEnd,Et=Me.requestBytesLoaded,Ve=Me.requestResponseHeaders,fe=Me.requestMediaDuration,Wt=Me.requestHostname,zt=Me.requestUrl,Pt=Me.requestId,tt=nr(we,M),It=tt.currentLevel,hi=tt.renditionWidth,qr=tt.renditionHeight,Dr=tt.renditionBitrate;Se("requestcompleted",{request_event_type:et,request_start:st,request_response_start:Rt,request_response_end:lt,request_bytes_loaded:Et,request_type:we,request_response_headers:Ve,request_hostname:Wt,request_id:Pt,request_url:zt,request_media_start_time:te,request_media_duration:fe,request_current_level:It,request_labeled_bitrate:Dr,request_video_width:hi,request_video_height:qr})};M.on("mediaFragmentLoaded",pe);var Be={video:void 0,audio:void 0,totalBitrate:void 0},Ze=function(){if(Be.video&&typeof Be.video.bitrate=="number"){if(Be.video.width&&Be.video.height){var ce=Be.video.bitrate;return Be.audio&&typeof Be.audio.bitrate=="number"&&(ce+=Be.audio.bitrate),ce!==Be.totalBitrate?(Be.totalBitrate=ce,{video_source_bitrate:ce,video_source_height:Be.video.height,video_source_width:Be.video.width,video_source_codec:Gt(Be.video.codec)}):void 0}Y.warn("have bitrate info for video but missing width/height")}},gt=function(ce,et,Ge){if(typeof ce.newQuality=="number"){var $=ce.mediaType;if($==="audio"||$==="video"){var he=M.getBitrateInfoListFor($).find(function(we){return we.qualityIndex===ce.newQuality});if(he&&typeof he.bitrate=="number"){Be[$]=yt(yt({},he),{},{codec:M.getCurrentTrackFor($).codec});var te=Ze();te&&Se("renditionchange",te)}else Y.warn("missing bitrate info for ".concat($))}}else Y.warn("missing evt.newQuality in qualityChangeRendered event",ce)};M.on("qualityChangeRendered",gt);var Lt=function(ce){var et=ce.request,Ge=ce.mediaType;Se("requestcanceled",{request_event_type:(et=et||{}).type+"_"+et.action,request_url:et.url,request_type:Ge,request_hostname:ie(et.url)})};M.on("fragmentLoadingAbandoned",Lt);var Ct=function(ce){var et,Ge,$=ce.error,he=($==null||(et=$.data)===null||et===void 0?void 0:et.request)||{},te=($==null||(Ge=$.data)===null||Ge===void 0?void 0:Ge.response)||{};($==null?void 0:$.code)===27&&Se("requestfailed",{request_error:he.type+"_"+he.action,request_url:he.url,request_hostname:ie(he.url),request_type:he.mediaType,request_error_code:te.status,request_error_text:te.statusText});var we="".concat(he!=null&&he.url?"url: ".concat(he.url,`
|
|
14
|
+
`):"")+"".concat(te!=null&&te.status||te!=null&&te.statusText?"response: ".concat(te==null?void 0:te.status,", ").concat(te==null?void 0:te.statusText,`
|
|
15
|
+
`):"");Se("error",{player_error_code:$==null?void 0:$.code,player_error_message:$==null?void 0:$.message,player_error_context:we})};M.on("error",Ct),M._stopMuxMonitor=function(){M.off("manifestLoaded",ae),M.off("initFragmentLoaded",oe),M.off("mediaFragmentLoaded",pe),M.off("qualityChangeRendered",gt),M.off("error",Ct),M.off("fragmentLoadingAbandoned",Lt),delete M._stopMuxMonitor}}else Y.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,w.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var w;this.dashjs&&((w=this.dashjs)&&typeof w._stopMuxMonitor=="function"&&w._stopMuxMonitor(),this.dashjs=void 0)}}],g&&Ln(h.prototype,g),_&&Ln(h,_),Object.defineProperty(h,"prototype",{writable:!1}),D}(z),xi=Ur,ai=q(153),yr=q.n(ai);function Oi(m){return Oi=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},Oi(m)}function wn(m,h){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var k=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(k!=null){var D,w,x=[],G=!0,M=!1;try{for(k=k.call(g);!(G=(D=k.next()).done)&&(x.push(D.value),!_||x.length!==_);G=!0);}catch(Y){M=!0,w=Y}finally{try{G||k.return==null||k.return()}finally{if(M)throw w}}return x}}(m,h)||function(g,_){if(g){if(typeof g=="string")return si(g,_);var k=Object.prototype.toString.call(g).slice(8,-1);return k==="Object"&&g.constructor&&(k=g.constructor.name),k==="Map"||k==="Set"?Array.from(g):k==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(k)?si(g,_):void 0}}(m,h)||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 si(m,h){(h==null||h>m.length)&&(h=m.length);for(var g=0,_=new Array(h);g<h;g++)_[g]=m[g];return _}var lr,sa=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],oa={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};W()&&W().WeakMap&&(lr=new WeakMap);var Dn="#EXT-X-TARGETDURATION",Br="#EXT-X-PART-INF",Mi="#EXT-X-SERVER-CONTROL",In="#EXTINF",la="#EXT-X-PROGRAM-DATE-TIME",Cn="#EXT-X-VERSION",Fi="#EXT-X-SESSION-DATA",Gr=function(m){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(m),this.manifest};Gr.prototype.process=function(m){var h;for(this.buffer+=m,h=this.buffer.indexOf(`
|
|
6
17
|
`);h>-1;h=this.buffer.indexOf(`
|
|
7
|
-
`))this.processLine(this.buffer.substring(0,h)),this.buffer=this.buffer.substring(h+1)},
|
|
8
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Tt(p,h){(h==null||h>p.length)&&(h=p.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=p[f];return y}var gr={},Xr=function p(h){var f=arguments;typeof h=="string"?p.hasOwnProperty(h)?R().setTimeout(function(){f=Array.prototype.splice.call(f,1),p[h].apply(null,f)},0):q.warn("`"+h+"` is an unknown task"):typeof h=="function"?R().setTimeout(function(){h(p)},0):q.warn("`"+h+"` is invalid.")},vn={loaded:J.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(p,h){return function(f,y,b){var M=Ii(me(y),3),I=M[0],Y=M[1],he=M[2],ee=f.log,Me=f.utils.getComputedStyle,ut=f.utils.secondsToMs;if(!I)return ee.error("No element was found with the `"+Y+"` query selector.");if(he!=="video"&&he!=="audio")return ee.error("The element of `"+Y+"` was not a media element.");I.mux&&(I.mux.destroy(),delete I.mux,ee.warn("Already monitoring this video element, replacing existing event listeners")),(b=K()({automaticErrorTracking:!0},b)).data=K()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:f.VERSION},b.data),b.getPlayheadTime=function(){return ut(I.currentTime)},b.getStateData=function(){var st,Qe,ot=this.hlsjs&&this.hlsjs.url,Ot=this.dashjs&&ri(this.dashjs.getSource==="function")&&this.dashjs.getSource(),qt={player_is_paused:I.paused,player_playhead_time:ut(I.currentTime),player_width:parseInt(Me(I,"width")),player_height:parseInt(Me(I,"height")),player_autoplay_on:I.autoplay,player_preload_on:I.preload,player_language_code:I.lang,player_is_fullscreen:ti()&&!!(ti().fullscreenElement||ti().webkitFullscreenElement||ti().mozFullScreenElement||ti().msFullscreenElement),video_poster_url:I.poster,video_source_url:ot||Ot||I.currentSrc,video_source_duration:ut(I.duration),video_source_height:I.videoHeight,video_source_width:I.videoWidth,view_dropped_frame_count:(st=I)===null||st===void 0||(Qe=st.getVideoPlaybackQuality)===null||Qe===void 0?void 0:Qe.call(st).droppedVideoFrames},rr=b.getPlayheadTime();if(I.getStartDate&&rr>0){var ur=I.getStartDate();if(ur&&typeof ur.getTime=="function"&&ur.getTime()){var bt=ur.getTime();if(qt.player_program_time=bt+rr,I.seekable.length>0){var Zt=bt+I.seekable.end(I.seekable.length-1);qt.player_live_edge_program_time=Zt}}}return qt},I.mux=I.mux||{},I.mux.deleted=!1,I.mux.emit=function(st,Qe){f.emit(Y,st,Qe)};var Ze=function(){ee.error("The monitor for this video element has already been destroyed.")};I.mux.destroy=function(){Object.keys(I.mux.listeners).forEach(function(st){I.removeEventListener(st,I.mux.listeners[st],!1)}),delete I.mux.listeners,I.mux.destroy=Ze,I.mux.swapElement=Ze,I.mux.emit=Ze,I.mux.addHLSJS=Ze,I.mux.addDashJS=Ze,I.mux.removeHLSJS=Ze,I.mux.removeDashJS=Ze,I.mux.deleted=!0,f.emit(Y,"destroy")},I.mux.swapElement=function(st){var Qe=Ii(me(st),3),ot=Qe[0],Ot=Qe[1],qt=Qe[2];return ot?qt!=="video"&&qt!=="audio"?f.log.error("The element of `"+Ot+"` was not a media element."):(ot.muxId=I.muxId,delete I.muxId,ot.mux=ot.mux||{},ot.mux.listeners=K()({},I.mux.listeners),delete I.mux.listeners,Object.keys(ot.mux.listeners).forEach(function(rr){I.removeEventListener(rr,ot.mux.listeners[rr],!1),ot.addEventListener(rr,ot.mux.listeners[rr],!1)}),ot.mux.swapElement=I.mux.swapElement,ot.mux.destroy=I.mux.destroy,delete I.mux,void(I=ot)):f.log.error("No element was found with the `"+Ot+"` query selector.")},I.mux.addHLSJS=function(st){f.addHLSJS(Y,st)},I.mux.addDashJS=function(st){f.addDashJS(Y,st)},I.mux.removeHLSJS=function(){f.removeHLSJS(Y)},I.mux.removeDashJS=function(){f.removeDashJS(Y)},f.init(Y,b),f.emit(Y,"playerready"),I.paused||(f.emit(Y,"play"),I.readyState>2&&f.emit(Y,"playing")),I.mux.listeners={},Ci.forEach(function(st){(st!=="error"||b.automaticErrorTracking)&&(I.mux.listeners[st]=function(){var Qe={};if(st==="error"){if(!I.error||I.error.code===1)return;Qe.player_error_code=I.error.code,Qe.player_error_message=Ln[I.error.code]||I.error.message}f.emit(Y,st,Qe)},I.addEventListener(st,I.mux.listeners[st],!1))})}(Xr,p,h)},destroyMonitor:function(p){var h=Nn(me(p),1)[0];h&&h.mux&&typeof h.mux.destroy=="function"?h.mux.destroy():q.error("A video element monitor for `"+p+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(p,h){var f=L(p);gr[f]?gr[f].addHLSJS(h):q.error("A monitor for `"+f+"` has not been initialized.")},addDashJS:function(p,h){var f=L(p);gr[f]?gr[f].addDashJS(h):q.error("A monitor for `"+f+"` has not been initialized.")},removeHLSJS:function(p){var h=L(p);gr[h]?gr[h].removeHLSJS():q.error("A monitor for `"+h+"` has not been initialized.")},removeDashJS:function(p){var h=L(p);gr[h]?gr[h].removeDashJS():q.error("A monitor for `"+h+"` has not been initialized.")},init:function(p,h){ye()&&h&&h.respectDoNotTrack&&q.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var f=L(p);gr[f]=new Br(Xr,f,h)},emit:function(p,h,f){var y=L(p);gr[y]?(gr[y].emit(h,f),h==="destroy"&&delete gr[y]):q.error("A monitor for `"+y+"` has not been initialized.")},checkDoNotTrack:ye,log:q,utils:Mi,events:Fi,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Xr,vn),R()!==void 0&&typeof R().addEventListener=="function"&&R().addEventListener("pagehide",function(p){p.persisted||(Xr.WINDOW_UNLOADING=!0)},!1);var Un=Xr},655:function(W,B,j){var re,R;function g(k){return g=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(L){return typeof L}:function(L){return L&&typeof Symbol=="function"&&L.constructor===Symbol&&L!==Symbol.prototype?"symbol":typeof L},g(k);}(function(k){var L=!1;if((R=typeof(re=k)=="function"?re.call(B,j,B,W):re)===void 0||(W.exports=R),L=!0,g(B)==="object"&&(W.exports=k(),L=!0),!L){var me=window.Cookies,ne=window.Cookies=k();ne.noConflict=function(){return window.Cookies=me,ne}}})(function(){var k=function(){for(var L=0,me={};L<arguments.length;L++){var ne=arguments[L];for(var ce in ne)me[ce]=ne[ce]}return me};return function L(me){function ne(ce,we,q){var ye;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(q=k({path:"/"},ne.defaults,q)).expires=="number"){var J=new Date;J.setMilliseconds(J.getMilliseconds()+864e5*q.expires),q.expires=J}try{ye=JSON.stringify(we),/^[\{\[]/.test(ye)&&(we=ye)}catch{}return we=me.write?me.write(we,ce):encodeURIComponent(String(we)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),ce=(ce=(ce=encodeURIComponent(String(ce))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[ce,"=",we,q.expires?"; expires="+q.expires.toUTCString():"",q.path?"; path="+q.path:"",q.domain?"; domain="+q.domain:"",q.secure?"; secure":""].join("")}ce||(ye={});for(var oe=document.cookie?document.cookie.split("; "):[],K=/(%[0-9A-Z]{2})+/g,Ee=0;Ee<oe.length;Ee++){var ke=oe[Ee].split("="),Ne=ke.slice(1).join("=");Ne.charAt(0)==='"'&&(Ne=Ne.slice(1,-1));try{var V=ke[0].replace(K,decodeURIComponent);if(Ne=me.read?me.read(Ne,V):me(Ne,V)||Ne.replace(K,decodeURIComponent),this.json)try{Ne=JSON.parse(Ne)}catch{}if(ce===V){ye=Ne;break}ce||(ye[V]=Ne)}catch{}}return ye}}return ne.set=ne,ne.get=function(ce){return ne.call(ne,ce)},ne.getJSON=function(){return ne.apply({json:!0},[].slice.call(arguments))},ne.defaults={},ne.remove=function(ce,we){ne(ce,"",k(we,{expires:-1}))},ne.withConverter=L,ne}(function(){})})},153:function(W,B,j){var re,R=j.g!==void 0?j.g:typeof window!="undefined"?window:{},g=j(558);typeof document!="undefined"?re=document:(re=R["__GLOBAL_DOCUMENT_CACHE@4"])||(re=R["__GLOBAL_DOCUMENT_CACHE@4"]=g),W.exports=re},48:function(W,B,j){var re;re=typeof window!="undefined"?window:j.g!==void 0?j.g:typeof self!="undefined"?self:{},W.exports=re},678:function(W){var B=9007199254740991,j="[object Arguments]",re="[object Function]",R="[object GeneratorFunction]",g=/^(?:0|[1-9]\d*)$/;function k(z,$,Le){switch(Le.length){case 0:return z.call($);case 1:return z.call($,Le[0]);case 2:return z.call($,Le[0],Le[1]);case 3:return z.call($,Le[0],Le[1],Le[2])}return z.apply($,Le)}var L,me,ne=Object.prototype,ce=ne.hasOwnProperty,we=ne.toString,q=ne.propertyIsEnumerable,ye=(L=Object.keys,me=Object,function(z){return L(me(z))}),J=Math.max,oe=!q.call({valueOf:1},"valueOf");function K(z,$){var Le=E(z)||function(qe){return function(at){return function(ie){return!!ie&&typeof ie=="object"}(at)&&U(at)}(qe)&&ce.call(qe,"callee")&&(!q.call(qe,"callee")||we.call(qe)==j)}(z)?function(qe,at){for(var ie=-1,pe=Array(qe);++ie<qe;)pe[ie]=at(ie);return pe}(z.length,String):[],Oe=Le.length,xe=!!Oe;for(var be in z)!$&&!ce.call(z,be)||xe&&(be=="length"||ke(be,Oe))||Le.push(be);return Le}function Ee(z,$,Le){var Oe=z[$];ce.call(z,$)&&V(Oe,Le)&&(Le!==void 0||$ in z)||(z[$]=Le)}function ke(z,$){return!!($=$==null?B:$)&&(typeof z=="number"||g.test(z))&&z>-1&&z%1==0&&z<$}function Ne(z){var $=z&&z.constructor;return z===(typeof $=="function"&&$.prototype||ne)}function V(z,$){return z===$||z!=z&&$!=$}var E=Array.isArray;function U(z){return z!=null&&function($){return typeof $=="number"&&$>-1&&$%1==0&&$<=B}(z.length)&&!function($){var Le=D($)?we.call($):"";return Le==re||Le==R}(z)}function D(z){var $=typeof z;return!!z&&($=="object"||$=="function")}var de,Se=(de=function(z,$){if(oe||Ne($)||U($))(function(Oe,xe,be,qe){be||(be={});for(var at=-1,ie=xe.length;++at<ie;){var pe=xe[at],se=qe?qe(be[pe],Oe[pe],pe,be,Oe):void 0;Ee(be,pe,se===void 0?Oe[pe]:se)}})($,function(Oe){return U(Oe)?K(Oe):function(xe){if(!Ne(xe))return ye(xe);var be=[];for(var qe in Object(xe))ce.call(xe,qe)&&qe!="constructor"&&be.push(qe);return be}(Oe)}($),z);else for(var Le in $)ce.call($,Le)&&Ee(z,Le,$[Le])},function(z,$){return $=J($===void 0?z.length-1:$,0),function(){for(var Le=arguments,Oe=-1,xe=J(Le.length-$,0),be=Array(xe);++Oe<xe;)be[Oe]=Le[$+Oe];Oe=-1;for(var qe=Array($+1);++Oe<$;)qe[Oe]=Le[Oe];return qe[$]=be,k(z,this,qe)}}(function(z,$){var Le=-1,Oe=$.length,xe=Oe>1?$[Oe-1]:void 0,be=Oe>2?$[2]:void 0;for(xe=de.length>3&&typeof xe=="function"?(Oe--,xe):void 0,be&&function(at,ie,pe){if(!D(pe))return!1;var se=typeof ie;return!!(se=="number"?U(pe)&&ke(ie,pe.length):se=="string"&&ie in pe)&&V(pe[ie],at)}($[0],$[1],be)&&(xe=Oe<3?void 0:xe,Oe=1),z=Object(z);++Le<Oe;){var qe=$[Le];qe&&de(z,qe,Le,xe)}return z}));W.exports=Se},640:function(W,B,j){var re,R;(function(g,k){"use strict";re=function(){var L=function(){},me="undefined",ne=typeof window!==me&&typeof window.navigator!==me&&/Trident\/|MSIE /.test(window.navigator.userAgent),ce=["trace","debug","info","warn","error"];function we(E,U){var D=E[U];if(typeof D.bind=="function")return D.bind(E);try{return Function.prototype.bind.call(D,E)}catch{return function(){return Function.prototype.apply.apply(D,[E,arguments])}}}function q(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function ye(E){return E==="debug"&&(E="log"),typeof console!==me&&(E==="trace"&&ne?q:console[E]!==void 0?we(console,E):console.log!==void 0?we(console,"log"):L)}function J(E,U){for(var D=0;D<ce.length;D++){var de=ce[D];this[de]=D<E?L:this.methodFactory(de,E,U)}this.log=this.debug}function oe(E,U,D){return function(){typeof console!==me&&(J.call(this,U,D),this[E].apply(this,arguments))}}function K(E,U,D){return ye(E)||oe.apply(this,arguments)}function Ee(E,U,D){var de,Se=this;U=U==null?"WARN":U;var z="loglevel";function $(be){var qe=(ce[be]||"silent").toUpperCase();if(typeof window!==me&&z){try{return void(window.localStorage[z]=qe)}catch{}try{window.document.cookie=encodeURIComponent(z)+"="+qe+";"}catch{}}}function Le(){var be;if(typeof window!==me&&z){try{be=window.localStorage[z]}catch{}if(typeof be===me)try{var qe=window.document.cookie,at=qe.indexOf(encodeURIComponent(z)+"=");at!==-1&&(be=/^([^;]+)/.exec(qe.slice(at))[1])}catch{}return Se.levels[be]===void 0&&(be=void 0),be}}function Oe(){if(typeof window!==me&&z){try{return void window.localStorage.removeItem(z)}catch{}try{window.document.cookie=encodeURIComponent(z)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof E=="string"?z+=":"+E:typeof E=="symbol"&&(z=void 0),Se.name=E,Se.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Se.methodFactory=D||K,Se.getLevel=function(){return de},Se.setLevel=function(be,qe){if(typeof be=="string"&&Se.levels[be.toUpperCase()]!==void 0&&(be=Se.levels[be.toUpperCase()]),!(typeof be=="number"&&be>=0&&be<=Se.levels.SILENT))throw"log.setLevel() called with invalid level: "+be;if(de=be,qe!==!1&&$(be),J.call(Se,be,E),typeof console===me&&be<Se.levels.SILENT)return"No console available for logging"},Se.setDefaultLevel=function(be){U=be,Le()||Se.setLevel(be,!1)},Se.resetLevel=function(){Se.setLevel(U,!1),Oe()},Se.enableAll=function(be){Se.setLevel(Se.levels.TRACE,be)},Se.disableAll=function(be){Se.setLevel(Se.levels.SILENT,be)};var xe=Le();xe==null&&(xe=U),Se.setLevel(xe,!1)}var ke=new Ee,Ne={};ke.getLogger=function(E){if(typeof E!="symbol"&&typeof E!="string"||E==="")throw new TypeError("You must supply a name when creating a logger.");var U=Ne[E];return U||(U=Ne[E]=new Ee(E,ke.getLevel(),ke.methodFactory)),U};var V=typeof window!==me?window.log:void 0;return ke.noConflict=function(){return typeof window!==me&&window.log===ke&&(window.log=V),ke},ke.getLoggers=function(){return Ne},ke.default=ke,ke},(R=typeof re=="function"?re.call(B,j,B,W):re)===void 0||(W.exports=R)})()},375:function(W,B){"use strict";var j=Object.prototype.hasOwnProperty;function re(g){try{return decodeURIComponent(g.replace(/\+/g," "))}catch{return null}}function R(g){try{return encodeURIComponent(g)}catch{return null}}B.stringify=function(g,k){k=k||"";var L,me,ne=[];for(me in typeof k!="string"&&(k="?"),g)if(j.call(g,me)){if((L=g[me])||L!=null&&!isNaN(L)||(L=""),me=R(me),L=R(L),me===null||L===null)continue;ne.push(me+"="+L)}return ne.length?k+ne.join("&"):""},B.parse=function(g){for(var k,L=/([^=?#&]+)=?([^&]*)/g,me={};k=L.exec(g);){var ne=re(k[1]),ce=re(k[2]);ne===null||ce===null||ne in me||(me[ne]=ce)}return me}},558:function(){}},le={};function ae(W){var B=le[W];if(B!==void 0)return B.exports;var j=le[W]={exports:{}};return A[W].call(j.exports,j,j.exports,ae),j.exports}return ae.n=function(W){var B=W&&W.__esModule?function(){return W.default}:function(){return W};return ae.d(B,{a:B}),B},ae.d=function(W,B){for(var j in B)ae.o(B,j)&&!ae.o(W,j)&&Object.defineProperty(W,j,{enumerable:!0,get:B[j]})},ae.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),ae.o=function(W,B){return Object.prototype.hasOwnProperty.call(W,B)},ae(80)}()},typeof En=="object"&&typeof ia=="object"?ia.exports=w():typeof En=="object"?En.mux=w():x.mux=w()})()});var Ya=Ga((Vi,na)=>{typeof window!="undefined"&&function(x,w){typeof Vi=="object"&&typeof na=="object"?na.exports=w():typeof define=="function"&&define.amd?define([],w):typeof Vi=="object"?Vi.Hls=w():x.Hls=w()}(Vi,()=>(()=>{var x={21:(ae,W,B)=>{"use strict";B.r(W),B.d(W,{default:()=>me});var j=function(){function ne(ce,we){this.subtle=void 0,this.aesIV=void 0,this.subtle=ce,this.aesIV=we}return ne.prototype.decrypt=function(ce,we){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},we,ce)},ne}(),re=function(){function ne(ce,we){this.subtle=void 0,this.key=void 0,this.subtle=ce,this.key=we}return ne.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},ne}(),R=B(145),g=function(){function ne(){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 ce=ne.prototype;return ce.uint8ArrayToUint32Array_=function(we){for(var q=new DataView(we),ye=new Uint32Array(4),J=0;J<4;J++)ye[J]=q.getUint32(4*J);return ye},ce.initTable=function(){var we=this.sBox,q=this.invSBox,ye=this.subMix,J=ye[0],oe=ye[1],K=ye[2],Ee=ye[3],ke=this.invSubMix,Ne=ke[0],V=ke[1],E=ke[2],U=ke[3],D=new Uint32Array(256),de=0,Se=0,z=0;for(z=0;z<256;z++)D[z]=z<128?z<<1:z<<1^283;for(z=0;z<256;z++){var $=Se^Se<<1^Se<<2^Se<<3^Se<<4;$=$>>>8^255&$^99,we[de]=$,q[$]=de;var Le=D[de],Oe=D[Le],xe=D[Oe],be=257*D[$]^16843008*$;J[de]=be<<24|be>>>8,oe[de]=be<<16|be>>>16,K[de]=be<<8|be>>>24,Ee[de]=be,be=16843009*xe^65537*Oe^257*Le^16843008*de,Ne[$]=be<<24|be>>>8,V[$]=be<<16|be>>>16,E[$]=be<<8|be>>>24,U[$]=be,de?(de=Le^D[D[D[xe^Le]]],Se^=D[D[Se]]):de=Se=1}},ce.expandKey=function(we){for(var q=this.uint8ArrayToUint32Array_(we),ye=!0,J=0;J<q.length&&ye;)ye=q[J]===this.key[J],J++;if(!ye){this.key=q;var oe=this.keySize=q.length;if(oe!==4&&oe!==6&&oe!==8)throw new Error("Invalid aes key size="+oe);var K,Ee,ke,Ne,V=this.ksRows=4*(oe+6+1),E=this.keySchedule=new Uint32Array(V),U=this.invKeySchedule=new Uint32Array(V),D=this.sBox,de=this.rcon,Se=this.invSubMix,z=Se[0],$=Se[1],Le=Se[2],Oe=Se[3];for(K=0;K<V;K++)K<oe?ke=E[K]=q[K]:(Ne=ke,K%oe==0?(Ne=D[(Ne=Ne<<8|Ne>>>24)>>>24]<<24|D[Ne>>>16&255]<<16|D[Ne>>>8&255]<<8|D[255&Ne],Ne^=de[K/oe|0]<<24):oe>6&&K%oe==4&&(Ne=D[Ne>>>24]<<24|D[Ne>>>16&255]<<16|D[Ne>>>8&255]<<8|D[255&Ne]),E[K]=ke=(E[K-oe]^Ne)>>>0);for(Ee=0;Ee<V;Ee++)K=V-Ee,Ne=3&Ee?E[K]:E[K-4],U[Ee]=Ee<4||K<=4?Ne:z[D[Ne>>>24]]^$[D[Ne>>>16&255]]^Le[D[Ne>>>8&255]]^Oe[D[255&Ne]],U[Ee]=U[Ee]>>>0}},ce.networkToHostOrderSwap=function(we){return we<<24|(65280&we)<<8|(16711680&we)>>8|we>>>24},ce.decrypt=function(we,q,ye){for(var J,oe,K,Ee,ke,Ne,V,E,U,D,de,Se,z,$,Le=this.keySize+6,Oe=this.invKeySchedule,xe=this.invSBox,be=this.invSubMix,qe=be[0],at=be[1],ie=be[2],pe=be[3],se=this.uint8ArrayToUint32Array_(ye),Ue=se[0],H=se[1],ve=se[2],Ie=se[3],Fe=new Int32Array(we),fe=new Int32Array(Fe.length),Ce=this.networkToHostOrderSwap;q<Fe.length;){for(U=Ce(Fe[q]),D=Ce(Fe[q+1]),de=Ce(Fe[q+2]),Se=Ce(Fe[q+3]),ke=U^Oe[0],Ne=Se^Oe[1],V=de^Oe[2],E=D^Oe[3],z=4,$=1;$<Le;$++)J=qe[ke>>>24]^at[Ne>>16&255]^ie[V>>8&255]^pe[255&E]^Oe[z],oe=qe[Ne>>>24]^at[V>>16&255]^ie[E>>8&255]^pe[255&ke]^Oe[z+1],K=qe[V>>>24]^at[E>>16&255]^ie[ke>>8&255]^pe[255&Ne]^Oe[z+2],Ee=qe[E>>>24]^at[ke>>16&255]^ie[Ne>>8&255]^pe[255&V]^Oe[z+3],ke=J,Ne=oe,V=K,E=Ee,z+=4;J=xe[ke>>>24]<<24^xe[Ne>>16&255]<<16^xe[V>>8&255]<<8^xe[255&E]^Oe[z],oe=xe[Ne>>>24]<<24^xe[V>>16&255]<<16^xe[E>>8&255]<<8^xe[255&ke]^Oe[z+1],K=xe[V>>>24]<<24^xe[E>>16&255]<<16^xe[ke>>8&255]<<8^xe[255&Ne]^Oe[z+2],Ee=xe[E>>>24]<<24^xe[ke>>16&255]<<16^xe[Ne>>8&255]<<8^xe[255&V]^Oe[z+3],fe[q]=Ce(J^Ue),fe[q+1]=Ce(Ee^H),fe[q+2]=Ce(K^ve),fe[q+3]=Ce(oe^Ie),Ue=U,H=D,ve=de,Ie=Se,q+=4}return fe.buffer},ne}(),k=B(93),L=B(63),me=function(){function ne(we,q){var ye=(q===void 0?{}:q).removePKCS7Padding,J=ye===void 0||ye;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=we.enableSoftwareAES,this.removePKCS7Padding=J,J)try{var oe=self.crypto;oe&&(this.subtle=oe.subtle||oe.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var ce=ne.prototype;return ce.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},ce.isSync=function(){return this.useSoftware},ce.flush=function(){var we=this.currentResult,q=this.remainderData;if(!we||q)return k.logger.error("[softwareDecrypt] "+(q?"overflow bytes: "+q.byteLength:"no result")),this.reset(),null;var ye,J,oe,K=new Uint8Array(we);return this.reset(),this.removePKCS7Padding?(oe=(J=(ye=K).byteLength)&&new DataView(ye.buffer).getUint8(J-1))?(0,R.sliceUint8)(ye,0,J-oe):ye:K},ce.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},ce.decrypt=function(we,q,ye){var J=this;return this.useSoftware?new Promise(function(oe,K){J.softwareDecrypt(new Uint8Array(we),q,ye);var Ee=J.flush();Ee?oe(Ee.buffer):K(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(we),q,ye)},ce.softwareDecrypt=function(we,q,ye){var J=this.currentIV,oe=this.currentResult,K=this.remainderData;this.logOnce("JS AES decrypt"),K&&(we=(0,L.appendUint8Array)(K,we),this.remainderData=null);var Ee=this.getValidChunk(we);if(!Ee.length)return null;J&&(ye=J);var ke=this.softwareDecrypter;ke||(ke=this.softwareDecrypter=new g),ke.expandKey(q);var Ne=oe;return this.currentResult=ke.decrypt(Ee.buffer,0,ye),this.currentIV=(0,R.sliceUint8)(Ee,-16).buffer,Ne||null},ce.webCryptoDecrypt=function(we,q,ye){var J=this,oe=this.subtle;return this.key===q&&this.fastAesKey||(this.key=q,this.fastAesKey=new re(oe,q)),this.fastAesKey.expandKey().then(function(K){return oe?(J.logOnce("WebCrypto AES decrypt"),new j(oe,new Uint8Array(ye)).decrypt(we.buffer,K)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(K){return k.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+K.name+": "+K.message),J.onWebCryptoError(we,q,ye)})},ce.onWebCryptoError=function(we,q,ye){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(we,q,ye);var J=this.flush();if(J)return J.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},ce.getValidChunk=function(we){var q=we,ye=we.length-we.length%16;return ye!==we.length&&(q=(0,R.sliceUint8)(we,0,ye),this.remainderData=(0,R.sliceUint8)(we,ye)),q},ce.logOnce=function(we){this.logEnabled&&(k.logger.log("[decrypter]: "+we),this.logEnabled=!1)},ne}()},181:(ae,W,B)=>{"use strict";B.r(W),B.d(W,{canParse:()=>L,decodeFrame:()=>q,getID3Data:()=>g,getID3Frames:()=>we,getTimeStamp:()=>me,isFooter:()=>R,isHeader:()=>re,isTimeStampFrame:()=>ne,testables:()=>ke,utf8ArrayToStr:()=>Ee});var j,re=function(V,E){return E+10<=V.length&&V[E]===73&&V[E+1]===68&&V[E+2]===51&&V[E+3]<255&&V[E+4]<255&&V[E+6]<128&&V[E+7]<128&&V[E+8]<128&&V[E+9]<128},R=function(V,E){return E+10<=V.length&&V[E]===51&&V[E+1]===68&&V[E+2]===73&&V[E+3]<255&&V[E+4]<255&&V[E+6]<128&&V[E+7]<128&&V[E+8]<128&&V[E+9]<128},g=function(V,E){for(var U=E,D=0;re(V,E);)D+=10,D+=k(V,E+6),R(V,E+10)&&(D+=10),E+=D;if(D>0)return V.subarray(U,U+D)},k=function(V,E){var U=0;return U=(127&V[E])<<21,U|=(127&V[E+1])<<14,(U|=(127&V[E+2])<<7)|127&V[E+3]},L=function(V,E){return re(V,E)&&k(V,E+6)+10<=V.length-E},me=function(V){for(var E=we(V),U=0;U<E.length;U++){var D=E[U];if(ne(D))return K(D)}},ne=function(V){return V&&V.key==="PRIV"&&V.info==="com.apple.streaming.transportStreamTimestamp"},ce=function(V){var E=String.fromCharCode(V[0],V[1],V[2],V[3]),U=k(V,4);return{type:E,size:U,data:V.subarray(10,10+U)}},we=function(V){for(var E=0,U=[];re(V,E);){for(var D=k(V,E+6),de=(E+=10)+D;E+8<de;){var Se=ce(V.subarray(E)),z=q(Se);z&&U.push(z),E+=Se.size+10}R(V,E)&&(E+=10)}return U},q=function(V){return V.type==="PRIV"?ye(V):V.type[0]==="W"?oe(V):J(V)},ye=function(V){if(!(V.size<2)){var E=Ee(V.data,!0),U=new Uint8Array(V.data.subarray(E.length+1));return{key:V.type,info:E,data:U.buffer}}},J=function(V){if(!(V.size<2)){if(V.type==="TXXX"){var E=1,U=Ee(V.data.subarray(E),!0);E+=U.length+1;var D=Ee(V.data.subarray(E));return{key:V.type,info:U,data:D}}var de=Ee(V.data.subarray(1));return{key:V.type,data:de}}},oe=function(V){if(V.type==="WXXX"){if(V.size<2)return;var E=1,U=Ee(V.data.subarray(E),!0);E+=U.length+1;var D=Ee(V.data.subarray(E));return{key:V.type,info:U,data:D}}var de=Ee(V.data);return{key:V.type,data:de}},K=function(V){if(V.data.byteLength===8){var E=new Uint8Array(V.data),U=1&E[3],D=(E[4]<<23)+(E[5]<<15)+(E[6]<<7)+E[7];return D/=45,U&&(D+=4772185884e-2),Math.round(D)}},Ee=function(V,E){E===void 0&&(E=!1);var U=Ne();if(U){var D=U.decode(V);if(E){var de=D.indexOf("\0");return de!==-1?D.substring(0,de):D}return D.replace(/\0/g,"")}for(var Se,z,$,Le=V.length,Oe="",xe=0;xe<Le;){if((Se=V[xe++])===0&&E)return Oe;if(Se!==0&&Se!==3)switch(Se>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:Oe+=String.fromCharCode(Se);break;case 12:case 13:z=V[xe++],Oe+=String.fromCharCode((31&Se)<<6|63&z);break;case 14:z=V[xe++],$=V[xe++],Oe+=String.fromCharCode((15&Se)<<12|(63&z)<<6|(63&$)<<0)}}return Oe},ke={decodeTextFrame:J};function Ne(){return j||self.TextDecoder===void 0||(j=new self.TextDecoder("utf-8")),j}},182:(ae,W,B)=>{"use strict";B.r(W),B.d(W,{default:()=>L});var j=B(544),re=B(851),R=B(93),g=B(729),k=B(973);function L(we){var q=new g.EventEmitter,ye=function(J,oe){we.postMessage({event:J,data:oe})};q.on(re.Events.FRAG_DECRYPTED,ye),q.on(re.Events.ERROR,ye),we.addEventListener("message",function(J){var oe=J.data;switch(oe.cmd){case"init":var K=JSON.parse(oe.config);we.transmuxer=new j.default(q,oe.typeSupported,K,oe.vendor,oe.id),(0,R.enableLogs)(K.debug,oe.id),function(){var V=function(U){R.logger[U]=function(D){ye("workerLog",{logType:U,message:D})}};for(var E in R.logger)V(E)}(),ye("init",null);break;case"configure":we.transmuxer.configure(oe.config);break;case"demux":var Ee=we.transmuxer.push(oe.data,oe.decryptdata,oe.chunkMeta,oe.state);(0,j.isPromise)(Ee)?(we.transmuxer.async=!0,Ee.then(function(V){me(we,V)}).catch(function(V){ye(re.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:oe.chunkMeta,fatal:!1,error:V,err:V,reason:"transmuxer-worker push error"})})):(we.transmuxer.async=!1,me(we,Ee));break;case"flush":var ke=oe.chunkMeta,Ne=we.transmuxer.flush(ke);(0,j.isPromise)(Ne)||we.transmuxer.async?((0,j.isPromise)(Ne)||(Ne=Promise.resolve(Ne)),Ne.then(function(V){ce(we,V,ke)}).catch(function(V){ye(re.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:oe.chunkMeta,fatal:!1,error:V,err:V,reason:"transmuxer-worker flush error"})})):ce(we,Ne,ke)}})}function me(we,q){if(!((ye=q.remuxResult).audio||ye.video||ye.text||ye.id3||ye.initSegment))return!1;var ye,J=[],oe=q.remuxResult,K=oe.audio,Ee=oe.video;return K&&ne(J,K),Ee&&ne(J,Ee),we.postMessage({event:"transmuxComplete",data:q},J),!0}function ne(we,q){q.data1&&we.push(q.data1.buffer),q.data2&&we.push(q.data2.buffer)}function ce(we,q,ye){q.reduce(function(J,oe){return me(we,oe)||J},!1)||we.postMessage({event:"transmuxComplete",data:q[0]}),we.postMessage({event:"flush",data:ye})}},544:(ae,W,B)=>{"use strict";B.r(W),B.d(W,{TransmuxConfig:()=>Bt,TransmuxState:()=>ar,default:()=>It,isPromise:()=>Wt});var j=B(851),re=B(973),R=B(21),g=B(965),k=B(181),L=B(856);function me(te,N){return te===void 0&&(te=""),N===void 0&&(N=9e4),{type:te,id:-1,pid:-1,inputTimeScale:N,sequenceNumber:-1,samples:[],dropped:0}}var ne=B(63),ce=B(145),we=function(){function te(){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=te.prototype;return N.resetInitSegment=function(T,O,C,G){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},N.resetTimeStamp=function(T){this.initPTS=T,this.resetContiguity()},N.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},N.canParse=function(T,O){return!1},N.appendFrame=function(T,O,C){},N.demux=function(T,O){this.cachedData&&(T=(0,ne.appendUint8Array)(this.cachedData,T),this.cachedData=null);var C,G=k.getID3Data(T,0),Q=G?G.length:0,Z=this._audioTrack,Te=this._id3Track,Re=G?k.getTimeStamp(G):void 0,Pe=T.length;for((this.basePTS===null||this.frameIndex===0&&(0,g.isFiniteNumber)(Re))&&(this.basePTS=q(Re,O,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),G&&G.length>0&&Te.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:G,type:L.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});Q<Pe;){if(this.canParse(T,Q)){var Be=this.appendFrame(Z,T,Q);Be?(this.frameIndex++,this.lastPTS=Be.sample.pts,C=Q+=Be.length):Q=Pe}else k.canParse(T,Q)?(G=k.getID3Data(T,Q),Te.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:G,type:L.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),C=Q+=G.length):Q++;if(Q===Pe&&C!==Pe){var We=(0,ce.sliceUint8)(T,C);this.cachedData?this.cachedData=(0,ne.appendUint8Array)(this.cachedData,We):this.cachedData=We}}return{audioTrack:Z,videoTrack:me(),id3Track:Te,textTrack:me()}},N.demuxSampleAes=function(T,O,C){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},N.flush=function(T){var O=this.cachedData;return O&&(this.cachedData=null,this.demux(O,0)),{audioTrack:this._audioTrack,videoTrack:me(),id3Track:this._id3Track,textTrack:me()}},N.destroy=function(){},te}(),q=function(te,N,T){return(0,g.isFiniteNumber)(te)?90*te:9e4*N+(T||0)};let ye=we;var J=B(93);function oe(te,N){return te[N]===255&&(246&te[N+1])==240}function K(te,N){return 1&te[N+1]?7:9}function Ee(te,N){return(3&te[N+3])<<11|te[N+4]<<3|(224&te[N+5])>>>5}function ke(te,N){return N+1<te.length&&oe(te,N)}function Ne(te,N){if(ke(te,N)){var T=K(te,N);if(N+T>=te.length)return!1;var O=Ee(te,N);if(O<=T)return!1;var C=N+O;return C===te.length||ke(te,C)}return!1}function V(te,N,T,O,C){if(!te.samplerate){var G=function(Q,Z,Te,Re){var Pe,Be,We,Ge,$e=navigator.userAgent.toLowerCase(),ht=Re,Dt=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Pe=1+((192&Z[Te+2])>>>6);var ze=(60&Z[Te+2])>>>2;if(!(ze>Dt.length-1))return We=(1&Z[Te+2])<<2,We|=(192&Z[Te+3])>>>6,J.logger.log("manifest codec:"+Re+", ADTS type:"+Pe+", samplingIndex:"+ze),/firefox/i.test($e)?ze>=6?(Pe=5,Ge=new Array(4),Be=ze-3):(Pe=2,Ge=new Array(2),Be=ze):$e.indexOf("android")!==-1?(Pe=2,Ge=new Array(2),Be=ze):(Pe=5,Ge=new Array(4),Re&&(Re.indexOf("mp4a.40.29")!==-1||Re.indexOf("mp4a.40.5")!==-1)||!Re&&ze>=6?Be=ze-3:((Re&&Re.indexOf("mp4a.40.2")!==-1&&(ze>=6&&We===1||/vivaldi/i.test($e))||!Re&&We===1)&&(Pe=2,Ge=new Array(2)),Be=ze)),Ge[0]=Pe<<3,Ge[0]|=(14&ze)>>1,Ge[1]|=(1&ze)<<7,Ge[1]|=We<<3,Pe===5&&(Ge[1]|=(14&Be)>>1,Ge[2]=(1&Be)<<7,Ge[2]|=8,Ge[3]=0),{config:Ge,samplerate:Dt[ze],channelCount:We,codec:"mp4a.40."+Pe,manifestCodec:ht};Q.trigger(j.Events.ERROR,{type:re.ErrorTypes.MEDIA_ERROR,details:re.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+ze})}(N,T,O,C);if(!G)return;te.config=G.config,te.samplerate=G.samplerate,te.channelCount=G.channelCount,te.codec=G.codec,te.manifestCodec=G.manifestCodec,J.logger.log("parsed codec:"+te.codec+", rate:"+G.samplerate+", channels:"+G.channelCount)}}function E(te){return 9216e4/te}function U(te,N,T,O,C){var G,Q=O+C*E(te.samplerate),Z=function($e,ht){var Dt=K($e,ht);if(ht+Dt<=$e.length){var ze=Ee($e,ht)-Dt;if(ze>0)return{headerLength:Dt,frameLength:ze}}}(N,T);if(Z){var Te=Z.frameLength,Re=Z.headerLength,Pe=Re+Te,Be=Math.max(0,T+Pe-N.length);Be?(G=new Uint8Array(Pe-Re)).set(N.subarray(T+Re,N.length),0):G=N.subarray(T+Re,T+Pe);var We={unit:G,pts:Q};return Be||te.samples.push(We),{sample:We,length:Pe,missing:Be}}var Ge=N.length-T;return(G=new Uint8Array(Ge)).set(N.subarray(T,N.length),0),{sample:{unit:G,pts:Q},length:Ge,missing:-1}}function D(te,N){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,O){return T.__proto__=O,T},D(te,N)}let de=function(te){var N,T;function O(G,Q){var Z;return(Z=te.call(this)||this).observer=void 0,Z.config=void 0,Z.observer=G,Z.config=Q,Z}T=te,(N=O).prototype=Object.create(T.prototype),N.prototype.constructor=N,D(N,T);var C=O.prototype;return C.resetInitSegment=function(G,Q,Z,Te){te.prototype.resetInitSegment.call(this,G,Q,Z,Te),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:Q,duration:Te,inputTimeScale:9e4,dropped:0}},O.probe=function(G){if(!G)return!1;for(var Q=(k.getID3Data(G,0)||[]).length,Z=G.length;Q<Z;Q++)if(Ne(G,Q))return J.logger.log("ADTS sync word found !"),!0;return!1},C.canParse=function(G,Q){return function(Z,Te){return function(Re,Pe){return Pe+5<Re.length}(Z,Te)&&oe(Z,Te)&&Ee(Z,Te)<=Z.length-Te}(G,Q)},C.appendFrame=function(G,Q,Z){V(G,this.observer,Q,Z,G.manifestCodec);var Te=U(G,Q,Z,this.basePTS,this.frameIndex);if(Te&&Te.missing===0)return Te},O}(ye);var Se=/\/emsg[-/]ID3/i;let z=function(){function te(T,O){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=O}var N=te.prototype;return N.resetTimeStamp=function(){},N.resetInitSegment=function(T,O,C,G){var Q=this.videoTrack=me("video",1),Z=this.audioTrack=me("audio",1),Te=this.txtTrack=me("text",1);if(this.id3Track=me("id3",1),this.timeOffset=0,T&&T.byteLength){var Re=(0,ne.parseInitSegment)(T);if(Re.video){var Pe=Re.video,Be=Pe.id,We=Pe.timescale,Ge=Pe.codec;Q.id=Be,Q.timescale=Te.timescale=We,Q.codec=Ge}if(Re.audio){var $e=Re.audio,ht=$e.id,Dt=$e.timescale,ze=$e.codec;Z.id=ht,Z.timescale=Dt,Z.codec=ze}Te.id=ne.RemuxerTrackIdConfig.text,Q.sampleDuration=0,Q.duration=Z.duration=G}},N.resetContiguity=function(){},te.probe=function(T){return T=T.length>16384?T.subarray(0,16384):T,(0,ne.findBox)(T,["moof"]).length>0},N.demux=function(T,O){this.timeOffset=O;var C=T,G=this.videoTrack,Q=this.txtTrack;if(this.config.progressive){this.remainderData&&(C=(0,ne.appendUint8Array)(this.remainderData,T));var Z=(0,ne.segmentValidRange)(C);this.remainderData=Z.remainder,G.samples=Z.valid||new Uint8Array}else G.samples=C;var Te=this.extractID3Track(G,O);return Q.samples=(0,ne.parseSamples)(O,G),{videoTrack:G,audioTrack:this.audioTrack,id3Track:Te,textTrack:this.txtTrack}},N.flush=function(){var T=this.timeOffset,O=this.videoTrack,C=this.txtTrack;O.samples=this.remainderData||new Uint8Array,this.remainderData=null;var G=this.extractID3Track(O,this.timeOffset);return C.samples=(0,ne.parseSamples)(T,O),{videoTrack:O,audioTrack:me(),id3Track:G,textTrack:me()}},N.extractID3Track=function(T,O){var C=this.id3Track;if(T.samples.length){var G=(0,ne.findBox)(T.samples,["emsg"]);G&&G.forEach(function(Q){var Z=(0,ne.parseEmsg)(Q);if(Se.test(Z.schemeIdUri)){var Te=(0,g.isFiniteNumber)(Z.presentationTime)?Z.presentationTime/Z.timeScale:O+Z.presentationTimeDelta/Z.timeScale,Re=Z.eventDuration===4294967295?Number.POSITIVE_INFINITY:Z.eventDuration/Z.timeScale;Re<=.001&&(Re=Number.POSITIVE_INFINITY);var Pe=Z.payload;C.samples.push({data:Pe,len:Pe.byteLength,dts:Te,pts:Te,type:L.MetadataSchema.emsg,duration:Re})}})}return C},N.demuxSampleAes=function(T,O,C){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},N.destroy=function(){},te}();var $=null,Le=[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],Oe=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],xe=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],be=[0,1,1,4];function qe(te,N,T,O,C){if(!(T+24>N.length)){var G=at(N,T);if(G&&T+G.frameLength<=N.length){var Q=O+C*(9e4*G.samplesPerFrame/G.sampleRate),Z={unit:N.subarray(T,T+G.frameLength),pts:Q,dts:Q};return te.config=[],te.channelCount=G.channelCount,te.samplerate=G.sampleRate,te.samples.push(Z),{sample:Z,length:G.frameLength,missing:0}}}}function at(te,N){var T=te[N+1]>>3&3,O=te[N+1]>>1&3,C=te[N+2]>>4&15,G=te[N+2]>>2&3;if(T!==1&&C!==0&&C!==15&&G!==3){var Q=te[N+2]>>1&1,Z=te[N+3]>>6,Te=1e3*Le[14*(T===3?3-O:O===3?3:4)+C-1],Re=Oe[3*(T===3?0:T===2?1:2)+G],Pe=Z===3?1:2,Be=xe[T][O],We=be[O],Ge=8*Be*We,$e=Math.floor(Be*Te/Re+Q)*We;if($===null){var ht=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);$=ht?parseInt(ht[1]):0}return!!$&&$<=87&&O===2&&Te>=224e3&&Z===0&&(te[N+3]=128|te[N+3]),{sampleRate:Re,channelCount:Pe,frameLength:$e,samplesPerFrame:Ge}}}function ie(te,N){return te[N]===255&&(224&te[N+1])==224&&(6&te[N+1])!=0}function pe(te,N){return N+1<te.length&&ie(te,N)}function se(te,N){if(N+1<te.length&&ie(te,N)){var T=at(te,N),O=4;T!=null&&T.frameLength&&(O=T.frameLength);var C=N+O;return C===te.length||pe(te,C)}return!1}let Ue=function(){function te(T){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=T,this.bytesAvailable=T.byteLength,this.word=0,this.bitsAvailable=0}var N=te.prototype;return N.loadWord=function(){var T=this.data,O=this.bytesAvailable,C=T.byteLength-O,G=new Uint8Array(4),Q=Math.min(4,O);if(Q===0)throw new Error("no bytes available");G.set(T.subarray(C,C+Q)),this.word=new DataView(G.buffer).getUint32(0),this.bitsAvailable=8*Q,this.bytesAvailable-=Q},N.skipBits=function(T){var O;T=Math.min(T,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>T?(this.word<<=T,this.bitsAvailable-=T):(T-=this.bitsAvailable,T-=(O=T>>3)<<3,this.bytesAvailable-=O,this.loadWord(),this.word<<=T,this.bitsAvailable-=T)},N.readBits=function(T){var O=Math.min(this.bitsAvailable,T),C=this.word>>>32-O;if(T>32&&J.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=O,this.bitsAvailable>0)this.word<<=O;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(O=T-O)>0&&this.bitsAvailable?C<<O|this.readBits(O):C},N.skipLZ=function(){var T;for(T=0;T<this.bitsAvailable;++T)if((this.word&2147483648>>>T)!=0)return this.word<<=T,this.bitsAvailable-=T,T;return this.loadWord(),T+this.skipLZ()},N.skipUEG=function(){this.skipBits(1+this.skipLZ())},N.skipEG=function(){this.skipBits(1+this.skipLZ())},N.readUEG=function(){var T=this.skipLZ();return this.readBits(T+1)-1},N.readEG=function(){var T=this.readUEG();return 1&T?1+T>>>1:-1*(T>>>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(T){for(var O=8,C=8,G=0;G<T;G++)C!==0&&(C=(O+this.readEG()+256)%256),O=C===0?O:C},N.readSPS=function(){var T,O,C,G=0,Q=0,Z=0,Te=0,Re=this.readUByte.bind(this),Pe=this.readBits.bind(this),Be=this.readUEG.bind(this),We=this.readBoolean.bind(this),Ge=this.skipBits.bind(this),$e=this.skipEG.bind(this),ht=this.skipUEG.bind(this),Dt=this.skipScalingList.bind(this);Re();var ze=Re();if(Pe(5),Ge(3),Re(),ht(),ze===100||ze===110||ze===122||ze===244||ze===44||ze===83||ze===86||ze===118||ze===128){var Pt=Be();if(Pt===3&&Ge(1),ht(),ht(),Ge(1),We())for(O=Pt!==3?8:12,C=0;C<O;C++)We()&&Dt(C<6?16:64)}ht();var tr=Be();if(tr===0)Be();else if(tr===1)for(Ge(1),$e(),$e(),T=Be(),C=0;C<T;C++)$e();ht(),Ge(1);var jt=Be(),Ft=Be(),Ht=Pe(1);Ht===0&&Ge(1),Ge(1),We()&&(G=Be(),Q=Be(),Z=Be(),Te=Be());var rt=[1,1];if(We()&&We())switch(Re()){case 1:rt=[1,1];break;case 2:rt=[12,11];break;case 3:rt=[10,11];break;case 4:rt=[16,11];break;case 5:rt=[40,33];break;case 6:rt=[24,11];break;case 7:rt=[20,11];break;case 8:rt=[32,11];break;case 9:rt=[80,33];break;case 10:rt=[18,11];break;case 11:rt=[15,11];break;case 12:rt=[64,33];break;case 13:rt=[160,99];break;case 14:rt=[4,3];break;case 15:rt=[3,2];break;case 16:rt=[2,1];break;case 255:rt=[Re()<<8|Re(),Re()<<8|Re()]}return{width:Math.ceil(16*(jt+1)-2*G-2*Q),height:(2-Ht)*(Ft+1)*16-(Ht?2:4)*(Z+Te),pixelRatio:rt}},N.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},te}(),H=function(){function te(T,O,C){this.keyData=void 0,this.decrypter=void 0,this.keyData=C,this.decrypter=new R.default(O,{removePKCS7Padding:!1})}var N=te.prototype;return N.decryptBuffer=function(T){return this.decrypter.decrypt(T,this.keyData.key.buffer,this.keyData.iv.buffer)},N.decryptAacSample=function(T,O,C){var G=this,Q=T[O].unit;if(!(Q.length<=16)){var Z=Q.subarray(16,Q.length-Q.length%16),Te=Z.buffer.slice(Z.byteOffset,Z.byteOffset+Z.length);this.decryptBuffer(Te).then(function(Re){var Pe=new Uint8Array(Re);Q.set(Pe,16),G.decrypter.isSync()||G.decryptAacSamples(T,O+1,C)})}},N.decryptAacSamples=function(T,O,C){for(;;O++){if(O>=T.length)return void C();if(!(T[O].unit.length<32||(this.decryptAacSample(T,O,C),this.decrypter.isSync())))return}},N.getAvcEncryptedData=function(T){for(var O=16*Math.floor((T.length-48)/160)+16,C=new Int8Array(O),G=0,Q=32;Q<T.length-16;Q+=160,G+=16)C.set(T.subarray(Q,Q+16),G);return C},N.getAvcDecryptedUnit=function(T,O){for(var C=new Uint8Array(O),G=0,Q=32;Q<T.length-16;Q+=160,G+=16)T.set(C.subarray(G,G+16),Q);return T},N.decryptAvcSample=function(T,O,C,G,Q){var Z=this,Te=(0,ne.discardEPB)(Q.data),Re=this.getAvcEncryptedData(Te);this.decryptBuffer(Re.buffer).then(function(Pe){Q.data=Z.getAvcDecryptedUnit(Te,Pe),Z.decrypter.isSync()||Z.decryptAvcSamples(T,O,C+1,G)})},N.decryptAvcSamples=function(T,O,C,G){if(T instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;O++,C=0){if(O>=T.length)return void G();for(var Q=T[O].units;!(C>=Q.length);C++){var Z=Q[C];if(!(Z.data.length<=48||Z.type!==1&&Z.type!==5||(this.decryptAvcSample(T,O,C,G,Z),this.decrypter.isSync())))return}}},te}();function ve(){return ve=Object.assign?Object.assign.bind():function(te){for(var N=1;N<arguments.length;N++){var T=arguments[N];for(var O in T)Object.prototype.hasOwnProperty.call(T,O)&&(te[O]=T[O])}return te},ve.apply(this,arguments)}var Ie=188;function Fe(te,N,T,O){return{key:te,frame:!1,pts:N,dts:T,units:[],debug:O,length:0}}function fe(te,N){return(31&te[N+10])<<8|te[N+11]}function Ce(te,N,T,O){var C={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},G=N+3+((15&te[N+1])<<8|te[N+2])-4;for(N+=12+((15&te[N+10])<<8|te[N+11]);N<G;){var Q=(31&te[N+1])<<8|te[N+2];switch(te[N]){case 207:if(!O){J.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:C.audio===-1&&(C.audio=Q);break;case 21:C.id3===-1&&(C.id3=Q);break;case 219:if(!O){J.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:C.avc===-1&&(C.avc=Q);break;case 3:case 4:T.mpeg!==!0&&T.mp3!==!0?J.logger.log("MPEG audio found, not supported in this browser"):C.audio===-1&&(C.audio=Q,C.segmentCodec="mp3");break;case 36:J.logger.warn("Unsupported HEVC stream type found")}N+=5+((15&te[N+3])<<8|te[N+4])}return C}function Ve(te){var N,T,O,C,G,Q=0,Z=te.data;if(!te||te.size===0)return null;for(;Z[0].length<19&&Z.length>1;){var Te=new Uint8Array(Z[0].length+Z[1].length);Te.set(Z[0]),Te.set(Z[1],Z[0].length),Z[0]=Te,Z.splice(1,1)}if(((N=Z[0])[0]<<16)+(N[1]<<8)+N[2]===1){if((T=(N[4]<<8)+N[5])&&T>te.size-6)return null;var Re=N[7];192&Re&&(C=536870912*(14&N[9])+4194304*(255&N[10])+16384*(254&N[11])+128*(255&N[12])+(254&N[13])/2,64&Re?C-(G=536870912*(14&N[14])+4194304*(255&N[15])+16384*(254&N[16])+128*(255&N[17])+(254&N[18])/2)>54e5&&(J.logger.warn(Math.round((C-G)/9e4)+"s delta between PTS and DTS, align them"),C=G):G=C);var Pe=(O=N[8])+9;if(te.size<=Pe)return null;te.size-=Pe;for(var Be=new Uint8Array(te.size),We=0,Ge=Z.length;We<Ge;We++){var $e=(N=Z[We]).byteLength;if(Pe){if(Pe>$e){Pe-=$e;continue}N=N.subarray(Pe),$e-=Pe,Pe=0}Be.set(N,Q),Q+=$e}return T&&(T-=O+3),{data:Be,pts:C,dts:G,len:T}}return null}function Xe(te,N){if(te.units.length&&te.frame){if(te.pts===void 0){var T=N.samples,O=T.length;if(!O)return void N.dropped++;var C=T[O-1];te.pts=C.pts,te.dts=C.dts}N.samples.push(te)}te.debug.length&&J.logger.log(te.pts+"/"+te.dts+":"+te.debug)}let it=function(){function te(T,O,C){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=T,this.config=O,this.typeSupported=C}te.probe=function(T){var O=te.syncOffset(T);return O>0&&J.logger.warn("MPEG2-TS detected but first sync word found @ offset "+O),O!==-1},te.syncOffset=function(T){for(var O=Math.min(940,T.length-376)+1,C=0;C<O;){if(T[C]===71&&T[C+Ie]===71)return C;C++}return-1},te.createTrack=function(T,O){return{container:T==="video"||T==="audio"?"video/mp2t":void 0,type:T,id:ne.RemuxerTrackIdConfig[T],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:T==="audio"?O:void 0}};var N=te.prototype;return N.resetInitSegment=function(T,O,C,G){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=te.createTrack("video"),this._audioTrack=te.createTrack("audio",G),this._id3Track=te.createTrack("id3"),this._txtTrack=te.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=O,this.videoCodec=C,this._duration=G},N.resetTimeStamp=function(){},N.resetContiguity=function(){var T=this._audioTrack,O=this._avcTrack,C=this._id3Track;T&&(T.pesData=null),O&&(O.pesData=null),C&&(C.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},N.demux=function(T,O,C,G){var Q;C===void 0&&(C=!1),G===void 0&&(G=!1),C||(this.sampleAes=null);var Z=this._avcTrack,Te=this._audioTrack,Re=this._id3Track,Pe=this._txtTrack,Be=Z.pid,We=Z.pesData,Ge=Te.pid,$e=Re.pid,ht=Te.pesData,Dt=Re.pesData,ze=null,Pt=this.pmtParsed,tr=this._pmtId,jt=T.length;if(this.remainderData&&(jt=(T=(0,ne.appendUint8Array)(this.remainderData,T)).length,this.remainderData=null),jt<Ie&&!G)return this.remainderData=T,{audioTrack:Te,videoTrack:Z,id3Track:Re,textTrack:Pe};var Ft=Math.max(0,te.syncOffset(T));(jt-=(jt-Ft)%Ie)<T.byteLength&&!G&&(this.remainderData=new Uint8Array(T.buffer,jt,T.buffer.byteLength-jt));for(var Ht=0,rt=Ft;rt<jt;rt+=Ie)if(T[rt]===71){var lr=!!(64&T[rt+1]),Ar=((31&T[rt+1])<<8)+T[rt+2],Kt=void 0;if((48&T[rt+3])>>4>1){if((Kt=rt+5+T[rt+4])===rt+Ie)continue}else Kt=rt+4;switch(Ar){case Be:lr&&(We&&(Q=Ve(We))&&this.parseAVCPES(Z,Pe,Q,!1),We={data:[],size:0}),We&&(We.data.push(T.subarray(Kt,rt+Ie)),We.size+=rt+Ie-Kt);break;case Ge:if(lr){if(ht&&(Q=Ve(ht)))switch(Te.segmentCodec){case"aac":this.parseAACPES(Te,Q);break;case"mp3":this.parseMPEGPES(Te,Q)}ht={data:[],size:0}}ht&&(ht.data.push(T.subarray(Kt,rt+Ie)),ht.size+=rt+Ie-Kt);break;case $e:lr&&(Dt&&(Q=Ve(Dt))&&this.parseID3PES(Re,Q),Dt={data:[],size:0}),Dt&&(Dt.data.push(T.subarray(Kt,rt+Ie)),Dt.size+=rt+Ie-Kt);break;case 0:lr&&(Kt+=T[Kt]+1),tr=this._pmtId=fe(T,Kt);break;case tr:lr&&(Kt+=T[Kt]+1);var Jt=Ce(T,Kt,this.typeSupported,C);(Be=Jt.avc)>0&&(Z.pid=Be),(Ge=Jt.audio)>0&&(Te.pid=Ge,Te.segmentCodec=Jt.segmentCodec),($e=Jt.id3)>0&&(Re.pid=$e),ze===null||Pt||(J.logger.log("unknown PID '"+ze+"' in TS found"),ze=null,rt=Ft-188),Pt=this.pmtParsed=!0;break;case 17:case 8191:break;default:ze=Ar}}else Ht++;Ht>0&&this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:re.ErrorTypes.MEDIA_ERROR,details:re.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Ht+" TS packet/s that do not start with 0x47"}),Z.pesData=We,Te.pesData=ht,Re.pesData=Dt;var pr={audioTrack:Te,videoTrack:Z,id3Track:Re,textTrack:Pe};return G&&this.extractRemainingSamples(pr),pr},N.flush=function(){var T,O=this.remainderData;return this.remainderData=null,T=O?this.demux(O,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(T),this.sampleAes?this.decrypt(T,this.sampleAes):T},N.extractRemainingSamples=function(T){var O,C=T.audioTrack,G=T.videoTrack,Q=T.id3Track,Z=T.textTrack,Te=G.pesData,Re=C.pesData,Pe=Q.pesData;if(Te&&(O=Ve(Te))?(this.parseAVCPES(G,Z,O,!0),G.pesData=null):G.pesData=Te,Re&&(O=Ve(Re))){switch(C.segmentCodec){case"aac":this.parseAACPES(C,O);break;case"mp3":this.parseMPEGPES(C,O)}C.pesData=null}else Re!=null&&Re.size&&J.logger.log("last AAC PES packet truncated,might overlap between fragments"),C.pesData=Re;Pe&&(O=Ve(Pe))?(this.parseID3PES(Q,O),Q.pesData=null):Q.pesData=Pe},N.demuxSampleAes=function(T,O,C){var G=this.demux(T,C,!0,!this.config.progressive),Q=this.sampleAes=new H(this.observer,this.config,O);return this.decrypt(G,Q)},N.decrypt=function(T,O){return new Promise(function(C){var G=T.audioTrack,Q=T.videoTrack;G.samples&&G.segmentCodec==="aac"?O.decryptAacSamples(G.samples,0,function(){Q.samples?O.decryptAvcSamples(Q.samples,0,0,function(){C(T)}):C(T)}):Q.samples&&O.decryptAvcSamples(Q.samples,0,0,function(){C(T)})})},N.destroy=function(){this._duration=0},N.parseAVCPES=function(T,O,C,G){var Q,Z=this,Te=this.parseAVCNALu(T,C.data),Re=this.avcSample,Pe=!1;C.data=null,Re&&Te.length&&!T.audFound&&(Xe(Re,T),Re=this.avcSample=Fe(!1,C.pts,C.dts,"")),Te.forEach(function(Be){switch(Be.type){case 1:Q=!0,Re||(Re=Z.avcSample=Fe(!0,C.pts,C.dts,"")),Re.frame=!0;var We=Be.data;if(Pe&&We.length>4){var Ge=new Ue(We).readSliceType();Ge!==2&&Ge!==4&&Ge!==7&&Ge!==9||(Re.key=!0)}break;case 5:Q=!0,Re||(Re=Z.avcSample=Fe(!0,C.pts,C.dts,"")),Re.key=!0,Re.frame=!0;break;case 6:Q=!0,(0,ne.parseSEIMessageFromNALu)(Be.data,1,C.pts,O.samples);break;case 7:if(Q=!0,Pe=!0,!T.sps){var $e=new Ue(Be.data).readSPS();T.width=$e.width,T.height=$e.height,T.pixelRatio=$e.pixelRatio,T.sps=[Be.data],T.duration=Z._duration;for(var ht=Be.data.subarray(1,4),Dt="avc1.",ze=0;ze<3;ze++){var Pt=ht[ze].toString(16);Pt.length<2&&(Pt="0"+Pt),Dt+=Pt}T.codec=Dt}break;case 8:Q=!0,T.pps||(T.pps=[Be.data]);break;case 9:Q=!1,T.audFound=!0,Re&&Xe(Re,T),Re=Z.avcSample=Fe(!1,C.pts,C.dts,"");break;case 12:Q=!0;break;default:Q=!1,Re&&(Re.debug+="unknown NAL "+Be.type+" ")}Re&&Q&&Re.units.push(Be)}),G&&Re&&(Xe(Re,T),this.avcSample=null)},N.getLastNalUnit=function(T){var O,C,G=this.avcSample;if(G&&G.units.length!==0||(G=T[T.length-1]),(O=G)!==null&&O!==void 0&&O.units){var Q=G.units;C=Q[Q.length-1]}return C},N.parseAVCNALu=function(T,O){var C,G,Q=O.byteLength,Z=T.naluState||0,Te=Z,Re=[],Pe=0,Be=-1,We=0;for(Z===-1&&(Be=0,We=31&O[0],Z=0,Pe=1);Pe<Q;)if(C=O[Pe++],Z)if(Z!==1)if(C)if(C===1){if(Be>=0){var Ge={data:O.subarray(Be,Pe-Z-1),type:We};Re.push(Ge)}else{var $e=this.getLastNalUnit(T.samples);if($e&&(Te&&Pe<=4-Te&&$e.state&&($e.data=$e.data.subarray(0,$e.data.byteLength-Te)),(G=Pe-Z-1)>0)){var ht=new Uint8Array($e.data.byteLength+G);ht.set($e.data,0),ht.set(O.subarray(0,G),$e.data.byteLength),$e.data=ht,$e.state=0}}Pe<Q?(Be=Pe,We=31&O[Pe],Z=0):Z=-1}else Z=0;else Z=3;else Z=C?0:2;else Z=C?0:1;if(Be>=0&&Z>=0){var Dt={data:O.subarray(Be,Q),type:We,state:Z};Re.push(Dt)}if(Re.length===0){var ze=this.getLastNalUnit(T.samples);if(ze){var Pt=new Uint8Array(ze.data.byteLength+O.byteLength);Pt.set(ze.data,0),Pt.set(O,ze.data.byteLength),ze.data=Pt}}return T.naluState=Z,Re},N.parseAACPES=function(T,O){var C,G,Q,Z,Te,Re=0,Pe=this.aacOverFlow,Be=O.data;if(Pe){this.aacOverFlow=null;var We=Pe.missing,Ge=Pe.sample.unit.byteLength;if(We===-1){var $e=new Uint8Array(Ge+Be.byteLength);$e.set(Pe.sample.unit,0),$e.set(Be,Ge),Be=$e}else{var ht=Ge-We;Pe.sample.unit.set(Be.subarray(0,We),ht),T.samples.push(Pe.sample),Re=Pe.missing}}for(C=Re,G=Be.length;C<G-1&&!ke(Be,C);C++);if(C===Re||(C<G-1?(Q="AAC PES did not start with ADTS header,offset:"+C,Z=!1):(Q="no ADTS header found in AAC PES",Z=!0),J.logger.warn("parsing error:"+Q),this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:re.ErrorTypes.MEDIA_ERROR,details:re.ErrorDetails.FRAG_PARSING_ERROR,fatal:Z,reason:Q}),!Z)){if(V(T,this.observer,Be,C,this.audioCodec),O.pts!==void 0)Te=O.pts;else{if(!Pe)return void J.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var Dt=E(T.samplerate);Te=Pe.sample.pts+Dt}for(var ze,Pt=0;C<G;){if(C+=(ze=U(T,Be,C,Te,Pt)).length,ze.missing){this.aacOverFlow=ze;break}for(Pt++;C<G-1&&!ke(Be,C);C++);}}},N.parseMPEGPES=function(T,O){var C=O.data,G=C.length,Q=0,Z=0,Te=O.pts;if(Te!==void 0)for(;Z<G;)if(pe(C,Z)){var Re=qe(T,C,Z,Te,Q);if(!Re)break;Z+=Re.length,Q++}else Z++;else J.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},N.parseID3PES=function(T,O){if(O.pts!==void 0){var C=ve({},O,{type:this._avcTrack?L.MetadataSchema.emsg:L.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});T.samples.push(C)}else J.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},te}();function lt(te,N){return lt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,O){return T.__proto__=O,T},lt(te,N)}let Ct=function(te){var N,T;function O(){return te.apply(this,arguments)||this}T=te,(N=O).prototype=Object.create(T.prototype),N.prototype.constructor=N,lt(N,T);var C=O.prototype;return C.resetInitSegment=function(G,Q,Z,Te){te.prototype.resetInitSegment.call(this,G,Q,Z,Te),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:Q,duration:Te,inputTimeScale:9e4,dropped:0}},O.probe=function(G){if(!G)return!1;for(var Q=(k.getID3Data(G,0)||[]).length,Z=G.length;Q<Z;Q++)if(se(G,Q))return J.logger.log("MPEG Audio sync word found !"),!0;return!1},C.canParse=function(G,Q){return function(Z,Te){return ie(Z,Te)&&4<=Z.length-Te}(G,Q)},C.appendFrame=function(G,Q,Z){if(this.basePTS!==null)return qe(G,Q,Z,this.basePTS,this.frameIndex)},O}(ye);var Rt=B(524),St=B(923);function wt(te,N){var T=te==null?void 0:te.codec;return T&&T.length>4?T:T==="hvc1"||T==="hev1"?"hvc1.1.c.L120.90":T==="av01"?"av01.0.04M.08":T==="avc1"||N===St.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}let gt=function(){function te(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var N=te.prototype;return N.destroy=function(){},N.resetTimeStamp=function(T){this.initPTS=T,this.lastEndTime=null},N.resetNextTimestamp=function(){this.lastEndTime=null},N.resetInitSegment=function(T,O,C,G){this.audioCodec=O,this.videoCodec=C,this.generateInitSegment((0,ne.patchEncyptionData)(T,G)),this.emitInitSegment=!0},N.generateInitSegment=function(T){var O=this.audioCodec,C=this.videoCodec;if(!T||!T.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var G=this.initData=(0,ne.parseInitSegment)(T);O||(O=wt(G.audio,St.ElementaryStreamTypes.AUDIO)),C||(C=wt(G.video,St.ElementaryStreamTypes.VIDEO));var Q={};G.audio&&G.video?Q.audiovideo={container:"video/mp4",codec:O+","+C,initSegment:T,id:"main"}:G.audio?Q.audio={container:"audio/mp4",codec:O,initSegment:T,id:"audio"}:G.video?Q.video={container:"video/mp4",codec:C,initSegment:T,id:"main"}:J.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=Q},N.remux=function(T,O,C,G,Q){var Z,Te=this.initPTS,Re=this.lastEndTime,Pe={audio:void 0,video:void 0,text:G,id3:C,initSegment:void 0};(0,g.isFiniteNumber)(Re)||(Re=this.lastEndTime=Q||0);var Be=O.samples;if(!Be||!Be.length)return Pe;var We={initPTS:void 0,timescale:1},Ge=this.initData;if(Ge&&Ge.length||(this.generateInitSegment(Be),Ge=this.initData),!Ge||!Ge.length)return J.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),Pe;this.emitInitSegment&&(We.tracks=this.initTracks,this.emitInitSegment=!1);var $e=(0,ne.getStartDTS)(Ge,Be);(0,g.isFiniteNumber)(Te)||(this.initPTS=We.initPTS=Te=$e-Q);var ht=(0,ne.getDuration)(Be,Ge),Dt=T?$e-Te:Re,ze=Dt+ht;(0,ne.offsetStartDTS)(Ge,Be,Te),ht>0?this.lastEndTime=ze:(J.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var Pt=!!Ge.audio,tr=!!Ge.video,jt="";Pt&&(jt+="audio"),tr&&(jt+="video");var Ft={data1:Be,startPTS:Dt,startDTS:Dt,endPTS:ze,endDTS:ze,type:jt,hasAudio:Pt,hasVideo:tr,nb:1,dropped:0};Pe.audio=Ft.type==="audio"?Ft:void 0,Pe.video=Ft.type!=="audio"?Ft:void 0,Pe.initSegment=We;var Ht=(Z=this.initPTS)!=null?Z:0;return Pe.id3=(0,Rt.flushTextTrackMetadataCueSamples)(C,Q,Ht,Ht),G.samples.length&&(Pe.text=(0,Rt.flushTextTrackUserdataCueSamples)(G,Q,Ht)),Pe},te}();var dt;try{dt=self.performance.now.bind(self.performance)}catch{J.logger.debug("Unable to use Performance API on this environment"),dt=self.Date.now}var tt=[{demux:z,remux:gt},{demux:it,remux:Rt.default},{demux:de,remux:Rt.default},{demux:Ct,remux:Rt.default}],It=function(){function te(T,O,C,G,Q){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=T,this.typeSupported=O,this.config=C,this.vendor=G,this.id=Q}var N=te.prototype;return N.configure=function(T){this.transmuxConfig=T,this.decrypter&&this.decrypter.reset()},N.push=function(T,O,C,G){var Q=this,Z=C.transmuxing;Z.executeStart=dt();var Te=new Uint8Array(T),Re=this.currentTransmuxState,Pe=this.transmuxConfig;G&&(this.currentTransmuxState=G);var Be=G||Re,We=Be.contiguous,Ge=Be.discontinuity,$e=Be.trackSwitch,ht=Be.accurateTimeOffset,Dt=Be.timeOffset,ze=Be.initSegmentChange,Pt=Pe.audioCodec,tr=Pe.videoCodec,jt=Pe.defaultInitPts,Ft=Pe.duration,Ht=Pe.initSegmentData,rt=function(Cr,vr){var Gt=null;return Cr.byteLength>0&&vr!=null&&vr.key!=null&&vr.iv!==null&&vr.method!=null&&(Gt=vr),Gt}(Te,O);if(rt&&rt.method==="AES-128"){var lr=this.getDecrypter();if(!lr.isSync())return this.decryptionPromise=lr.webCryptoDecrypt(Te,rt.key.buffer,rt.iv.buffer).then(function(Cr){var vr=Q.push(Cr,null,C);return Q.decryptionPromise=null,vr}),this.decryptionPromise;var Ar=lr.softwareDecrypt(Te,rt.key.buffer,rt.iv.buffer);if(!Ar)return Z.executeEnd=dt(),Ut(C);Te=new Uint8Array(Ar)}var Kt=this.needsProbing(Ge,$e);Kt&&this.configureTransmuxer(Te),(Ge||$e||ze||Kt)&&this.resetInitSegment(Ht,Pt,tr,Ft,O),(Ge||ze||Kt)&&this.resetInitialTimestamp(jt),We||this.resetContiguity();var Jt=this.transmux(Te,rt,Dt,ht,C),pr=this.currentTransmuxState;return pr.contiguous=!0,pr.discontinuity=!1,pr.trackSwitch=!1,Z.executeEnd=dt(),Jt},N.flush=function(T){var O=this,C=T.transmuxing;C.executeStart=dt();var G=this.decrypter,Q=this.currentTransmuxState,Z=this.decryptionPromise;if(Z)return Z.then(function(){return O.flush(T)});var Te=[],Re=Q.timeOffset;if(G){var Pe=G.flush();Pe&&Te.push(this.push(Pe,null,T))}var Be=this.demuxer,We=this.remuxer;if(!Be||!We)return this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:re.ErrorTypes.MEDIA_ERROR,details:re.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),C.executeEnd=dt(),[Ut(T)];var Ge=Be.flush(Re);return Wt(Ge)?Ge.then(function($e){return O.flushRemux(Te,$e,T),Te}):(this.flushRemux(Te,Ge,T),Te)},N.flushRemux=function(T,O,C){var G=O.audioTrack,Q=O.videoTrack,Z=O.id3Track,Te=O.textTrack,Re=this.currentTransmuxState,Pe=Re.accurateTimeOffset,Be=Re.timeOffset;J.logger.log("[transmuxer.ts]: Flushed fragment "+C.sn+(C.part>-1?" p: "+C.part:"")+" of level "+C.level);var We=this.remuxer.remux(G,Q,Z,Te,Be,Pe,!0,this.id);T.push({remuxResult:We,chunkMeta:C}),C.transmuxing.executeEnd=dt()},N.resetInitialTimestamp=function(T){var O=this.demuxer,C=this.remuxer;O&&C&&(O.resetTimeStamp(T),C.resetTimeStamp(T))},N.resetContiguity=function(){var T=this.demuxer,O=this.remuxer;T&&O&&(T.resetContiguity(),O.resetNextTimestamp())},N.resetInitSegment=function(T,O,C,G,Q){var Z=this.demuxer,Te=this.remuxer;Z&&Te&&(Z.resetInitSegment(T,O,C,G),Te.resetInitSegment(T,O,C,Q))},N.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},N.transmux=function(T,O,C,G,Q){return O&&O.method==="SAMPLE-AES"?this.transmuxSampleAes(T,O,C,G,Q):this.transmuxUnencrypted(T,C,G,Q)},N.transmuxUnencrypted=function(T,O,C,G){var Q=this.demuxer.demux(T,O,!1,!this.config.progressive),Z=Q.audioTrack,Te=Q.videoTrack,Re=Q.id3Track,Pe=Q.textTrack;return{remuxResult:this.remuxer.remux(Z,Te,Re,Pe,O,C,!1,this.id),chunkMeta:G}},N.transmuxSampleAes=function(T,O,C,G,Q){var Z=this;return this.demuxer.demuxSampleAes(T,O,C).then(function(Te){return{remuxResult:Z.remuxer.remux(Te.audioTrack,Te.videoTrack,Te.id3Track,Te.textTrack,C,G,!1,Z.id),chunkMeta:Q}})},N.configureTransmuxer=function(T){for(var O,C=this.config,G=this.observer,Q=this.typeSupported,Z=this.vendor,Te=0,Re=tt.length;Te<Re;Te++)if(tt[Te].demux.probe(T)){O=tt[Te];break}O||(J.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),O={demux:z,remux:gt});var Pe=this.demuxer,Be=this.remuxer,We=O.remux,Ge=O.demux;Be&&Be instanceof We||(this.remuxer=new We(G,C,Q,Z)),Pe&&Pe instanceof Ge||(this.demuxer=new Ge(G,C,Q),this.probe=Ge.probe)},N.needsProbing=function(T,O){return!this.demuxer||!this.remuxer||T||O},N.getDecrypter=function(){var T=this.decrypter;return T||(T=this.decrypter=new R.default(this.config)),T},te}(),Ut=function(te){return{remuxResult:{},chunkMeta:te}};function Wt(te){return"then"in te&&te.then instanceof Function}var Bt=function(te,N,T,O,C){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=te,this.videoCodec=N,this.initSegmentData=T,this.duration=O,this.defaultInitPts=C},ar=function(te,N,T,O,C,G){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=te,this.contiguous=N,this.accurateTimeOffset=T,this.trackSwitch=O,this.timeOffset=C,this.initSegmentChange=G}},973:(ae,W,B)=>{"use strict";var j,re;B.r(W),B.d(W,{ErrorDetails:()=>re,ErrorTypes:()=>j}),function(R){R.NETWORK_ERROR="networkError",R.MEDIA_ERROR="mediaError",R.KEY_SYSTEM_ERROR="keySystemError",R.MUX_ERROR="muxError",R.OTHER_ERROR="otherError"}(j||(j={})),function(R){R.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",R.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",R.KEY_SYSTEM_NO_SESSION="keySystemNoSession",R.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",R.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",R.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",R.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",R.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",R.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",R.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",R.MANIFEST_LOAD_ERROR="manifestLoadError",R.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",R.MANIFEST_PARSING_ERROR="manifestParsingError",R.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",R.LEVEL_EMPTY_ERROR="levelEmptyError",R.LEVEL_LOAD_ERROR="levelLoadError",R.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",R.LEVEL_SWITCH_ERROR="levelSwitchError",R.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",R.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",R.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",R.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",R.FRAG_LOAD_ERROR="fragLoadError",R.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",R.FRAG_DECRYPT_ERROR="fragDecryptError",R.FRAG_PARSING_ERROR="fragParsingError",R.REMUX_ALLOC_ERROR="remuxAllocError",R.KEY_LOAD_ERROR="keyLoadError",R.KEY_LOAD_TIMEOUT="keyLoadTimeOut",R.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",R.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",R.BUFFER_APPEND_ERROR="bufferAppendError",R.BUFFER_APPENDING_ERROR="bufferAppendingError",R.BUFFER_STALLED_ERROR="bufferStalledError",R.BUFFER_FULL_ERROR="bufferFullError",R.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",R.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",R.INTERNAL_EXCEPTION="internalException",R.INTERNAL_ABORTED="aborted",R.UNKNOWN="unknown"}(re||(re={}))},851:(ae,W,B)=>{"use strict";var j;B.r(W),B.d(W,{Events:()=>j}),function(re){re.MEDIA_ATTACHING="hlsMediaAttaching",re.MEDIA_ATTACHED="hlsMediaAttached",re.MEDIA_DETACHING="hlsMediaDetaching",re.MEDIA_DETACHED="hlsMediaDetached",re.BUFFER_RESET="hlsBufferReset",re.BUFFER_CODECS="hlsBufferCodecs",re.BUFFER_CREATED="hlsBufferCreated",re.BUFFER_APPENDING="hlsBufferAppending",re.BUFFER_APPENDED="hlsBufferAppended",re.BUFFER_EOS="hlsBufferEos",re.BUFFER_FLUSHING="hlsBufferFlushing",re.BUFFER_FLUSHED="hlsBufferFlushed",re.MANIFEST_LOADING="hlsManifestLoading",re.MANIFEST_LOADED="hlsManifestLoaded",re.MANIFEST_PARSED="hlsManifestParsed",re.LEVEL_SWITCHING="hlsLevelSwitching",re.LEVEL_SWITCHED="hlsLevelSwitched",re.LEVEL_LOADING="hlsLevelLoading",re.LEVEL_LOADED="hlsLevelLoaded",re.LEVEL_UPDATED="hlsLevelUpdated",re.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",re.LEVELS_UPDATED="hlsLevelsUpdated",re.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",re.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",re.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",re.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",re.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",re.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",re.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",re.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",re.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",re.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",re.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",re.CUES_PARSED="hlsCuesParsed",re.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",re.INIT_PTS_FOUND="hlsInitPtsFound",re.FRAG_LOADING="hlsFragLoading",re.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",re.FRAG_LOADED="hlsFragLoaded",re.FRAG_DECRYPTED="hlsFragDecrypted",re.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",re.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",re.FRAG_PARSING_METADATA="hlsFragParsingMetadata",re.FRAG_PARSED="hlsFragParsed",re.FRAG_BUFFERED="hlsFragBuffered",re.FRAG_CHANGED="hlsFragChanged",re.FPS_DROP="hlsFpsDrop",re.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",re.ERROR="hlsError",re.DESTROYING="hlsDestroying",re.KEY_LOADING="hlsKeyLoading",re.KEY_LOADED="hlsKeyLoaded",re.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",re.BACK_BUFFER_REACHED="hlsBackBufferReached"}(j||(j={}))},76:(ae,W,B)=>{"use strict";B.r(W),B.d(W,{default:()=>ja});var j,re=B(945),R=B(965),g=B(851),k=B(973),L=B(93),me=/^(\d+)x(\d+)$/,ne=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,ce=function(){function d(e){for(var t in typeof e=="string"&&(e=d.parseAttrList(e)),e)e.hasOwnProperty(t)&&(this[t]=e[t])}var o=d.prototype;return o.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},o.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var i=new Uint8Array(t.length/2),n=0;n<t.length/2;n++)i[n]=parseInt(t.slice(2*n,2*n+2),16);return i}return null},o.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},o.decimalFloatingPoint=function(e){return parseFloat(this[e])},o.optionalFloat=function(e,t){var i=this[e];return i?parseFloat(i):t},o.enumeratedString=function(e){return this[e]},o.bool=function(e){return this[e]==="YES"},o.decimalResolution=function(e){var t=me.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},d.parseAttrList=function(e){var t,i={};for(ne.lastIndex=0;(t=ne.exec(e))!==null;){var n=t[2];n.indexOf('"')===0&&n.lastIndexOf('"')===n.length-1&&(n=n.slice(1,-1)),i[t[1]]=n}return i},d}();function we(){return we=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},we.apply(this,arguments)}function q(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}(function(d){d.ID="ID",d.CLASS="CLASS",d.START_DATE="START-DATE",d.DURATION="DURATION",d.END_DATE="END-DATE",d.END_ON_NEXT="END-ON-NEXT",d.PLANNED_DURATION="PLANNED-DURATION",d.SCTE35_OUT="SCTE35-OUT",d.SCTE35_IN="SCTE35-IN"})(j||(j={}));var ye=function(){function d(t,i){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,i){var n=i.attr;for(var a in n)if(Object.prototype.hasOwnProperty.call(t,a)&&t[a]!==n[a]){L.logger.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=a;break}t=we(new ce({}),n,t)}if(this.attr=t,this._startDate=new Date(t[j.START_DATE]),j.END_DATE in this.attr){var r=new Date(this.attr[j.END_DATE]);(0,R.isFiniteNumber)(r.getTime())&&(this._endDate=r)}}var o,e;return o=d,(e=[{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 t=this.duration;return t!==null?new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if(j.DURATION in this.attr){var t=this.attr.decimalFloatingPoint(j.DURATION);if((0,R.isFiniteNumber)(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return j.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(j.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(j.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,R.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}])&&q(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}(),J=B(923);function oe(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var K,Ee,ke,Ne=function(){function d(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}var o,e;return d.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var i=this.lastPartSn-t.lastPartSn,n=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!n||!!i,this.advanced=this.endSN>t.endSN||i>0||i===0&&n>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},o=d,(e=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&(0,R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return(t=this.partList)!==null&&t!==void 0&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return(t=this.fragments)!==null&&t!==void 0&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return(t=this.partList)!==null&&t!==void 0&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return(t=this.partList)!==null&&t!==void 0&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&oe(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function V(d){return Uint8Array.from(atob(d),function(o){return o.charCodeAt(0)})}function E(d){return Uint8Array.from(unescape(encodeURIComponent(d)),function(o){return o.charCodeAt(0)})}function U(d){switch(d){case Ee.FAIRPLAY:return K.FAIRPLAY;case Ee.PLAYREADY:return K.PLAYREADY;case Ee.WIDEVINE:return K.WIDEVINE;case Ee.CLEARKEY:return K.CLEARKEY}}function D(d){switch(d){case K.FAIRPLAY:return Ee.FAIRPLAY;case K.PLAYREADY:return Ee.PLAYREADY;case K.WIDEVINE:return Ee.WIDEVINE;case K.CLEARKEY:return Ee.CLEARKEY}}function de(d){var o=d.drmSystems,e=d.widevineLicenseUrl,t=o?[K.FAIRPLAY,K.WIDEVINE,K.PLAYREADY,K.CLEARKEY].filter(function(i){return!!o[i]}):[];return!t[K.WIDEVINE]&&e&&t.push(K.WIDEVINE),t}(function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.fps",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="com.widevine.alpha"})(K||(K={})),function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.streamingkeydelivery",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"}(Ee||(Ee={})),function(d){d.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"}(ke||(ke={}));var Se=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null,z=B(63),$={},Le=function(){function d(e,t,i,n,a){n===void 0&&(n=[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=i,this.keyFormatVersions=n,this.iv=a,this.encrypted=!!e&&e!=="NONE",this.isCommonEncryption=this.encrypted&&e!=="AES-128"}d.clearKeyUriToKeyIdMap=function(){$={}};var o=d.prototype;return o.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;switch(this.keyFormat){case"identity":return this.method==="SAMPLE-AES";case Ee.FAIRPLAY:case Ee.WIDEVINE:case Ee.PLAYREADY:case Ee.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},o.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||L.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=function(F){for(var P=new Uint8Array(16),X=12;X<16;X++)P[X]=F>>8*(15-X)&255;return P}(e);return new d(this.method,this.uri,"identity",this.keyFormatVersions,t)}var i=function(F){var P,X,ue=F.split(":"),_e=null;if(ue[0]==="data"&&ue.length===2){var ge=ue[1].split(";"),De=ge[ge.length-1].split(",");if(De.length===2){var He=De[0]==="base64",Je=De[1];He?(ge.splice(-1,1),_e=V(Je)):(P=E(Je).subarray(0,16),(X=new Uint8Array(16)).set(P,16-P.length),_e=X)}}return _e}(this.uri);if(i)switch(this.keyFormat){case Ee.WIDEVINE:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case Ee.PLAYREADY:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,z.mp4pssh)(n,null,i);var a=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2),r=String.fromCharCode.apply(null,Array.from(a)),s=r.substring(r.indexOf("<"),r.length),l=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(l){var u=l.childNodes[0]?l.childNodes[0].nodeValue:l.getAttribute("VALUE");if(u){var c=V(u).subarray(0,16);(function(F){var P=function(X,ue,_e){var ge=X[ue];X[ue]=X[_e],X[_e]=ge};P(F,0,3),P(F,1,2),P(F,4,5),P(F,6,7)})(c),this.keyId=c}}break;default:var v=i.subarray(0,16);if(v.length!==16){var m=new Uint8Array(16);m.set(v,16-v.length),v=m}this.keyId=v}if(!this.keyId||this.keyId.byteLength!==16){var _=$[this.uri];if(!_){var S=Object.keys($).length%Number.MAX_SAFE_INTEGER;_=new Uint8Array(16),new DataView(_.buffer,12,4).setUint32(0,S),$[this.uri]=_}this.keyId=_}return this},d}(),Oe={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function xe(d,o){return MediaSource.isTypeSupported((o||"video")+'/mp4;codecs="'+d+'"')}function be(){return be=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},be.apply(this,arguments)}var qe=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+|#EXT-X-SESSION-KEY:([^\n\r]*)[\r\n]+/g,at=/#EXT-X-MEDIA:(.*)/g,ie=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),pe=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),se=function(){function d(){}return d.findGroup=function(o,e){for(var t=0;t<o.length;t++){var i=o[t];if(i.id===e)return i}},d.convertAVC1ToAVCOTI=function(o){var e=o.split(".");if(e.length>2){var t=e.shift()+".";return(t+=parseInt(e.shift()).toString(16))+("000"+parseInt(e.shift()).toString(16)).slice(-4)}return o},d.resolve=function(o,e){return(0,re.buildAbsoluteURL)(e,o,{alwaysNormalize:!0})},d.parseMasterPlaylist=function(o,e){var t,i=[],n=[],a={},r=[],s=!1;for(qe.lastIndex=0;(t=qe.exec(o))!=null;)if(t[1]){var l,u=new ce(t[1]),c={attrs:u,bitrate:u.decimalInteger("AVERAGE-BANDWIDTH")||u.decimalInteger("BANDWIDTH"),name:u.NAME,url:d.resolve(t[2],e)},v=u.decimalResolution("RESOLUTION");v&&(c.width=v.width,c.height=v.height),H((u.CODECS||"").split(/[ ,]+/).filter(function(F){return F}),c),c.videoCodec&&c.videoCodec.indexOf("avc1")!==-1&&(c.videoCodec=d.convertAVC1ToAVCOTI(c.videoCodec)),(l=c.unknownCodecs)!==null&&l!==void 0&&l.length||n.push(c),i.push(c)}else if(t[3]){var m=new ce(t[3]);m["DATA-ID"]&&(s=!0,a[m["DATA-ID"]]=m)}else if(t[4]){var _=t[4],S=Ue(_,e);S.encrypted&&S.isSupported()?r.push(S):L.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+_+'"')}return{levels:n.length>0&&n.length<i.length?n:i,sessionData:s?a:null,sessionKeys:r.length?r:null}},d.parseMasterPlaylistMedia=function(o,e,t,i){var n;i===void 0&&(i=[]);var a=[],r=0;for(at.lastIndex=0;(n=at.exec(o))!==null;){var s=new ce(n[1]);if(s.TYPE===t){var l={attrs:s,bitrate:0,id:r++,groupId:s["GROUP-ID"],instreamId:s["INSTREAM-ID"],name:s.NAME||s.LANGUAGE||"",type:t,default:s.bool("DEFAULT"),autoselect:s.bool("AUTOSELECT"),forced:s.bool("FORCED"),lang:s.LANGUAGE,url:s.URI?d.resolve(s.URI,e):""};if(i.length){var u=d.findGroup(i,l.groupId)||i[0];ve(l,u,"audioCodec"),ve(l,u,"textCodec")}a.push(l)}}return a},d.parseLevelPlaylist=function(o,e,t,i,n){var a,r,s,l=new Ne(e),u=l.fragments,c=null,v=0,m=0,_=0,S=0,F=null,P=new J.Fragment(i,e),X=-1,ue=!1;for(ie.lastIndex=0,l.m3u8=o;(a=ie.exec(o))!==null;){ue&&(ue=!1,(P=new J.Fragment(i,e)).start=_,P.sn=v,P.cc=S,P.level=t,c&&(P.initSegment=c,P.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null));var _e=a[1];if(_e){P.duration=parseFloat(_e);var ge=(" "+a[2]).slice(1);P.title=ge||null,P.tagList.push(ge?["INF",_e,ge]:["INF",_e])}else if(a[3]){if((0,R.isFiniteNumber)(P.duration)){if(P.start=_,s){P.levelkeys=s;var De=l.encryptedFragments;!P.levelkeys||!Object.keys(P.levelkeys).some(function(Ir){return P.levelkeys[Ir].isCommonEncryption})||De.length&&De[De.length-1].levelkeys===s||De.push(P)}P.sn=v,P.level=t,P.cc=S,P.urlId=n,u.push(P),P.relurl=(" "+a[3]).slice(1),Ie(P,F),F=P,_+=P.duration,v++,m=0,ue=!0}}else if(a[4]){var He=(" "+a[4]).slice(1);F?P.setByteRange(He,F):P.setByteRange(He)}else if(a[5])P.rawProgramDateTime=(" "+a[5]).slice(1),P.tagList.push(["PROGRAM-DATE-TIME",P.rawProgramDateTime]),X===-1&&(X=u.length);else{if(!(a=a[0].match(pe))){L.logger.warn("No matches on slow regex match for level playlist!");continue}for(r=1;r<a.length&&a[r]===void 0;r++);var Je=(" "+a[r]).slice(1),Ae=(" "+a[r+1]).slice(1),Ke=a[r+2]?(" "+a[r+2]).slice(1):"";switch(Je){case"PLAYLIST-TYPE":l.type=Ae.toUpperCase();break;case"MEDIA-SEQUENCE":v=l.startSN=parseInt(Ae);break;case"SKIP":var je=new ce(Ae),pt=je.decimalInteger("SKIPPED-SEGMENTS");if((0,R.isFiniteNumber)(pt)){l.skippedSegments=pt;for(var Mt=pt;Mt--;)u.unshift(null);v+=pt}var yt=je.enumeratedString("RECENTLY-REMOVED-DATERANGES");yt&&(l.recentlyRemovedDateranges=yt.split(" "));break;case"TARGETDURATION":l.targetduration=parseFloat(Ae);break;case"VERSION":l.version=parseInt(Ae);break;case"EXTM3U":break;case"ENDLIST":l.live=!1;break;case"#":(Ae||Ke)&&P.tagList.push(Ke?[Ae,Ke]:[Ae]);break;case"DISCONTINUITY":S++,P.tagList.push(["DIS"]);break;case"GAP":P.tagList.push([Je]);break;case"BITRATE":P.tagList.push([Je,Ae]);break;case"DATERANGE":var kt=new ce(Ae),xt=new ye(kt,l.dateRanges[kt.ID]);xt.isValid||l.skippedSegments?l.dateRanges[xt.id]=xt:L.logger.warn('Ignoring invalid DATERANGE tag: "'+Ae+'"'),P.tagList.push(["EXT-X-DATERANGE",Ae]);break;case"DISCONTINUITY-SEQUENCE":S=parseInt(Ae);break;case"KEY":var ir=Ue(Ae,e);if(ir.isSupported()){if(ir.method==="NONE"){s=void 0;break}s||(s={}),s[ir.keyFormat]&&(s=be({},s)),s[ir.keyFormat]=ir}else L.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+Ae+'"');break;case"START":var er=new ce(Ae).decimalFloatingPoint("TIME-OFFSET");(0,R.isFiniteNumber)(er)&&(l.startTimeOffset=er);break;case"MAP":var Yt=new ce(Ae);if(P.duration){var nr=new J.Fragment(i,e);Fe(nr,Yt,t,s),c=nr,P.initSegment=c,c.rawProgramDateTime&&!P.rawProgramDateTime&&(P.rawProgramDateTime=c.rawProgramDateTime)}else Fe(P,Yt,t,s),c=P,ue=!0;break;case"SERVER-CONTROL":var _r=new ce(Ae);l.canBlockReload=_r.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=_r.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&_r.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=_r.optionalFloat("PART-HOLD-BACK",0),l.holdBack=_r.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Jn=new ce(Ae);l.partTarget=Jn.decimalFloatingPoint("PART-TARGET");break;case"PART":var Pr=l.partList;Pr||(Pr=l.partList=[]);var Bi=m>0?Pr[Pr.length-1]:void 0,ji=m++,Gi=new J.Part(new ce(Ae),P,e,ji,Bi);Pr.push(Gi),P.duration+=Gi.duration;break;case"PRELOAD-HINT":var ct=new ce(Ae);l.preloadHint=ct;break;case"RENDITION-REPORT":var Et=new ce(Ae);l.renditionReports=l.renditionReports||[],l.renditionReports.push(Et);break;default:L.logger.warn("line parsed but not handled: "+a)}}}F&&!F.relurl?(u.pop(),_-=F.duration,l.partList&&(l.fragmentHint=F)):l.partList&&(Ie(P,F),P.cc=S,l.fragmentHint=P);var Ei=u.length,jr=u[0],Or=u[Ei-1];if((_+=l.skippedSegments*l.targetduration)>0&&Ei&&Or){l.averagetargetduration=_/Ei;var Ti=Or.sn;l.endSN=Ti!=="initSegment"?Ti:0,l.live||(Or.endList=!0),jr&&(l.startCC=jr.cc)}else l.endSN=0,l.startCC=0;return l.fragmentHint&&(_+=l.fragmentHint.duration),l.totalduration=_,l.endCC=S,X>0&&function(Ir,Gr){for(var Qr=Ir[Gr],Dr=Gr;Dr--;){var Jr=Ir[Dr];if(!Jr)return;Jr.programDateTime=Qr.programDateTime-1e3*Jr.duration,Qr=Jr}}(u,X),l},d}();function Ue(d,o){var e,t,i=new ce(d),n=(e=i.enumeratedString("METHOD"))!=null?e:"",a=i.URI,r=i.hexadecimalInteger("IV"),s=i.enumeratedString("KEYFORMATVERSIONS"),l=(t=i.enumeratedString("KEYFORMAT"))!=null?t:"identity";a&&i.IV&&!r&&L.logger.error("Invalid IV: "+i.IV);var u=a?se.resolve(a,o):"",c=(s||"1").split("/").map(Number).filter(Number.isFinite);return new Le(n,u,l,c,r)}function H(d,o){["video","audio","text"].forEach(function(e){var t=d.filter(function(n){return function(a,r){var s=Oe[r];return!!s&&s[a.slice(0,4)]===!0}(n,e)});if(t.length){var i=t.filter(function(n){return n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0});o[e+"Codec"]=i.length>0?i[0]:t[0],d=d.filter(function(n){return t.indexOf(n)===-1})}}),o.unknownCodecs=d}function ve(d,o,e){var t=o[e];t&&(d[e]=t)}function Ie(d,o){d.rawProgramDateTime?d.programDateTime=Date.parse(d.rawProgramDateTime):o!=null&&o.programDateTime&&(d.programDateTime=o.endProgramDateTime),(0,R.isFiniteNumber)(d.programDateTime)||(d.programDateTime=null,d.rawProgramDateTime=null)}function Fe(d,o,e,t){d.relurl=o.URI,o.BYTERANGE&&d.setByteRange(o.BYTERANGE),d.level=e,d.sn="initSegment",t&&(d.levelkeys=t),d.initSegment=null}var fe=B(308);function Ce(d,o){var e=d.url;return e!==void 0&&e.indexOf("data:")!==0||(e=o.url),e}let Ve=function(){function d(e){this.hls=void 0,this.loaders=Object.create(null),this.hls=e,this.registerListeners()}var o=d.prototype;return o.startLoad=function(e){},o.stopLoad=function(){this.destroyInternalLoaders()},o.registerListeners=function(){var e=this.hls;e.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(g.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(g.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},o.unregisterListeners=function(){var e=this.hls;e.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(g.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(g.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},o.createInternalLoader=function(e){var t=this.hls.config,i=t.pLoader,n=t.loader,a=new(i||n)(t);return e.loader=a,this.loaders[e.type]=a,a},o.getInternalLoader=function(e){return this.loaders[e.type]},o.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},o.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},o.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},o.onManifestLoading=function(e,t){var i=t.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:fe.PlaylistContextType.MANIFEST,url:i,deliveryDirectives:null})},o.onLevelLoading=function(e,t){var i=t.id,n=t.level,a=t.url,r=t.deliveryDirectives;this.load({id:i,groupId:null,level:n,responseType:"text",type:fe.PlaylistContextType.LEVEL,url:a,deliveryDirectives:r})},o.onAudioTrackLoading=function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives;this.load({id:i,groupId:n,level:null,responseType:"text",type:fe.PlaylistContextType.AUDIO_TRACK,url:a,deliveryDirectives:r})},o.onSubtitleTrackLoading=function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives;this.load({id:i,groupId:n,level:null,responseType:"text",type:fe.PlaylistContextType.SUBTITLE_TRACK,url:a,deliveryDirectives:r})},o.load=function(e){var t,i,n,a,r,s,l=this.hls.config,u=this.getInternalLoader(e);if(u){var c=u.context;if(c&&c.url===e.url)return void L.logger.trace("[playlist-loader]: playlist request ongoing");L.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),u.abort()}switch(e.type){case fe.PlaylistContextType.MANIFEST:i=l.manifestLoadingMaxRetry,n=l.manifestLoadingTimeOut,a=l.manifestLoadingRetryDelay,r=l.manifestLoadingMaxRetryTimeout;break;case fe.PlaylistContextType.LEVEL:case fe.PlaylistContextType.AUDIO_TRACK:case fe.PlaylistContextType.SUBTITLE_TRACK:i=0,n=l.levelLoadingTimeOut;break;default:i=l.levelLoadingMaxRetry,n=l.levelLoadingTimeOut,a=l.levelLoadingRetryDelay,r=l.levelLoadingMaxRetryTimeout}if(u=this.createInternalLoader(e),(t=e.deliveryDirectives)!==null&&t!==void 0&&t.part&&(e.type===fe.PlaylistContextType.LEVEL&&e.level!==null?s=this.hls.levels[e.level].details:e.type===fe.PlaylistContextType.AUDIO_TRACK&&e.id!==null?s=this.hls.audioTracks[e.id].details:e.type===fe.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(s=this.hls.subtitleTracks[e.id].details),s)){var v=s.partTarget,m=s.targetduration;v&&m&&(n=Math.min(1e3*Math.max(3*v,.8*m),n))}var _={timeout:n,maxRetry:i,retryDelay:a,maxRetryDelay:r,highWaterMark:0},S={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};u.load(e,_,S)},o.loadsuccess=function(e,t,i,n){n===void 0&&(n=null),this.resetInternalLoader(i.type);var a=e.data;a.indexOf("#EXTM3U")===0?(t.parsing.start=performance.now(),a.indexOf("#EXTINF:")>0||a.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,t,i,n):this.handleMasterPlaylist(e,t,i,n)):this.handleManifestParsingError(e,i,"no EXTM3U delimiter",n)},o.loaderror=function(e,t,i){i===void 0&&(i=null),this.handleNetworkError(t,i,!1,e)},o.loadtimeout=function(e,t,i){i===void 0&&(i=null),this.handleNetworkError(t,i,!0)},o.handleMasterPlaylist=function(e,t,i,n){var a=this.hls,r=e.data,s=Ce(e,i),l=se.parseMasterPlaylist(r,s),u=l.levels,c=l.sessionData,v=l.sessionKeys;if(u.length){var m=u.map(function(X){return{id:X.attrs.AUDIO,audioCodec:X.audioCodec}}),_=u.map(function(X){return{id:X.attrs.SUBTITLES,textCodec:X.textCodec}}),S=se.parseMasterPlaylistMedia(r,s,"AUDIO",m),F=se.parseMasterPlaylistMedia(r,s,"SUBTITLES",_),P=se.parseMasterPlaylistMedia(r,s,"CLOSED-CAPTIONS");S.length&&(S.some(function(X){return!X.url})||!u[0].audioCodec||u[0].attrs.AUDIO||(L.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),S.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new ce({}),bitrate:0,url:""}))),a.trigger(g.Events.MANIFEST_LOADED,{levels:u,audioTracks:S,subtitles:F,captions:P,url:s,stats:t,networkDetails:n,sessionData:c,sessionKeys:v})}else this.handleManifestParsingError(e,i,"no level found in manifest",n)},o.handleTrackOrLevelPlaylist=function(e,t,i,n){var a=this.hls,r=i.id,s=i.level,l=i.type,u=Ce(e,i),c=(0,R.isFiniteNumber)(r)?r:0,v=(0,R.isFiniteNumber)(s)?s:c,m=function(F){switch(F.type){case fe.PlaylistContextType.AUDIO_TRACK:return fe.PlaylistLevelType.AUDIO;case fe.PlaylistContextType.SUBTITLE_TRACK:return fe.PlaylistLevelType.SUBTITLE;default:return fe.PlaylistLevelType.MAIN}}(i),_=se.parseLevelPlaylist(e.data,u,v,m,c);if(_.fragments.length){if(l===fe.PlaylistContextType.MANIFEST){var S={attrs:new ce({}),bitrate:0,details:_,name:"",url:u};a.trigger(g.Events.MANIFEST_LOADED,{levels:[S],audioTracks:[],url:u,stats:t,networkDetails:n,sessionData:null,sessionKeys:null})}t.parsing.end=performance.now(),i.levelDetails=_,this.handlePlaylistLoaded(e,t,i,n)}else a.trigger(g.Events.ERROR,{type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:u,reason:"no fragments found in level",level:typeof i.level=="number"?i.level:void 0})},o.handleManifestParsingError=function(e,t,i,n){this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===fe.PlaylistContextType.MANIFEST,url:e.url,reason:i,response:e,context:t,networkDetails:n})},o.handleNetworkError=function(e,t,i,n){i===void 0&&(i=!1),L.logger.warn("[playlist-loader]: A network "+(i?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var a=k.ErrorDetails.UNKNOWN,r=!1,s=this.getInternalLoader(e);switch(e.type){case fe.PlaylistContextType.MANIFEST:a=i?k.ErrorDetails.MANIFEST_LOAD_TIMEOUT:k.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case fe.PlaylistContextType.LEVEL:a=i?k.ErrorDetails.LEVEL_LOAD_TIMEOUT:k.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case fe.PlaylistContextType.AUDIO_TRACK:a=i?k.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:k.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case fe.PlaylistContextType.SUBTITLE_TRACK:a=i?k.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:k.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1}s&&this.resetInternalLoader(e.type);var l={type:k.ErrorTypes.NETWORK_ERROR,details:a,fatal:r,url:e.url,loader:s,context:e,networkDetails:t};n&&(l.response=n),this.hls.trigger(g.Events.ERROR,l)},o.handlePlaylistLoaded=function(e,t,i,n){var a=i.type,r=i.level,s=i.id,l=i.groupId,u=i.loader,c=i.levelDetails,v=i.deliveryDirectives;if(c!=null&&c.targetduration){if(u)switch(c.live&&(u.getCacheAge&&(c.ageHeader=u.getCacheAge()||0),u.getCacheAge&&!isNaN(c.ageHeader)||(c.ageHeader=0)),a){case fe.PlaylistContextType.MANIFEST:case fe.PlaylistContextType.LEVEL:this.hls.trigger(g.Events.LEVEL_LOADED,{details:c,level:r||0,id:s||0,stats:t,networkDetails:n,deliveryDirectives:v});break;case fe.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(g.Events.AUDIO_TRACK_LOADED,{details:c,id:s||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:v});break;case fe.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(g.Events.SUBTITLE_TRACK_LOADED,{details:c,id:s||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:v})}}else this.handleManifestParsingError(e,i,"invalid target duration",n)},d}();function Xe(d,o){var e;try{e=new Event("addtrack")}catch{(e=document.createEvent("Event")).initEvent("addtrack",!1,!1)}e.track=d,o.dispatchEvent(e)}function it(d,o){var e=d.mode;if(e==="disabled"&&(d.mode="hidden"),d.cues&&!d.cues.getCueById(o.id))try{if(d.addCue(o),!d.cues.getCueById(o.id))throw new Error("addCue is failed for: "+o)}catch(i){L.logger.debug("[texttrack-utils]: "+i);var t=new self.TextTrackCue(o.startTime,o.endTime,o.text);t.id=o.id,d.addCue(t)}e==="disabled"&&(d.mode=e)}function lt(d){var o=d.mode;if(o==="disabled"&&(d.mode="hidden"),d.cues)for(var e=d.cues.length;e--;)d.removeCue(d.cues[e]);o==="disabled"&&(d.mode=o)}function Ct(d,o,e,t){var i=d.mode;if(i==="disabled"&&(d.mode="hidden"),d.cues&&d.cues.length>0)for(var n=function(r,s,l){var u=[],c=function(S,F){if(F<S[0].startTime)return 0;var P=S.length-1;if(F>S[P].endTime)return-1;for(var X=0,ue=P;X<=ue;){var _e=Math.floor((ue+X)/2);if(F<S[_e].startTime)ue=_e-1;else{if(!(F>S[_e].startTime&&X<P))return _e;X=_e+1}}return S[X].startTime-F<F-S[ue].startTime?X:ue}(r,s);if(c>-1)for(var v=c,m=r.length;v<m;v++){var _=r[v];if(_.startTime>=s&&_.endTime<=l)u.push(_);else if(_.startTime>l)return u}return u}(d.cues,o,e),a=0;a<n.length;a++)t&&!t(n[a])||d.removeCue(n[a]);i==="disabled"&&(d.mode=i)}var Rt=B(181),St=B(856);function wt(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var gt=function(){var d=wt();try{new d(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function dt(d,o){return d.getTime()/1e3-o}let tt=function(){function d(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var o=d.prototype;return o.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},o._registerListeners=function(){var e=this.hls;e.on(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(g.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},o._unregisterListeners=function(){var e=this.hls;e.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(g.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},o.onMediaAttached=function(e,t){this.media=t.media},o.onMediaDetaching=function(){this.id3Track&&(lt(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},o.onManifestLoading=function(){this.dateRangeCuesAppended={}},o.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},o.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var i=e[t];if(i.kind==="metadata"&&i.label==="id3")return Xe(i,this.media),i}return this.media.addTextTrack("metadata","id3")}},o.onFragParsingMetadata=function(e,t){if(this.media){var i=this.hls.config,n=i.enableEmsgMetadataCues,a=i.enableID3MetadataCues;if(n||a){var r=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var s=wt(),l=0;l<r.length;l++){var u=r[l].type;if((u!==St.MetadataSchema.emsg||n)&&a){var c=Rt.getID3Frames(r[l].data);if(c){var v=r[l].pts,m=v+r[l].duration;m>gt&&(m=gt),m-v<=0&&(m=v+.25);for(var _=0;_<c.length;_++){var S=c[_];if(!Rt.isTimeStampFrame(S)){this.updateId3CueEnds(v);var F=new s(v,m,"");F.value=S,u&&(F.type=u),this.id3Track.addCue(F)}}}}}}}},o.updateId3CueEnds=function(e){var t,i=(t=this.id3Track)===null||t===void 0?void 0:t.cues;if(i)for(var n=i.length;n--;){var a=i[n];a.startTime<e&&a.endTime===gt&&(a.endTime=e)}},o.onBufferFlushing=function(e,t){var i=t.startOffset,n=t.endOffset,a=t.type,r=this.id3Track,s=this.hls;if(s){var l=s.config,u=l.enableEmsgMetadataCues,c=l.enableID3MetadataCues;r&&(u||c)&&Ct(r,i,n,a==="audio"?function(v){return v.type===St.MetadataSchema.audioId3&&c}:a==="video"?function(v){return v.type===St.MetadataSchema.emsg&&u}:function(v){return v.type===St.MetadataSchema.audioId3&&c||v.type===St.MetadataSchema.emsg&&u})}},o.onLevelUpdated=function(e,t){var i=this,n=t.details;if(this.media&&n.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,r=this.id3Track,s=n.dateRanges,l=Object.keys(s);if(r)for(var u=Object.keys(a).filter(function(X){return!l.includes(X)}),c=function(X){var ue=u[X];Object.keys(a[ue].cues).forEach(function(_e){r.removeCue(a[ue].cues[_e])}),delete a[ue]},v=u.length;v--;)c(v);var m=n.fragments[n.fragments.length-1];if(l.length!==0&&(0,R.isFiniteNumber)(m==null?void 0:m.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var _=m.programDateTime/1e3-m.start,S=wt(),F=function(X){var ue=l[X],_e=s[ue],ge=a[ue],De=(ge==null?void 0:ge.cues)||{},He=(ge==null?void 0:ge.durationKnown)||!1,Je=dt(_e.startDate,_),Ae=gt,Ke=_e.endDate;if(Ke)Ae=dt(Ke,_),He=!0;else if(_e.endOnNext&&!He){var je=l.reduce(function(er,Yt){var nr=s[Yt];return nr.class===_e.class&&nr.id!==Yt&&nr.startDate>_e.startDate&&er.push(nr),er},[]).sort(function(er,Yt){return er.startDate.getTime()-Yt.startDate.getTime()})[0];je&&(Ae=dt(je.startDate,_),He=!0)}for(var pt,Mt=Object.keys(_e.attr),yt=0;yt<Mt.length;yt++){var kt=Mt[yt];if(kt!==j.ID&&kt!==j.CLASS&&kt!==j.START_DATE&&kt!==j.DURATION&&kt!==j.END_DATE&&kt!==j.END_ON_NEXT){var xt=De[kt];if(xt)He&&!ge.durationKnown&&(xt.endTime=Ae);else{var ir=_e.attr[kt];xt=new S(Je,Ae,""),kt!==j.SCTE35_OUT&&kt!==j.SCTE35_IN||(pt=ir,ir=Uint8Array.from(pt.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),xt.value={key:kt,data:ir},xt.type=St.MetadataSchema.dateRange,i.id3Track.addCue(xt),De[kt]=xt}}}a[ue]={cues:De,dateRange:_e,durationKnown:He}},P=0;P<l.length;P++)F(P)}}},d}();function It(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var Ut=function(){function d(i){var n=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 n.timeupdate()},this.hls=i,this.config=i.config,this.registerListeners()}var o,e,t=d.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},t.registerListeners=function(){this.hls.on(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(g.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(g.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){this.hls.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(g.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(g.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(g.Events.ERROR,this.onError)},t.onMediaAttached=function(i,n){this.media=n.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},t.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},t.onLevelUpdated=function(i,n){var a=n.details;this.levelDetails=a,a.advanced&&this.timeupdate(),!a.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},t.onError=function(i,n){n.details===k.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,L.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},t.timeupdate=function(){var i=this.media,n=this.levelDetails;if(i&&n){this.currentTime=i.currentTime;var a=this.computeLatency();if(a!==null){this._latency=a;var r=this.config,s=r.lowLatencyMode,l=r.maxLiveSyncPlaybackRate;if(s&&l!==1){var u=this.targetLatency;if(u!==null){var c=a-u,v=c<Math.min(this.maxLatency,u+n.targetduration);if(n.live&&v&&c>.05&&this.forwardBufferLength>1){var m=Math.min(2,Math.max(1,l)),_=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20;i.playbackRate=Math.min(m,Math.max(1,_))}else i.playbackRate!==1&&i.playbackRate!==0&&(i.playbackRate=1)}}}}},t.estimateLiveEdge=function(){var i=this.levelDetails;return i===null?null:i.edge+i.age},t.computeLatency=function(){var i=this.estimateLiveEdge();return i===null?null:i-this.currentTime},o=d,(e=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var i=this.config,n=this.levelDetails;return i.liveMaxLatencyDuration!==void 0?i.liveMaxLatencyDuration:n?i.liveMaxLatencyDurationCount*n.targetduration:0}},{key:"targetLatency",get:function(){var i=this.levelDetails;if(i===null)return null;var n=i.holdBack,a=i.partHoldBack,r=i.targetduration,s=this.config,l=s.liveSyncDuration,u=s.liveSyncDurationCount,c=s.lowLatencyMode,v=this.hls.userConfig,m=c&&a||n;(v.liveSyncDuration||v.liveSyncDurationCount||m===0)&&(m=l!==void 0?l:u*r);var _=r;return m+Math.min(1*this.stallCount,_)}},{key:"liveSyncPosition",get:function(){var i=this.estimateLiveEdge(),n=this.targetLatency,a=this.levelDetails;if(i===null||n===null||a===null)return null;var r=a.edge,s=i-n-this.edgeStalled,l=r-a.totalduration,u=r-(this.config.lowLatencyMode&&a.partTarget||a.targetduration);return Math.min(Math.max(l,s),u)}},{key:"drift",get:function(){var i=this.levelDetails;return i===null?1:i.drift}},{key:"edgeStalled",get:function(){var i=this.levelDetails;if(i===null)return 0;var n=3*(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.max(i.age-n,0)}},{key:"forwardBufferLength",get:function(){var i=this.media,n=this.levelDetails;if(!i||!n)return 0;var a=i.buffered.length;return(a?i.buffered.end(a-1):n.edge)-this.currentTime}}])&&It(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function Wt(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var Bt,ar=["NONE","TYPE-0","TYPE-1","TYPE-2",null];(function(d){d.No="",d.Yes="YES",d.v2="v2"})(Bt||(Bt={}));var te=function(){function d(o,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=o,this.part=e,this.skip=t}return d.prototype.addDirectives=function(o){var e=new self.URL(o);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},d}(),N=function(){function d(t){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=[t.url],this.attrs=t.attrs,this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(function(i){return i}).join(",").replace(/\.[^.,]+/g,"")}var o,e;return o=d,(e=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var i=t%this.url.length;this._urlId!==i&&(this.details=void 0,this._urlId=i)}}])&&Wt(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function T(){return T=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},T.apply(this,arguments)}function O(d,o,e){switch(o){case"audio":d.audioGroupIds||(d.audioGroupIds=[]),d.audioGroupIds.push(e);break;case"text":d.textGroupIds||(d.textGroupIds=[]),d.textGroupIds.push(e)}}function C(d){var o={};d.forEach(function(e){var t=e.groupId||"";e.id=o[t]=o[t]||0,o[t]++})}function G(d,o){var e=o.startPTS;if((0,R.isFiniteNumber)(e)){var t,i=0;o.sn>d.sn?(i=e-d.start,t=d):(i=d.start-e,t=o),t.duration!==i&&(t.duration=i)}else o.sn>d.sn?d.cc===o.cc&&d.minEndPTS?o.start=d.start+(d.minEndPTS-d.start):o.start=d.start+d.duration:o.start=Math.max(d.start-o.duration,0)}function Q(d,o,e,t,i,n){t-e<=0&&(L.logger.warn("Fragment should have a positive duration",o),t=e+o.duration,n=i+o.duration);var a=e,r=t,s=o.startPTS,l=o.endPTS;if((0,R.isFiniteNumber)(s)){var u=Math.abs(s-e);(0,R.isFiniteNumber)(o.deltaPTS)?o.deltaPTS=Math.max(u,o.deltaPTS):o.deltaPTS=u,a=Math.max(e,s),e=Math.min(e,s),i=Math.min(i,o.startDTS),r=Math.min(t,l),t=Math.max(t,l),n=Math.max(n,o.endDTS)}o.duration=t-e;var c=e-o.start;o.start=o.startPTS=e,o.maxStartPTS=a,o.startDTS=i,o.endPTS=t,o.minEndPTS=r,o.endDTS=n;var v,m=o.sn;if(!d||m<d.startSN||m>d.endSN)return 0;var _=m-d.startSN,S=d.fragments;for(S[_]=o,v=_;v>0;v--)G(S[v],S[v-1]);for(v=_;v<S.length-1;v++)G(S[v],S[v+1]);return d.fragmentHint&&G(S[S.length-1],d.fragmentHint),d.PTSKnown=d.alignedSliding=!0,c}function Z(d,o){var e=o.startSN+o.skippedSegments-d.startSN,t=d.fragments;e<0||e>=t.length||Te(o,t[e].start)}function Te(d,o){if(o){for(var e=d.fragments,t=d.skippedSegments;t<e.length;t++)e[t].start+=o;d.fragmentHint&&(d.fragmentHint.start+=o)}}var Re=function(){function d(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=L.logger.log.bind(L.logger,t+":"),this.warn=L.logger.warn.bind(L.logger,t+":"),this.hls=e}var o=d.prototype;return o.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},o.onError=function(e,t){!t.fatal||t.type!==k.ErrorTypes.NETWORK_ERROR&&t.type!==k.ErrorTypes.KEY_SYSTEM_ERROR||this.stopLoad()},o.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},o.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},o.stopLoad=function(){this.canLoad=!1,this.clearTimer()},o.switchParams=function(e,t){var i=t==null?void 0:t.renditionReports;if(i)for(var n=0;n<i.length;n++){var a=i[n],r=void 0;try{r=new self.URL(a.URI,t.url).href}catch(c){L.logger.warn("Could not construct new URL for Rendition Report: "+c),r=a.URI||""}if(r===e.slice(-r.length)){var s=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn),l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}return new te(s,l>=0?l:void 0,Bt.No)}}},o.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},o.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},o.playlistLoaded=function(e,t,i){var n=this,a=t.details,r=t.stats,s=self.performance.now(),l=r.loading.first?Math.max(0,s-r.loading.first):0;if(a.advancedDateTime=Date.now()-l,a.live||i!=null&&i.live){if(a.reloaded(i),i&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),i&&a.fragments.length>0&&function(Ke,je){for(var pt=null,Mt=Ke.fragments,yt=Mt.length-1;yt>=0;yt--){var kt=Mt[yt].initSegment;if(kt){pt=kt;break}}Ke.fragmentHint&&delete Ke.fragmentHint.endPTS;var xt,ir,er,Yt,nr,_r=0;if(function(ct,Et,Ei){for(var jr=Et.skippedSegments,Or=Math.max(ct.startSN,Et.startSN)-Et.startSN,Ti=(ct.fragmentHint?1:0)+(jr?Et.endSN:Math.min(ct.endSN,Et.endSN))-Et.startSN,Ir=Et.startSN-ct.startSN,Gr=Et.fragmentHint?Et.fragments.concat(Et.fragmentHint):Et.fragments,Qr=ct.fragmentHint?ct.fragments.concat(ct.fragmentHint):ct.fragments,Dr=Or;Dr<=Ti;Dr++){var Jr=Qr[Ir+Dr],yn=Gr[Dr];jr&&!yn&&Dr<jr&&(yn=Et.fragments[Dr]=Jr),Jr&&yn&&Ei(Jr,yn)}}(Ke,je,function(ct,Et){ct.relurl&&(_r=ct.cc-Et.cc),(0,R.isFiniteNumber)(ct.startPTS)&&(0,R.isFiniteNumber)(ct.endPTS)&&(Et.start=Et.startPTS=ct.startPTS,Et.startDTS=ct.startDTS,Et.appendedPTS=ct.appendedPTS,Et.maxStartPTS=ct.maxStartPTS,Et.endPTS=ct.endPTS,Et.endDTS=ct.endDTS,Et.minEndPTS=ct.minEndPTS,Et.duration=ct.endPTS-ct.startPTS,Et.duration&&(xt=Et),je.PTSKnown=je.alignedSliding=!0),Et.elementaryStreams=ct.elementaryStreams,Et.loader=ct.loader,Et.stats=ct.stats,Et.urlId=ct.urlId,ct.initSegment&&(Et.initSegment=ct.initSegment,pt=ct.initSegment)}),pt&&(je.fragmentHint?je.fragments.concat(je.fragmentHint):je.fragments).forEach(function(ct){var Et;ct.initSegment&&ct.initSegment.relurl!==((Et=pt)===null||Et===void 0?void 0:Et.relurl)||(ct.initSegment=pt)}),je.skippedSegments)if(je.deltaUpdateFailed=je.fragments.some(function(ct){return!ct}),je.deltaUpdateFailed){L.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var Jn=je.skippedSegments;Jn--;)je.fragments.shift();je.startSN=je.fragments[0].sn,je.startCC=je.fragments[0].cc}else je.canSkipDateRanges&&(je.dateRanges=(ir=Ke.dateRanges,er=je.dateRanges,Yt=je.recentlyRemovedDateranges,nr=T({},ir),Yt&&Yt.forEach(function(ct){delete nr[ct]}),Object.keys(er).forEach(function(ct){var Et=new ye(er[ct].attr,nr[ct]);Et.isValid?nr[ct]=Et:L.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(er[ct].attr)+'"')}),nr));var Pr=je.fragments;if(_r){L.logger.warn("discontinuity sliding from playlist, take drift into account");for(var Bi=0;Bi<Pr.length;Bi++)Pr[Bi].cc+=_r}je.skippedSegments&&(je.startCC=je.fragments[0].cc),function(ct,Et,Ei){if(ct&&Et)for(var jr=0,Or=0,Ti=ct.length;Or<=Ti;Or++){var Ir=ct[Or],Gr=Et[Or+jr];Ir&&Gr&&Ir.index===Gr.index&&Ir.fragment.sn===Gr.fragment.sn?(Qr=Ir,(Dr=Gr).elementaryStreams=Qr.elementaryStreams,Dr.stats=Qr.stats):jr--}var Qr,Dr}(Ke.partList,je.partList),xt?Q(je,xt,xt.startPTS,xt.endPTS,xt.startDTS,xt.endDTS):Z(Ke,je),Pr.length&&(je.totalduration=je.edge-Pr[0].start),je.driftStartTime=Ke.driftStartTime,je.driftStart=Ke.driftStart;var ji=je.advancedDateTime;if(je.advanced&&ji){var Gi=je.edge;je.driftStart||(je.driftStartTime=ji,je.driftStart=Gi),je.driftEndTime=ji,je.driftEnd=Gi}else je.driftEndTime=Ke.driftEndTime,je.driftEnd=Ke.driftEnd,je.advancedDateTime=Ke.advancedDateTime}(i,a),!this.canLoad||!a.live)return;var u,c=void 0,v=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var m=this.hls.config.lowLatencyMode,_=a.lastPartSn,S=a.endSN,F=a.lastPartIndex,P=_===S;F!==-1?(c=P?S+1:_,v=P?m?0:F:F+1):c=S+1;var X=a.age,ue=X+a.ageHeader,_e=Math.min(ue-a.partTarget,1.5*a.targetduration);if(_e>0){if(i&&_e>i.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+_e+" with playlist age: "+a.age),_e=0;else{var ge=Math.floor(_e/a.targetduration);c+=ge,v!==void 0&&(v+=Math.round(_e%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+X.toFixed(2)+"s goal: "+_e+" skip sn "+ge+" to part "+v)}a.tuneInGoal=_e}if(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,v),m||!P)return void this.loadPlaylist(u)}else u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,v);var De=this.hls.mainForwardBufferInfo,He=De?De.end-De.len:0,Je=function(Ke,je){je===void 0&&(je=1/0);var pt=1e3*Ke.targetduration;if(Ke.updated){var Mt=Ke.fragments;if(Mt.length&&4*pt>je){var yt=1e3*Mt[Mt.length-1].duration;yt<pt&&(pt=yt)}}else pt/=2;return Math.round(pt)}(a,1e3*(a.edge-He));a.updated?s>this.requestScheduled+Je&&(this.requestScheduled=r.loading.start):this.requestScheduled=-1,c!==void 0&&a.canBlockReload?this.requestScheduled=r.loading.first+Je-(1e3*a.partTarget||1e3):this.requestScheduled=(this.requestScheduled===-1?s:this.requestScheduled)+Je;var Ae=this.requestScheduled-s;Ae=Math.max(0,Ae),this.log("reload live playlist "+e+" in "+Math.round(Ae)+" ms"),this.timer=self.setTimeout(function(){return n.loadPlaylist(u)},Ae)}else this.clearTimer()},o.getDeliveryDirectives=function(e,t,i,n){var a=function(r,s){var l=r.canSkipUntil,u=r.canSkipDateRanges,c=r.endSN;return l&&(s!==void 0?s-c:0)<l?u?Bt.v2:Bt.Yes:Bt.No}(e,i);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,a=Bt.No),new te(i,n,a)},o.retryLoadingOrFail=function(e){var t,i=this,n=this.hls.config,a=this.retryCount<n.levelLoadingMaxRetry;if(a)if(this.requestScheduled=-1,this.retryCount++,e.details.indexOf("LoadTimeOut")>-1&&(t=e.context)!==null&&t!==void 0&&t.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+e.details+'"'),this.loadPlaylist();else{var r=Math.min(Math.pow(2,this.retryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return i.loadPlaylist()},r),this.warn("retry playlist loading #"+this.retryCount+" in "+r+' ms after "'+e.details+'"')}else this.warn('cannot recover from error "'+e.details+'"'),this.clearTimer(),e.fatal=!0;return a},d}();function Pe(){return Pe=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},Pe.apply(this,arguments)}function Be(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function We(d,o){return We=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},We(d,o)}var Ge,$e=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),ht=function(d){var o,e;function t(r){var s;return(s=d.call(this,r,"[level-controller]")||this)._levels=[],s._firstLevel=-1,s._startLevel=void 0,s.currentLevelIndex=-1,s.manualLevelIndex=-1,s.onParsedComplete=void 0,s._registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,We(o,e);var i,n,a=t.prototype;return a._registerListeners=function(){var r=this.hls;r.on(g.Events.MANIFEST_LOADED,this.onManifestLoaded,this),r.on(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(g.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(g.Events.FRAG_LOADED,this.onFragLoaded,this),r.on(g.Events.ERROR,this.onError,this)},a._unregisterListeners=function(){var r=this.hls;r.off(g.Events.MANIFEST_LOADED,this.onManifestLoaded,this),r.off(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(g.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(g.Events.FRAG_LOADED,this.onFragLoaded,this),r.off(g.Events.ERROR,this.onError,this)},a.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,d.prototype.destroy.call(this)},a.startLoad=function(){this._levels.forEach(function(r){r.loadError=0}),d.prototype.startLoad.call(this)},a.onManifestLoaded=function(r,s){var l,u,c=[],v=[],m=[],_={},S=!1,F=!1,P=!1;if(s.levels.forEach(function(ge){var De=ge.attrs;S=S||!(!ge.width||!ge.height),F=F||!!ge.videoCodec,P=P||!!ge.audioCodec,$e&&ge.audioCodec&&ge.audioCodec.indexOf("mp4a.40.34")!==-1&&(ge.audioCodec=void 0);var He=ge.bitrate+"-"+ge.attrs.RESOLUTION+"-"+ge.attrs.CODECS;(u=_[He])?u.url.push(ge.url):(u=new N(ge),_[He]=u,c.push(u)),De&&(De.AUDIO&&O(u,"audio",De.AUDIO),De.SUBTITLES&&O(u,"text",De.SUBTITLES))}),(S||F)&&P&&(c=c.filter(function(ge){var De=ge.videoCodec,He=ge.width,Je=ge.height;return!!De||!(!He||!Je)})),c=c.filter(function(ge){var De=ge.audioCodec,He=ge.videoCodec;return(!De||xe(De,"audio"))&&(!He||xe(He,"video"))}),s.audioTracks&&C(v=s.audioTracks.filter(function(ge){return!ge.audioCodec||xe(ge.audioCodec,"audio")})),s.subtitles&&C(m=s.subtitles),c.length>0){l=c[0].bitrate,c.sort(function(ge,De){return ge.attrs["HDCP-LEVEL"]!==De.attrs["HDCP-LEVEL"]?(ge.attrs["HDCP-LEVEL"]||"")>(De.attrs["HDCP-LEVEL"]||"")?1:-1:ge.bitrate!==De.bitrate?ge.bitrate-De.bitrate:ge.attrs.SCORE!==De.attrs.SCORE?ge.attrs.decimalFloatingPoint("SCORE")-De.attrs.decimalFloatingPoint("SCORE"):S&&ge.height!==De.height?ge.height-De.height:0}),this._levels=c;for(var X=0;X<c.length;X++)if(c[X].bitrate===l){this._firstLevel=X,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+l);break}var ue=P&&!F,_e={levels:c,audioTracks:v,subtitleTracks:m,sessionData:s.sessionData,sessionKeys:s.sessionKeys,firstLevel:this._firstLevel,stats:s.stats,audio:P,video:F,altAudio:!ue&&v.some(function(ge){return!!ge.url})};this.hls.trigger(g.Events.MANIFEST_PARSED,_e),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:s.url,reason:"no level with compatible codecs found in manifest"})},a.onError=function(r,s){var l,u;if(d.prototype.onError.call(this,r,s),!s.fatal){var c=s.context,v=this._levels[this.currentLevelIndex];if(c&&(c.type===fe.PlaylistContextType.AUDIO_TRACK&&v.audioGroupIds&&c.groupId===v.audioGroupIds[v.urlId]||c.type===fe.PlaylistContextType.SUBTITLE_TRACK&&v.textGroupIds&&c.groupId===v.textGroupIds[v.urlId]))this.redundantFailover(this.currentLevelIndex);else{var m,_=!1,S=!0;switch(s.details){case k.ErrorDetails.FRAG_LOAD_ERROR:case k.ErrorDetails.FRAG_LOAD_TIMEOUT:case k.ErrorDetails.KEY_LOAD_ERROR:case k.ErrorDetails.KEY_LOAD_TIMEOUT:if(s.frag){var F=s.frag.type===fe.PlaylistLevelType.MAIN?s.frag.level:this.currentLevelIndex,P=this._levels[F];P?(P.fragmentError++,P.fragmentError>this.hls.config.fragLoadingMaxRetry&&(m=F)):m=F}break;case k.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var X=v.attrs["HDCP-LEVEL"];X&&(this.hls.maxHdcpLevel=ar[ar.indexOf(X)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'));case k.ErrorDetails.FRAG_PARSING_ERROR:case k.ErrorDetails.KEY_SYSTEM_NO_SESSION:m=((l=s.frag)===null||l===void 0?void 0:l.type)===fe.PlaylistLevelType.MAIN?s.frag.level:this.currentLevelIndex,s.levelRetry=!1;break;case k.ErrorDetails.LEVEL_LOAD_ERROR:case k.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(S=!1),m=c.level),_=!0;break;case k.ErrorDetails.REMUX_ALLOC_ERROR:m=(u=s.level)!=null?u:this.currentLevelIndex,_=!0}m!==void 0&&this.recoverLevel(s,m,_,S)}}},a.recoverLevel=function(r,s,l,u){var c=r.details,v=this._levels[s];if(v.loadError++,l){if(!this.retryLoadingOrFail(r))return void(this.currentLevelIndex=-1);r.levelRetry=!0}if(u){var m=v.url.length;if(m>1&&v.loadError<m)r.levelRetry=!0,this.redundantFailover(s);else if(this.manualLevelIndex===-1){for(var _=-1,S=this._levels,F=S.length;F--;){var P=(F+this.currentLevelIndex)%S.length;if(P!==this.currentLevelIndex&&S[P].loadError===0){_=P;break}}_>-1&&this.currentLevelIndex!==_?(this.warn(c+": switch to "+_),r.levelRetry=!0,this.hls.nextAutoLevel=_):r.levelRetry===!1&&(r.fatal=!0)}}},a.redundantFailover=function(r){var s=this._levels[r],l=s.url.length;if(l>1){var u=(s.urlId+1)%l;this.warn("Switching to redundant URL-id "+u),this._levels.forEach(function(c){c.urlId=u}),this.level=r}},a.onFragLoaded=function(r,s){var l=s.frag;if(l!==void 0&&l.type===fe.PlaylistLevelType.MAIN){var u=this._levels[l.level];u!==void 0&&(u.fragmentError=0,u.loadError=0)}},a.onLevelLoaded=function(r,s){var l,u,c=s.level,v=s.details,m=this._levels[c];if(!m)return this.warn("Invalid level index "+c),void((u=s.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(v.deltaUpdateFailed=!0));c===this.currentLevelIndex?(m.fragmentError===0&&(m.loadError=0,this.retryCount=0),this.playlistLoaded(c,s,m.details)):(l=s.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(v.deltaUpdateFailed=!0)},a.onAudioTrackSwitched=function(r,s){var l=this.hls.levels[this.currentLevelIndex];if(l&&l.audioGroupIds){for(var u=-1,c=this.hls.audioTracks[s.id].groupId,v=0;v<l.audioGroupIds.length;v++)if(l.audioGroupIds[v]===c){u=v;break}u!==l.urlId&&(l.urlId=u,this.startLoad())}},a.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var s=this.currentLevelIndex,l=this._levels[s];if(this.canLoad&&l&&l.url.length>0){var u=l.urlId,c=l.url[u];if(r)try{c=r.addDirectives(c)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("Attempt loading level index "+s+(r?" at sn "+r.msn+" part "+r.part:"")+" with URL-id "+u+" "+c),this.clearTimer(),this.hls.trigger(g.Events.LEVEL_LOADING,{url:c,level:s,id:u,deliveryDirectives:r||null})}},a.removeLevel=function(r,s){var l=function(c,v){return v!==s},u=this._levels.filter(function(c,v){return v!==r||c.url.length>1&&s!==void 0&&(c.url=c.url.filter(l),c.audioGroupIds&&(c.audioGroupIds=c.audioGroupIds.filter(l)),c.textGroupIds&&(c.textGroupIds=c.textGroupIds.filter(l)),c.urlId=0,!0)}).map(function(c,v){var m=c.details;return m!=null&&m.fragments&&m.fragments.forEach(function(_){_.level=v}),c});this._levels=u,this.hls.trigger(g.Events.LEVELS_UPDATED,{levels:u})},i=t,(n=[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(r){var s,l=this._levels;if(l.length!==0&&(this.currentLevelIndex!==r||(s=l[r])===null||s===void 0||!s.details)){if(r<0||r>=l.length){var u=r<0;if(this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.OTHER_ERROR,details:k.ErrorDetails.LEVEL_SWITCH_ERROR,level:r,fatal:u,reason:"invalid level idx"}),u)return;r=Math.min(r,l.length-1)}this.clearTimer();var c=this.currentLevelIndex,v=l[c],m=l[r];this.log("switching to level "+r+" from "+c),this.currentLevelIndex=r;var _=Pe({},m,{level:r,maxBitrate:m.maxBitrate,uri:m.uri,urlId:m.urlId});delete _._urlId,this.hls.trigger(g.Events.LEVEL_SWITCHING,_);var S=m.details;if(!S||S.live){var F=this.switchParams(m.uri,v==null?void 0:v.details);this.loadPlaylist(F)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(r){this.manualLevelIndex=r,this._startLevel===void 0&&(this._startLevel=r),r!==-1&&(this.level=r)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(r){this._firstLevel=r}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var r=this.hls.config.startLevel;return r!==void 0?r:this._firstLevel}return this._startLevel},set:function(r){this._startLevel=r}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(r){this.level=r,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=r)}}])&&Be(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Re);(function(d){d.NOT_LOADED="NOT_LOADED",d.APPENDING="APPENDING",d.PARTIAL="PARTIAL",d.OK="OK"})(Ge||(Ge={}));var Dt=function(){function d(e){this.activeFragment=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}var o=d.prototype;return o._registerListeners=function(){var e=this.hls;e.on(g.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(g.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(g.Events.FRAG_LOADED,this.onFragLoaded,this)},o._unregisterListeners=function(){var e=this.hls;e.off(g.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(g.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(g.Events.FRAG_LOADED,this.onFragLoaded,this)},o.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},o.getAppendedFrag=function(e,t){if(t===fe.PlaylistLevelType.MAIN){var i=this.activeFragment,n=this.activeParts;if(!i)return null;if(n)for(var a=n.length;a--;){var r=n[a],s=r?r.end:i.appendedPTS;if(r.start<=e&&s!==void 0&&e<=s)return a>9&&(this.activeParts=n.slice(a-9)),r}else if(i.start<=e&&i.appendedPTS!==void 0&&e<=i.appendedPTS)return i}return this.getBufferedFrag(e,t)},o.getBufferedFrag=function(e,t){for(var i=this.fragments,n=Object.keys(i),a=n.length;a--;){var r=i[n[a]];if((r==null?void 0:r.body.type)===t&&r.buffered){var s=r.body;if(s.start<=e&&e<=s.end)return s}}return null},o.detectEvictedFragments=function(e,t,i){var n=this;this.timeRanges&&(this.timeRanges[e]=t),Object.keys(this.fragments).forEach(function(a){var r=n.fragments[a];if(r)if(r.buffered||r.loaded){var s=r.range[e];s&&s.time.some(function(l){var u=!n.isTimeBuffered(l.startPTS,l.endPTS,t);return u&&n.removeFragment(r.body),u})}else r.body.type===i&&n.removeFragment(r.body)})},o.detectPartialFragments=function(e){var t=this,i=this.timeRanges,n=e.frag,a=e.part;if(i&&n.sn!=="initSegment"){var r=Pt(n),s=this.fragments[r];s&&(Object.keys(i).forEach(function(l){var u=n.elementaryStreams[l];if(u){var c=i[l],v=a!==null||u.partial===!0;s.range[l]=t.getBufferedTimes(n,a,v,c)}}),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,s.body.endList&&(this.endListFragments[s.body.type]=s)):this.removeFragment(s.body))}},o.fragBuffered=function(e){var t=Pt(e),i=this.fragments[t];i&&(i.loaded=null,i.buffered=!0)},o.getBufferedTimes=function(e,t,i,n){for(var a={time:[],partial:i},r=t?t.start:e.start,s=t?t.end:e.end,l=e.minEndPTS||s,u=e.maxStartPTS||r,c=0;c<n.length;c++){var v=n.start(c)-this.bufferPadding,m=n.end(c)+this.bufferPadding;if(u>=v&&l<=m){a.time.push({startPTS:Math.max(r,n.start(c)),endPTS:Math.min(s,n.end(c))});break}if(r<m&&s>v)a.partial=!0,a.time.push({startPTS:Math.max(r,n.start(c)),endPTS:Math.min(s,n.end(c))});else if(s<=v)break}return a},o.getPartialFragment=function(e){var t,i,n,a=null,r=0,s=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach(function(u){var c=l[u];c&&ze(c)&&(i=c.body.start-s,n=c.body.end+s,e>=i&&e<=n&&(t=Math.min(e-i,n-e),r<=t&&(a=c.body,r=t)))}),a},o.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||ze(t))},o.getState=function(e){var t=Pt(e),i=this.fragments[t];return i?i.buffered?ze(i)?Ge.PARTIAL:Ge.OK:Ge.APPENDING:Ge.NOT_LOADED},o.isTimeBuffered=function(e,t,i){for(var n,a,r=0;r<i.length;r++){if(n=i.start(r)-this.bufferPadding,a=i.end(r)+this.bufferPadding,e>=n&&t<=a)return!0;if(t<=n)return!1}return!1},o.onFragLoaded=function(e,t){var i=t.frag,n=t.part;if(i.sn!=="initSegment"&&!i.bitrateTest&&!n){var a=Pt(i);this.fragments[a]={body:i,loaded:t,buffered:!1,range:Object.create(null)}}},o.onBufferAppended=function(e,t){var i=this,n=t.frag,a=t.part,r=t.timeRanges;if(n.type===fe.PlaylistLevelType.MAIN)if(this.activeFragment!==n&&(this.activeFragment=n,n.appendedPTS=void 0),a){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(a)}else this.activeParts=null;this.timeRanges=r,Object.keys(r).forEach(function(l){var u=r[l];if(i.detectEvictedFragments(l,u),!a&&n.type===fe.PlaylistLevelType.MAIN){var c=n.elementaryStreams[l];if(!c)return;for(var v=0;v<u.length;v++){var m=u.end(v);m<=c.endPTS&&m>c.startPTS?n.appendedPTS=Math.max(m,n.appendedPTS||0):n.appendedPTS=c.endPTS}}})},o.onFragBuffered=function(e,t){this.detectPartialFragments(t)},o.hasFragment=function(e){var t=Pt(e);return!!this.fragments[t]},o.removeFragmentsInRange=function(e,t,i){var n=this;Object.keys(this.fragments).forEach(function(a){var r=n.fragments[a];if(r&&r.buffered){var s=r.body;s.type===i&&s.start<t&&s.end>e&&n.removeFragment(s)}})},o.removeFragment=function(e){var t=Pt(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),e.appendedPTS=void 0,delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},o.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},d}();function ze(d){var o,e;return d.buffered&&(((o=d.range.video)===null||o===void 0?void 0:o.partial)||((e=d.range.audio)===null||e===void 0?void 0:e.partial))}function Pt(d){return d.type+"_"+d.level+"_"+d.urlId+"_"+d.sn}function tr(d){var o=typeof Map=="function"?new Map:void 0;return tr=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(o!==void 0){if(o.has(e))return o.get(e);o.set(e,i)}function i(){return jt(e,arguments,rt(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ht(i,e)},tr(d)}function jt(d,o,e){return jt=Ft()?Reflect.construct.bind():function(t,i,n){var a=[null];a.push.apply(a,i);var r=new(Function.bind.apply(t,a));return n&&Ht(r,n.prototype),r},jt.apply(null,arguments)}function Ft(){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 Ht(d,o){return Ht=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ht(d,o)}function rt(d){return rt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},rt(d)}var lr=Math.pow(2,17),Ar=function(){function d(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var o=d.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(e,t){var i=this,n=e.url;if(!n)return Promise.reject(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(n?"part list":"url")));this.abort();var a=this.config,r=a.fLoader,s=a.loader;return new Promise(function(l,u){i.loader&&i.loader.destroy();var c=i.loader=e.loader=r?new r(a):new s(a),v=Kt(e),m={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:e.sn==="initSegment"?1/0:lr};e.stats=c.stats,c.load(v,m,{onSuccess:function(_,S,F,P){i.resetLoader(e,c);var X=_.data;F.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(X.slice(0,16)),X=X.slice(16)),l({frag:e,part:null,payload:X,networkDetails:P})},onError:function(_,S,F){i.resetLoader(e,c),u(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:_,networkDetails:F}))},onAbort:function(_,S,F){i.resetLoader(e,c),u(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:F}))},onTimeout:function(_,S,F){i.resetLoader(e,c),u(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:F}))},onProgress:function(_,S,F,P){t&&t({frag:e,part:null,payload:F,networkDetails:P})}})})},o.loadPart=function(e,t,i){var n=this;this.abort();var a=this.config,r=a.fLoader,s=a.loader;return new Promise(function(l,u){n.loader&&n.loader.destroy();var c=n.loader=e.loader=r?new r(a):new s(a),v=Kt(e,t),m={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:lr};t.stats=c.stats,c.load(v,m,{onSuccess:function(_,S,F,P){n.resetLoader(e,c),n.updateStatsFromPart(e,t);var X={frag:e,part:t,payload:_.data,networkDetails:P};i(X),l(X)},onError:function(_,S,F){n.resetLoader(e,c),u(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:_,networkDetails:F}))},onAbort:function(_,S,F){e.stats.aborted=t.stats.aborted,n.resetLoader(e,c),u(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,networkDetails:F}))},onTimeout:function(_,S,F){n.resetLoader(e,c),u(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,networkDetails:F}))}})})},o.updateStatsFromPart=function(e,t){var i=e.stats,n=t.stats,a=n.total;if(i.loaded+=n.loaded,a){var r=Math.round(e.duration/t.duration),s=Math.min(Math.round(i.loaded/a),r),l=(r-s)*Math.round(i.loaded/s);i.total=i.loaded+l}else i.total=Math.max(i.loaded,i.total);var u=i.loading,c=n.loading;u.start?u.first+=c.first-c.start:(u.start=c.start,u.first=c.first),u.end=c.end},o.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},d}();function Kt(d,o){o===void 0&&(o=null);var e=o||d,t={frag:d,part:o,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},i=e.byteRangeStartOffset,n=e.byteRangeEndOffset;if((0,R.isFiniteNumber)(i)&&(0,R.isFiniteNumber)(n)){var a,r=i,s=n;if(d.sn==="initSegment"&&((a=d.decryptdata)===null||a===void 0?void 0:a.method)==="AES-128"){var l=n-i;l%16&&(s=n+(16-l%16)),i!==0&&(t.resetIV=!0,r=i-16)}t.rangeStart=r,t.rangeEnd=s}return t}var Jt=function(d){var o,e;function t(i){for(var n,a=arguments.length,r=new Array(a>1?a-1:0),s=1;s<a;s++)r[s-1]=arguments[s];return(n=d.call.apply(d,[this].concat(r))||this).data=void 0,n.data=i,n}return e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ht(o,e),t}(tr(Error)),pr=function(){function d(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var o=d.prototype;return o.abort=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.abort()}},o.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},o.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},o.createKeyLoadError=function(e,t,i,n){return t===void 0&&(t=k.ErrorDetails.KEY_LOAD_ERROR),new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:t,fatal:!1,frag:e,networkDetails:i})},o.loadClear=function(e,t){var i=this;if(this.emeController&&this.config.emeEnabled)for(var n=e.sn,a=e.cc,r=function(l){var u=t[l];if(a<=u.cc&&(n==="initSegment"||n<u.sn))return i.emeController.selectKeySystemFormat(u).then(function(c){u.setKeyFormat(c)}),"break"},s=0;s<t.length&&r(s)!=="break";s++);},o.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(i){return t.loadInternal(e,i)}):this.loadInternal(e)},o.loadInternal=function(e,t){var i,n;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var r=t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(e,k.ErrorDetails.KEY_LOAD_ERROR,null,r))}var s=a.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,k.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+s+'"'));var l,u=this.keyUriToKeyInfo[s];if((i=u)!==null&&i!==void 0&&i.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if((n=u)!==null&&n!==void 0&&n.keyLoadPromise)switch((l=u.mediaKeySessionContext)===null||l===void 0?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise}switch(u=this.keyUriToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return a.keyFormat==="identity"?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,k.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+a.method+'"'))}},o.loadKeyEME=function(e,t){var i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n=this.emeController.loadKey(i);if(n)return(e.keyLoadPromise=n.then(function(a){return e.mediaKeySessionContext=a,i})).catch(function(a){throw e.keyLoadPromise=null,a})}return Promise.resolve(i)},o.loadKeyHTTP=function(e,t){var i=this,n=this.config,a=new n.loader(n);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise(function(r,s){var l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},u={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:n.fragLoadingRetryDelay,maxRetryDelay:n.fragLoadingMaxRetryTimeout,highWaterMark:0},c={onSuccess:function(v,m,_,S){var F=_.frag,P=_.keyInfo,X=_.url;if(!F.decryptdata||P!==i.keyUriToKeyInfo[X])return s(i.createKeyLoadError(F,k.ErrorDetails.KEY_LOAD_ERROR,S,"after key load, decryptdata unset or changed"));P.decryptdata.key=F.decryptdata.key=new Uint8Array(v.data),F.keyLoader=null,P.loader=null,r({frag:F,keyInfo:P})},onError:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,k.ErrorDetails.KEY_LOAD_ERROR,_))},onTimeout:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,k.ErrorDetails.KEY_LOAD_TIMEOUT,_))},onAbort:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,k.ErrorDetails.INTERNAL_ABORTED,_))}};a.load(l,u,c)})},o.resetLoader=function(e){var t=e.frag,i=e.keyInfo,n=e.url,a=i.loader;t.keyLoader===a&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],a&&a.destroy()},d}(),Cr=function(){function d(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var o=d.prototype;return o.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},o.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},o.onHandlerDestroyed=function(){},o.hasInterval=function(){return!!this._tickInterval},o.hasNextTick=function(){return!!this._tickTimer},o.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},o.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},o.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},o.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},o.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},o.doTick=function(){},d}(),vr={length:0,start:function(){return 0},end:function(){return 0}},Gt=function(){function d(){}return d.isBuffered=function(o,e){try{if(o){for(var t=d.getBuffered(o),i=0;i<t.length;i++)if(e>=t.start(i)&&e<=t.end(i))return!0}}catch{}return!1},d.bufferInfo=function(o,e,t){try{if(o){var i,n=d.getBuffered(o),a=[];for(i=0;i<n.length;i++)a.push({start:n.start(i),end:n.end(i)});return this.bufferedInfo(a,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},d.bufferedInfo=function(o,e,t){e=Math.max(0,e),o.sort(function(S,F){return S.start-F.start||F.end-S.end});var i=[];if(t)for(var n=0;n<o.length;n++){var a=i.length;if(a){var r=i[a-1].end;o[n].start-r<t?o[n].end>r&&(i[a-1].end=o[n].end):i.push(o[n])}else i.push(o[n])}else i=o;for(var s,l=0,u=e,c=e,v=0;v<i.length;v++){var m=i[v].start,_=i[v].end;if(e+t>=m&&e<_)u=m,l=(c=_)-e;else if(e+t<m){s=m;break}}return{len:l,start:u||0,end:c||0,nextStart:s}},d.getBuffered=function(o){try{return o.buffered}catch(e){return L.logger.log("failed to get media.buffered",e),vr}},d}(),Di=function(d,o,e,t,i,n){t===void 0&&(t=0),i===void 0&&(i=-1),n===void 0&&(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={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=d,this.sn=o,this.id=e,this.size=t,this.part=i,this.partial=n};function nn(d,o){for(var e=null,t=0,i=d.length;t<i;t++){var n=d[t];if(n&&n.cc===o){e=n;break}}return e}function kr(d,o){if(d){var e=d.start+o;d.start=d.startPTS=e,d.endPTS=e+d.duration}}function li(d,o){for(var e=o.fragments,t=0,i=e.length;t<i;t++)kr(e[t],d);o.fragmentHint&&kr(o.fragmentHint,d),o.alignedSliding=!0}function an(d,o){if(d.hasProgramDateTime&&o.hasProgramDateTime){var e=d.fragments,t=o.fragments;if(e.length&&t.length){var i=t[Math.round(t.length/2)-1],n=nn(e,i.cc)||e[Math.round(e.length/2)-1],a=i.programDateTime,r=n.programDateTime;a!==null&&r!==null&&li((r-a)/1e3-(n.start-i.start),d)}}}let sn=function(d,o){for(var e=0,t=d.length-1,i=null,n=null;e<=t;){var a=o(n=d[i=(e+t)/2|0]);if(a>0)e=i+1;else{if(!(a<0))return n;t=i-1}}return null};function ui(d,o,e,t){e===void 0&&(e=0),t===void 0&&(t=0);var i=null;if(d?i=o[d.sn-o[0].sn+1]||null:e===0&&o[0].start===0&&(i=o[0]),i&&di(e,t,i)===0)return i;var n=sn(o,di.bind(null,e,t));return!n||n===d&&i?i:n}function di(d,o,e){if(d===void 0&&(d=0),o===void 0&&(o=0),e.start<=d&&e.start+e.duration>d)return 0;var t=Math.min(o,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-t<=d?1:e.start-t>d&&e.start?-1:0}function Kr(d,o,e){var t=1e3*Math.min(o,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>d}var Zr=B(21);let wn=function(d){for(var o="",e=d.length,t=0;t<e;t++)o+="["+d.start(t).toFixed(3)+","+d.end(t).toFixed(3)+"]";return o};function on(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Hr(d,o){return Hr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Hr(d,o)}var br="STOPPED",At="IDLE",ln="KEY_LOADING",qr="FRAG_LOADING",Nr="FRAG_LOADING_WAITING_RETRY",ci="WAITING_TRACK",wr="PARSING",Vr="PARSED",ei="ENDED",Lr="ERROR",Ur="WAITING_INIT_PTS",Yr="WAITING_LEVEL",hi=function(d){var o,e;function t(r,s,l,u){var c;return(c=d.call(this)||this).hls=void 0,c.fragPrevious=null,c.fragCurrent=null,c.fragmentTracker=void 0,c.transmuxer=null,c._state=br,c.media=null,c.mediaBuffer=null,c.config=void 0,c.bitrateTest=!1,c.lastCurrentTime=0,c.nextLoadPosition=0,c.startPosition=0,c.loadedmetadata=!1,c.fragLoadError=0,c.retryDate=0,c.levels=null,c.fragmentLoader=void 0,c.keyLoader=void 0,c.levelLastLoaded=null,c.startFragRequested=!1,c.decrypter=void 0,c.initPTS=[],c.onvseeking=null,c.onvended=null,c.logPrefix="",c.log=void 0,c.warn=void 0,c.logPrefix=u,c.log=L.logger.log.bind(L.logger,u+":"),c.warn=L.logger.warn.bind(L.logger,u+":"),c.hls=r,c.fragmentLoader=new Ar(r.config),c.keyLoader=l,c.fragmentTracker=s,c.config=r.config,c.decrypter=new Zr.default(r.config),r.on(g.Events.LEVEL_SWITCHING,c.onLevelSwitching,function(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}(c)),c}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Hr(o,e);var i,n,a=t.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(r){},a.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var r=this.fragCurrent;r&&(r.abortRequests(),this.fragmentTracker.removeFragment(r)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=br},a._streamEnded=function(r,s){if(s.live||r.nextStart||!r.end||!this.media)return!1;var l=s.partList;if(l!=null&&l.length){var u=l[l.length-1];return Gt.isBuffered(this.media,u.start+u.duration/2)}var c=s.fragments[s.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(c)},a.getLevelDetails=function(){var r;if(this.levels&&this.levelLastLoaded!==null)return(r=this.levels[this.levelLastLoaded])===null||r===void 0?void 0:r.details},a.onMediaAttached=function(r,s){var l=this.media=this.mediaBuffer=s.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),l.addEventListener("seeking",this.onvseeking),l.addEventListener("ended",this.onvended);var u=this.config;this.levels&&u.autoStartLoad&&this.state===br&&this.startLoad(u.startPosition)},a.onMediaDetaching=function(){var r=this.media;r!=null&&r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),r&&this.onvseeking&&this.onvended&&(r.removeEventListener("seeking",this.onvseeking),r.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()},a.onMediaSeeking=function(){var r=this.config,s=this.fragCurrent,l=this.media,u=this.mediaBuffer,c=this.state,v=l?l.currentTime:0,m=Gt.bufferInfo(u||l,v,r.maxBufferHole);if(this.log("media seeking to "+((0,R.isFiniteNumber)(v)?v.toFixed(3):v)+", state: "+c),this.state===ei)this.resetLoadingState();else if(s){var _=r.maxFragLookUpTolerance,S=s.start-_,F=s.start+s.duration+_;if(!m.len||F<m.start||S>m.end){var P=v>F;(v<S||P)&&(P&&s.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),s.abortRequests()),this.resetLoadingState())}}l&&(this.lastCurrentTime=v),this.loadedmetadata||m.len||(this.nextLoadPosition=this.startPosition=v),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onLevelSwitching=function(r,s){this.fragLoadError=0},a.onHandlerDestroying=function(){this.stopLoad(),d.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=br,this.hls.off(g.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,d.prototype.onHandlerDestroyed.call(this)},a.loadFragment=function(r,s,l){this._loadFragForPlayback(r,s,l)},a._loadFragForPlayback=function(r,s,l){var u=this;this._doFragLoad(r,s,l,function(c){if(u.fragContextChanged(r))return u.warn("Fragment "+r.sn+(c.part?" p: "+c.part.index:"")+" of level "+r.level+" was dropped during download."),void u.fragmentTracker.removeFragment(r);r.stats.chunkCount++,u._handleFragmentLoadProgress(c)}).then(function(c){if(c){u.fragLoadError=0;var v=u.state;u.fragContextChanged(r)?(v===qr||!u.fragCurrent&&v===wr)&&(u.fragmentTracker.removeFragment(r),u.state=At):("payload"in c&&(u.log("Loaded fragment "+r.sn+" of level "+r.level),u.hls.trigger(g.Events.FRAG_LOADED,c)),u._handleFragmentLoadComplete(c))}}).catch(function(c){u.state!==br&&u.state!==Lr&&(u.warn(c),u.resetFragmentLoading(r))})},a.flushMainBuffer=function(r,s,l){if(l===void 0&&(l=null),r-s){var u={startOffset:r,endOffset:s,type:l};this.fragLoadError=0,this.hls.trigger(g.Events.BUFFER_FLUSHING,u)}},a._loadInitSegment=function(r,s){var l=this;this._doFragLoad(r,s).then(function(u){if(!u||l.fragContextChanged(r)||!l.levels)throw new Error("init load aborted");return u}).then(function(u){var c=l.hls,v=u.payload,m=r.decryptdata;if(v&&v.byteLength>0&&m&&m.key&&m.iv&&m.method==="AES-128"){var _=self.performance.now();return l.decrypter.decrypt(new Uint8Array(v),m.key.buffer,m.iv.buffer).then(function(S){var F=self.performance.now();return c.trigger(g.Events.FRAG_DECRYPTED,{frag:r,payload:S,stats:{tstart:_,tdecrypt:F}}),u.payload=S,u})}return u}).then(function(u){var c=l.fragCurrent,v=l.hls,m=l.levels;if(!m)throw new Error("init load aborted, missing levels");m[r.level].details;var _=r.stats;l.state=At,l.fragLoadError=0,r.data=new Uint8Array(u.payload),_.parsing.start=_.buffering.start=self.performance.now(),_.parsing.end=_.buffering.end=self.performance.now(),u.frag===c&&v.trigger(g.Events.FRAG_BUFFERED,{stats:_,frag:c,part:null,id:r.type}),l.tick()}).catch(function(u){l.state!==br&&l.state!==Lr&&(l.warn(u),l.resetFragmentLoading(r))})},a.fragContextChanged=function(r){var s=this.fragCurrent;return!r||!s||r.level!==s.level||r.sn!==s.sn||r.urlId!==s.urlId},a.fragBufferedComplete=function(r,s){var l,u,c=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+r.type+" sn: "+r.sn+(s?" part: "+s.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+r.level+" "+(c?wn(Gt.getBuffered(c)):"(detached)")),this.state=At,c&&(!this.loadedmetadata&&r.type==fe.PlaylistLevelType.MAIN&&c.buffered.length&&((l=this.fragCurrent)===null||l===void 0?void 0:l.sn)===((u=this.fragPrevious)===null||u===void 0?void 0:u.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},a.seekToStartPos=function(){},a._handleFragmentLoadComplete=function(r){var s=this.transmuxer;if(s){var l=r.frag,u=r.part,c=r.partsLoaded,v=!c||c.length===0||c.some(function(_){return!_}),m=new Di(l.level,l.sn,l.stats.chunkCount+1,0,u?u.index:-1,!v);s.flush(m)}},a._handleFragmentLoadProgress=function(r){},a._doFragLoad=function(r,s,l,u){var c,v=this;if(l===void 0&&(l=null),!this.levels)throw new Error("frag load aborted, missing levels");var m=null;if(!r.encrypted||(c=r.decryptdata)!==null&&c!==void 0&&c.key?!r.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(r,s.encryptedFragments):(this.log("Loading key for "+r.sn+" of ["+s.startSN+"-"+s.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+r.level),this.state=ln,this.fragCurrent=r,m=this.keyLoader.load(r).then(function(X){if(!v.fragContextChanged(X.frag))return v.hls.trigger(g.Events.KEY_LOADED,X),X}),this.hls.trigger(g.Events.KEY_LOADING,{frag:r}),this.throwIfFragContextChanged("KEY_LOADING")),l=Math.max(r.start,l||0),this.config.lowLatencyMode&&s){var _=s.partList;if(_&&u){l>r.end&&s.fragmentHint&&(r=s.fragmentHint);var S=this.getNextPart(_,r,l);if(S>-1){var F=_[S];return this.log("Loading part sn: "+r.sn+" p: "+F.index+" cc: "+r.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+S+"-"+(_.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+r.level+", target: "+parseFloat(l.toFixed(3))),this.nextLoadPosition=F.start+F.duration,this.state=qr,this.hls.trigger(g.Events.FRAG_LOADING,{frag:r,part:_[S],targetBufferTime:l}),this.throwIfFragContextChanged("FRAG_LOADING parts"),m?m.then(function(X){return!X||v.fragContextChanged(X.frag)?null:v.doFragPartsLoad(r,_,S,u)}).catch(function(X){return v.handleFragLoadError(X)}):this.doFragPartsLoad(r,_,S,u).catch(function(X){return v.handleFragLoadError(X)})}if(!r.url||this.loadedEndOfParts(_,l))return Promise.resolve(null)}}this.log("Loading fragment "+r.sn+" cc: "+r.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+r.level+", target: "+parseFloat(l.toFixed(3))),(0,R.isFiniteNumber)(r.sn)&&!this.bitrateTest&&(this.nextLoadPosition=r.start+r.duration),this.state=qr,this.hls.trigger(g.Events.FRAG_LOADING,{frag:r,targetBufferTime:l}),this.throwIfFragContextChanged("FRAG_LOADING");var P=this.config.progressive;return P&&m?m.then(function(X){return!X||v.fragContextChanged(X==null?void 0:X.frag)?null:v.fragmentLoader.load(r,u)}).catch(function(X){return v.handleFragLoadError(X)}):Promise.all([this.fragmentLoader.load(r,P?u:void 0),m]).then(function(X){var ue=X[0];return!P&&ue&&u&&u(ue),ue}).catch(function(X){return v.handleFragLoadError(X)})},a.throwIfFragContextChanged=function(r){if(this.fragCurrent===null)throw new Error("frag load aborted, context changed in "+r)},a.doFragPartsLoad=function(r,s,l,u){var c=this;return new Promise(function(v,m){var _=[];(function S(F){var P=s[F];c.fragmentLoader.loadPart(r,P,u).then(function(X){_[P.index]=X;var ue=X.part;c.hls.trigger(g.Events.FRAG_LOADED,X);var _e=s[F+1];if(!_e||_e.fragment!==r)return v({frag:r,part:ue,partsLoaded:_});S(F+1)}).catch(m)})(l)})},a.handleFragLoadError=function(r){if("data"in r){var s=r.data;r.data&&s.details===k.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(s.frag,s.part):this.hls.trigger(g.Events.ERROR,s)}else this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.OTHER_ERROR,details:k.ErrorDetails.INTERNAL_EXCEPTION,err:r,fatal:!0});return null},a._handleTransmuxerFlush=function(r){var s=this.getCurrentContext(r);if(s&&this.state===wr){var l=s.frag,u=s.part,c=s.level,v=self.performance.now();l.stats.parsing.end=v,u&&(u.stats.parsing.end=v),this.updateLevelTiming(l,u,c,r.partial)}else this.fragCurrent||this.state===br||this.state===Lr||(this.state=At)},a.getCurrentContext=function(r){var s=this.levels,l=r.level,u=r.sn,c=r.part;if(!s||!s[l])return this.warn("Levels object was unset while buffering fragment "+u+" of level "+l+". The current chunk will not be buffered."),null;var v=s[l],m=c>-1?function(S,F,P){if(!S||!S.details)return null;var X=S.details.partList;if(X)for(var ue=X.length;ue--;){var _e=X[ue];if(_e.index===P&&_e.fragment.sn===F)return _e}return null}(v,u,c):null,_=m?m.fragment:function(S,F,P){if(!S||!S.details)return null;var X=S.details,ue=X.fragments[F-X.startSN];return ue||((ue=X.fragmentHint)&&ue.sn===F?ue:F<X.startSN&&P&&P.sn===F?P:null)}(v,u,this.fragCurrent);return _?{frag:_,part:m,level:v}:null},a.bufferFragmentData=function(r,s,l,u){if(r&&this.state===wr){var c=r.data1,v=r.data2,m=c;if(c&&v&&(m=(0,z.appendUint8Array)(c,v)),m&&m.length){var _={type:r.type,frag:s,part:l,chunkMeta:u,parent:s.type,data:m};this.hls.trigger(g.Events.BUFFER_APPENDING,_),r.dropped&&r.independent&&!l&&this.flushBufferGap(s)}}},a.flushBufferGap=function(r){var s=this.media;if(s)if(Gt.isBuffered(s,s.currentTime)){var l=s.currentTime,u=Gt.bufferInfo(s,l,0),c=r.duration,v=Math.min(2*this.config.maxFragLookUpTolerance,.25*c),m=Math.max(Math.min(r.start-v,u.end-v),l+v);r.start-m>v&&this.flushMainBuffer(m,r.start)}else this.flushMainBuffer(0,r.start)},a.getFwdBufferInfo=function(r,s){var l=this.config,u=this.getLoadPosition();if(!(0,R.isFiniteNumber)(u))return null;var c=Gt.bufferInfo(r,u,l.maxBufferHole);if(c.len===0&&c.nextStart!==void 0){var v=this.fragmentTracker.getBufferedFrag(u,s);if(v&&c.nextStart<v.end)return Gt.bufferInfo(r,u,Math.max(c.nextStart,l.maxBufferHole))}return c},a.getMaxBufferLength=function(r){var s,l=this.config;return s=r?Math.max(8*l.maxBufferSize/r,l.maxBufferLength):l.maxBufferLength,Math.min(s,l.maxMaxBufferLength)},a.reduceMaxBufferLength=function(r){var s=this.config,l=r||s.maxBufferLength;return s.maxMaxBufferLength>=l&&(s.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+s.maxMaxBufferLength+"s"),!0)},a.getNextFragment=function(r,s){var l=s.fragments,u=l.length;if(!u)return null;var c,v=this.config,m=l[0].start;if(s.live){var _=v.initialLiveManifestSize;if(u<_)return this.warn("Not enough fragments to start playback (have: "+u+", need: "+_+")"),null;s.PTSKnown||this.startFragRequested||this.startPosition!==-1||(c=this.getInitialLiveFragment(s,l),this.startPosition=c?this.hls.liveSyncPosition||c.start:r)}else r<=m&&(c=l[0]);if(!c){var S=v.lowLatencyMode?s.partEnd:s.fragmentEnd;c=this.getFragmentAtPosition(r,S,s)}return this.mapToInitFragWhenRequired(c)},a.mapToInitFragWhenRequired=function(r){return r==null||!r.initSegment||r!=null&&r.initSegment.data||this.bitrateTest?r:r.initSegment},a.getNextPart=function(r,s,l){for(var u=-1,c=!1,v=!0,m=0,_=r.length;m<_;m++){var S=r[m];if(v=v&&!S.independent,u>-1&&l<S.start)break;var F=S.loaded;F?u=-1:(c||S.independent||v)&&S.fragment===s&&(u=m),c=F}return u},a.loadedEndOfParts=function(r,s){var l=r[r.length-1];return l&&s>l.start&&l.loaded},a.getInitialLiveFragment=function(r,s){var l=this.fragPrevious,u=null;if(l){if(r.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+l.programDateTime),u=function(_,S,F){if(S===null||!Array.isArray(_)||!_.length||!(0,R.isFiniteNumber)(S)||S<(_[0].programDateTime||0)||S>=(_[_.length-1].endProgramDateTime||0))return null;F=F||0;for(var P=0;P<_.length;++P){var X=_[P];if(Kr(S,F,X))return X}return null}(s,l.endProgramDateTime,this.config.maxFragLookUpTolerance)),!u){var c=l.sn+1;if(c>=r.startSN&&c<=r.endSN){var v=s[c-r.startSN];l.cc===v.cc&&(u=v,this.log("Live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=function(_,S){return sn(_,function(F){return F.cc<S?1:F.cc>S?-1:0})}(s,l.cc),u&&this.log("Live playlist, switching playlist, load frag with same CC: "+u.sn))}}else{var m=this.hls.liveSyncPosition;m!==null&&(u=this.getFragmentAtPosition(m,this.bitrateTest?r.fragmentEnd:r.edge,r))}return u},a.getFragmentAtPosition=function(r,s,l){var u,c=this.config,v=this.fragPrevious,m=l.fragments,_=l.endSN,S=l.fragmentHint,F=c.maxFragLookUpTolerance,P=!!(c.lowLatencyMode&&l.partList&&S);if(P&&S&&!this.bitrateTest&&(m=m.concat(S),_=S.sn),u=r<s?ui(v,m,r,r>s-F?0:F):m[m.length-1]){var X=u.sn-l.startSN;if(this.fragmentTracker.getState(u)===Ge.OK&&(v=u),v&&u.sn===v.sn&&!P&&v&&u.level===v.level){var ue=m[X+1];u.sn<_&&this.fragmentTracker.getState(ue)!==Ge.OK?(this.log("SN "+u.sn+" just loaded, load next one: "+ue.sn),u=ue):u=null}}return u},a.synchronizeToLiveEdge=function(r){var s=this.config,l=this.media;if(l){var u=this.hls.liveSyncPosition,c=l.currentTime,v=r.fragments[0].start,m=r.edge,_=c>=v-s.maxFragLookUpTolerance&&c<=m;if(u!==null&&l.duration>u&&(c<u||!_)){var S=s.liveMaxLatencyDuration!==void 0?s.liveMaxLatencyDuration:s.liveMaxLatencyDurationCount*r.targetduration;(!_&&l.readyState<4||c<m-S)&&(this.loadedmetadata||(this.nextLoadPosition=u),l.readyState&&(this.warn("Playback: "+c.toFixed(3)+" is located too far from the end of live sliding playlist: "+m+", reset currentTime to : "+u.toFixed(3)),l.currentTime=u))}}},a.alignPlaylists=function(r,s){var l=this.levels,u=this.levelLastLoaded,c=this.fragPrevious,v=u!==null?l[u]:null,m=r.fragments.length;if(!m)return this.warn("No fragments in live playlist"),0;var _=r.fragments[0].start,S=!s,F=r.alignedSliding&&(0,R.isFiniteNumber)(_);if(S||!F&&!_){(function(X,ue,_e){ue&&(function(ge,De,He){if(function(Ae,Ke,je){return!(!Ke.details||!(je.endCC>je.startCC||Ae&&Ae.cc<je.startCC))}(ge,He,De)){var Je=function(Ae,Ke,je){je===void 0&&(je=0);var pt=Ae.fragments,Mt=Ke.fragments;if(Mt.length&&pt.length){var yt=nn(pt,Mt[0].cc);if(yt&&(!yt||yt.startPTS))return yt;L.logger.log("No frag in previous level to align on")}else L.logger.log("No fragments to align")}(He.details,De);Je&&(0,R.isFiniteNumber)(Je.start)&&(L.logger.log("Adjusting PTS using last level due to CC increase within current level "+De.url),li(Je.start,De))}}(X,_e,ue),!_e.alignedSliding&&ue.details&&function(ge,De){if(De.fragments.length&&ge.hasProgramDateTime&&De.hasProgramDateTime){var He=De.fragments[0].programDateTime,Je=ge.fragments[0].programDateTime,Ae=(Je-He)/1e3+De.fragments[0].start;Ae&&(0,R.isFiniteNumber)(Ae)&&(L.logger.log("Adjusting PTS using programDateTime delta "+(Je-He)+"ms, sliding:"+Ae.toFixed(3)+" "+ge.url+" "),li(Ae,ge))}}(_e,ue.details),_e.alignedSliding||!ue.details||_e.skippedSegments||Z(ue.details,_e))})(c,v,r);var P=r.fragments[0].start;return this.log("Live playlist sliding: "+P.toFixed(2)+" start-sn: "+(s?s.startSN:"na")+"->"+r.startSN+" prev-sn: "+(c?c.sn:"na")+" fragments: "+m),P}return _},a.waitForCdnTuneIn=function(r){return r.live&&r.canBlockReload&&r.partTarget&&r.tuneInGoal>Math.max(r.partHoldBack,3*r.partTarget)},a.setStartPosition=function(r,s){var l=this.startPosition;if(l<s&&(l=-1),l===-1||this.lastCurrentTime===-1){var u=r.startTimeOffset;(0,R.isFiniteNumber)(u)?(l=s+u,u<0&&(l+=r.totalduration),l=Math.min(Math.max(s,l),s+r.totalduration),this.log("Start time offset "+u+" found in playlist, adjust startPosition to "+l),this.startPosition=l):r.live?l=this.hls.liveSyncPosition||s:this.startPosition=l=0,this.lastCurrentTime=l}this.nextLoadPosition=l},a.getLoadPosition=function(){var r=this.media,s=0;return this.loadedmetadata&&r?s=r.currentTime:this.nextLoadPosition&&(s=this.nextLoadPosition),s},a.handleFragLoadAborted=function(r,s){this.transmuxer&&r.sn!=="initSegment"&&r.stats.aborted&&(this.warn("Fragment "+r.sn+(s?" part"+s.index:"")+" of level "+r.level+" was aborted"),this.resetFragmentLoading(r))},a.resetFragmentLoading=function(r){this.fragCurrent&&(this.fragContextChanged(r)||this.state===Nr)||(this.state=At)},a.onFragmentOrKeyLoadError=function(r,s){if(s.fatal)return this.stopLoad(),void(this.state=Lr);var l=this.config;if(s.chunkMeta){var u=this.getCurrentContext(s.chunkMeta);u&&(s.frag=u.frag,s.levelRetry=!0,this.fragLoadError=l.fragLoadingMaxRetry)}var c=s.frag;if(c&&c.type===r)if(this.fragCurrent,this.fragLoadError+1<=l.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var v=Math.min(Math.pow(2,this.fragLoadError)*l.fragLoadingRetryDelay,l.fragLoadingMaxRetryTimeout);this.warn("Fragment "+c.sn+" of "+r+" "+c.level+" failed to load, retrying in "+v+"ms"),this.retryDate=self.performance.now()+v,this.fragLoadError++,this.state=Nr}else s.levelRetry?(r===fe.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=At):(L.logger.error(s.details+" reaches max retry, redispatch as fatal ..."),s.fatal=!0,this.hls.stopLoad(),this.state=Lr)},a.afterBufferFlushed=function(r,s,l){if(r){var u=Gt.getBuffered(r);this.fragmentTracker.detectEvictedFragments(s,u,l),this.state===ei&&this.resetLoadingState()}},a.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=At},a.resetStartWhenNotLoaded=function(r){if(!this.loadedmetadata){this.startFragRequested=!1;var s=this.levels?this.levels[r].details:null;s!=null&&s.live?(this.startPosition=-1,this.setStartPosition(s,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},a.updateLevelTiming=function(r,s,l,u){var c=this,v=l.details;Object.keys(r.elementaryStreams).reduce(function(m,_){var S=r.elementaryStreams[_];if(S){var F=S.endPTS-S.startPTS;if(F<=0)return c.warn("Could not parse fragment "+r.sn+" "+_+" duration reliably ("+F+")"),m||!1;var P=u?0:Q(v,r,S.startPTS,S.endPTS,S.startDTS,S.endDTS);return c.hls.trigger(g.Events.LEVEL_PTS_UPDATED,{details:v,level:l,drift:P,type:_,frag:r,start:S.startPTS,end:S.endPTS}),!0}return m},!1)||(this.warn("Found no media in fragment "+r.sn+" of level "+l.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=Vr,this.hls.trigger(g.Events.FRAG_PARSED,{frag:r,part:s})},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i=t,(n=[{key:"state",get:function(){return this._state},set:function(r){var s=this._state;s!==r&&(this._state=r,this.log(s+"->"+r))}}])&&on(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Cr);function fi(){return self.MediaSource||self.WebKitMediaSource}function vi(){return self.SourceBuffer||self.WebKitSourceBuffer}var Li=function(){var d=ENTRY_MODULE,o={},e=function i(n){var a=o[n];if(a!==void 0)return a.exports;var r=o[n]={exports:{}};return d[n].call(r.exports,r,r.exports,i),r.exports};e.m=d,e.n=function(i){var n=i&&i.__esModule?function(){return i.default}:function(){return i};return e.d(n,{a:n}),n},e.d=function(i,n){for(var a in n)e.o(n,a)&&!e.o(i,a)&&Object.defineProperty(i,a,{enumerable:!0,get:n[a]})},e.o=function(i,n){return Object.prototype.hasOwnProperty.call(i,n)},e.r=function(i){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var t=e(ENTRY_MODULE);return t.default||t}.toString().split("ENTRY_MODULE"),un="\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)";function $t(d){return(d+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function pi(d,o,e){var t={};t[e]=[];var i=o.toString().replace(/^"[^"]+"/,"function"),n=i.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||i.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!n)return t;for(var a,r=n[1],s=new RegExp("(\\\\n|\\W)"+$t(r)+un,"g");a=s.exec(i);)a[3]!=="dll-reference"&&t[e].push(a[3]);for(s=new RegExp("\\("+$t(r)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)'+un,"g");a=s.exec(i);)d[a[2]]||(t[e].push(a[1]),d[a[2]]=B(a[1]).m),t[a[2]]=t[a[2]]||[],t[a[2]].push(a[4]);for(var l,u=Object.keys(t),c=0;c<u.length;c++)for(var v=0;v<t[u[c]].length;v++)l=t[u[c]][v],isNaN(1*l)||(t[u[c]][v]=1*t[u[c]][v]);return t}function Dn(d){return Object.keys(d).reduce(function(o,e){return o||d[e].length>0},!1)}function dn(d,o,e,t){var i=d[t].map(function(n){return'"'+n+'": '+o[t][n].toString().replace(/^"[^"]+"/,"function")}).join(",");return Li[0]+"{"+i+"}"+Li[1]+'"'+e+'"'+Li[2]}var Br=B(544),Ri=B(729),ti=B.n(Ri),ri=fi()||{isTypeSupported:function(){return!1}},Ii=function(){function d(e,t,i,n){var a=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;var s=function(v,m){(m=m||{}).frag=a.frag,m.id=a.id,a.hls.trigger(v,m)};this.observer=new Ri.EventEmitter,this.observer.on(g.Events.FRAG_DECRYPTED,s),this.observer.on(g.Events.ERROR,s);var l={mp4:ri.isTypeSupported("video/mp4"),mpeg:ri.isTypeSupported("audio/mpeg"),mp3:ri.isTypeSupported('audio/mp4; codecs="mp3"')},u=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"){var c;L.logger.log("demuxing in webworker");try{c=this.worker=function(v,m){m=m||{};var _={main:B.m},S=m.all?{main:Object.keys(_.main)}:function(_e,ge){for(var De={main:[ge]},He={main:[]},Je={main:{}};Dn(De);)for(var Ae=Object.keys(De),Ke=0;Ke<Ae.length;Ke++){var je=Ae[Ke],pt=De[je].pop();if(Je[je]=Je[je]||{},!Je[je][pt]&&_e[je][pt]){Je[je][pt]=!0,He[je]=He[je]||[],He[je].push(pt);for(var Mt=pi(_e,_e[je][pt],je),yt=Object.keys(Mt),kt=0;kt<yt.length;kt++)De[yt[kt]]=De[yt[kt]]||[],De[yt[kt]]=De[yt[kt]].concat(Mt[yt[kt]])}}return He}(_,v),F="";Object.keys(S).filter(function(_e){return _e!=="main"}).forEach(function(_e){for(var ge=0;S[_e][ge];)ge++;S[_e].push(ge),_[_e][ge]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",F=F+"var "+_e+" = ("+dn(S,_,ge,modules)+`)();
|
|
9
|
-
`}),F=F+"new (("+dn(S,_,v,"main")+")())(self);";var P=new window.Blob([F],{type:"text/javascript"}),X=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(P),ue=new window.Worker(X);return ue.objectURL=X,ue}(182),this.onwmsg=this.onWorkerMessage.bind(this),c.addEventListener("message",this.onwmsg),c.onerror=function(v){a.useWorker=!1,L.logger.warn("Exception in webworker, fallback to inline"),a.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.OTHER_ERROR,details:k.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(v.message+" ("+v.filename+":"+v.lineno+")")})},c.postMessage({cmd:"init",typeSupported:l,vendor:u,id:t,config:JSON.stringify(r)})}catch(v){L.logger.warn("Error in worker:",v),L.logger.error("Error while initializing DemuxerWorker, fallback to inline"),c&&self.URL.revokeObjectURL(c.objectURL),this.transmuxer=new Br.default(this.observer,l,r,u,t),this.worker=null}}else this.transmuxer=new Br.default(this.observer,l,r,u,t)}var o=d.prototype;return o.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var i=this.observer;i&&i.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},o.push=function(e,t,i,n,a,r,s,l,u,c){var v,m,_=this;u.transmuxing.start=self.performance.now();var S=this.transmuxer,F=this.worker,P=r?r.start:a.start,X=a.decryptdata,ue=this.frag,_e=!(ue&&a.cc===ue.cc),ge=!(ue&&u.level===ue.level),De=ue?u.sn-ue.sn:-1,He=this.part?u.part-this.part.index:-1,Je=De===0&&u.id>1&&u.id===(ue==null?void 0:ue.stats.chunkCount),Ae=!ge&&(De===1||De===0&&(He===1||Je&&He<=0)),Ke=self.performance.now();(ge||De||a.stats.parsing.start===0)&&(a.stats.parsing.start=Ke),!r||!He&&Ae||(r.stats.parsing.start=Ke);var je=!(ue&&((v=a.initSegment)===null||v===void 0?void 0:v.url)===((m=ue.initSegment)===null||m===void 0?void 0:m.url)),pt=new Br.TransmuxState(_e,Ae,l,ge,P,je);if(!Ae||_e||je){L.logger.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
|
10
|
-
discontinuity: `+
|
|
11
|
-
trackSwitch: `+
|
|
12
|
-
contiguous: `+
|
|
13
|
-
accurateTimeOffset: `+
|
|
14
|
-
timeOffset: `+
|
|
15
|
-
initSegmentChange: `+je);var Mt=new Br.TransmuxConfig(i,n,t,s,c);this.configureTransmuxer(Mt)}if(this.frag=a,this.part=r,F)F.postMessage({cmd:"demux",data:e,decryptdata:X,chunkMeta:u,state:pt},e instanceof ArrayBuffer?[e]:[]);else if(S){var yt=S.push(e,X,u,pt);(0,Br.isPromise)(yt)?(S.async=!0,yt.then(function(kt){_.handleTransmuxComplete(kt)}).catch(function(kt){_.transmuxerError(kt,u,"transmuxer-interface push error")})):(S.async=!1,this.handleTransmuxComplete(yt))}},o.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var i=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:e});else if(i){var a=i.flush(e);(0,Br.isPromise)(a)||i.async?((0,Br.isPromise)(a)||(a=Promise.resolve(a)),a.then(function(r){t.handleFlushResult(r,e)}).catch(function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")})):this.handleFlushResult(a,e)}},o.transmuxerError=function(e,t,i){this.hls&&this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i})},o.handleFlushResult=function(e,t){var i=this;e.forEach(function(n){i.handleTransmuxComplete(n)}),this.onFlush(t)},o.onWorkerMessage=function(e){var t=e.data,i=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":L.logger[t.data.logType]&&L.logger[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)}},o.configureTransmuxer=function(e){var t=this.worker,i=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):i&&i.configure(e)},o.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},d}(),cn=function(){function d(e,t,i,n){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=n}var o=d.prototype;return o.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},o.poll=function(e,t){var i=this.config,n=this.media,a=this.stalled;if(n!==null){var r=n.currentTime,s=n.seeking,l=this.seeking&&!s,u=!this.seeking&&s;if(this.seeking=s,r===e){if((u||l)&&(this.stalled=null),!(n.paused&&!s||n.ended||n.playbackRate===0)&&Gt.getBuffered(n).length){var c=Gt.bufferInfo(n,r,0),v=c.len>0,m=c.nextStart||0;if(v||m){if(s){var _=c.len>2,S=!m||t&&t.start<=r||m-r>2&&!this.fragmentTracker.getPartialFragment(r);if(_||S)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var F,P=Math.max(m,c.start||0)-r,X=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,ue=!(X==null||(F=X.details)===null||F===void 0)&&F.live?2*X.details.targetduration:2;if(P>0&&P<=ue)return void this._trySkipBufferHole(null)}var _e=self.performance.now();if(a!==null){var ge=_e-a;if(s||!(ge>=250)||(this._reportStall(c),this.media)){var De=Gt.bufferInfo(n,r,i.maxBufferHole);this._tryFixBufferStall(De,ge)}}else this.stalled=_e}}}else if(this.moved=!0,a!==null){if(this.stallReported){var He=self.performance.now()-a;L.logger.warn("playback not stuck anymore @"+r+", after "+Math.round(He)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},o._tryFixBufferStall=function(e,t){var i=this.config,n=this.fragmentTracker,a=this.media;if(a!==null){var r=a.currentTime,s=n.getPartialFragment(r);if(s&&(this._trySkipBufferHole(s)||!this.media))return;e.len>i.maxBufferHole&&t>1e3*i.highBufferWatchdogPeriod&&(L.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},o._reportStall=function(e){var t=this.hls,i=this.media;!this.stallReported&&i&&(this.stallReported=!0,L.logger.warn("Playback stalling at @"+i.currentTime+" due to low buffer ("+JSON.stringify(e)+")"),t.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e.len}))},o._trySkipBufferHole=function(e){var t=this.config,i=this.hls,n=this.media;if(n===null)return 0;for(var a=n.currentTime,r=0,s=Gt.getBuffered(n),l=0;l<s.length;l++){var u=s.start(l);if(a+t.maxBufferHole>=r&&a<u){var c=Math.max(u+.05,n.currentTime+.1);return L.logger.warn("skipping hole, adjusting currentTime from "+a+" to "+c),this.moved=!0,this.stalled=null,n.currentTime=c,e&&i.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+a+" to "+c,frag:e}),c}r=s.end(l)}return 0},o._tryNudgeBuffer=function(){var e=this.config,t=this.hls,i=this.media,n=this.nudgeRetry;if(i!==null){var a=i.currentTime;if(this.nudgeRetry++,n<e.nudgeMaxRetry){var r=a+(n+1)*e.nudgeOffset;L.logger.warn("Nudging 'currentTime' from "+a+" to "+r),i.currentTime=r,t.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else L.logger.error("Playhead still not moving while enough data buffered @"+a+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},d}();function Wr(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Ci(d,o){return Ci=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ci(d,o)}var Ln=function(d){var o,e;function t(r,s,l){var u;return(u=d.call(this,r,s,l,"[stream-controller]")||this).audioCodecSwap=!1,u.gapController=null,u.level=-1,u._forceStartLoad=!1,u.altAudio=!1,u.audioOnly=!1,u.fragPlaying=null,u.onvplaying=null,u.onvseeked=null,u.fragLastKbps=0,u.couldBacktrack=!1,u.backtrackFragment=null,u.audioCodecSwitch=!1,u.videoBuffer=null,u._registerListeners(),u}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ci(o,e);var i,n,a=t.prototype;return a._registerListeners=function(){var r=this.hls;r.on(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(g.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(g.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(g.Events.ERROR,this.onError,this),r.on(g.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(g.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(g.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(g.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(g.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(g.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var r=this.hls;r.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(g.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(g.Events.ERROR,this.onError,this),r.off(g.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(g.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(g.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(g.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(g.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(g.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},a.startLoad=function(r){if(this.levels){var s=this.lastCurrentTime,l=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var u=l.startLevel;u===-1&&(l.config.testBandwidth&&this.levels.length>1?(u=0,this.bitrateTest=!0):u=l.nextAutoLevel),this.level=l.nextLoadLevel=u,this.loadedmetadata=!1}s>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+s.toFixed(3)),r=s),this.state=At,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=br},a.stopLoad=function(){this._forceStartLoad=!1,d.prototype.stopLoad.call(this)},a.doTick=function(){switch(this.state){case At:this.doTickIdle();break;case Yr:var r,s=this.levels,l=this.level,u=s==null||(r=s[l])===null||r===void 0?void 0:r.details;if(u&&(!u.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(u))break;this.state=At;break}break;case Nr:var c,v=self.performance.now(),m=this.retryDate;(!m||v>=m||(c=this.media)!==null&&c!==void 0&&c.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=At)}this.onTickEnd()},a.onTickEnd=function(){d.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},a.doTickIdle=function(){var r=this.hls,s=this.levelLastLoaded,l=this.levels,u=this.media,c=r.config,v=r.nextLoadLevel;if(s!==null&&(u||!this.startFragRequested&&c.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&l&&l[v]){var m=l[v],_=this.getMainFwdBufferInfo();if(_!==null){var S=this.getLevelDetails();if(S&&this._streamEnded(_,S)){var F={};return this.altAudio&&(F.type="video"),this.hls.trigger(g.Events.BUFFER_EOS,F),void(this.state=ei)}this.level=r.nextLoadLevel=v;var P=m.details;if(!P||this.state===Yr||P.live&&this.levelLastLoaded!==v)return this.level=v,void(this.state=Yr);if(!(_.len>=this.getMaxBufferLength(m.maxBitrate))){this.backtrackFragment&&this.backtrackFragment.start>_.end&&(this.backtrackFragment=null);var X=this.backtrackFragment?this.backtrackFragment.start:_.end,ue=this.getNextFragment(X,P);if(this.couldBacktrack&&!this.fragPrevious&&ue&&ue.sn!=="initSegment"&&this.fragmentTracker.getState(ue)!==Ge.OK){var _e,ge=((_e=this.backtrackFragment)!=null?_e:ue).sn-P.startSN,De=P.fragments[ge-1];De&&ue.cc===De.cc&&(ue=De,this.fragmentTracker.removeFragment(De))}else this.backtrackFragment&&_.len&&(this.backtrackFragment=null);if(ue&&this.fragmentTracker.getState(ue)===Ge.OK&&this.nextLoadPosition>X){var He=this.audioOnly&&!this.altAudio?J.ElementaryStreamTypes.AUDIO:J.ElementaryStreamTypes.VIDEO,Je=(He===J.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;Je&&this.afterBufferFlushed(Je,He,fe.PlaylistLevelType.MAIN),ue=this.getNextFragment(this.nextLoadPosition,P)}ue&&(!ue.initSegment||ue.initSegment.data||this.bitrateTest||(ue=ue.initSegment),this.loadFragment(ue,P,X))}}}},a.loadFragment=function(r,s,l){var u,c=this.fragmentTracker.getState(r);this.fragCurrent=r,c===Ge.NOT_LOADED?r.sn==="initSegment"?this._loadInitSegment(r,s):this.bitrateTest?(this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r,s)):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,s,l)):c===Ge.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((u=this.media)===null||u===void 0?void 0:u.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},a.getAppendedFrag=function(r){var s=this.fragmentTracker.getAppendedFrag(r,fe.PlaylistLevelType.MAIN);return s&&"fragment"in s?s.fragment:s},a.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,fe.PlaylistLevelType.MAIN)},a.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},a.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},a.nextLevelSwitch=function(){var r=this.levels,s=this.media;if(s!=null&&s.readyState){var l,u=this.getAppendedFrag(s.currentTime);if(u&&u.start>1&&this.flushMainBuffer(0,u.start-1),!s.paused&&r){var c=r[this.hls.nextLoadLevel],v=this.fragLastKbps;l=v&&this.fragCurrent?this.fragCurrent.duration*c.maxBitrate/(1e3*v)+1:0}else l=0;var m=this.getBufferedFrag(s.currentTime+l);if(m){var _=this.followingBufferedFrag(m);if(_){this.abortCurrentFrag();var S=_.maxStartPTS?_.maxStartPTS:_.start,F=_.duration,P=Math.max(m.end,S+Math.min(Math.max(F-this.config.maxFragLookUpTolerance,.5*F),.75*F));this.flushMainBuffer(P,Number.POSITIVE_INFINITY)}}}},a.abortCurrentFrag=function(){var r=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,r&&r.abortRequests(),this.state){case ln:case qr:case Nr:case wr:case Vr:this.state=At}this.nextLoadPosition=this.getLoadPosition()},a.flushMainBuffer=function(r,s){d.prototype.flushMainBuffer.call(this,r,s,this.altAudio?"video":null)},a.onMediaAttached=function(r,s){d.prototype.onMediaAttached.call(this,r,s);var l=s.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),l.addEventListener("playing",this.onvplaying),l.addEventListener("seeked",this.onvseeked),this.gapController=new cn(this.config,l,this.fragmentTracker,this.hls)},a.onMediaDetaching=function(){var r=this.media;r&&this.onvplaying&&this.onvseeked&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),d.prototype.onMediaDetaching.call(this)},a.onMediaPlaying=function(){this.tick()},a.onMediaSeeked=function(){var r=this.media,s=r?r.currentTime:null;(0,R.isFiniteNumber)(s)&&this.log("Media seeked to "+s.toFixed(3)),this.tick()},a.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(g.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},a.onManifestParsed=function(r,s){var l,u,c,v=!1,m=!1;s.levels.forEach(function(_){(l=_.audioCodec)&&(l.indexOf("mp4a.40.2")!==-1&&(v=!0),l.indexOf("mp4a.40.5")!==-1&&(m=!0))}),this.audioCodecSwitch=v&&m&&typeof((c=vi())==null||(u=c.prototype)===null||u===void 0?void 0:u.changeType)!="function",this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=s.levels,this.startFragRequested=!1},a.onLevelLoading=function(r,s){var l=this.levels;if(l&&this.state===At){var u=l[s.level];(!u.details||u.details.live&&this.levelLastLoaded!==s.level||this.waitForCdnTuneIn(u.details))&&(this.state=Yr)}},a.onLevelLoaded=function(r,s){var l,u=this.levels,c=s.level,v=s.details,m=v.totalduration;if(u){this.log("Level "+c+" loaded ["+v.startSN+","+v.endSN+"], cc ["+v.startCC+", "+v.endCC+"] duration:"+m);var _=this.fragCurrent;!_||this.state!==qr&&this.state!==Nr||_.level!==s.level&&_.loader&&(this.state=At,this.backtrackFragment=null,_.abortRequests());var S=u[c],F=0;if(v.live||(l=S.details)!==null&&l!==void 0&&l.live){if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed)return;F=this.alignPlaylists(v,S.details)}if(S.details=v,this.levelLastLoaded=c,this.hls.trigger(g.Events.LEVEL_UPDATED,{details:v,level:c}),this.state===Yr){if(this.waitForCdnTuneIn(v))return;this.state=At}this.startFragRequested?v.live&&this.synchronizeToLiveEdge(v):this.setStartPosition(v,F),this.tick()}else this.warn("Levels were reset while loading level "+c)},a._handleFragmentLoadProgress=function(r){var s,l=r.frag,u=r.part,c=r.payload,v=this.levels;if(v){var m=v[l.level],_=m.details;if(_){var S=m.videoCodec,F=_.PTSKnown||!_.live,P=(s=l.initSegment)===null||s===void 0?void 0:s.data,X=this._getAudioCodec(m),ue=this.transmuxer=this.transmuxer||new Ii(this.hls,fe.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),_e=u?u.index:-1,ge=_e!==-1,De=new Di(l.level,l.sn,l.stats.chunkCount,c.byteLength,_e,ge),He=this.initPTS[l.cc];ue.push(c,P,X,S,l,u,_.totalduration,F,De,He)}else this.warn("Dropping fragment "+l.sn+" of level "+l.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered")},a.onAudioTrackSwitching=function(r,s){var l=this.altAudio,u=!!s.url,c=s.id;if(!u){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var v=this.fragCurrent;v&&(this.log("Switching to main audio track, cancel main fragment load"),v.abortRequests()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var m=this.hls;l&&m.trigger(g.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),m.trigger(g.Events.AUDIO_TRACK_SWITCHED,{id:c})}},a.onAudioTrackSwitched=function(r,s){var l=s.id,u=!!this.hls.audioTracks[l].url;if(u){var c=this.videoBuffer;c&&this.mediaBuffer!==c&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=c)}this.altAudio=u,this.tick()},a.onBufferCreated=function(r,s){var l,u,c=s.tracks,v=!1;for(var m in c){var _=c[m];if(_.id==="main"){if(u=m,l=_,m==="video"){var S=c[m];S&&(this.videoBuffer=S.buffer)}}else v=!0}v&&l?(this.log("Alternate track found, use "+u+".buffered to schedule main fragment loading"),this.mediaBuffer=l.buffer):this.mediaBuffer=this.media},a.onFragBuffered=function(r,s){var l=s.frag,u=s.part;if(!l||l.type===fe.PlaylistLevelType.MAIN){if(this.fragContextChanged(l))return this.warn("Fragment "+l.sn+(u?" p: "+u.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Vr&&(this.state=At));var c=u?u.stats:l.stats;this.fragLastKbps=Math.round(8*c.total/(c.buffering.end-c.loading.first)),l.sn!=="initSegment"&&(this.fragPrevious=l),this.fragBufferedComplete(l,u)}},a.onError=function(r,s){if(s.type!==k.ErrorTypes.KEY_SYSTEM_ERROR)switch(s.details){case k.ErrorDetails.FRAG_LOAD_ERROR:case k.ErrorDetails.FRAG_LOAD_TIMEOUT:case k.ErrorDetails.FRAG_PARSING_ERROR:case k.ErrorDetails.KEY_LOAD_ERROR:case k.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(fe.PlaylistLevelType.MAIN,s);break;case k.ErrorDetails.LEVEL_LOAD_ERROR:case k.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==Lr&&(s.fatal?(this.warn(""+s.details),this.state=Lr):s.levelRetry||this.state!==Yr||(this.state=At));break;case k.ErrorDetails.BUFFER_FULL_ERROR:if(s.parent==="main"&&(this.state===wr||this.state===Vr)){var l=!0,u=this.getFwdBufferInfo(this.media,fe.PlaylistLevelType.MAIN);u&&u.len>.5&&(l=!this.reduceMaxBufferLength(u.len)),l&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}else this.onFragmentOrKeyLoadError(fe.PlaylistLevelType.MAIN,s)},a.checkBuffer=function(){var r=this.media,s=this.gapController;if(r&&s&&r.readyState){if(this.loadedmetadata||!Gt.getBuffered(r).length){var l=this.state!==At?this.fragCurrent:null;s.poll(this.lastCurrentTime,l)}this.lastCurrentTime=r.currentTime}},a.onFragLoadEmergencyAborted=function(){this.state=At,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},a.onBufferFlushed=function(r,s){var l=s.type;if(l!==J.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var u=(l===J.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(u,l,fe.PlaylistLevelType.MAIN)}},a.onLevelsUpdated=function(r,s){this.levels=s.levels},a.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},a.seekToStartPos=function(){var r=this.media;if(r){var s=r.currentTime,l=this.startPosition;if(l>=0&&s<l){if(r.seeking)return void this.log("could not seek to "+l+", already seeking at "+s);var u=Gt.getBuffered(r),c=(u.length?u.start(0):0)-l;c>0&&(c<this.config.maxBufferHole||c<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+c+" to match buffer start"),l+=c,this.startPosition=l),this.log("seek to target start position "+l+" from current time "+s),r.currentTime=l}}},a._getAudioCodec=function(r){var s=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&s&&(this.log("Swapping audio codec"),s=s.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),s},a._loadBitrateTestFrag=function(r,s){var l=this;r.bitrateTest=!0,this._doFragLoad(r,s).then(function(u){var c=l.hls;if(u&&!c.nextLoadLevel&&!l.fragContextChanged(r)){l.fragLoadError=0,l.state=At,l.startFragRequested=!1,l.bitrateTest=!1;var v=r.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),c.trigger(g.Events.FRAG_LOADED,u),r.bitrateTest=!1}})},a._handleTransmuxComplete=function(r){var s,l="main",u=this.hls,c=r.remuxResult,v=r.chunkMeta,m=this.getCurrentContext(v);if(!m)return this.warn("The loading context changed while buffering fragment "+v.sn+" of level "+v.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(v.level);var _=m.frag,S=m.part,F=m.level,P=c.video,X=c.text,ue=c.id3,_e=c.initSegment,ge=F.details,De=this.altAudio?void 0:c.audio;if(!this.fragContextChanged(_)){if(this.state=wr,_e){_e.tracks&&(this._bufferInitSegment(F,_e.tracks,_,v),u.trigger(g.Events.FRAG_PARSING_INIT_SEGMENT,{frag:_,id:l,tracks:_e.tracks}));var He=_e.initPTS,Je=_e.timescale;(0,R.isFiniteNumber)(He)&&(this.initPTS[_.cc]=He,u.trigger(g.Events.INIT_PTS_FOUND,{frag:_,id:l,initPTS:He,timescale:Je}))}if(P&&c.independent!==!1){if(ge){var Ae=P.startPTS,Ke=P.endPTS,je=P.startDTS,pt=P.endDTS;if(S)S.elementaryStreams[P.type]={startPTS:Ae,endPTS:Ke,startDTS:je,endDTS:pt};else if(P.firstKeyFrame&&P.independent&&v.id===1&&(this.couldBacktrack=!0),P.dropped&&P.independent){var Mt=this.getMainFwdBufferInfo();if((Mt?Mt.end:this.getLoadPosition())+this.config.maxBufferHole<(P.firstKeyFramePTS?P.firstKeyFramePTS:Ae)-this.config.maxBufferHole)return void this.backtrack(_);_.setElementaryStreamInfo(P.type,_.start,Ke,_.start,pt,!0)}_.setElementaryStreamInfo(P.type,Ae,Ke,je,pt),this.backtrackFragment&&(this.backtrackFragment=_),this.bufferFragmentData(P,_,S,v)}}else if(c.independent===!1)return void this.backtrack(_);if(De){var yt=De.startPTS,kt=De.endPTS,xt=De.startDTS,ir=De.endDTS;S&&(S.elementaryStreams[J.ElementaryStreamTypes.AUDIO]={startPTS:yt,endPTS:kt,startDTS:xt,endDTS:ir}),_.setElementaryStreamInfo(J.ElementaryStreamTypes.AUDIO,yt,kt,xt,ir),this.bufferFragmentData(De,_,S,v)}if(ge&&ue!=null&&(s=ue.samples)!==null&&s!==void 0&&s.length){var er={id:l,frag:_,details:ge,samples:ue.samples};u.trigger(g.Events.FRAG_PARSING_METADATA,er)}if(ge&&X){var Yt={id:l,frag:_,details:ge,samples:X.samples};u.trigger(g.Events.FRAG_PARSING_USERDATA,Yt)}}},a._bufferInitSegment=function(r,s,l,u){var c=this;if(this.state===wr){this.audioOnly=!!s.audio&&!s.video,this.altAudio&&!this.audioOnly&&delete s.audio;var v=s.audio,m=s.video,_=s.audiovideo;if(v){var S=r.audioCodec,F=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(S&&(S=S.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),v.metadata.channelCount!==1&&F.indexOf("firefox")===-1&&(S="mp4a.40.5")),F.indexOf("android")!==-1&&v.container!=="audio/mpeg"&&(S="mp4a.40.2",this.log("Android: force audio codec to "+S)),r.audioCodec&&r.audioCodec!==S&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+S+'"'),v.levelCodec=S,v.id="main",this.log("Init audio buffer, container:"+v.container+", codecs[selected/level/parsed]=["+(S||"")+"/"+(r.audioCodec||"")+"/"+v.codec+"]")}m&&(m.levelCodec=r.videoCodec,m.id="main",this.log("Init video buffer, container:"+m.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+m.codec+"]")),_&&this.log("Init audiovideo buffer, container:"+_.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+_.codec+"]"),this.hls.trigger(g.Events.BUFFER_CODECS,s),Object.keys(s).forEach(function(P){var X=s[P].initSegment;X!=null&&X.byteLength&&c.hls.trigger(g.Events.BUFFER_APPENDING,{type:P,data:X,frag:l,part:null,chunkMeta:u,parent:l.type})}),this.tick()}},a.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,fe.PlaylistLevelType.MAIN)},a.backtrack=function(r){this.couldBacktrack=!0,this.backtrackFragment=r,this.resetTransmuxer(),this.flushBufferGap(r),this.fragmentTracker.removeFragment(r),this.fragPrevious=null,this.nextLoadPosition=r.start,this.state=At},a.checkFragmentChanged=function(){var r=this.media,s=null;if(r&&r.readyState>1&&r.seeking===!1){var l=r.currentTime;if(Gt.isBuffered(r,l)?s=this.getAppendedFrag(l):Gt.isBuffered(r,l+.1)&&(s=this.getAppendedFrag(l+.1)),s){this.backtrackFragment=null;var u=this.fragPlaying,c=s.level;u&&s.sn===u.sn&&u.level===c&&s.urlId===u.urlId||(this.fragPlaying=s,this.hls.trigger(g.Events.FRAG_CHANGED,{frag:s}),u&&u.level===c||this.hls.trigger(g.Events.LEVEL_SWITCHED,{level:c}))}}},i=t,(n=[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentFrag",get:function(){var r=this.media;return r?this.fragPlaying||this.getAppendedFrag(r.currentTime):null}},{key:"currentProgramDateTime",get:function(){var r=this.media;if(r){var s=r.currentTime,l=this.currentFrag;if(l&&(0,R.isFiniteNumber)(s)&&(0,R.isFiniteNumber)(l.programDateTime)){var u=l.programDateTime+1e3*(s-l.start);return new Date(u)}}return null}},{key:"currentLevel",get:function(){var r=this.currentFrag;return r?r.level:-1}},{key:"nextBufferedFrag",get:function(){var r=this.currentFrag;return r?this.followingBufferedFrag(r):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&Wr(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(hi);let gi=function(){function d(e,t,i){t===void 0&&(t=0),i===void 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}var o=d.prototype;return o.sample=function(e,t){var i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e},o.getTotalWeight=function(){return this.totalWeight_},o.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},d}(),Rn=function(){function d(e,t,i){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new gi(e),this.fast_=new gi(t)}var o=d.prototype;return o.update=function(e,t){var i=this.slow_,n=this.fast_;this.slow_.halfLife!==e&&(this.slow_=new gi(e,i.getEstimate(),i.getTotalWeight())),this.fast_.halfLife!==t&&(this.fast_=new gi(t,n.getEstimate(),n.getTotalWeight()))},o.sample=function(e,t){var i=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/i;this.fast_.sample(i,n),this.slow_.sample(i,n)},o.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},o.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},o.destroy=function(){},d}();function In(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}let Cn=function(){function d(i){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=i;var n=i.config;this.bwEstimator=new Rn(n.abrEwmaSlowVoD,n.abrEwmaFastVoD,n.abrEwmaDefaultEstimate),this.registerListeners()}var o,e,t=d.prototype;return t.registerListeners=function(){var i=this.hls;i.on(g.Events.FRAG_LOADING,this.onFragLoading,this),i.on(g.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(g.Events.FRAG_BUFFERED,this.onFragBuffered,this),i.on(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(g.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){var i=this.hls;i.off(g.Events.FRAG_LOADING,this.onFragLoading,this),i.off(g.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(g.Events.FRAG_BUFFERED,this.onFragBuffered,this),i.off(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(g.Events.ERROR,this.onError,this)},t.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},t.onFragLoading=function(i,n){var a,r=n.frag;r.type===fe.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=r,this.partCurrent=(a=n.part)!=null?a:null,this.timer=self.setInterval(this.onCheck,100)))},t.onLevelLoaded=function(i,n){var a=this.hls.config;n.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD)},t._abandonRulesCheck=function(){var i=this.fragCurrent,n=this.partCurrent,a=this.hls,r=a.autoLevelEnabled,s=a.media;if(i&&s){var l=n?n.stats:i.stats,u=n?n.duration:i.duration;if(l.aborted||l.loaded&&l.loaded===l.total||i.level===0)return this.clearTimer(),void(this._nextAutoLevel=-1);if(r&&!s.paused&&s.playbackRate&&s.readyState){var c=a.mainForwardBufferInfo;if(c!==null){var v=performance.now()-l.loading.start,m=Math.abs(s.playbackRate);if(!(v<=500*u/m)){var _=l.loaded&&l.loading.first,S=this.bwEstimator.getEstimate(),F=a.levels,P=a.minAutoLevel,X=F[i.level],ue=l.total||Math.max(l.loaded,Math.round(u*X.maxBitrate/8)),_e=_?1e3*l.loaded/v:0,ge=_e?(ue-l.loaded)/_e:8*ue/S,De=c.len/m;if(!(ge<=De)){var He,Je=Number.POSITIVE_INFINITY;for(He=i.level-1;He>P;He--){var Ae=F[He].maxBitrate;if((Je=_e?u*Ae/(6.4*_e):u*Ae/S)<De)break}Je>=ge||(L.logger.warn("Fragment "+i.sn+(n?" part "+n.index:"")+" of level "+i.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+He+`
|
|
16
|
-
|
|
17
|
-
Estimated load time for current fragment: `+
|
|
18
|
-
Estimated load time for
|
|
19
|
-
Time to underbuffer: `+De.toFixed(3)+" s"),a.nextLoadLevel=He,_&&this.bwEstimator.sample(v,l.loaded),this.clearTimer(),(i.loader||i.keyLoader)&&(this.fragCurrent=this.partCurrent=null,i.abortRequests()),a.trigger(g.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:n,stats:l}))}}}}}},t.onFragLoaded=function(i,n){var a=n.frag,r=n.part;if(a.type===fe.PlaylistLevelType.MAIN&&(0,R.isFiniteNumber)(a.sn)){var s=r?r.stats:a.stats,l=r?r.duration:a.duration;if(this.clearTimer(),this.lastLoadedFragLevel=a.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[a.level],c=(u.loaded?u.loaded.bytes:0)+s.loaded,v=(u.loaded?u.loaded.duration:0)+l;u.loaded={bytes:c,duration:v},u.realBitrate=Math.round(8*c/v)}if(a.bitrateTest){var m={stats:s,frag:a,part:r,id:a.type};this.onFragBuffered(g.Events.FRAG_BUFFERED,m)}}},t.onFragBuffered=function(i,n){var a=n.frag,r=n.part,s=r?r.stats:a.stats;if(!s.aborted&&a.type===fe.PlaylistLevelType.MAIN&&a.sn!=="initSegment"){var l=s.parsing.end-s.loading.start;this.bwEstimator.sample(l,s.loaded),s.bwEstimate=this.bwEstimator.getEstimate(),a.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}},t.onError=function(i,n){var a;if(((a=n.frag)===null||a===void 0?void 0:a.type)===fe.PlaylistLevelType.MAIN){if(n.type===k.ErrorTypes.KEY_SYSTEM_ERROR)return void this.clearTimer();switch(n.details){case k.ErrorDetails.FRAG_LOAD_ERROR:case k.ErrorDetails.FRAG_LOAD_TIMEOUT:case k.ErrorDetails.KEY_LOAD_ERROR:case k.ErrorDetails.KEY_LOAD_TIMEOUT:this.clearTimer()}}},t.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},t.getNextABRAutoLevel=function(){var i=this.fragCurrent,n=this.partCurrent,a=this.hls,r=a.maxAutoLevel,s=a.config,l=a.minAutoLevel,u=a.media,c=n?n.duration:i?i.duration:0,v=u&&u.playbackRate!==0?Math.abs(u.playbackRate):1,m=this.bwEstimator?this.bwEstimator.getEstimate():s.abrEwmaDefaultEstimate,_=a.mainForwardBufferInfo,S=(_?_.len:0)/v,F=this.findBestLevel(m,l,r,S,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(F>=0)return F;L.logger.trace((S?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var P=c?Math.min(c,s.maxStarvationDelay):s.maxStarvationDelay,X=s.abrBandWidthFactor,ue=s.abrBandWidthUpFactor;if(!S){var _e=this.bitrateTestDelay;_e&&(P=(c?Math.min(c,s.maxLoadingDelay):s.maxLoadingDelay)-_e,L.logger.trace("bitrate test took "+Math.round(1e3*_e)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*P)+" ms"),X=ue=1)}return F=this.findBestLevel(m,l,r,S+P,X,ue),Math.max(F,0)},t.findBestLevel=function(i,n,a,r,s,l){for(var u,c=this.fragCurrent,v=this.partCurrent,m=this.lastLoadedFragLevel,_=this.hls.levels,S=_[m],F=!(S==null||(u=S.details)===null||u===void 0||!u.live),P=S==null?void 0:S.codecSet,X=v?v.duration:c?c.duration:0,ue=a;ue>=n;ue--){var _e=_[ue];if(_e&&(!P||_e.codecSet===P)){var ge,De=_e.details,He=(v?De==null?void 0:De.partTarget:De==null?void 0:De.averagetargetduration)||X;ge=ue<=m?s*i:l*i;var Je=_[ue].maxBitrate,Ae=Je*He/ge;if(L.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+ue+"/"+Math.round(ge)+"/"+Je+"/"+He+"/"+r+"/"+Ae),ge>Je&&(Ae===0||!(0,R.isFiniteNumber)(Ae)||F&&!this.bitrateTestDelay||Ae<r))return ue}}return-1},o=d,(e=[{key:"nextAutoLevel",get:function(){var i=this._nextAutoLevel,n=this.bwEstimator;if(i!==-1&&!n.canEstimate())return i;var a=this.getNextABRAutoLevel();return i!==-1&&this.hls.levels[a].loadError?i:(i!==-1&&(a=Math.min(i,a)),a)},set:function(i){this._nextAutoLevel=i}}])&&In(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();var hn=function(){function d(){this.chunks=[],this.dataLength=0}var o=d.prototype;return o.push=function(e){this.chunks.push(e),this.dataLength+=e.length},o.flush=function(){var e,t=this.chunks,i=this.dataLength;return t.length?(e=t.length===1?t[0]:function(n,a){for(var r=new Uint8Array(a),s=0,l=0;l<n.length;l++){var u=n[l];r.set(u,s),s+=u.length}return r}(t,i),this.reset(),e):new Uint8Array(0)},o.reset=function(){this.chunks.length=0,this.dataLength=0},d}();function mi(){return mi=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},mi.apply(this,arguments)}function Pi(d,o){return Pi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Pi(d,o)}var yi=function(d){var o,e;function t(n,a,r){var s;return(s=d.call(this,n,a,r,"[audio-stream-controller]")||this).videoBuffer=null,s.videoTrackCC=-1,s.waitingVideoCC=-1,s.audioSwitch=!1,s.trackId=-1,s.waitingData=null,s.mainDetails=null,s.bufferFlushed=!1,s.cachedTrackLoadedData=null,s._registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Pi(o,e);var i=t.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var n=this.hls;n.on(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(g.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.on(g.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(g.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(g.Events.ERROR,this.onError,this),n.on(g.Events.BUFFER_RESET,this.onBufferReset,this),n.on(g.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(g.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(g.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(g.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var n=this.hls;n.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(g.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.off(g.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(g.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(g.Events.ERROR,this.onError,this),n.off(g.Events.BUFFER_RESET,this.onBufferReset,this),n.off(g.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(g.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(g.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(g.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i.onInitPtsFound=function(n,a){var r=a.frag,s=a.id,l=a.initPTS;if(s==="main"){var u=r.cc;this.initPTS[r.cc]=l,this.log("InitPTS for cc: "+u+" found from main: "+l),this.videoTrackCC=u,this.state===Ur&&this.tick()}},i.startLoad=function(n){if(!this.levels)return this.startPosition=n,void(this.state=br);var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,a>0&&n===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),n=a,this.state=At):(this.loadedmetadata=!1,this.state=ci),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()},i.doTick=function(){switch(this.state){case At:this.doTickIdle();break;case ci:var n,a=this.levels,r=this.trackId,s=a==null||(n=a[r])===null||n===void 0?void 0:n.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=Ur}break;case Nr:var l,u=performance.now(),c=this.retryDate;(!c||u>=c||(l=this.media)!==null&&l!==void 0&&l.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=At);break;case Ur:var v=this.waitingData;if(v){var m=v.frag,_=v.part,S=v.cache,F=v.complete;if(this.initPTS[m.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=qr;var P={frag:m,part:_,payload:S.flush(),networkDetails:null};this._handleFragmentLoadProgress(P),F&&d.prototype._handleFragmentLoadComplete.call(this,P)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+m.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var X=this.getLoadPosition(),ue=Gt.bufferInfo(this.mediaBuffer,X,this.config.maxBufferHole);di(ue.end,this.config.maxFragLookUpTolerance,m)<0&&(this.log("Waiting fragment cc ("+m.cc+") @ "+m.start+" cancelled because another fragment at "+ue.end+" is needed"),this.clearWaitingFragment())}}else this.state=At}this.onTickEnd()},i.clearWaitingFragment=function(){var n=this.waitingData;n&&(this.fragmentTracker.removeFragment(n.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=At)},i.resetLoadingState=function(){this.clearWaitingFragment(),d.prototype.resetLoadingState.call(this)},i.onTickEnd=function(){var n=this.media;n&&n.readyState&&(this.lastCurrentTime=n.currentTime)},i.doTickIdle=function(){var n=this.hls,a=this.levels,r=this.media,s=this.trackId,l=n.config;if(a&&a[s]&&(r||!this.startFragRequested&&l.startFragPrefetch)){var u=a[s].details;if(!u||u.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(u))this.state=ci;else{var c=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&c&&(this.bufferFlushed=!1,this.afterBufferFlushed(c,J.ElementaryStreamTypes.AUDIO,fe.PlaylistLevelType.AUDIO));var v=this.getFwdBufferInfo(c,fe.PlaylistLevelType.AUDIO);if(v!==null){var m=this.audioSwitch;if(!m&&this._streamEnded(v,u))return n.trigger(g.Events.BUFFER_EOS,{type:"audio"}),void(this.state=ei);var _=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,fe.PlaylistLevelType.MAIN);if(!(v.len>=this.getMaxBufferLength(_==null?void 0:_.len))||m){var S=u.fragments[0].start,F=v.end;if(m&&r){var P=this.getLoadPosition();F=P,u.PTSKnown&&P<S&&(v.end>S||v.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=S+.05)}if(!(_&&F>_.end+u.targetduration)&&(_&&_.len||!v.len)){var X=this.getNextFragment(F,u);X?this.loadFragment(X,u,F):this.bufferFlushed=!0}}}}}},i.getMaxBufferLength=function(n){var a=d.prototype.getMaxBufferLength.call(this);return n?Math.max(a,n):a},i.onMediaDetaching=function(){this.videoBuffer=null,d.prototype.onMediaDetaching.call(this)},i.onAudioTracksUpdated=function(n,a){var r=a.audioTracks;this.resetTransmuxer(),this.levels=r.map(function(s){return new N(s)})},i.onAudioTrackSwitching=function(n,a){var r=!!a.url;this.trackId=a.id;var s=this.fragCurrent;s&&s.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=At):this.state=br,this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},i.onLevelLoaded=function(n,a){this.mainDetails=a.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(g.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},i.onAudioTrackLoaded=function(n,a){var r;if(this.mainDetails!=null){var s=this.levels,l=a.details,u=a.id;if(s){this.log("Track "+u+" loaded ["+l.startSN+","+l.endSN+"],duration:"+l.totalduration);var c=s[u],v=0;if(l.live||(r=c.details)!==null&&r!==void 0&&r.live){var m=this.mainDetails;if(l.fragments[0]||(l.deltaUpdateFailed=!0),l.deltaUpdateFailed||!m)return;!c.details&&l.hasProgramDateTime&&m.hasProgramDateTime?(an(l,m),v=l.fragments[0].start):v=this.alignPlaylists(l,c.details)}c.details=l,this.levelLastLoaded=u,this.startFragRequested||!this.mainDetails&&l.live||this.setStartPosition(c.details,v),this.state!==ci||this.waitForCdnTuneIn(l)||(this.state=At),this.tick()}else this.warn("Audio tracks were reset while loading level "+u)}else this.cachedTrackLoadedData=a},i._handleFragmentLoadProgress=function(n){var a,r=n.frag,s=n.part,l=n.payload,u=this.config,c=this.trackId,v=this.levels;if(v){var m=v[c],_=m.details,S=u.defaultAudioCodec||m.audioCodec||"mp4a.40.2",F=this.transmuxer;F||(F=this.transmuxer=new Ii(this.hls,fe.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var P=this.initPTS[r.cc],X=(a=r.initSegment)===null||a===void 0?void 0:a.data;if(P!==void 0){var ue=s?s.index:-1,_e=ue!==-1,ge=new Di(r.level,r.sn,r.stats.chunkCount,l.byteLength,ue,_e);F.push(l,X,S,"",r,s,_.totalduration,!1,ge,P)}else this.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+_.startSN+" ,"+_.endSN+"],track "+c),(this.waitingData=this.waitingData||{frag:r,part:s,cache:new hn,complete:!1}).cache.push(new Uint8Array(l)),this.waitingVideoCC=this.videoTrackCC,this.state=Ur}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},i._handleFragmentLoadComplete=function(n){this.waitingData?this.waitingData.complete=!0:d.prototype._handleFragmentLoadComplete.call(this,n)},i.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},i.onBufferCreated=function(n,a){var r=a.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer||null)},i.onFragBuffered=function(n,a){var r,s=a.frag,l=a.part;s.type===fe.PlaylistLevelType.AUDIO?this.fragContextChanged(s)?this.warn("Fragment "+s.sn+(l?" p: "+l.index:"")+" of level "+s.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):(s.sn!=="initSegment"&&(this.fragPrevious=s,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(g.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(s,l)):this.loadedmetadata||s.type!==fe.PlaylistLevelType.MAIN||(r=this.videoBuffer||this.media)!==null&&r!==void 0&&r.buffered.length&&(this.loadedmetadata=!0)},i.onError=function(n,a){if(a.type!==k.ErrorTypes.KEY_SYSTEM_ERROR)switch(a.details){case k.ErrorDetails.FRAG_LOAD_ERROR:case k.ErrorDetails.FRAG_LOAD_TIMEOUT:case k.ErrorDetails.FRAG_PARSING_ERROR:case k.ErrorDetails.KEY_LOAD_ERROR:case k.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(fe.PlaylistLevelType.AUDIO,a);break;case k.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case k.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==Lr&&this.state!==br&&(this.state=a.fatal?Lr:At,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case k.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===wr||this.state===Vr)){var r=!0,s=this.getFwdBufferInfo(this.mediaBuffer,fe.PlaylistLevelType.AUDIO);s&&s.len>.5&&(r=!this.reduceMaxBufferLength(s.len)),r&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}else this.onFragmentOrKeyLoadError(fe.PlaylistLevelType.AUDIO,a)},i.onBufferFlushed=function(n,a){a.type===J.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0,this.state===ei&&(this.state=At))},i._handleTransmuxComplete=function(n){var a,r="audio",s=this.hls,l=n.remuxResult,u=n.chunkMeta,c=this.getCurrentContext(u);if(!c)return this.warn("The loading context changed while buffering fragment "+u.sn+" of level "+u.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(u.level);var v=c.frag,m=c.part,_=c.level.details,S=l.audio,F=l.text,P=l.id3,X=l.initSegment;if(!this.fragContextChanged(v)&&_){if(this.state=wr,this.audioSwitch&&S&&this.completeAudioSwitch(),X!=null&&X.tracks&&(this._bufferInitSegment(X.tracks,v,u),s.trigger(g.Events.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:r,tracks:X.tracks})),S){var ue=S.startPTS,_e=S.endPTS,ge=S.startDTS,De=S.endDTS;m&&(m.elementaryStreams[J.ElementaryStreamTypes.AUDIO]={startPTS:ue,endPTS:_e,startDTS:ge,endDTS:De}),v.setElementaryStreamInfo(J.ElementaryStreamTypes.AUDIO,ue,_e,ge,De),this.bufferFragmentData(S,v,m,u)}if(P!=null&&(a=P.samples)!==null&&a!==void 0&&a.length){var He=mi({id:r,frag:v,details:_},P);s.trigger(g.Events.FRAG_PARSING_METADATA,He)}if(F){var Je=mi({id:r,frag:v,details:_},F);s.trigger(g.Events.FRAG_PARSING_USERDATA,Je)}}},i._bufferInitSegment=function(n,a,r){if(this.state===wr){n.video&&delete n.video;var s=n.audio;if(s){s.levelCodec=s.codec,s.id="audio",this.log("Init audio buffer, container:"+s.container+", codecs[parsed]=["+s.codec+"]"),this.hls.trigger(g.Events.BUFFER_CODECS,n);var l=s.initSegment;if(l!=null&&l.byteLength){var u={type:"audio",frag:a,part:null,chunkMeta:r,parent:a.type,data:l};this.hls.trigger(g.Events.BUFFER_APPENDING,u)}this.tick()}}},i.loadFragment=function(n,a,r){var s=this.fragmentTracker.getState(n);this.fragCurrent=n,(this.audioSwitch||s===Ge.NOT_LOADED||s===Ge.PARTIAL)&&(n.sn==="initSegment"?this._loadInitSegment(n,a):a.live&&!(0,R.isFiniteNumber)(this.initPTS[n.cc])?(this.log("Waiting for video PTS in continuity counter "+n.cc+" of live stream before loading audio fragment "+n.sn+" of level "+this.trackId),this.state=Ur):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,n,a,r)))},i.completeAudioSwitch=function(){var n=this.hls,a=this.media,r=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,n.trigger(g.Events.AUDIO_TRACK_SWITCHED,{id:r})},t}(hi);let Oi=yi;function fn(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function ii(d,o){return ii=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ii(d,o)}let Pn=function(d){var o,e;function t(r){var s;return(s=d.call(this,r,"[audio-track-controller]")||this).tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.trackName="",s.selectDefaultTrack=!0,s.registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,ii(o,e);var i,n,a=t.prototype;return a.registerListeners=function(){var r=this.hls;r.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(g.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(g.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(g.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.on(g.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var r=this.hls;r.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(g.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(g.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(g.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.off(g.Events.ERROR,this.onError,this)},a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,d.prototype.destroy.call(this)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},a.onManifestParsed=function(r,s){this.tracks=s.audioTracks||[]},a.onAudioTrackLoaded=function(r,s){var l=s.id,u=s.details,c=this.tracksInGroup[l];if(c){var v=c.details;c.details=s.details,this.log("audioTrack "+l+" loaded ["+u.startSN+"-"+u.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,v))}else this.warn("Invalid audio track id "+l)},a.onLevelLoading=function(r,s){this.switchLevel(s.level)},a.onLevelSwitching=function(r,s){this.switchLevel(s.level)},a.switchLevel=function(r){var s=this.hls.levels[r];if(s!=null&&s.audioGroupIds){var l=s.audioGroupIds[s.urlId];if(this.groupId!==l){this.groupId=l;var u=this.tracks.filter(function(v){return!l||v.groupId===l});this.selectDefaultTrack&&!u.some(function(v){return v.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=u;var c={audioTracks:u};this.log("Updating audio tracks, "+u.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(g.Events.AUDIO_TRACKS_UPDATED,c),this.selectInitialTrack()}}},a.onError=function(r,s){d.prototype.onError.call(this,r,s),!s.fatal&&s.context&&s.context.type===fe.PlaylistContextType.AUDIO_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},a.setAudioTrack=function(r){var s=this.tracksInGroup;if(r<0||r>=s.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var l=s[this.trackId];this.log("Now switching to audio-track index "+r);var u=s[r],c=u.id,v=u.groupId,m=v===void 0?"":v,_=u.name,S=u.type,F=u.url;if(this.trackId=r,this.trackName=_,this.selectDefaultTrack=!1,this.hls.trigger(g.Events.AUDIO_TRACK_SWITCHING,{id:c,groupId:m,name:_,type:S,url:F}),!u.details||u.details.live){var P=this.switchParams(u.url,l==null?void 0:l.details);this.loadPlaylist(P)}}},a.selectInitialTrack=function(){this.tracksInGroup;var r=this.trackName,s=this.findTrackId(r)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},a.findTrackId=function(r){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var u=s[l];if((!this.selectDefaultTrack||u.default)&&(!r||r===u.name))return u.id}return-1},a.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,u=s.groupId,c=s.url;if(r)try{c=r.addDirectives(c)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(g.Events.AUDIO_TRACK_LOADING,{url:c,id:l,groupId:u,deliveryDirectives:r||null})}},i=t,(n=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1,this.setAudioTrack(r)}}])&&fn(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Re);function On(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function xi(d,o){return xi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},xi(d,o)}var xn=function(d){var o,e;function t(r,s,l){var u;return(u=d.call(this,r,s,l,"[subtitle-stream-controller]")||this).levels=[],u.currentTrackId=-1,u.tracksBuffered=[],u.mainDetails=null,u._registerListeners(),u}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,xi(o,e);var i,n,a=t.prototype;return a.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},a._registerListeners=function(){var r=this.hls;r.on(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(g.Events.ERROR,this.onError,this),r.on(g.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.on(g.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.on(g.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(g.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.on(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.on(g.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var r=this.hls;r.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(g.Events.ERROR,this.onError,this),r.off(g.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.off(g.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.off(g.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(g.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.off(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.off(g.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a.startLoad=function(r){this.stopLoad(),this.state=At,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()},a.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},a.onLevelLoaded=function(r,s){this.mainDetails=s.details},a.onSubtitleFragProcessed=function(r,s){var l=s.frag,u=s.success;if(this.fragPrevious=l,this.state=At,u){var c=this.tracksBuffered[this.currentTrackId];if(c){for(var v,m=l.start,_=0;_<c.length;_++)if(m>=c[_].start&&m<=c[_].end){v=c[_];break}var S=l.start+l.duration;v?v.end=S:(v={start:m,end:S},c.push(v)),this.fragmentTracker.fragBuffered(l)}}},a.onBufferFlushing=function(r,s){var l=s.startOffset,u=s.endOffset;if(l===0&&u!==Number.POSITIVE_INFINITY){var c=this.currentTrackId,v=this.levels;if(!v.length||!v[c]||!v[c].details)return;var m=u-v[c].details.targetduration;if(m<=0)return;s.endOffsetSubtitles=Math.max(0,m),this.tracksBuffered.forEach(function(_){for(var S=0;S<_.length;)if(_[S].end<=m)_.shift();else{if(!(_[S].start<m))break;_[S].start=m,S++}}),this.fragmentTracker.removeFragmentsInRange(l,m,fe.PlaylistLevelType.SUBTITLE)}},a.onFragBuffered=function(r,s){var l;this.loadedmetadata||s.frag.type!==fe.PlaylistLevelType.MAIN||(l=this.media)!==null&&l!==void 0&&l.buffered.length&&(this.loadedmetadata=!0)},a.onError=function(r,s){var l=s.frag;l&&l.type===fe.PlaylistLevelType.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state=At)},a.onSubtitleTracksUpdated=function(r,s){var l=this,u=s.subtitleTracks;this.tracksBuffered=[],this.levels=u.map(function(c){return new N(c)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(c){l.tracksBuffered[c.id]=[]}),this.mediaBuffer=null},a.onSubtitleTrackSwitch=function(r,s){if(this.currentTrackId=s.id,this.levels.length&&this.currentTrackId!==-1){var l=this.levels[this.currentTrackId];l!=null&&l.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,l&&this.setInterval(500)}else this.clearInterval()},a.onSubtitleTrackLoaded=function(r,s){var l,u=s.details,c=s.id,v=this.currentTrackId,m=this.levels;if(m.length){var _=m[v];if(!(c>=m.length||c!==v)&&_){this.mediaBuffer=this.mediaBufferTimeRanges;var S=0;if(u.live||(l=_.details)!==null&&l!==void 0&&l.live){var F=this.mainDetails;if(u.deltaUpdateFailed||!F)return;var P=F.fragments[0];_.details?(S=this.alignPlaylists(u,_.details))===0&&P&&Te(u,S=P.start):u.hasProgramDateTime&&F.hasProgramDateTime?(an(u,F),S=u.fragments[0].start):P&&Te(u,S=P.start)}_.details=u,this.levelLastLoaded=c,this.startFragRequested||!this.mainDetails&&u.live||this.setStartPosition(_.details,S),this.tick(),u.live&&!this.fragCurrent&&this.media&&this.state===At&&(ui(null,u.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),_.details=void 0))}}},a._handleFragmentLoadComplete=function(r){var s=this,l=r.frag,u=r.payload,c=l.decryptdata,v=this.hls;if(!this.fragContextChanged(l)&&u&&u.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var m=performance.now();this.decrypter.decrypt(new Uint8Array(u),c.key.buffer,c.iv.buffer).then(function(_){var S=performance.now();v.trigger(g.Events.FRAG_DECRYPTED,{frag:l,payload:_,stats:{tstart:m,tdecrypt:S}})}).catch(function(_){s.warn(_.name+": "+_.message),s.state=At})}},a.doTick=function(){if(this.media){if(this.state===At){var r=this.currentTrackId,s=this.levels;if(!s.length||!s[r]||!s[r].details)return;var l=s[r].details,u=l.targetduration,c=this.config,v=this.getLoadPosition(),m=Gt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],v-u,c.maxBufferHole),_=m.end,S=m.len,F=this.getFwdBufferInfo(this.media,fe.PlaylistLevelType.MAIN);if(S>this.getMaxBufferLength(F==null?void 0:F.len)+u)return;var P=l.fragments,X=P.length,ue=l.edge,_e=null,ge=this.fragPrevious;if(_<ue){var De=c.maxFragLookUpTolerance;!(_e=ui(ge,P,Math.max(P[0].start,_),De))&&ge&&ge.start<P[0].start&&(_e=P[0])}else _e=P[X-1];if(!_e)return;_e=this.mapToInitFragWhenRequired(_e),this.fragmentTracker.getState(_e)===Ge.NOT_LOADED&&this.loadFragment(_e,l,_)}}else this.state=At},a.getMaxBufferLength=function(r){var s=d.prototype.getMaxBufferLength.call(this);return r?Math.max(s,r):s},a.loadFragment=function(r,s,l){this.fragCurrent=r,r.sn==="initSegment"?this._loadInitSegment(r,s):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,s,l))},i=t,(n=[{key:"mediaBufferTimeRanges",get:function(){return new Mn(this.tracksBuffered[this.currentTrackId]||[])}}])&&On(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(hi),Mn=function(d){this.buffered=void 0;var o=function(e,t,i){if((t>>>=0)>i-1)throw new DOMException("Failed to execute '"+e+"' on 'TimeRanges': The index provided ("+t+") is greater than the maximum bound ("+i+")");return d[t][e]};this.buffered={get length(){return d.length},end:function(e){return o("end",e,d.length)},start:function(e){return o("start",e,d.length)}}};function Fn(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Mi(d,o){return Mi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Mi(d,o)}function Fi(d){for(var o=[],e=0;e<d.length;e++){var t=d[e];t.kind==="subtitles"&&t.label&&o.push(d[e])}return o}let Nn=function(d){var o,e;function t(r){var s;return(s=d.call(this,r,"[subtitle-track-controller]")||this).media=null,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.selectDefaultTrack=!0,s.queuedDefaultTrack=-1,s.trackChangeListener=function(){return s.onTextTracksChanged()},s.asyncPollTrackChange=function(){return s.pollTrackChange(0)},s.useTextTrackPolling=!1,s.subtitlePollingInterval=-1,s._subtitleDisplay=!0,s.registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Mi(o,e);var i,n,a=t.prototype;return a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,d.prototype.destroy.call(this)},a.registerListeners=function(){var r=this.hls;r.on(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(g.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(g.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(g.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(g.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var r=this.hls;r.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(g.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(g.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(g.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(g.Events.ERROR,this.onError,this)},a.onMediaAttached=function(r,s){this.media=s.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},a.pollTrackChange=function(r){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,r)},a.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Fi(this.media.textTracks).forEach(function(r){lt(r)}),this.subtitleTrack=-1,this.media=null)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},a.onManifestParsed=function(r,s){this.tracks=s.subtitleTracks},a.onSubtitleTrackLoaded=function(r,s){var l=s.id,u=s.details,c=this.trackId,v=this.tracksInGroup[c];if(v){var m=v.details;v.details=s.details,this.log("subtitle track "+l+" loaded ["+u.startSN+"-"+u.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,m))}else this.warn("Invalid subtitle track id "+l)},a.onLevelLoading=function(r,s){this.switchLevel(s.level)},a.onLevelSwitching=function(r,s){this.switchLevel(s.level)},a.switchLevel=function(r){var s=this.hls.levels[r];if(s!=null&&s.textGroupIds){var l=s.textGroupIds[s.urlId];if(this.groupId!==l){var u=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,c=this.tracks.filter(function(_){return!l||_.groupId===l});this.tracksInGroup=c;var v=this.findTrackId(u==null?void 0:u.name)||this.findTrackId();this.groupId=l;var m={subtitleTracks:c};this.log("Updating subtitle tracks, "+c.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(g.Events.SUBTITLE_TRACKS_UPDATED,m),v!==-1&&this.setSubtitleTrack(v,u)}}},a.findTrackId=function(r){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var u=s[l];if((!this.selectDefaultTrack||u.default)&&(!r||r===u.name))return u.id}return-1},a.onError=function(r,s){d.prototype.onError.call(this,r,s),!s.fatal&&s.context&&s.context.type===fe.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},a.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,u=s.groupId,c=s.url;if(r)try{c=r.addDirectives(c)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("Loading subtitle playlist for id "+l),this.hls.trigger(g.Events.SUBTITLE_TRACK_LOADING,{url:c,id:l,groupId:u,deliveryDirectives:r||null})}},a.toggleTrackModes=function(r){var s=this,l=this.media,u=this.trackId;if(l){var c=Fi(l.textTracks),v=c.filter(function(S){return S.groupId===s.groupId});if(r===-1)[].slice.call(c).forEach(function(S){S.mode="disabled"});else{var m=v[u];m&&(m.mode="disabled")}var _=v[r];_&&(_.mode=this.subtitleDisplay?"showing":"hidden")}},a.setSubtitleTrack=function(r,s){var l,u=this.tracksInGroup;if(this.media){if(this.trackId!==r&&this.toggleTrackModes(r),!(this.trackId===r&&(r===-1||(l=u[r])!==null&&l!==void 0&&l.details)||r<-1||r>=u.length)){this.clearTimer();var c=u[r];if(this.log("Switching to subtitle track "+r),this.trackId=r,c){var v=c.id,m=c.groupId,_=m===void 0?"":m,S=c.name,F=c.type,P=c.url;this.hls.trigger(g.Events.SUBTITLE_TRACK_SWITCH,{id:v,groupId:_,name:S,type:F,url:P});var X=this.switchParams(c.url,s==null?void 0:s.details);this.loadPlaylist(X)}else this.hls.trigger(g.Events.SUBTITLE_TRACK_SWITCH,{id:r})}}else this.queuedDefaultTrack=r},a.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var r=-1,s=Fi(this.media.textTracks),l=0;l<s.length;l++)if(s[l].mode==="hidden")r=l;else if(s[l].mode==="showing"){r=l;break}this.subtitleTrack!==r&&(this.subtitleTrack=r)}},i=t,(n=[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(r){this._subtitleDisplay=r,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(r,s)}}])&&Fn(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Re);var Tt,gr=function(){function d(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var o=d.prototype;return o.append=function(e,t){var i=this.queues[t];i.push(e),i.length===1&&this.buffers[t]&&this.executeNext(t)},o.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},o.appendBlocker=function(e){var t,i=new Promise(function(a){t=a}),n={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(n,e),i},o.executeNext=function(e){var t=this.buffers,i=this.queues,n=t[e],a=i[e];if(a.length){var r=a[0];try{r.execute()}catch(s){L.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),r.onError(s),n&&n.updating||(a.shift(),this.executeNext(e))}}},o.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},o.current=function(e){return this.queues[e][0]},d}(),Xr=fi(),vn=/([ha]vc.)(?:\.[^.,]+)+/,Un=function(){function d(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 i=t.hls,n=t.media,a=t.mediaSource;L.logger.log("[buffer-controller]: Media source opened"),n&&(t.updateMediaElementDuration(),i.trigger(g.Events.MEDIA_ATTACHED,{media:n})),a&&a.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){L.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){L.logger.log("[buffer-controller]: Media source ended")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var o=d.prototype;return o.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},o.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},o.registerListeners=function(){var e=this.hls;e.on(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.Events.BUFFER_RESET,this.onBufferReset,this),e.on(g.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(g.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(g.Events.BUFFER_EOS,this.onBufferEos,this),e.on(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(g.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(g.Events.FRAG_PARSED,this.onFragParsed,this),e.on(g.Events.FRAG_CHANGED,this.onFragChanged,this)},o.unregisterListeners=function(){var e=this.hls;e.off(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.Events.BUFFER_RESET,this.onBufferReset,this),e.off(g.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(g.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(g.Events.BUFFER_EOS,this.onBufferEos,this),e.off(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(g.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(g.Events.FRAG_PARSED,this.onFragParsed,this),e.off(g.Events.FRAG_CHANGED,this.onFragChanged,this)},o._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new gr(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},o.onManifestParsed=function(e,t){var i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.details=null,L.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},o.onMediaAttaching=function(e,t){var i=this.media=t.media;if(i&&Xr){var n=this.mediaSource=new Xr;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(n),this._objectUrl=i.src}},o.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,i=this._objectUrl;if(t){if(L.logger.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(n){L.logger.warn("[buffer-controller]: onMediaDetaching: "+n.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(i&&self.URL.revokeObjectURL(i),e.src===i?(e.removeAttribute("src"),e.load()):L.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(g.Events.MEDIA_DETACHED,void 0)},o.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){var i=e.sourceBuffer[t];try{i&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(i),e.sourceBuffer[t]=void 0)}catch(n){L.logger.warn("[buffer-controller]: Failed to reset the "+t+" buffer",n)}}),this._initSourceBuffer()},o.onBufferCodecs=function(e,t){var i=this,n=this.getSourceBufferTypes().length;Object.keys(t).forEach(function(a){if(n){var r=i.tracks[a];if(r&&typeof r.buffer.changeType=="function"){var s=t[a],l=s.id,u=s.codec,c=s.levelCodec,v=s.container,m=s.metadata,_=(r.levelCodec||r.codec).replace(vn,"$1"),S=(c||u).replace(vn,"$1");if(_!==S){var F=v+";codecs="+(c||u);i.appendChangeType(a,F),L.logger.log("[buffer-controller]: switching codec "+_+" to "+S),i.tracks[a]={buffer:r.buffer,codec:u,container:v,levelCodec:c,metadata:m,id:l}}}}else i.pendingTracks[a]=t[a]}),n||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},o.appendChangeType=function(e,t){var i=this,n=this.operationQueue,a={execute:function(){var r=i.sourceBuffer[e];r&&(L.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),r.changeType(t)),n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(r){L.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",r)}};n.append(a,e)},o.onBufferAppending=function(e,t){var i=this,n=this.hls,a=this.operationQueue,r=this.tracks,s=t.data,l=t.type,u=t.frag,c=t.part,v=t.chunkMeta,m=v.buffering[l],_=self.performance.now();m.start=_;var S=u.stats.buffering,F=c?c.stats.buffering:null;S.start===0&&(S.start=_),F&&F.start===0&&(F.start=_);var P=r.audio,X=!1;l==="audio"&&(P==null?void 0:P.container)==="audio/mpeg"&&(X=!this.lastMpegAudioChunk||v.id===1||this.lastMpegAudioChunk.sn!==v.sn,this.lastMpegAudioChunk=v);var ue=u.start,_e={execute:function(){if(m.executeStart=self.performance.now(),X){var ge=i.sourceBuffer[l];if(ge){var De=ue-ge.timestampOffset;Math.abs(De)>=.1&&(L.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+ue+" (delta: "+De+") sn: "+u.sn+")"),ge.timestampOffset=ue)}}i.appendExecutor(s,l)},onStart:function(){},onComplete:function(){var ge=self.performance.now();m.executeEnd=m.end=ge,S.first===0&&(S.first=ge),F&&F.first===0&&(F.first=ge);var De=i.sourceBuffer,He={};for(var Je in De)He[Je]=Gt.getBuffered(De[Je]);i.appendError=0,i.hls.trigger(g.Events.BUFFER_APPENDED,{type:l,frag:u,part:c,chunkMeta:v,parent:u.type,timeRanges:He})},onError:function(ge){L.logger.error("[buffer-controller]: Error encountered while trying to append to the "+l+" SourceBuffer",ge);var De={type:k.ErrorTypes.MEDIA_ERROR,parent:u.type,details:k.ErrorDetails.BUFFER_APPEND_ERROR,err:ge,fatal:!1};ge.code===DOMException.QUOTA_EXCEEDED_ERR?De.details=k.ErrorDetails.BUFFER_FULL_ERROR:(i.appendError++,De.details=k.ErrorDetails.BUFFER_APPEND_ERROR,i.appendError>n.config.appendErrorMaxRetry&&(L.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),De.fatal=!0,n.stopLoad())),n.trigger(g.Events.ERROR,De)}};a.append(_e,l)},o.onBufferFlushing=function(e,t){var i=this,n=this.operationQueue,a=function(r){return{execute:i.removeExecutor.bind(i,r,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){i.hls.trigger(g.Events.BUFFER_FLUSHED,{type:r})},onError:function(s){L.logger.warn("[buffer-controller]: Failed to remove from "+r+" SourceBuffer",s)}}};t.type?n.append(a(t.type),t.type):this.getSourceBufferTypes().forEach(function(r){n.append(a(r),r)})},o.onFragParsed=function(e,t){var i=this,n=t.frag,a=t.part,r=[],s=a?a.elementaryStreams:n.elementaryStreams;s[J.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(s[J.ElementaryStreamTypes.AUDIO]&&r.push("audio"),s[J.ElementaryStreamTypes.VIDEO]&&r.push("video")),r.length===0&&L.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers(function(){var l=self.performance.now();n.stats.buffering.end=l,a&&(a.stats.buffering.end=l);var u=a?a.stats:n.stats;i.hls.trigger(g.Events.FRAG_BUFFERED,{frag:n,part:a,stats:u,id:n.type})},r)},o.onFragChanged=function(e,t){this.flushBackBuffer()},o.onBufferEos=function(e,t){var i=this;this.getSourceBufferTypes().reduce(function(n,a){var r=i.sourceBuffer[a];return!r||t.type&&t.type!==a||(r.ending=!0,r.ended||(r.ended=!0,L.logger.log("[buffer-controller]: "+a+" sourceBuffer now EOS"))),n&&!(r&&!r.ended)},!0)&&(L.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){i.getSourceBufferTypes().forEach(function(a){var r=i.sourceBuffer[a];r&&(r.ending=!1)});var n=i.mediaSource;n&&n.readyState==="open"?(L.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),n.endOfStream()):n&&L.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+n.readyState)}))},o.onLevelUpdated=function(e,t){var i=t.details;i.fragments.length&&(this.details=i,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},o.flushBackBuffer=function(){var e=this.hls,t=this.details,i=this.media,n=this.sourceBuffer;if(i&&t!==null){var a=this.getSourceBufferTypes();if(a.length){var r=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if((0,R.isFiniteNumber)(r)&&!(r<0)){var s=i.currentTime,l=t.levelTargetDuration,u=Math.max(r,l),c=Math.floor(s/l)*l-u;a.forEach(function(v){var m=n[v];if(m){var _=Gt.getBuffered(m);if(_.length>0&&c>_.start(0)){if(e.trigger(g.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(g.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(m.ended&&_.end(_.length-1)-s<2*l)return void L.logger.info("[buffer-controller]: Cannot flush "+v+" back buffer while SourceBuffer is in ended state");e.trigger(g.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:v})}}})}}}},o.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var e=this.details,t=this.hls,i=this.media,n=this.mediaSource,a=e.fragments[0].start+e.totalduration,r=i.duration,s=(0,R.isFiniteNumber)(n.duration)?n.duration:0;e.live&&t.config.liveDurationInfinity?(L.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(a>s&&a>r||!(0,R.isFiniteNumber)(r))&&(L.logger.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),n.duration=a)}},o.updateSeekableRange=function(e){var t=this.mediaSource,i=e.fragments;if(i.length&&e.live&&t!=null&&t.setLiveSeekableRange){var n=Math.max(0,i[0].start),a=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,a)}},o.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,i=this.pendingTracks,n=Object.keys(i).length;if(n&&!e||n===2){this.createSourceBuffers(i),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length===0)return void this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});a.forEach(function(r){t.executeNext(r)})}},o.createSourceBuffers=function(e){var t=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var n=0;for(var a in e)if(!t[a]){var r=e[a];if(!r)throw Error("source buffer exists for track "+a+", however track does not");var s=r.levelCodec||r.codec,l=r.container+";codecs="+s;L.logger.log("[buffer-controller]: creating sourceBuffer("+l+")");try{var u=t[a]=i.addSourceBuffer(l),c=a;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[a]={buffer:u,codec:s,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id},n++}catch(v){L.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+v.message),this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:v,mimeType:l})}}n&&this.hls.trigger(g.Events.BUFFER_CREATED,{tracks:this.tracks})},o._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},o._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},o._onSBUpdateError=function(e,t){L.logger.error("[buffer-controller]: "+e+" SourceBuffer error",t),this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var i=this.operationQueue.current(e);i&&i.onError(t)},o.removeExecutor=function(e,t,i){var n=this.media,a=this.mediaSource,r=this.operationQueue,s=this.sourceBuffer[e];if(!n||!a||!s)return L.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(e);var l=(0,R.isFiniteNumber)(n.duration)?n.duration:1/0,u=(0,R.isFiniteNumber)(a.duration)?a.duration:1/0,c=Math.max(0,t),v=Math.min(i,l,u);v>c&&!s.ending?(s.ended=!1,L.logger.log("[buffer-controller]: Removing ["+c+","+v+"] from the "+e+" SourceBuffer"),s.remove(c,v)):r.shiftAndExecuteNext(e)},o.appendExecutor=function(e,t){var i=this.operationQueue,n=this.sourceBuffer[t];if(!n)return L.logger.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void i.shiftAndExecuteNext(t);n.ended=!1,n.appendBuffer(e)},o.blockBuffers=function(e,t){var i=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length)return L.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var n=this.operationQueue,a=t.map(function(r){return n.appendBlocker(r)});Promise.all(a).then(function(){e(),t.forEach(function(r){var s=i.sourceBuffer[r];s&&s.updating||n.shiftAndExecuteNext(r)})})},o.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},o.addBufferListener=function(e,t,i){var n=this.sourceBuffer[e];if(n){var a=i.bind(this,e);this.listeners[e].push({event:t,listener:a}),n.addEventListener(t,a)}},o.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(i){t.removeEventListener(i.event,i.listener)})},d}(),p={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},h=function(d){var o=d;return p.hasOwnProperty(d)&&(o=p[d]),String.fromCharCode(o)},f=15,y=100,b={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},M={17:2,18:4,21:6,22:8,23:10,19:13,20:15},I={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Y={25:2,26:4,29:6,30:8,31:10,27:13,28:15},he=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];(function(d){d[d.ERROR=0]="ERROR",d[d.TEXT=1]="TEXT",d[d.WARNING=2]="WARNING",d[d.INFO=2]="INFO",d[d.DEBUG=3]="DEBUG",d[d.DATA=3]="DATA"})(Tt||(Tt={}));var ee=function(){function d(){this.time=null,this.verboseLevel=Tt.ERROR}return d.prototype.log=function(o,e){if(this.verboseLevel>=o){var t=typeof e=="function"?e():e;L.logger.log(this.time+" ["+o+"] "+t)}},d}(),Me=function(d){for(var o=[],e=0;e<d.length;e++)o.push(d[e].toString(16));return o},ut=function(){function d(e,t,i,n,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=i||!1,this.background=n||"black",this.flash=a||!1}var o=d.prototype;return o.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},o.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],i=0;i<t.length;i++){var n=t[i];e.hasOwnProperty(n)&&(this[n]=e[n])}},o.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},o.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},o.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},o.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},d}(),Ze=function(){function d(e,t,i,n,a,r){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new ut(t,i,n,a,r)}var o=d.prototype;return o.reset=function(){this.uchar=" ",this.penState.reset()},o.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},o.setPenState=function(e){this.penState.copy(e)},o.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},o.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},o.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},d}(),st=function(){function d(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<y;t++)this.chars.push(new Ze);this.logger=e,this.pos=0,this.currPenState=new ut}var o=d.prototype;return o.equals=function(e){for(var t=!0,i=0;i<y;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t},o.copy=function(e){for(var t=0;t<y;t++)this.chars[t].copy(e.chars[t])},o.isEmpty=function(){for(var e=!0,t=0;t<y;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},o.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(Tt.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>y&&(this.logger.log(Tt.DEBUG,"Too large cursor position "+this.pos),this.pos=y)},o.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)},o.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},o.insertChar=function(e){var t=this;e>=144&&this.backSpace();var i=h(e);this.pos>=y?this.logger.log(Tt.ERROR,function(){return"Cannot insert "+e.toString(16)+" ("+i+") at position "+t.pos+". Skipping it!"}):(this.chars[this.pos].setChar(i,this.currPenState),this.moveCursor(1))},o.clearFromPos=function(e){var t;for(t=e;t<y;t++)this.chars[t].reset()},o.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},o.clearToEndOfRow=function(){this.clearFromPos(this.pos)},o.getTextString=function(){for(var e=[],t=!0,i=0;i<y;i++){var n=this.chars[i].uchar;n!==" "&&(t=!1),e.push(n)}return t?"":e.join("")},o.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},d}(),Qe=function(){function d(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<f;t++)this.rows.push(new st(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var o=d.prototype;return o.reset=function(){for(var e=0;e<f;e++)this.rows[e].clear();this.currRow=14},o.equals=function(e){for(var t=!0,i=0;i<f;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t},o.copy=function(e){for(var t=0;t<f;t++)this.rows[t].copy(e.rows[t])},o.isEmpty=function(){for(var e=!0,t=0;t<f;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},o.backSpace=function(){this.rows[this.currRow].backSpace()},o.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},o.insertChar=function(e){this.rows[this.currRow].insertChar(e)},o.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},o.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},o.setCursor=function(e){this.logger.log(Tt.INFO,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},o.setPAC=function(e){this.logger.log(Tt.INFO,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 i=0;i<f;i++)this.rows[i].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var r=a.rows[n].cueStartTime,s=this.logger.time;if(r&&s!==null&&r<s)for(var l=0;l<this.nrRollUpRows;l++)this.rows[t-this.nrRollUpRows+l+1].copy(a.rows[n+l])}}this.currRow=t;var u=this.rows[this.currRow];if(e.indent!==null){var c=e.indent,v=Math.max(c-1,0);u.setCursor(e.indent),e.color=u.chars[v].penState.foreground}var m={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(m)},o.setBkgData=function(e){this.logger.log(Tt.INFO,function(){return"bkgData = "+JSON.stringify(e)}),this.backSpace(),this.setPen(e),this.insertChar(32)},o.setRollUpRows=function(e){this.nrRollUpRows=e},o.rollUp=function(){var e=this;if(this.nrRollUpRows!==null){this.logger.log(Tt.TEXT,function(){return e.getDisplayText()});var t=this.currRow+1-this.nrRollUpRows,i=this.rows.splice(t,1)[0];i.clear(),this.rows.splice(this.currRow,0,i),this.logger.log(Tt.INFO,"Rolling up")}else this.logger.log(Tt.DEBUG,"roll_up but nrRollUpRows not set yet")},o.getDisplayText=function(e){e=e||!1;for(var t=[],i="",n=-1,a=0;a<f;a++){var r=this.rows[a].getTextString();r&&(n=a+1,e?t.push("Row "+n+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join(`
|
|
20
|
-
`)),i},o.getTextAndFormat=function(){return this.rows},d}(),ot=function(){function d(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 Qe(i),this.nonDisplayedMemory=new Qe(i),this.lastOutputScreen=new Qe(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}var o=d.prototype;return o.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},o.getHandler=function(){return this.outputFilter},o.setHandler=function(e){this.outputFilter=e},o.setPAC=function(e){this.writeScreen.setPAC(e)},o.setBkgData=function(e){this.writeScreen.setBkgData(e)},o.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(Tt.INFO,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)},o.insertChars=function(e){for(var t=this,i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);var n=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(Tt.INFO,function(){return n+": "+t.writeScreen.getDisplayText(!0)}),this.mode!=="MODE_PAINT-ON"&&this.mode!=="MODE_ROLL-UP"||(this.logger.log(Tt.TEXT,function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},o.ccRCL=function(){this.logger.log(Tt.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},o.ccBS=function(){this.logger.log(Tt.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},o.ccAOF=function(){},o.ccAON=function(){},o.ccDER=function(){this.logger.log(Tt.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},o.ccRU=function(e){this.logger.log(Tt.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},o.ccFON=function(){this.logger.log(Tt.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},o.ccRDC=function(){this.logger.log(Tt.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},o.ccTR=function(){this.logger.log(Tt.INFO,"TR"),this.setMode("MODE_TEXT")},o.ccRTD=function(){this.logger.log(Tt.INFO,"RTD"),this.setMode("MODE_TEXT")},o.ccEDM=function(){this.logger.log(Tt.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},o.ccCR=function(){this.logger.log(Tt.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},o.ccENM=function(){this.logger.log(Tt.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},o.ccEOC=function(){var e=this;if(this.logger.log(Tt.INFO,"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(Tt.TEXT,function(){return"DISP: "+e.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},o.ccTO=function(e){this.logger.log(Tt.INFO,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},o.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var i=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][i]}this.logger.log(Tt.INFO,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},o.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))},o.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},d}(),Ot=function(){function d(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var n=new ee;this.channels=[null,new ot(e,t,n),new ot(e+1,i,n)],this.cmdHistory={a:null,b:null},this.logger=n}var o=d.prototype;return o.getHandler=function(e){return this.channels[e].getHandler()},o.setHandler=function(e,t){this.channels[e].setHandler(t)},o.addData=function(e,t){var i,n,a,r=!1;this.logger.time=e;for(var s=0;s<t.length;s+=2)if(n=127&t[s],a=127&t[s+1],n!==0||a!==0){if(this.logger.log(Tt.DATA,"["+Me([t[s],t[s+1]])+"] -> ("+Me([n,a])+")"),(i=this.parseCmd(n,a))||(i=this.parseMidrow(n,a)),i||(i=this.parsePAC(n,a)),i||(i=this.parseBackgroundAttributes(n,a)),!i&&(r=this.parseChars(n,a))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(r):this.logger.log(Tt.WARNING,"No channel found yet. TEXT-MODE?")}i||r||this.logger.log(Tt.WARNING,"Couldn't parse cleaned data "+Me([n,a])+" orig: "+Me([t[s],t[s+1]]))}},o.parseCmd=function(e,t){var i=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(rr(e,t,i))return qt(null,null,i),this.logger.log(Tt.DEBUG,"Repeated command ("+Me([e,t])+") is dropped"),!0;var n=e===20||e===21||e===23?1:2,a=this.channels[n];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),qt(e,t,i),this.currentChannel=n,!0},o.parseMidrow=function(e,t){var i=0;if((e===17||e===25)&&t>=32&&t<=47){if((i=e===17?1:2)!==this.currentChannel)return this.logger.log(Tt.ERROR,"Mismatch channel in midrow parsing"),!1;var n=this.channels[i];return!!n&&(n.ccMIDROW(t),this.logger.log(Tt.DEBUG,"MIDROW ("+Me([e,t])+")"),!0)}return!1},o.parsePAC=function(e,t){var i,n=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(rr(e,t,n))return qt(null,null,n),!0;var a=e<=23?1:2;i=t>=64&&t<=95?a===1?b[e]:I[e]:a===1?M[e]:Y[e];var r=this.channels[a];return!!r&&(r.setPAC(this.interpretPAC(i,t)),qt(e,t,n),this.currentChannel=a,!0)},o.interpretPAC=function(e,t){var i,n={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,n.underline=(1&i)==1,i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((i-16)/2),n},o.parseChars=function(e,t){var i,n,a=null,r=null;if(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19?(n=r===17?t+80:r===18?t+112:t+144,this.logger.log(Tt.INFO,"Special char '"+h(n)+"' in channel "+i),a=[n]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var s=Me(a);this.logger.log(Tt.DEBUG,"Char codes = "+s.join(",")),qt(e,t,this.cmdHistory)}return a},o.parseBackgroundAttributes=function(e,t){var i;if(!((e===16||e===24)&&t>=32&&t<=47||(e===23||e===31)&&t>=45&&t<=47))return!1;var n={};e===16||e===24?(i=Math.floor((t-32)/2),n.background=he[i],t%2==1&&(n.background=n.background+"_semi")):t===45?n.background="transparent":(n.foreground="black",t===47&&(n.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(n),qt(e,t,this.cmdHistory),!0},o.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}},o.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var i=this.channels[t];i&&i.cueSplitAtTime(e)}},d}();function qt(d,o,e){e.a=d,e.b=o}function rr(d,o,e){return e.a===d&&e.b===o}let ur=Ot;var bt=function(){function d(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 o=d.prototype;return o.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},o.newCue=function(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)},o.reset=function(){this.cueRanges=[],this.startTime=null},d}();let Zt=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var d=["","lr","rl"],o=["start","middle","end","left","right"];function e(a,r){if(typeof r!="string"||!Array.isArray(a))return!1;var s=r.toLowerCase();return!!~a.indexOf(s)&&s}function t(a){return e(o,a)}function i(a){for(var r=arguments.length,s=new Array(r>1?r-1:0),l=1;l<r;l++)s[l-1]=arguments[l];for(var u=1;u<arguments.length;u++){var c=arguments[u];for(var v in c)a[v]=c[v]}return a}function n(a,r,s){var l=this,u={enumerable:!0};l.hasBeenReset=!1;var c="",v=!1,m=a,_=r,S=s,F=null,P="",X=!0,ue="auto",_e="start",ge=50,De="middle",He=50,Je="middle";Object.defineProperty(l,"id",i({},u,{get:function(){return c},set:function(Ae){c=""+Ae}})),Object.defineProperty(l,"pauseOnExit",i({},u,{get:function(){return v},set:function(Ae){v=!!Ae}})),Object.defineProperty(l,"startTime",i({},u,{get:function(){return m},set:function(Ae){if(typeof Ae!="number")throw new TypeError("Start time must be set to a number.");m=Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"endTime",i({},u,{get:function(){return _},set:function(Ae){if(typeof Ae!="number")throw new TypeError("End time must be set to a number.");_=Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"text",i({},u,{get:function(){return S},set:function(Ae){S=""+Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"region",i({},u,{get:function(){return F},set:function(Ae){F=Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"vertical",i({},u,{get:function(){return P},set:function(Ae){var Ke=function(je){return e(d,je)}(Ae);if(Ke===!1)throw new SyntaxError("An invalid or illegal string was specified.");P=Ke,this.hasBeenReset=!0}})),Object.defineProperty(l,"snapToLines",i({},u,{get:function(){return X},set:function(Ae){X=!!Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"line",i({},u,{get:function(){return ue},set:function(Ae){if(typeof Ae!="number"&&Ae!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");ue=Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"lineAlign",i({},u,{get:function(){return _e},set:function(Ae){var Ke=t(Ae);if(!Ke)throw new SyntaxError("An invalid or illegal string was specified.");_e=Ke,this.hasBeenReset=!0}})),Object.defineProperty(l,"position",i({},u,{get:function(){return ge},set:function(Ae){if(Ae<0||Ae>100)throw new Error("Position must be between 0 and 100.");ge=Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"positionAlign",i({},u,{get:function(){return De},set:function(Ae){var Ke=t(Ae);if(!Ke)throw new SyntaxError("An invalid or illegal string was specified.");De=Ke,this.hasBeenReset=!0}})),Object.defineProperty(l,"size",i({},u,{get:function(){return He},set:function(Ae){if(Ae<0||Ae>100)throw new Error("Size must be between 0 and 100.");He=Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"align",i({},u,{get:function(){return Je},set:function(Ae){var Ke=t(Ae);if(!Ke)throw new SyntaxError("An invalid or illegal string was specified.");Je=Ke,this.hasBeenReset=!0}})),l.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}();var sr=function(){function d(){}return d.prototype.decode=function(o,e){if(!o)return"";if(typeof o!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(o))},d}();function Lt(d){function o(t,i,n,a){return 3600*(0|t)+60*(0|i)+(0|n)+parseFloat(a||0)}var e=d.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?o(e[2],e[3],0,e[4]):o(e[1],e[2],e[3],e[4]):null}var nt=function(){function d(){this.values=Object.create(null)}var o=d.prototype;return o.set=function(e,t){this.get(e)||t===""||(this.values[e]=t)},o.get=function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t},o.has=function(e){return e in this.values},o.alt=function(e,t,i){for(var n=0;n<i.length;++n)if(t===i[n]){this.set(e,t);break}},o.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},o.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1},d}();function vt(d,o,e,t){var i=t?d.split(t):[d];for(var n in i)if(typeof i[n]=="string"){var a=i[n].split(e);a.length===2&&o(a[0],a[1])}}var et=new Zt(0,0,""),ft=et.align==="middle"?"middle":"center";function Vt(d,o,e){var t=d;function i(){var a=Lt(d);if(a===null)throw new Error("Malformed timestamp: "+t);return d=d.replace(/^[^\sa-zA-Z-]+/,""),a}function n(){d=d.replace(/^\s+/,"")}if(n(),o.startTime=i(),n(),d.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+t);d=d.slice(3),n(),o.endTime=i(),n(),function(a,r){var s=new nt;vt(a,function(c,v){var m;switch(c){case"region":for(var _=e.length-1;_>=0;_--)if(e[_].id===v){s.set(c,e[_].region);break}break;case"vertical":s.alt(c,v,["rl","lr"]);break;case"line":m=v.split(","),s.integer(c,m[0]),s.percent(c,m[0])&&s.set("snapToLines",!1),s.alt(c,m[0],["auto"]),m.length===2&&s.alt("lineAlign",m[1],["start",ft,"end"]);break;case"position":m=v.split(","),s.percent(c,m[0]),m.length===2&&s.alt("positionAlign",m[1],["start",ft,"end","line-left","line-right","auto"]);break;case"size":s.percent(c,v);break;case"align":s.alt(c,v,["start",ft,"end","left","right"])}},/:/,/\s/),r.region=s.get("region",null),r.vertical=s.get("vertical","");var l=s.get("line","auto");l==="auto"&&et.line===-1&&(l=-1),r.line=l,r.lineAlign=s.get("lineAlign","start"),r.snapToLines=s.get("snapToLines",!0),r.size=s.get("size",100),r.align=s.get("align",ft);var u=s.get("position","auto");u==="auto"&&et.position===50&&(u=r.align==="start"||r.align==="left"?0:r.align==="end"||r.align==="right"?100:50),r.position=u}(d,o)}function Xt(d){return d.replace(/<br(?: \/)?>/gi,`
|
|
21
|
-
|
|
22
|
-
`;)++u;var c=l.slice(0,u);return l[u]==="\r"&&++u,l[u]===`
|
|
23
|
-
`&&++u,t.buffer=l.slice(u),c}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;var a=(n=i()).match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var r=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(r?r=!1:n=i(),t.state){case"HEADER":/:/.test(n)?vt(n,function(l,u){},/:/):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new Zt(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Vt(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=n.indexOf("-->")!==-1;if(!n||s&&(r=!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+=`
|
|
24
|
-
`)
|
|
18
|
+
`))this.processLine(this.buffer.substring(0,h)),this.buffer=this.buffer.substring(h+1)},Gr.prototype.processLine=function(m){var h=m.indexOf(":"),g=xn(m,h),_=g[0],k=g.length===2?li(g[1]):void 0;if(_[0]!=="#")this.currentUri.uri=_,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(_){case Dn:if(!isFinite(k)||k<0)return;this.manifest.targetDuration=k,this.setHoldBack();break;case Br:oi(this.manifest,g),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Mi:oi(this.manifest,g),this.setHoldBack();break;case In:k===0?this.currentUri.duration=.01:k>0&&(this.currentUri.duration=k);break;case la:var D=k,w=new Date(D);this.manifest.dateTimeString||(this.manifest.dateTimeString=D,this.manifest.dateTimeObject=w),this.currentUri.dateTimeString=D,this.currentUri.dateTimeObject=w;break;case Cn:oi(this.manifest,g);break;case Fi:var x=Kr(g[1]),G=ut(x);Object.assign(this.manifest.sessionData,G)}},Gr.prototype.setHoldBack=function(){var m=this.manifest,h=m.serverControl,g=m.targetDuration,_=m.partTargetDuration;if(h){var k="holdBack",D="partHoldBack",w=g&&3*g,x=_&&2*_;g&&!h.hasOwnProperty(k)&&(h[k]=w),w&&h[k]<w&&(h[k]=w),_&&!h.hasOwnProperty(D)&&(h[D]=3*_),_&&h[D]<x&&(h[D]=x)}};var oi=function(m,h){var g,_=Hr(h[0].replace("#EXT-X-",""));ui(h[1])?(g={},g=Object.assign(Pn(h[1]),g)):g=li(h[1]),m[_]=g},Hr=function(m){return m.toLowerCase().replace(/-(\w)/g,function(h){return h[1].toUpperCase()})},li=function(m){if(m.toLowerCase()==="yes"||m.toLowerCase()==="no")return m.toLowerCase()==="yes";var h=m.indexOf(":")!==-1?m:parseFloat(m);return isNaN(h)?m:h},Ni=function(m){var h={},g=m.split("=");return g.length>1&&(h[Hr(g[0])]=li(g[1])),h},Pn=function(m){for(var h=m.split(","),g={},_=0;h.length>_;_++){var k=h[_],D=Ni(k);g=Object.assign(D,g)}return g},ui=function(m){return m.indexOf("=")>-1},xn=function(m,h){return h===-1?[m]:[m.substring(0,h),m.substring(h+1)]},Kr=function(m){var h={};if(m){var g=m.search(",");return[m.slice(0,g),m.slice(g+1)].forEach(function(_,k){for(var D=_.replace(/['"]+/g,"").split("="),w=0;w<D.length;w++)D[w]==="DATA-ID"&&(h["DATA-ID"]=D[1-w]),D[w]==="VALUE"&&(h.VALUE=D[1-w])}),{data:h}}},Ui=Gr,ua={safeCall:function(m,h,g,_){var k=_;if(m&&typeof m[h]=="function")try{k=m[h].apply(m,g)}catch(D){Le.info("safeCall error",D)}return k},safeIncrement:N,getComputedStyle:function(m,h){var g;if(m&&h&&W()&&typeof W().getComputedStyle=="function")return lr&&lr.has(m)&&(g=lr.get(m)),g||(g=W().getComputedStyle(m,null),lr&&lr.set(m,g)),g.getPropertyValue(h)},secondsToMs:function(m){return Math.floor(1e3*m)},assign:Object.assign,headersStringToObject:_e,cdnHeadersToRequestId:je,extractHostnameAndDomain:T,extractHostname:ie,manifestParser:Ui,generateShortID:ve,generateUUID:de,now:Ne.now},Bi={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 da(m,h){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var k=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(k!=null){var D,w,x=[],G=!0,M=!1;try{for(k=k.call(g);!(G=(D=k.next()).done)&&(x.push(D.value),!_||x.length!==_);G=!0);}catch(Y){M=!0,w=Y}finally{try{G||k.return==null||k.return()}finally{if(M)throw w}}return x}}(m,h)||function(g,_){if(g){if(typeof g=="string")return di(g,_);var k=Object.prototype.toString.call(g).slice(8,-1);return k==="Object"&&g.constructor&&(k=g.constructor.name),k==="Map"||k==="Set"?Array.from(g):k==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(k)?di(g,_):void 0}}(m,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
19
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function di(m,h){(h==null||h>m.length)&&(h=m.length);for(var g=0,_=new Array(h);g<h;g++)_[g]=m[g];return _}var ct={},ur=function m(h){var g=arguments;typeof h=="string"?m.hasOwnProperty(h)?W().setTimeout(function(){g=Array.prototype.splice.call(g,1),m[h].apply(null,g)},0):Le.warn("`"+h+"` is an unknown task"):typeof h=="function"?W().setTimeout(function(){h(m)},0):Le.warn("`"+h+"` is invalid.")},wr={loaded:Ne.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(m,h){return function(g,_,k){var D=wn(Ee(_),3),w=D[0],x=D[1],G=D[2],M=g.log,Y=g.utils.getComputedStyle,Se=g.utils.secondsToMs;if(!w)return M.error("No element was found with the `"+x+"` query selector.");if(G!=="video"&&G!=="audio")return M.error("The element of `"+x+"` was not a media element.");w.mux&&(w.mux.destroy(),delete w.mux,M.warn("Already monitoring this video element, replacing existing event listeners")),(k=Object.assign({automaticErrorTracking:!0},k)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:g.VERSION},k.data),k.getPlayheadTime=function(){return Se(w.currentTime)},k.getStateData=function(){var me,oe,pe=this.hlsjs&&this.hlsjs.url,Be=this.dashjs&&Oi(this.dashjs.getSource==="function")&&this.dashjs.getSource(),Ze={player_is_paused:w.paused,player_playhead_time:Se(w.currentTime),player_width:parseInt(Y(w,"width")),player_height:parseInt(Y(w,"height")),player_autoplay_on:w.autoplay,player_preload_on:w.preload,player_language_code:w.lang,player_is_fullscreen:yr()&&!!(yr().fullscreenElement||yr().webkitFullscreenElement||yr().mozFullScreenElement||yr().msFullscreenElement),video_poster_url:w.poster,video_source_url:pe||Be||w.currentSrc,video_source_duration:Se(w.duration),video_source_height:w.videoHeight,video_source_width:w.videoWidth,view_dropped_frame_count:(me=w)===null||me===void 0||(oe=me.getVideoPlaybackQuality)===null||oe===void 0?void 0:oe.call(me).droppedVideoFrames},gt=k.getPlayheadTime();if(w.getStartDate&>>0){var Lt=w.getStartDate();if(Lt&&typeof Lt.getTime=="function"&&Lt.getTime()){var Ct=Lt.getTime();if(Ze.player_program_time=Ct+gt,w.seekable.length>0){var ce=Ct+w.seekable.end(w.seekable.length-1);Ze.player_live_edge_program_time=ce}}}return Ze},w.mux=w.mux||{},w.mux.deleted=!1,w.mux.emit=function(me,oe){g.emit(x,me,oe)};var ae=function(){M.error("The monitor for this video element has already been destroyed.")};w.mux.destroy=function(){Object.keys(w.mux.listeners).forEach(function(me){w.removeEventListener(me,w.mux.listeners[me],!1)}),delete w.mux.listeners,w.mux.destroy=ae,w.mux.swapElement=ae,w.mux.emit=ae,w.mux.addHLSJS=ae,w.mux.addDashJS=ae,w.mux.removeHLSJS=ae,w.mux.removeDashJS=ae,w.mux.deleted=!0,g.emit(x,"destroy")},w.mux.swapElement=function(me){var oe=wn(Ee(me),3),pe=oe[0],Be=oe[1],Ze=oe[2];return pe?Ze!=="video"&&Ze!=="audio"?g.log.error("The element of `"+Be+"` was not a media element."):(pe.muxId=w.muxId,delete w.muxId,pe.mux=pe.mux||{},pe.mux.listeners=Object.assign({},w.mux.listeners),delete w.mux.listeners,Object.keys(pe.mux.listeners).forEach(function(gt){w.removeEventListener(gt,pe.mux.listeners[gt],!1),pe.addEventListener(gt,pe.mux.listeners[gt],!1)}),pe.mux.swapElement=w.mux.swapElement,pe.mux.destroy=w.mux.destroy,delete w.mux,void(w=pe)):g.log.error("No element was found with the `"+Be+"` query selector.")},w.mux.addHLSJS=function(me){g.addHLSJS(x,me)},w.mux.addDashJS=function(me){g.addDashJS(x,me)},w.mux.removeHLSJS=function(){g.removeHLSJS(x)},w.mux.removeDashJS=function(){g.removeDashJS(x)},g.init(x,k),g.emit(x,"playerready"),w.paused||(g.emit(x,"play"),w.readyState>2&&g.emit(x,"playing")),w.mux.listeners={},sa.forEach(function(me){(me!=="error"||k.automaticErrorTracking)&&(w.mux.listeners[me]=function(){var oe={};if(me==="error"){if(!w.error||w.error.code===1)return;oe.player_error_code=w.error.code,oe.player_error_message=oa[w.error.code]||w.error.message}g.emit(x,me,oe)},w.addEventListener(me,w.mux.listeners[me],!1))})}(ur,m,h)},destroyMonitor:function(m){var h=da(Ee(m),1)[0];h&&h.mux&&typeof h.mux.destroy=="function"?h.mux.destroy():Le.error("A video element monitor for `"+m+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(m,h){var g=ge(m);ct[g]?ct[g].addHLSJS(h):Le.error("A monitor for `"+g+"` has not been initialized.")},addDashJS:function(m,h){var g=ge(m);ct[g]?ct[g].addDashJS(h):Le.error("A monitor for `"+g+"` has not been initialized.")},removeHLSJS:function(m){var h=ge(m);ct[h]?ct[h].removeHLSJS():Le.error("A monitor for `"+h+"` has not been initialized.")},removeDashJS:function(m){var h=ge(m);ct[h]?ct[h].removeDashJS():Le.error("A monitor for `"+h+"` has not been initialized.")},init:function(m,h){St()&&h&&h.respectDoNotTrack&&Le.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var g=ge(m);ct[g]=new xi(ur,g,h)},emit:function(m,h,g){var _=ge(m);ct[_]?(ct[_].emit(h,g),h==="destroy"&&delete ct[_]):Le.error("A monitor for `"+_+"` has not been initialized.")},checkDoNotTrack:St,log:Le,utils:ua,events:Bi,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(ur,wr),W()!==void 0&&typeof W().addEventListener=="function"&&W().addEventListener("pagehide",function(m){m.persisted||(ur.WINDOW_UNLOADING=!0)},!1);var ci=ur},655:function(H,Q,q){var ne,W;function de(ve){return de=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(ge){return typeof ge}:function(ge){return ge&&typeof Symbol=="function"&&ge.constructor===Symbol&&ge!==Symbol.prototype?"symbol":typeof ge},de(ve);}(function(ve){var ge=!1;if((W=typeof(ne=ve)=="function"?ne.call(Q,q,Q,H):ne)===void 0||(H.exports=W),ge=!0,de(Q)==="object"&&(H.exports=ve(),ge=!0),!ge){var Ee=window.Cookies,xe=window.Cookies=ve();xe.noConflict=function(){return window.Cookies=Ee,xe}}})(function(){var ve=function(){for(var ge=0,Ee={};ge<arguments.length;ge++){var xe=arguments[ge];for(var Pe in xe)Ee[Pe]=xe[Pe]}return Ee};return function ge(Ee){function xe(Pe,it,Le){var St;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(Le=ve({path:"/"},xe.defaults,Le)).expires=="number"){var Ne=new Date;Ne.setMilliseconds(Ne.getMilliseconds()+864e5*Le.expires),Le.expires=Ne}try{St=JSON.stringify(it),/^[\{\[]/.test(St)&&(it=St)}catch{}return it=Ee.write?Ee.write(it,Pe):encodeURIComponent(String(it)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),Pe=(Pe=(Pe=encodeURIComponent(String(Pe))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[Pe,"=",it,Le.expires?"; expires="+Le.expires.toUTCString():"",Le.path?"; path="+Le.path:"",Le.domain?"; domain="+Le.domain:"",Le.secure?"; secure":""].join("")}Pe||(St={});for(var ie=document.cookie?document.cookie.split("; "):[],T=/(%[0-9A-Z]{2})+/g,Z=0;Z<ie.length;Z++){var N=ie[Z].split("="),Ke=N.slice(1).join("=");Ke.charAt(0)==='"'&&(Ke=Ke.slice(1,-1));try{var ot=N[0].replace(T,decodeURIComponent);if(Ke=Ee.read?Ee.read(Ke,ot):Ee(Ke,ot)||Ke.replace(T,decodeURIComponent),this.json)try{Ke=JSON.parse(Ke)}catch{}if(Pe===ot){St=Ke;break}Pe||(St[ot]=Ke)}catch{}}return St}}return xe.set=xe,xe.get=function(Pe){return xe.call(xe,Pe)},xe.getJSON=function(){return xe.apply({json:!0},[].slice.call(arguments))},xe.defaults={},xe.remove=function(Pe,it){xe(Pe,"",ve(it,{expires:-1}))},xe.withConverter=ge,xe}(function(){})})},153:function(H,Q,q){var ne,W=q.g!==void 0?q.g:typeof window!="undefined"?window:{},de=q(558);typeof document!="undefined"?ne=document:(ne=W["__GLOBAL_DOCUMENT_CACHE@4"])||(ne=W["__GLOBAL_DOCUMENT_CACHE@4"]=de),H.exports=ne},48:function(H,Q,q){var ne;ne=typeof window!="undefined"?window:q.g!==void 0?q.g:typeof self!="undefined"?self:{},H.exports=ne},640:function(H,Q,q){var ne,W;(function(de,ve){"use strict";ne=function(){var ge=function(){},Ee="undefined",xe=typeof window!==Ee&&typeof window.navigator!==Ee&&/Trident\/|MSIE /.test(window.navigator.userAgent),Pe=["trace","debug","info","warn","error"];function it(_e,je){var ut=_e[je];if(typeof ut.bind=="function")return ut.bind(_e);try{return Function.prototype.bind.call(ut,_e)}catch{return function(){return Function.prototype.apply.apply(ut,[_e,arguments])}}}function Le(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function St(_e){return _e==="debug"&&(_e="log"),typeof console!==Ee&&(_e==="trace"&&xe?Le:console[_e]!==void 0?it(console,_e):console.log!==void 0?it(console,"log"):ge)}function Ne(_e,je){for(var ut=0;ut<Pe.length;ut++){var P=Pe[ut];this[P]=ut<_e?ge:this.methodFactory(P,_e,je)}this.log=this.debug}function ie(_e,je,ut){return function(){typeof console!==Ee&&(Ne.call(this,je,ut),this[_e].apply(this,arguments))}}function T(_e,je,ut){return St(_e)||ie.apply(this,arguments)}function Z(_e,je,ut){var P,Qe=this;je=je==null?"WARN":je;var nt="loglevel";function ze(De){var Je=(Pe[De]||"silent").toUpperCase();if(typeof window!==Ee&&nt){try{return void(window.localStorage[nt]=Je)}catch{}try{window.document.cookie=encodeURIComponent(nt)+"="+Je+";"}catch{}}}function wt(){var De;if(typeof window!==Ee&&nt){try{De=window.localStorage[nt]}catch{}if(typeof De===Ee)try{var Je=window.document.cookie,nr=Je.indexOf(encodeURIComponent(nt)+"=");nr!==-1&&(De=/^([^;]+)/.exec(Je.slice(nr))[1])}catch{}return Qe.levels[De]===void 0&&(De=void 0),De}}function Or(){if(typeof window!==Ee&&nt){try{return void window.localStorage.removeItem(nt)}catch{}try{window.document.cookie=encodeURIComponent(nt)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof _e=="string"?nt+=":"+_e:typeof _e=="symbol"&&(nt=void 0),Qe.name=_e,Qe.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Qe.methodFactory=ut||T,Qe.getLevel=function(){return P},Qe.setLevel=function(De,Je){if(typeof De=="string"&&Qe.levels[De.toUpperCase()]!==void 0&&(De=Qe.levels[De.toUpperCase()]),!(typeof De=="number"&&De>=0&&De<=Qe.levels.SILENT))throw"log.setLevel() called with invalid level: "+De;if(P=De,Je!==!1&&ze(De),Ne.call(Qe,De,_e),typeof console===Ee&&De<Qe.levels.SILENT)return"No console available for logging"},Qe.setDefaultLevel=function(De){je=De,wt()||Qe.setLevel(De,!1)},Qe.resetLevel=function(){Qe.setLevel(je,!1),Or()},Qe.enableAll=function(De){Qe.setLevel(Qe.levels.TRACE,De)},Qe.disableAll=function(De){Qe.setLevel(Qe.levels.SILENT,De)};var yt=wt();yt==null&&(yt=je),Qe.setLevel(yt,!1)}var N=new Z,Ke={};N.getLogger=function(_e){if(typeof _e!="symbol"&&typeof _e!="string"||_e==="")throw new TypeError("You must supply a name when creating a logger.");var je=Ke[_e];return je||(je=Ke[_e]=new Z(_e,N.getLevel(),N.methodFactory)),je};var ot=typeof window!==Ee?window.log:void 0;return N.noConflict=function(){return typeof window!==Ee&&window.log===N&&(window.log=ot),N},N.getLoggers=function(){return Ke},N.default=N,N},(W=typeof ne=="function"?ne.call(Q,q,Q,H):ne)===void 0||(H.exports=W)})()},375:function(H,Q){"use strict";var q=Object.prototype.hasOwnProperty;function ne(de){try{return decodeURIComponent(de.replace(/\+/g," "))}catch{return null}}function W(de){try{return encodeURIComponent(de)}catch{return null}}Q.stringify=function(de,ve){ve=ve||"";var ge,Ee,xe=[];for(Ee in typeof ve!="string"&&(ve="?"),de)if(q.call(de,Ee)){if((ge=de[Ee])||ge!=null&&!isNaN(ge)||(ge=""),Ee=W(Ee),ge=W(ge),Ee===null||ge===null)continue;xe.push(Ee+"="+ge)}return xe.length?ve+xe.join("&"):""},Q.parse=function(de){for(var ve,ge=/([^=?#&]+)=?([^&]*)/g,Ee={};ve=ge.exec(de);){var xe=ne(ve[1]),Pe=ne(ve[2]);xe===null||Pe===null||xe in Ee||(Ee[xe]=Pe)}return Ee}},558:function(){}},F={};function U(H){var Q=F[H];if(Q!==void 0)return Q.exports;var q=F[H]={exports:{}};return S[H].call(q.exports,q,q.exports,U),q.exports}return U.n=function(H){var Q=H&&H.__esModule?function(){return H.default}:function(){return H};return U.d(Q,{a:Q}),Q},U.d=function(H,Q){for(var q in Q)U.o(Q,q)&&!U.o(H,q)&&Object.defineProperty(H,q,{enumerable:!0,get:Q[q]})},U.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),U.o=function(H,Q){return Object.prototype.hasOwnProperty.call(H,Q)},U(80)}()},typeof Vn=="object"&&typeof Wa=="object"?Wa.exports=L():typeof Vn=="object"?Vn.mux=L():R.mux=L()})()});var po=co((mo,za)=>{(function R(L){var S,F;S=this,F=function(){"use strict";function U(s,n){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);n&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),e.push.apply(e,t)}return e}function H(s){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?U(Object(e),!0).forEach(function(t){ne(s,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):U(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,St(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 ne(s,n,e){return(n=St(n))in s?Object.defineProperty(s,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[n]=e,s}function W(){return W=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},W.apply(this,arguments)}function de(s,n){s.prototype=Object.create(n.prototype),s.prototype.constructor=s,ge(s,n)}function ve(s){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ve(s)}function ge(s,n){return ge=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ge(s,n)}function Ee(){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 xe(s,n,e){return xe=Ee()?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&&ge(o,i.prototype),o},xe.apply(null,arguments)}function Pe(s){var n=typeof Map=="function"?new Map:void 0;return Pe=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 xe(e,arguments,ve(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ge(r,e)},Pe(s)}function it(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 Le(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 it(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)?it(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 St(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)}var Ne={};(function(s,n){var e,t,r,i,a;e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(o,l,d){if(d=d||{},o=o.trim(),!(l=l.trim())){if(!d.alwaysNormalize)return o;var u=a.parseURL(o);if(!u)throw new Error("Error trying to parse base URL.");return u.path=a.normalizePath(u.path),a.buildURLFromParts(u)}var c=a.parseURL(l);if(!c)throw new Error("Error trying to parse relative URL.");if(c.scheme)return d.alwaysNormalize?(c.path=a.normalizePath(c.path),a.buildURLFromParts(c)):l;var f=a.parseURL(o);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var v=t.exec(f.path);f.netLoc=v[1],f.path=v[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:c.netLoc,path:null,params:c.params,query:c.query,fragment:c.fragment};if(!c.netLoc&&(p.netLoc=f.netLoc,c.path[0]!=="/"))if(c.path){var E=f.path,A=E.substring(0,E.lastIndexOf("/")+1)+c.path;p.path=a.normalizePath(A)}else p.path=f.path,c.params||(p.params=f.params,c.query||(p.query=f.query));return p.path===null&&(p.path=d.alwaysNormalize?a.normalizePath(c.path):c.path),a.buildURLFromParts(p)},parseURL:function(o){var l=e.exec(o);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(o){for(o=o.split("").reverse().join("").replace(r,"");o.length!==(o=o.replace(i,"")).length;);return o.split("").reverse().join("")},buildURLFromParts:function(o){return o.scheme+o.netLoc+o.path+o.params+o.query+o.fragment}},s.exports=a})({get exports(){return Ne},set exports(s){Ne=s}});var ie=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},T=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}({}),Z=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}({}),N=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}({}),Ke=function(){},ot={trace:Ke,debug:Ke,log:Ke,warn:Ke,info:Ke,error:Ke},_e=ot;function je(s){var n=self.console[s];return n?n.bind(self.console,"["+s+"] >"):Ke}function ut(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){_e[a]=e[a]?e[a].bind(e):je(a)})})(s,"debug","log","info","warn","error");try{_e.log('Debug logs enabled for "'+n+'" in hls.js version 1.4.0')}catch{_e=ot}}else _e=ot}var P=_e,Qe=/^(\d+)x(\d+)$/,nt=/(.+?)=(".*?"|.*?)(?:,|$)/g,ze=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=Qe.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(nt.lastIndex=0;(t=nt.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 wt(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var Or=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]){P.warn('DATERANGE tag attribute: "'+r+'" does not match for tags with ID: "'+n.ID+'"'),this._badValueForSameId=r;break}n=W(new ze({}),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}(),yt=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}},De="audio",Je="video",nr="audiovideo",Gt=function(){function s(n){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[De]=null,e[Je]=null,e[nr]=null,e),this.baseurl=n}return s.prototype.setByteRange=function(n,e){var t=n.split("@",2),r=[];t.length===1?r[0]=e?e.byteRangeEndOffset:0:r[0]=parseInt(t[1]),r[1]=parseInt(t[0])+r[0],this._byteRange=r},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=Ne.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 yt,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}de(n,s);var e=n.prototype;return e.setKeyFormat=function(t){if(this.levelkeys){var r=this.levelkeys[t];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},e.abortRequests=function(){var t,r;(t=this.loader)==null||t.abort(),(r=this.keyLoader)==null||r.abort()},e.setElementaryStreamInfo=function(t,r,i,a,o,l){l===void 0&&(l=!1);var d=this.elementaryStreams,u=d[t];u?(u.startPTS=Math.min(u.startPTS,r),u.endPTS=Math.max(u.endPTS,i),u.startDTS=Math.min(u.startDTS,a),u.endDTS=Math.max(u.endDTS,o)):d[t]={startPTS:r,endPTS:i,startDTS:a,endDTS:o,partial:l}},e.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[De]=null,t[Je]=null,t[nr]=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}(Gt),sn=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 yt,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 de(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}(Gt),on=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 z(s){return Uint8Array.from(atob(s),function(n){return n.charCodeAt(0)})}function se(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=z(l)):(n=Ye(l).subarray(0,16),(e=new Uint8Array(16)).set(n,16-n.length),r=e)}}return r}function Ye(s){return Uint8Array.from(unescape(encodeURIComponent(s)),function(n){return n.charCodeAt(0)})}var Ce={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},dt="org.w3.clearkey",At="com.apple.streamingkeydelivery",Dt="com.microsoft.playready",ht="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function ft(s){switch(s){case At:return Ce.FAIRPLAY;case Dt:return Ce.PLAYREADY;case ht:return Ce.WIDEVINE;case dt:return Ce.CLEARKEY}}var Ht="edef8ba979d64acea3c827dcd51d21ed";function _r(s){switch(s){case Ce.FAIRPLAY:return At;case Ce.PLAYREADY:return Dt;case Ce.WIDEVINE:return ht;case Ce.CLEARKEY:return dt}}function Sr(s){var n=s.drmSystems,e=s.widevineLicenseUrl,t=n?[Ce.FAIRPLAY,Ce.WIDEVINE,Ce.PLAYREADY,Ce.CLEARKEY].filter(function(r){return!!n[r]}):[];return!t[Ce.WIDEVINE]&&e&&t.push(Ce.WIDEVINE),t}var Ar=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function Kt(s,n,e){return Uint8Array.prototype.slice?s.slice(n,e):new Uint8Array(Array.prototype.slice.call(s,n,e))}var gr,kr=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},$e=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},Zt=function(s,n){for(var e=n,t=0;kr(s,n);)t+=10,t+=ar(s,n+6),$e(s,n+10)&&(t+=10),n+=t;if(t>0)return s.subarray(e,e+t)},ar=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]},Mr=function(s,n){return kr(s,n)&&ar(s,n+6)+10<=s.length-n},Fr=function(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"},Nr=function(s){var n=String.fromCharCode(s[0],s[1],s[2],s[3]),e=ar(s,4);return{type:n,size:e,data:s.subarray(10,10+e)}},ln=function(s){for(var n=0,e=[];kr(s,n);){for(var t=ar(s,n+6),r=(n+=10)+t;n+8<r;){var i=Nr(s.subarray(n)),a=Jn(i);a&&e.push(a),n+=i.size+10}$e(s,n)&&(n+=10)}return e},Jn=function(s){return s.type==="PRIV"?un(s):s.type[0]==="W"?Zn(s):$n(s)},un=function(s){if(!(s.size<2)){var n=Ft(s.data,!0),e=new Uint8Array(s.data.subarray(n.length+1));return{key:s.type,info:n,data:e.buffer}}},$n=function(s){if(!(s.size<2)){if(s.type==="TXXX"){var n=1,e=Ft(s.data.subarray(n),!0);n+=e.length+1;var t=Ft(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=Ft(s.data.subarray(1));return{key:s.type,data:r}}},Zn=function(s){if(s.type==="WXXX"){if(s.size<2)return;var n=1,e=Ft(s.data.subarray(n),!0);n+=e.length+1;var t=Ft(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=Ft(s.data);return{key:s.type,data:r}},dn=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)}},Ft=function(s,n){n===void 0&&(n=!1);var e=cn();if(e){var t=e.decode(s);if(n){var r=t.indexOf("\0");return r!==-1?t.substring(0,r):t}return t.replace(/\0/g,"")}for(var i,a,o,l=s.length,d="",u=0;u<l;){if((i=s[u++])===0&&n)return d;if(i!==0&&i!==3)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(i);break;case 12:case 13:a=s[u++],d+=String.fromCharCode((31&i)<<6|63&a);break;case 14:a=s[u++],o=s[u++],d+=String.fromCharCode((15&i)<<12|(63&a)<<6|(63&o)<<0)}}return d};function cn(){return gr||self.TextDecoder===void 0||(gr=new self.TextDecoder("utf-8")),gr}var Nt=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},Jr=Math.pow(2,32)-1,ea=[].push,Si={video:1,audio:2,id3:3,text:4};function vt(s){return String.fromCharCode.apply(null,s)}function hn(s,n){var e=s[n]<<8|s[n+1];return e<0?65536+e:e}function Re(s,n){var e=fn(s,n);return e<0?4294967296+e:e}function fn(s,n){return s[n]<<24|s[n+1]<<16|s[n+2]<<8|s[n+3]}function Ai(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 Ue(s,n){var e=[];if(!n.length)return e;for(var t=s.byteLength,r=0;r<t;){var i=Re(s,r),a=i>1?r+i:t;if(vt(s.subarray(r+4,r+8))===n[0])if(n.length===1)e.push(s.subarray(r+8,a));else{var o=Ue(s.subarray(r+8,a),n.slice(1));o.length&&ea.apply(e,o)}r=a}return e}function ta(s){var n=[],e=s[0],t=8,r=Re(s,t);t+=4,t+=e===0?8:16,t+=2;var i=s.length+0,a=hn(s,t);t+=2;for(var o=0;o<a;o++){var l=t,d=Re(s,l);l+=4;var u=2147483647&d;if((2147483648&d)>>>31==1)return P.warn("SIDX has hierarchical references (not supported)"),null;var c=Re(s,l);l+=4,n.push({referenceSize:u,subsegmentDuration:c,info:{duration:c/r,start:i,end:i+u-1}}),i+=u,t=l+=4}return{earliestPresentationTime:0,timescale:r,version:e,referencesCount:a,references:n}}function ki(s){for(var n=[],e=Ue(s,["moov","trak"]),t=0;t<e.length;t++){var r=e[t],i=Ue(r,["tkhd"])[0];if(i){var a=i[0],o=a===0?12:20,l=Re(i,o),d=Ue(r,["mdia","mdhd"])[0];if(d){var u=Re(d,o=(a=d[0])===0?12:20),c=Ue(r,["mdia","hdlr"])[0];if(c){var f=vt(c.subarray(8,12)),v={soun:De,vide:Je}[f];if(v){var p=Ue(r,["mdia","minf","stbl","stsd"])[0],E=void 0;p&&(E=vt(p.subarray(12,16))),n[l]={timescale:u,type:v},n[v]={timescale:u,id:l,codec:E}}}}}}return Ue(s,["moov","mvex","trex"]).forEach(function(A){var y=Re(A,4),b=n[y];b&&(b.default={duration:Re(A,12),flags:Re(A,20)})}),n}function Li(s){var n=Ue(s,["schm"])[0];if(n){var e=vt(n.subarray(4,8));if(e==="cbcs"||e==="cenc")return Ue(s,["schi","tenc"])[0]}return P.error("[eme] missing 'schm' box"),null}function vn(s){var n=Re(s,0),e=8;1&n&&(e+=4),4&n&&(e+=4);for(var t=0,r=Re(s,4),i=0;i<r;i++)256&n&&(t+=Re(s,e),e+=4),512&n&&(e+=4),1024&n&&(e+=4),2048&n&&(e+=4);return t}function sr(s,n){var e=new Uint8Array(s.length+n.length);return e.set(s),e.set(n,s.length),e}function gn(s,n){var e=[],t=n.samples,r=n.timescale,i=n.id,a=!1;return Ue(t,["moof"]).map(function(o){var l=o.byteOffset-8;Ue(o,["traf"]).map(function(d){var u=Ue(d,["tfdt"]).map(function(c){var f=c[0],v=Re(c,4);return f===1&&(v*=Math.pow(2,32),v+=Re(c,8)),v/r})[0];return u!==void 0&&(s=u),Ue(d,["tfhd"]).map(function(c){var f=Re(c,4),v=16777215&Re(c,0),p=0,E=(16&v)!=0,A=0,y=(32&v)!=0,b=8;f===i&&((1&v)!=0&&(b+=8),(2&v)!=0&&(b+=4),(8&v)!=0&&(p=Re(c,b),b+=4),E&&(A=Re(c,b),b+=4),y&&(b+=4),n.type==="video"&&(a=function(C){if(!C)return!1;var I=C.indexOf("."),O=I<0?C:C.substring(0,I);return O==="hvc1"||O==="hev1"||O==="dvh1"||O==="dvhe"}(n.codec)),Ue(d,["trun"]).map(function(C){var I=C[0],O=16777215&Re(C,0),B=(1&O)!=0,K=0,X=(4&O)!=0,j=(256&O)!=0,V=0,ee=(512&O)!=0,J=0,ue=(1024&O)!=0,ke=(2048&O)!=0,le=0,Te=Re(C,4),Ae=8;B&&(K=Re(C,Ae),Ae+=4),X&&(Ae+=4);for(var be=K+l,Ie=0;Ie<Te;Ie++){if(j?(V=Re(C,Ae),Ae+=4):V=p,ee?(J=Re(C,Ae),Ae+=4):J=A,ue&&(Ae+=4),ke&&(le=I===0?Re(C,Ae):fn(C,Ae),Ae+=4),n.type===Je)for(var Fe=0;Fe<J;){var He=Re(t,be);ra(a,t[be+=4])&&Ri(t.subarray(be,be+He),a?2:1,s+le/r,e),be+=He,Fe+=He+4}s+=V/r}}))})})}),e}function ra(s,n){if(s){var e=n>>1&63;return e===39||e===40}return(31&n)==6}function Ri(s,n,e,t){var r=wi(s),i=0;i+=n;for(var a=0,o=0,l=!1,d=0;i<r.length;){a=0;do{if(i>=r.length)break;a+=d=r[i++]}while(d===255);o=0;do{if(i>=r.length)break;o+=d=r[i++]}while(d===255);var u=r.length-i;if(!l&&a===4&&i<r.length){if(l=!0,r[i++]===181){var c=hn(r,i);if(i+=2,c===49){var f=Re(r,i);if(i+=4,f===1195456820){var v=r[i++];if(v===3){var p=r[i++],E=64&p,A=E?2+3*(31&p):0,y=new Uint8Array(A);if(E){y[0]=p;for(var b=1;b<A;b++)y[b]=r[i++]}t.push({type:v,payloadType:a,pts:e,bytes:y})}}}}}else if(a===5&&o<u){if(l=!0,o>16){for(var C=[],I=0;I<16;I++){var O=r[i++].toString(16);C.push(O.length==1?"0"+O:O),I!==3&&I!==5&&I!==7&&I!==9||C.push("-")}for(var B=o-16,K=new Uint8Array(B),X=0;X<B;X++)K[X]=r[i++];t.push({payloadType:a,pts:e,uuid:C.join(""),userData:Ft(K),userDataBytes:K})}}else if(o<u)i+=o;else if(o>u)break}}function wi(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 ia(s,n,e){if(s.byteLength!==16)throw new RangeError("Invalid system id");var t,r,i;if(n){t=1,r=new Uint8Array(16*n.length);for(var a=0;a<n.length;a++){var o=n[a];if(o.byteLength!==16)throw new RangeError("Invalid key");r.set(o,16*a)}}else t=0,r=new Uint8Array;t>0?(i=new Uint8Array(4),n.length>0&&new DataView(i.buffer).setUint32(0,n.length,!1)):i=new Uint8Array;var l=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(l.buffer).setUint32(0,e.byteLength,!1),function(d){for(var u=arguments.length,c=new Array(u>1?u-1:0),f=1;f<u;f++)c[f-1]=arguments[f];for(var v=c.length,p=8,E=v;E--;)p+=c[E].byteLength;var A=new Uint8Array(p);for(A[0]=p>>24&255,A[1]=p>>16&255,A[2]=p>>8&255,A[3]=255&p,A.set(d,4),E=0,p=8;E<v;E++)A.set(c[E],p),p+=c[E].byteLength;return A}([112,115,115,104],new Uint8Array([t,0,0,0]),s,i,r,l,e||new Uint8Array)}var $r={},Zr=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(){$r={}};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 At:case ht:case Dt:case dt: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||P.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=function(A){for(var y=new Uint8Array(16),b=12;b<16;b++)y[b]=A>>8*(15-b)&255;return y}(e);return new s(this.method,this.uri,"identity",this.keyFormatVersions,t)}var r=se(this.uri);if(r)switch(this.keyFormat){case ht:this.pssh=r,r.length>=22&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case Dt:var i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=ia(i,null,r);var a=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),o=String.fromCharCode.apply(null,Array.from(a)),l=o.substring(o.indexOf("<"),o.length),d=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(d){var u=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(u){var c=z(u).subarray(0,16);(function(A){var y=function(b,C,I){var O=b[C];b[C]=b[I],b[I]=O};y(A,0,3),y(A,1,2),y(A,4,5),y(A,6,7)})(c),this.keyId=c}}break;default:var f=r.subarray(0,16);if(f.length!==16){var v=new Uint8Array(16);v.set(f,16-f.length),f=v}this.keyId=f}if(!this.keyId||this.keyId.byteLength!==16){var p=$r[this.uri];if(!p){var E=Object.keys($r).length%Number.MAX_SAFE_INTEGER;p=new Uint8Array(16),new DataView(p.buffer,12,4).setUint32(0,E),$r[this.uri]=p}this.keyId=p}return this},s}(),Di=/\{\$([a-zA-Z0-9-_]+)\}/g;function ei(s){return Di.test(s)}function kt(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]=Ii(s,i))}}function Ii(s,n){if(s.variableList!==null||s.hasVariableRefs){var e=s.variableList;return n.replace(Di,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 mn(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 er(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+'"'))}var na={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function ti(s,n){return MediaSource.isTypeSupported((n||"video")+'/mp4;codecs="'+s+'"')}var pn=/#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,yn=/#EXT-X-MEDIA:(.*)/g,En=/^#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"),Lr=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("|")),tr=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 Ne.buildAbsoluteURL(e,n,{alwaysNormalize:!0})},s.isMediaPlaylist=function(n){return En.test(n)},s.parseMasterPlaylist=function(n,e){var t,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:ei(n)},i=[];for(pn.lastIndex=0;(t=pn.exec(n))!=null;)if(t[1]){var a,o=new ze(t[1]);kt(r,o,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=Ii(r,t[2]),d={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:s.resolve(l,e)},u=o.decimalResolution("RESOLUTION");u&&(d.width=u.width,d.height=u.height),ri((o.CODECS||"").split(/[ ,]+/).filter(function(C){return C}),d),d.videoCodec&&d.videoCodec.indexOf("avc1")!==-1&&(d.videoCodec=s.convertAVC1ToAVCOTI(d.videoCodec)),(a=d.unknownCodecs)!=null&&a.length||i.push(d),r.levels.push(d)}else if(t[3]){var c=t[3],f=t[4];switch(c){case"SESSION-DATA":var v=new ze(f);kt(r,v,["DATA-ID","LANGUAGE","VALUE","URI"]);var p=v["DATA-ID"];p&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[p]=v);break;case"SESSION-KEY":var E=Tn(f,e,r);E.encrypted&&E.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(E)):P.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+f+'"');break;case"DEFINE":var A=new ze(f);kt(r,A,["NAME","VALUE","QUERYPARAM"]),mn(r,A,e);break;case"CONTENT-STEERING":var y=new ze(f);kt(r,y,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:s.resolve(y["SERVER-URI"],e),pathwayId:y["PATHWAY-ID"]||"."};break;case"START":r.startTimeOffset=Pi(f)}}var b=i.length>0&&i.length<r.levels.length;return r.levels=b?i:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},s.parseMasterPlaylistMedia=function(n,e,t){var r,i={},a=t.levels,o={AUDIO:a.map(function(E){return{id:E.attrs.AUDIO,audioCodec:E.audioCodec}}),SUBTITLES:a.map(function(E){return{id:E.attrs.SUBTITLES,textCodec:E.textCodec}}),"CLOSED-CAPTIONS":[]},l=0;for(yn.lastIndex=0;(r=yn.exec(n))!==null;){var d=new ze(r[1]),u=d.TYPE;if(u){var c=o[u],f=i[u]||[];i[u]=f,kt(t,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var v={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",instreamId:d["INSTREAM-ID"],name:d.NAME||d.LANGUAGE||"",type:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:d.LANGUAGE,url:d.URI?s.resolve(d.URI,e):""};if(c!=null&&c.length){var p=s.findGroup(c,v.groupId)||c[0];bn(v,p,"audioCodec"),bn(v,p,"textCodec")}f.push(v)}}return i},s.parseLevelPlaylist=function(n,e,t,r,i,a){var o,l,d,u=new on(e),c=u.fragments,f=null,v=0,p=0,E=0,A=0,y=null,b=new Qr(r,e),C=-1,I=!1;for(Ci.lastIndex=0,u.m3u8=n,u.hasVariableRefs=ei(n);(o=Ci.exec(n))!==null;){I&&(I=!1,(b=new Qr(r,e)).start=E,b.sn=v,b.cc=A,b.level=t,f&&(b.initSegment=f,b.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null));var O=o[1];if(O){b.duration=parseFloat(O);var B=(" "+o[2]).slice(1);b.title=B||null,b.tagList.push(B?["INF",O,B]:["INF",O])}else if(o[3]){if(ie(b.duration)){b.start=E,d&&An(b,d,u),b.sn=v,b.level=t,b.cc=A,b.urlId=i,c.push(b);var K=(" "+o[3]).slice(1);b.relurl=Ii(u,K),_n(b,y),y=b,E+=b.duration,v++,p=0,I=!0}}else if(o[4]){var X=(" "+o[4]).slice(1);y?b.setByteRange(X,y):b.setByteRange(X)}else if(o[5])b.rawProgramDateTime=(" "+o[5]).slice(1),b.tagList.push(["PROGRAM-DATE-TIME",b.rawProgramDateTime]),C===-1&&(C=c.length);else{if(!(o=o[0].match(Lr))){P.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<o.length&&o[l]===void 0;l++);var j=(" "+o[l]).slice(1),V=(" "+o[l+1]).slice(1),ee=o[l+2]?(" "+o[l+2]).slice(1):"";switch(j){case"PLAYLIST-TYPE":u.type=V.toUpperCase();break;case"MEDIA-SEQUENCE":v=u.startSN=parseInt(V);break;case"SKIP":var J=new ze(V);kt(u,J,["RECENTLY-REMOVED-DATERANGES"]);var ue=J.decimalInteger("SKIPPED-SEGMENTS");if(ie(ue)){u.skippedSegments=ue;for(var ke=ue;ke--;)c.unshift(null);v+=ue}var le=J.enumeratedString("RECENTLY-REMOVED-DATERANGES");le&&(u.recentlyRemovedDateranges=le.split(" "));break;case"TARGETDURATION":u.targetduration=Math.max(parseInt(V),1);break;case"VERSION":u.version=parseInt(V);break;case"EXTM3U":break;case"ENDLIST":u.live=!1;break;case"#":(V||ee)&&b.tagList.push(ee?[V,ee]:[V]);break;case"DISCONTINUITY":A++,b.tagList.push(["DIS"]);break;case"GAP":b.gap=!0,b.tagList.push([j]);break;case"BITRATE":b.tagList.push([j,V]);break;case"DATERANGE":var Te=new ze(V);kt(u,Te,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),kt(u,Te,Te.clientAttrs);var Ae=new Or(Te,u.dateRanges[Te.ID]);Ae.isValid||u.skippedSegments?u.dateRanges[Ae.id]=Ae:P.warn('Ignoring invalid DATERANGE tag: "'+V+'"'),b.tagList.push(["EXT-X-DATERANGE",V]);break;case"DEFINE":var be=new ze(V);kt(u,be,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in be?er(u,be,a):mn(u,be,e);break;case"DISCONTINUITY-SEQUENCE":A=parseInt(V);break;case"KEY":var Ie=Tn(V,e,u);if(Ie.isSupported()){if(Ie.method==="NONE"){d=void 0;break}d||(d={}),d[Ie.keyFormat]&&(d=W({},d)),d[Ie.keyFormat]=Ie}else P.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+V+'"');break;case"START":u.startTimeOffset=Pi(V);break;case"MAP":var Fe=new ze(V);if(kt(u,Fe,["BYTERANGE","URI"]),b.duration){var He=new Qr(r,e);Sn(He,Fe,t,d),f=He,b.initSegment=f,f.rawProgramDateTime&&!b.rawProgramDateTime&&(b.rawProgramDateTime=f.rawProgramDateTime)}else Sn(b,Fe,t,d),f=b,I=!0;break;case"SERVER-CONTROL":var We=new ze(V);u.canBlockReload=We.bool("CAN-BLOCK-RELOAD"),u.canSkipUntil=We.optionalFloat("CAN-SKIP-UNTIL",0),u.canSkipDateRanges=u.canSkipUntil>0&&We.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=We.optionalFloat("PART-HOLD-BACK",0),u.holdBack=We.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var xt=new ze(V);u.partTarget=xt.decimalFloatingPoint("PART-TARGET");break;case"PART":var mt=u.partList;mt||(mt=u.partList=[]);var rr=p>0?mt[mt.length-1]:void 0,Jt=p++,$t=new ze(V);kt(u,$t,["BYTERANGE","URI"]);var pt=new sn($t,b,e,Jt,rr);mt.push(pt),b.duration+=pt.duration;break;case"PRELOAD-HINT":var bt=new ze(V);kt(u,bt,["URI"]),u.preloadHint=bt;break;case"RENDITION-REPORT":var cr=new ze(V);kt(u,cr,["URI"]),u.renditionReports=u.renditionReports||[],u.renditionReports.push(cr);break;default:P.warn("line parsed but not handled: "+o)}}}y&&!y.relurl?(c.pop(),E-=y.duration,u.partList&&(u.fragmentHint=y)):u.partList&&(_n(b,y),b.cc=A,u.fragmentHint=b,d&&An(b,d,u));var Cr=c.length,Bt=c[0],Ki=c[Cr-1];if((E+=u.skippedSegments*u.targetduration)>0&&Cr&&Ki){u.averagetargetduration=E/Cr;var qi=Ki.sn;u.endSN=qi!=="initSegment"?qi:0,u.live||(Ki.endList=!0),Bt&&(u.startCC=Bt.cc)}else u.endSN=0,u.startCC=0;return u.fragmentHint&&(E+=u.fragmentHint.duration),u.totalduration=E,u.endCC=A,C>0&&function(qn,pi){for(var Wr=qn[pi],ji=pi;ji--;){var br=qn[ji];if(!br)return;br.programDateTime=Wr.programDateTime-1e3*br.duration,Wr=br}}(c,C),u},s}();function Tn(s,n,e){var t,r,i=new ze(s);kt(e,i,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var a=(t=i.METHOD)!=null?t:"",o=i.URI,l=i.hexadecimalInteger("IV"),d=i.KEYFORMATVERSIONS,u=(r=i.KEYFORMAT)!=null?r:"identity";o&&i.IV&&!l&&P.error("Invalid IV: "+i.IV);var c=o?tr.resolve(o,n):"",f=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Zr(a,c,u,f,l)}function Pi(s){var n=new ze(s).decimalFloatingPoint("TIME-OFFSET");return ie(n)?n:null}function ri(s,n){["video","audio","text"].forEach(function(e){var t=s.filter(function(i){return function(a,o){var l=na[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 bn(s,n,e){var t=n[e];t&&(s[e]=t)}function _n(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 Sn(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 An(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 mr="manifest",pr="level",qt="audioTrack",jt="subtitleTrack",qe="main",Vt="audio",Yt="subtitle";function kn(s){switch(s.type){case qt:return Vt;case jt:return Yt;default:return qe}}function ii(s,n){var e=s.url;return e!==void 0&&e.indexOf("data:")!==0||(e=n.url),e}var Ln=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(T.MANIFEST_LOADING,this.onManifestLoading,this),e.on(T.LEVEL_LOADING,this.onLevelLoading,this),e.on(T.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(T.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.unregisterListeners=function(){var e=this.hls;e.off(T.MANIFEST_LOADING,this.onManifestLoading,this),e.off(T.LEVEL_LOADING,this.onLevelLoading,this),e.off(T.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(T.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:mr,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:pr,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:qt,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:jt,url:a,deliveryDirectives:o})},n.load=function(e){var t,r,i,a=this,o=this.hls.config,l=this.getInternalLoader(e);if(l){var d=l.context;if(d&&d.url===e.url)return void P.trace("[playlist-loader]: playlist request ongoing");P.log("[playlist-loader]: aborting previous loader for type: "+e.type),l.abort()}if(r=e.type===mr?o.manifestLoadPolicy.default:W({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),l=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part&&(e.type===pr&&e.level!==null?i=this.hls.levels[e.level].details:e.type===qt&&e.id!==null?i=this.hls.audioTracks[e.id].details:e.type===jt&&e.id!==null&&(i=this.hls.subtitleTracks[e.id].details),i)){var u=i.partTarget,c=i.targetduration;if(u&&c){var f=1e3*Math.max(3*u,.8*c);r=W({},r,{maxTimeToFirstByteMs:Math.min(f,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,r.maxTimeToFirstByteMs)})}}var v=r.errorRetry||r.timeoutRetry||{},p={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:v.maxNumRetry||0,retryDelay:v.retryDelayMs||0,maxRetryDelay:v.maxRetryDelayMs||0},E={onSuccess:function(A,y,b,C){var I=a.getInternalLoader(b);a.resetInternalLoader(b.type);var O=A.data;O.indexOf("#EXTM3U")===0?(y.parsing.start=performance.now(),tr.isMediaPlaylist(O)?a.handleTrackOrLevelPlaylist(A,y,b,C||null,I):a.handleMasterPlaylist(A,y,b,C)):a.handleManifestParsingError(A,b,new Error("no EXTM3U delimiter"),C||null,y)},onError:function(A,y,b,C){a.handleNetworkError(y,b,!1,A,C)},onTimeout:function(A,y,b){a.handleNetworkError(y,b,!0,void 0,A)}};l.load(e,p,E)},n.handleMasterPlaylist=function(e,t,r,i){var a=this.hls,o=e.data,l=ii(e,r),d=tr.parseMasterPlaylist(o,l);if(d.playlistParsingError)this.handleManifestParsingError(e,r,d.playlistParsingError,i,t);else{var u=d.contentSteering,c=d.levels,f=d.sessionData,v=d.sessionKeys,p=d.startTimeOffset,E=d.variableList;this.variableList=E;var A=tr.parseMasterPlaylistMedia(o,l,d),y=A.AUDIO,b=y===void 0?[]:y,C=A.SUBTITLES,I=A["CLOSED-CAPTIONS"];b.length&&(b.some(function(O){return!O.url})||!c[0].audioCodec||c[0].attrs.AUDIO||(P.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),b.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new ze({}),bitrate:0,url:""}))),a.trigger(T.MANIFEST_LOADED,{levels:c,audioTracks:b,subtitles:C,captions:I,contentSteering:u,url:l,stats:t,networkDetails:i,sessionData:f,sessionKeys:v,startTimeOffset:p,variableList:E})}},n.handleTrackOrLevelPlaylist=function(e,t,r,i,a){var o=this.hls,l=r.id,d=r.level,u=r.type,c=ii(e,r),f=ie(l)?l:0,v=ie(d)?d:f,p=kn(r),E=tr.parseLevelPlaylist(e.data,c,v,p,f,this.variableList);if(u===mr){var A={attrs:new ze({}),bitrate:0,details:E,name:"",url:c};o.trigger(T.MANIFEST_LOADED,{levels:[A],audioTracks:[],url:c,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=E,this.handlePlaylistLoaded(E,e,t,r,i,a)},n.handleManifestParsingError=function(e,t,r,i,a){this.hls.trigger(T.ERROR,{type:Z.NETWORK_ERROR,details:N.MANIFEST_PARSING_ERROR,fatal:t.type===mr,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===pr?o+=": "+e.level+" id: "+e.id:e.type!==qt&&e.type!==jt||(o+=" id: "+e.id+' group-id: "'+e.groupId+'"');var l=new Error(o);P.warn("[playlist-loader]: "+o);var d=N.UNKNOWN,u=!1,c=this.getInternalLoader(e);switch(e.type){case mr:d=r?N.MANIFEST_LOAD_TIMEOUT:N.MANIFEST_LOAD_ERROR,u=!0;break;case pr:d=r?N.LEVEL_LOAD_TIMEOUT:N.LEVEL_LOAD_ERROR,u=!1;break;case qt:d=r?N.AUDIO_TRACK_LOAD_TIMEOUT:N.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case jt:d=r?N.SUBTITLE_TRACK_LOAD_TIMEOUT:N.SUBTITLE_LOAD_ERROR,u=!1}c&&this.resetInternalLoader(e.type);var f={type:Z.NETWORK_ERROR,details:d,fatal:u,url:e.url,loader:c,context:e,error:l,networkDetails:t,stats:a};if(i){var v=(t==null?void 0:t.url)||e.url;f.response=H({url:v,data:void 0},i)}this.hls.trigger(T.ERROR,f)},n.handlePlaylistLoaded=function(e,t,r,i,a,o){var l=this.hls,d=i.type,u=i.level,c=i.id,f=i.groupId,v=i.deliveryDirectives,p=ii(t,i),E=kn(i),A=typeof i.level=="number"&&E===qe?u:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var y=e.playlistParsingError;if(y)l.trigger(T.ERROR,{type:Z.NETWORK_ERROR,details:N.LEVEL_PARSING_ERROR,fatal:!1,url:p,error:y,reason:y.message,response:t,context:i,level:A,parent:E,networkDetails:a,stats:r});else switch(e.live&&o&&(o.getCacheAge&&(e.ageHeader=o.getCacheAge()||0),o.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),d){case mr:case pr:l.trigger(T.LEVEL_LOADED,{details:e,level:A||0,id:c||0,stats:r,networkDetails:a,deliveryDirectives:v});break;case qt:l.trigger(T.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v});break;case jt:l.trigger(T.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v})}}else{var b=new Error("No Segments found in Playlist");l.trigger(T.ERROR,{type:Z.NETWORK_ERROR,details:N.LEVEL_EMPTY_ERROR,fatal:!1,url:p,error:b,reason:b.message,response:t,context:i,level:A,parent:E,networkDetails:a,stats:r})}},s}();function ni(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){P.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 Rr(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 at(s,n,e,t){var r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0)for(var i=function(o,l,d){var u=[],c=function(E,A){if(A<E[0].startTime)return 0;var y=E.length-1;if(A>E[y].endTime)return-1;for(var b=0,C=y;b<=C;){var I=Math.floor((C+b)/2);if(A<E[I].startTime)C=I-1;else{if(!(A>E[I].startTime&&b<y))return I;b=I+1}}return E[b].startTime-A<A-E[C].startTime?b:C}(o,l);if(c>-1)for(var f=c,v=o.length;f<v;f++){var p=o[f];if(p.startTime>=l&&p.endTime<=d)u.push(p);else if(p.startTime>d)return u}return u}(s.cues,n,e),a=0;a<i.length;a++)t&&!t(i[a])||s.removeCue(i[a]);r==="disabled"&&(s.mode=r)}var or="org.id3",aa="com.apple.quicktime.HLS",Ur="https://aomedia.org/emsg/ID3";function xi(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var ai=function(){var s=xi();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function yr(s,n){return s.getTime()/1e3-n}var Oi=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(T.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(T.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(T.MANIFEST_LOADING,this.onManifestLoading,this),e.on(T.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(T.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(T.LEVEL_UPDATED,this.onLevelUpdated,this)},n._unregisterListeners=function(){var e=this.hls;e.off(T.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(T.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(T.MANIFEST_LOADING,this.onManifestLoading,this),e.off(T.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(T.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(T.LEVEL_UPDATED,this.onLevelUpdated,this)},n.onMediaAttached=function(e,t){this.media=t.media},n.onMediaDetaching=function(){this.id3Track&&(Rr(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 ni(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=xi(),d=0;d<o.length;d++){var u=o[d].type;if((u!==Ur||i)&&a){var c=ln(o[d].data);if(c){var f=o[d].pts,v=f+o[d].duration;v>ai&&(v=ai),v-f<=0&&(v=f+.25);for(var p=0;p<c.length;p++){var E=c[p];if(!Fr(E)){this.updateId3CueEnds(f);var A=new l(f,v,"");A.value=E,u&&(A.type=u),this.id3Track.addCue(A)}}}}}}}},n.updateId3CueEnds=function(e){var t,r=(t=this.id3Track)==null?void 0:t.cues;if(r)for(var i=r.length;i--;){var a=r[i];a.startTime<e&&a.endTime===ai&&(a.endTime=e)}},n.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.type,o=this.id3Track,l=this.hls;if(l){var d=l.config,u=d.enableEmsgMetadataCues,c=d.enableID3MetadataCues;o&&(u||c)&&at(o,r,i,a==="audio"?function(f){return f.type===or&&c}:a==="video"?function(f){return f.type===Ur&&u}:function(f){return f.type===or&&c||f.type===Ur&&u})}},n.onLevelUpdated=function(e,t){var r=this,i=t.details;if(this.media&&i.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,o=this.id3Track,l=i.dateRanges,d=Object.keys(l);if(o)for(var u=Object.keys(a).filter(function(b){return!d.includes(b)}),c=function(){var b=u[f];Object.keys(a[b].cues).forEach(function(C){o.removeCue(a[b].cues[C])}),delete a[b]},f=u.length;f--;)c();var v=i.fragments[i.fragments.length-1];if(d.length!==0&&ie(v==null?void 0:v.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var p=v.programDateTime/1e3-v.start,E=xi(),A=function(){var b=d[y],C=l[b],I=a[b],O=(I==null?void 0:I.cues)||{},B=(I==null?void 0:I.durationKnown)||!1,K=yr(C.startDate,p),X=ai,j=C.endDate;if(j)X=yr(j,p),B=!0;else if(C.endOnNext&&!B){var V=d.reduce(function(be,Ie){var Fe=l[Ie];return Fe.class===C.class&&Fe.id!==Ie&&Fe.startDate>C.startDate&&be.push(Fe),be},[]).sort(function(be,Ie){return be.startDate.getTime()-Ie.startDate.getTime()})[0];V&&(X=yr(V.startDate,p),B=!0)}for(var ee,J,ue=Object.keys(C.attr),ke=0;ke<ue.length;ke++){var le=ue[ke];if((J=le)!=="ID"&&J!=="CLASS"&&J!=="START-DATE"&&J!=="DURATION"&&J!=="END-DATE"&&J!=="END-ON-NEXT"){var Te=O[le];if(Te)B&&!I.durationKnown&&(Te.endTime=X);else{var Ae=C.attr[le];Te=new E(K,X,""),wt(le)&&(ee=Ae,Ae=Uint8Array.from(ee.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),Te.value={key:le,data:Ae},Te.type=aa,Te.id=b,r.id3Track.addCue(Te),O[le]=Te}}}a[b]={cues:O,dateRange:C,durationKnown:B}},y=0;y<d.length;y++)A()}}},s}(),wn=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(T.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(T.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(T.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(T.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(T.ERROR,this.onError,this)},n.unregisterListeners=function(){this.hls.off(T.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(T.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(T.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(T.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(T.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===N.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&P.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},n.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(r!==null){this._latency=r;var i=this.config,a=i.lowLatencyMode,o=i.maxLiveSyncPlaybackRate;if(a&&o!==1){var l=this.targetLatency;if(l!==null){var d=r-l,u=d<Math.min(this.maxLatency,l+t.targetduration);if(t.live&&u&&d>.05&&this.forwardBufferLength>1){var c=Math.min(2,Math.max(1,o)),f=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,f))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}}}}},n.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},n.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},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,d=a.lowLatencyMode,u=this.hls.userConfig,c=d&&r||t;(u.liveSyncDuration||u.liveSyncDurationCount||c===0)&&(c=o!==void 0?o:l*i);var f=i;return c+Math.min(1*this.stallCount,f)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;var i=r.edge,a=e-t-this.edgeStalled,o=i-r.totalduration,l=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(o,a),l)}},{key:"drift",get:function(){var e=this.levelDetails;return e===null?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(e===null)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),s}(),si=["NONE","TYPE-0","TYPE-1",null],lr="",sa="YES",oa="v2",Dn=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}(),Br=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 Mi(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 In(s,n,e,t,r,i){t-e<=0&&(P.warn("Fragment should have a positive duration",n),t=e+n.duration,i=r+n.duration);var a=e,o=t,l=n.startPTS,d=n.endPTS;if(ie(l)){var u=Math.abs(l-e);ie(n.deltaPTS)?n.deltaPTS=Math.max(u,n.deltaPTS):n.deltaPTS=u,a=Math.max(e,l),e=Math.min(e,l),r=Math.min(r,n.startDTS),o=Math.min(t,d),t=Math.max(t,d),i=Math.max(i,n.endDTS)}var c=e-n.start;n.start!==0&&(n.start=e),n.duration=t-n.start,n.startPTS=e,n.maxStartPTS=a,n.startDTS=r,n.endPTS=t,n.minEndPTS=o,n.endDTS=i;var f,v=n.sn;if(!s||v<s.startSN||v>s.endSN)return 0;var p=v-s.startSN,E=s.fragments;for(E[p]=n,f=p;f>0;f--)Mi(E[f],E[f-1]);for(f=p;f<E.length-1;f++)Mi(E[f],E[f+1]);return s.fragmentHint&&Mi(E[E.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,c}function la(s,n){for(var e=null,t=s.fragments,r=t.length-1;r>=0;r--){var i=t[r].initSegment;if(i){e=i;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var a,o,l,d,u,c=0;if(function(y,b,C){for(var I=b.skippedSegments,O=Math.max(y.startSN,b.startSN)-b.startSN,B=(y.fragmentHint?1:0)+(I?b.endSN:Math.min(y.endSN,b.endSN))-b.startSN,K=b.startSN-y.startSN,X=b.fragmentHint?b.fragments.concat(b.fragmentHint):b.fragments,j=y.fragmentHint?y.fragments.concat(y.fragmentHint):y.fragments,V=O;V<=B;V++){var ee=j[K+V],J=X[V];I&&!J&&V<I&&(J=b.fragments[V]=ee),ee&&J&&C(ee,J)}}(s,n,function(y,b){y.relurl&&(c=y.cc-b.cc),ie(y.startPTS)&&ie(y.endPTS)&&(b.start=b.startPTS=y.startPTS,b.startDTS=y.startDTS,b.maxStartPTS=y.maxStartPTS,b.endPTS=y.endPTS,b.endDTS=y.endDTS,b.minEndPTS=y.minEndPTS,b.duration=y.endPTS-y.startPTS,b.duration&&(a=b),n.PTSKnown=n.alignedSliding=!0),b.elementaryStreams=y.elementaryStreams,b.loader=y.loader,b.stats=y.stats,b.urlId=y.urlId,y.initSegment&&(b.initSegment=y.initSegment,e=y.initSegment)}),e&&(n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments).forEach(function(y){var b;y.initSegment&&y.initSegment.relurl!==((b=e)==null?void 0:b.relurl)||(y.initSegment=e)}),n.skippedSegments)if(n.deltaUpdateFailed=n.fragments.some(function(y){return!y}),n.deltaUpdateFailed){P.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var f=n.skippedSegments;f--;)n.fragments.shift();n.startSN=n.fragments[0].sn,n.startCC=n.fragments[0].cc}else n.canSkipDateRanges&&(n.dateRanges=(o=s.dateRanges,l=n.dateRanges,d=n.recentlyRemovedDateranges,u=W({},o),d&&d.forEach(function(y){delete u[y]}),Object.keys(l).forEach(function(y){var b=new Or(l[y].attr,u[y]);b.isValid?u[y]=b:P.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(l[y].attr)+'"')}),u));var v=n.fragments;if(c){P.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<v.length;p++)v[p].cc+=c}n.skippedSegments&&(n.startCC=n.fragments[0].cc),function(y,b,C){if(y&&b)for(var I=0,O=0,B=y.length;O<=B;O++){var K=y[O],X=b[O+I];K&&X&&K.index===X.index&&K.fragment.sn===X.fragment.sn?C(K,X):I--}}(s.partList,n.partList,function(y,b){b.elementaryStreams=y.elementaryStreams,b.stats=y.stats}),a?In(n,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):Cn(s,n),v.length&&(n.totalduration=n.edge-v[0].start),n.driftStartTime=s.driftStartTime,n.driftStart=s.driftStart;var E=n.advancedDateTime;if(n.advanced&&E){var A=n.edge;n.driftStart||(n.driftStartTime=E,n.driftStart=A),n.driftEndTime=E,n.driftEnd=A}else n.driftEndTime=s.driftEndTime,n.driftEnd=s.driftEnd,n.advancedDateTime=s.advancedDateTime}function Cn(s,n){var e=n.startSN+n.skippedSegments-s.startSN,t=s.fragments;e<0||e>=t.length||Fi(n,t[e].start)}function Fi(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 Gr(s,n,e){var t;return s!=null&&s.details?oi((t=s.details)==null?void 0:t.partList,n,e):null}function oi(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 Hr(s){switch(s.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 li(s,n){var e=Hr(n);return s.default[(e?"timeout":"error")+"Retry"]}function Ni(s,n){var e=s.backoff==="linear"?1:Math.pow(2,n);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function Pn(s){return H(H({},s),{errorRetry:null,timeoutRetry:null})}function ui(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 xn=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 Kr(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&&Ui(e,t,r)===0)return r;var i=xn(n,Ui.bind(null,e,t));return!i||i===s&&r?r:i}function Ui(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 ua(s,n,e){var t=1e3*Math.min(n,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>s}var Bi,da=3e5,di=0,ct=2,ur=5,wr=0,ci=1,m=2,h=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=P.log.bind(P,"[info]:"),this.warn=P.warn.bind(P,"[warning]:"),this.error=P.error.bind(P,"[error]:"),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(T.ERROR,this.onError,this),e.on(T.MANIFEST_LOADING,this.onManifestLoading,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(T.ERROR,this.onError,this),e.off(T.ERROR,this.onErrorOut,this),e.off(T.MANIFEST_LOADING,this.onManifestLoading,this))},n.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},n.startLoad=function(e){this.playlistError=0},n.stopLoad=function(){},n.getVariantLevelIndex=function(e){return(e==null?void 0:e.type)===qe?e.level:this.hls.loadLevel},n.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},n.onError=function(e,t){var r;if(!t.fatal){var i=this.hls,a=t.context;switch(t.details){case N.FRAG_LOAD_ERROR:case N.FRAG_LOAD_TIMEOUT:case N.KEY_LOAD_ERROR:case N.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case N.FRAG_GAP:case N.FRAG_PARSING_ERROR:case N.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=ct);case N.LEVEL_EMPTY_ERROR:case N.LEVEL_PARSING_ERROR:var o,l,d=t.parent===qe?t.level:i.loadLevel;return void(t.details===N.LEVEL_EMPTY_ERROR&&(o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d)));case N.LEVEL_LOAD_ERROR:case N.LEVEL_LOAD_TIMEOUT:return void(typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case N.AUDIO_TRACK_LOAD_ERROR:case N.AUDIO_TRACK_LOAD_TIMEOUT:case N.SUBTITLE_LOAD_ERROR:case N.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var u=i.levels[i.loadLevel];if(u&&(a.type===qt&&a.groupId===u.audioGroupId||a.type===jt&&a.groupId===u.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=ct,void(t.errorAction.flags=ci)}return;case N.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:ct,flags:m,hdcpLevel:f}));case N.BUFFER_ADD_CODEC_ERROR:case N.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:i.loadLevel));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:return void(t.errorAction={action:di,flags:wr})}if(t.type===Z.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,a=li(this.hls.config.playlistLoadPolicy,e),o=this.playlistError++,l=(r=e.response)==null?void 0:r.code;return ui(a,o,Hr(e),l)?{action:ur,flags:wr,retryConfig:a,retryCount:o}:(i=e.context)!=null&&i.deliveryDirectives?{action:di,flags:wr,retryConfig:a||{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},retryCount:o}:this.getLevelSwitchAction(e,t)},n.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],a=t.config,o=a.fragLoadPolicy,l=a.keyLoadPolicy,d=li(e.details.startsWith("key")?l:o,e),u=t.levels.reduce(function(p,E){return p+E.fragmentError},0);if(i){var c;e.details!==N.FRAG_GAP&&i.fragmentError++;var f=(c=e.response)==null?void 0:c.code;if(ui(d,u,Hr(e),f))return{action:ur,flags:wr,retryConfig:d,retryCount:u}}var v=this.getLevelSwitchAction(e,r);return d&&(v.retryConfig=d,v.retryCount=u),v},n.getLevelSwitchAction=function(e,t){var r=this.hls;t==null&&(t=r.loadLevel);var i=this.hls.levels[t];if(i&&(i.loadError++,r.autoLevelEnabled)){for(var a,o,l=-1,d=r.levels,u=(a=e.frag)==null?void 0:a.type,c=(o=e.context)!=null?o:{},f=c.type,v=c.groupId,p=d.length;p--;){var E=(p+r.loadLevel)%d.length;if(E!==r.loadLevel&&d[E].loadError===0){var A=d[E];if(e.details===N.FRAG_GAP&&e.frag){var y=d[E].details;if(y){var b=Kr(e.frag,y.fragments,e.frag.start);if(b!=null&&b.gap)continue}}else if(f===qt&&v===A.audioGroupId||f===jt&&v===A.textGroupId||u===Vt&&i.audioGroupId===A.audioGroupId||u===Yt&&i.textGroupId===A.textGroupId)continue;l=E;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,{action:ct,flags:wr,nextAutoLevel:l}}return{action:ct,flags:ci}},n.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case di:break;case ct:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===N.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 wr:this.switchLevel(e,o);break;case ci:r.resolved||(r.resolved=this.redundantFailover(e));break;case m:a&&(t.maxHdcpLevel=si[si.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===qe?e.level:r.loadLevel,o=r.levels[a],l=o.url.length,d=e.frag?e.frag.urlId:o.urlId;o.urlId!==d||e.frag&&!o.details||this.penalizeRendition(o,e);for(var u=function(){var v=(d+c)%l,p=i[v];if(!p||function(E,A,y){if(performance.now()-E.lastErrorPerfMs>da)return!0;var b=E.details;if(A.details===N.FRAG_GAP&&b&&A.frag){var C=A.frag.start,I=Kr(null,b.fragments,C);if(I&&!I.gap)return!0}if(y&&E.errors.length<y.errors.length){var O=E.errors[E.errors.length-1];if(b&&O.frag&&A.frag&&Math.abs(O.frag.start-A.frag.start)>3*b.targetduration)return!0}return!1}(p,e,i[d]))return t.warn("Switching to Redundant Stream "+(v+1)+"/"+l+': "'+o.url[v]+'" after '+e.details),t.playlistError=0,r.levels.forEach(function(E){E.urlId=v}),r.nextLoadLevel=a,{v:!0}},c=1;c<l;c++){var f=u();if(typeof f=="object")return f.v}return!1},n.penalizeRendition=function(e,t){var r=this.penalizedRenditions,i=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(t),i.details=e.details,r[e.urlId]=i},s}(),g=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=P.log.bind(P,t+":"),this.warn=P.warn.bind(P,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){P.warn("Could not construct new URL for Rendition Report: "+v),l=o.URI||""}if(l===e){i=a;break}l===e.substring(0,l.length)&&(i=a)}if(i!==-1){var d=r[i],u=parseInt(d["LAST-MSN"])||(t==null?void 0:t.lastPartSn),c=parseInt(d["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var f=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&f>t.partTarget&&(c+=1)}return new Dn(u,c>=0?c:void 0,lr)}}},n.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},n.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},n.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)},n.playlistLoaded=function(e,t,r){var i=this,a=t.details,o=t.stats,l=self.performance.now(),d=o.loading.first?Math.max(0,l-o.loading.first):0;if(a.advancedDateTime=Date.now()-d,a.live||r!=null&&r.live){if(a.reloaded(r),r&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),r&&a.fragments.length>0&&la(r,a),!this.canLoad||!a.live)return;var u,c=void 0,f=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var v=this.hls.config.lowLatencyMode,p=a.lastPartSn,E=a.endSN,A=a.lastPartIndex,y=p===E;A!==-1?(c=y?E+1:p,f=y?v?0:A:A+1):c=E+1;var b=a.age,C=b+a.ageHeader,I=Math.min(C-a.partTarget,1.5*a.targetduration);if(I>0){if(r&&I>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+I+" with playlist age: "+a.age),I=0;else{var O=Math.floor(I/a.targetduration);c+=O,f!==void 0&&(f+=Math.round(I%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+b.toFixed(2)+"s goal: "+I+" skip sn "+O+" to part "+f)}a.tuneInGoal=I}if(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,f),v||!y)return void this.loadPlaylist(u)}else a.canBlockReload&&(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,f));var B=this.hls.mainForwardBufferInfo,K=B?B.end-B.len:0,X=function(V,ee){ee===void 0&&(ee=1/0);var J=1e3*V.targetduration;if(V.updated){var ue=V.fragments;if(ue.length&&4*J>ee){var ke=1e3*ue[ue.length-1].duration;ke<J&&(J=ke)}}else J/=2;return Math.round(J)}(a,1e3*(a.edge-K));a.updated&&l>this.requestScheduled+X&&(this.requestScheduled=o.loading.start),c!==void 0&&a.canBlockReload?this.requestScheduled=o.loading.first+X-(1e3*a.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+X<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=X);var j=this.requestScheduled-l;j=Math.max(0,j),this.log("reload live playlist "+e+" in "+Math.round(j)+" ms"),this.timer=self.setTimeout(function(){return i.loadPlaylist(u)},j)}else this.clearTimer()},n.getDeliveryDirectives=function(e,t,r,i){var a=function(o,l){var d=o.canSkipUntil,u=o.canSkipDateRanges,c=o.endSN;return d&&(l!==void 0?l-c:0)<d?u?oa:sa:lr}(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=lr),new Dn(r,i,a)},n.checkRetry=function(e){var t=this,r=e.details,i=Hr(e),a=e.errorAction,o=a||{},l=o.action,d=o.retryCount,u=d===void 0?0:d,c=o.retryConfig,f=l===ur&&!!a&&!!c;if(f){var v;if(this.requestScheduled=-1,i&&(v=e.context)!=null&&v.deliveryDirectives)this.warn("Retrying playlist loading "+(u+1)+"/"+c.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var p=Ni(c,u);this.timer=self.setTimeout(function(){return t.loadPlaylist()},p),this.warn("Retrying playlist loading "+(u+1)+"/"+c.maxNumRetry+' after "'+r+'" in '+p+"ms")}e.levelRetry=!0,a.resolved=!0}return f},s}(),_=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}de(n,s);var e=n.prototype;return e._registerListeners=function(){var t=this.hls;t.on(T.MANIFEST_LOADING,this.onManifestLoading,this),t.on(T.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(T.LEVEL_LOADED,this.onLevelLoaded,this),t.on(T.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(T.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(T.FRAG_LOADED,this.onFragLoaded,this),t.on(T.ERROR,this.onError,this)},e._unregisterListeners=function(){var t=this.hls;t.off(T.MANIFEST_LOADING,this.onManifestLoading,this),t.off(T.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(T.LEVEL_LOADED,this.onLevelLoaded,this),t.off(T.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(T.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(T.FRAG_LOADED,this.onFragLoaded,this),t.off(T.ERROR,this.onError,this)},e.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),s.prototype.destroy.call(this)},e.startLoad=function(){this._levels.forEach(function(t){t.loadError=0,t.fragmentError=0}),s.prototype.startLoad.call(this)},e.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},e.onManifestLoading=function(t,r){this.resetLevels()},e.onManifestLoaded=function(t,r){var i,a=[],o={};r.levels.forEach(function(l){var d,u=l.attrs;((d=l.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(Bi||(Bi=/chrome|firefox/i.test(navigator.userAgent)),Bi&&(l.audioCodec=void 0));var c=u.AUDIO,f=u.CODECS,v=u["FRAME-RATE"],p=u["PATHWAY-ID"],E=u.RESOLUTION,A=u.SUBTITLES,y=(p||".")+"-"+l.bitrate+"-"+E+"-"+v+"-"+f;(i=o[y])?i.addFallback(l):(i=new Br(l),o[y]=i,a.push(i)),k(i,"audio",c),k(i,"text",A)}),this.filterAndSortMediaOptions(a,r)},e.filterAndSortMediaOptions=function(t,r){var i=this,a=[],o=[],l=!1,d=!1,u=!1,c=t.filter(function(b){var C=b.audioCodec,I=b.videoCodec,O=b.width,B=b.height,K=b.unknownCodecs;return l||(l=!(!O||!B)),d||(d=!!I),u||(u=!!C),!(K!=null&&K.length)&&(!C||ti(C,"audio"))&&(!I||ti(I,"video"))});if((l||d)&&u&&(c=c.filter(function(b){var C=b.videoCodec,I=b.width,O=b.height;return!!C||!(!I||!O)})),c.length!==0){r.audioTracks&&D(a=r.audioTracks.filter(function(b){return!b.audioCodec||ti(b.audioCodec,"audio")})),r.subtitles&&D(o=r.subtitles);var f=c.slice(0);c.sort(function(b,C){return b.attrs["HDCP-LEVEL"]!==C.attrs["HDCP-LEVEL"]?(b.attrs["HDCP-LEVEL"]||"")>(C.attrs["HDCP-LEVEL"]||"")?1:-1:b.bitrate!==C.bitrate?b.bitrate-C.bitrate:b.attrs["FRAME-RATE"]!==C.attrs["FRAME-RATE"]?b.attrs.decimalFloatingPoint("FRAME-RATE")-C.attrs.decimalFloatingPoint("FRAME-RATE"):b.attrs.SCORE!==C.attrs.SCORE?b.attrs.decimalFloatingPoint("SCORE")-C.attrs.decimalFloatingPoint("SCORE"):l&&b.height!==C.height?b.height-C.height:0});var v=f[0];if(this.steering&&(c=this.steering.filterParsedLevels(c)).length!==f.length){for(var p=0;p<f.length;p++)if(f[p].pathwayId===c[0].pathwayId){v=f[p];break}}this._levels=c;for(var E=0;E<c.length;E++)if(c[E]===v){this._firstLevel=E,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+v.bitrate);break}var A=u&&!d,y={levels:c,audioTracks:a,subtitleTracks:o,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:u,video:d,altAudio:!A&&a.some(function(b){return!!b.url})};this.hls.trigger(T.MANIFEST_PARSED,y),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then(function(){if(i.hls){var b=new Error("no level with compatible codecs found in manifest");i.hls.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:N.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:b,reason:b.message})}})},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===pr&&r.context.level===this.level&&this.checkRetry(r)},e.onFragLoaded=function(t,r){var i=r.frag;if(i!==void 0&&i.type===qe){var a=this._levels[i.level];a!==void 0&&(a.loadError=0)}},e.onLevelLoaded=function(t,r){var i,a,o=r.level,l=r.details,d=this._levels[o];if(!d)return this.warn("Invalid level index "+o),void((a=r.deliveryDirectives)!=null&&a.skip&&(l.deltaUpdateFailed=!0));o===this.currentLevelIndex?(d.fragmentError===0&&(d.loadError=0),this.playlistLoaded(o,r,d.details)):(i=r.deliveryDirectives)!=null&&i.skip&&(l.deltaUpdateFailed=!0)},e.onAudioTrackSwitched=function(t,r){var i=this.currentLevel;if(i){var a=this.hls.audioTracks[r.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==a){for(var o=-1,l=0;l<i.audioGroupIds.length;l++)if(i.audioGroupIds[l]===a){o=l;break}o!==-1&&o!==i.urlId&&(i.urlId=o,this.canLoad&&this.startLoad())}}},e.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var a=i.urlId,o=i.uri;if(t)try{o=t.addDirectives(o)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}var l=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+((t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:"")+" with"+(l?" Pathway "+l:"")+" URI "+(a+1)+"/"+i.url.length+" "+o),this.clearTimer(),this.hls.trigger(T.LEVEL_LOADING,{url:o,level:r,id:a,deliveryDirectives:t||null})}},e.removeLevel=function(t,r){var i=this,a=function(l,d){return d!==r},o=this._levels.filter(function(l,d){return d!==t||(l.url.length>1&&r!==void 0?(l.url=l.url.filter(a),l.audioGroupIds&&(l.audioGroupIds=l.audioGroupIds.filter(a)),l.textGroupIds&&(l.textGroupIds=l.textGroupIds.filter(a)),l.urlId=0,!0):(i.steering&&i.steering.removeLevel(l),!1))});this.hls.trigger(T.LEVELS_UPDATED,{levels:o})},e.onLevelsUpdated=function(t,r){var i=r.levels;i.forEach(function(a,o){var l=a.details;l!=null&&l.fragments&&l.fragments.forEach(function(d){d.level=o})}),this._levels=i},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(T.ERROR,{type:Z.OTHER_ERROR,details:N.LEVEL_SWITCH_ERROR,level:t,fatal:a,error:i,reason:i.message}),a)return;t=Math.min(t,r.length-1)}var o=this.currentLevelIndex,l=this.currentLevel,d=l?l.attrs["PATHWAY-ID"]:void 0,u=r[t],c=u.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=u,o!==t||!u.details||!l||d!==c){this.log("Switching to level "+t+(c?" with Pathway "+c:"")+" from level "+o+(d?" with Pathway "+d:""));var f=W({},u,{level:t,maxBitrate:u.maxBitrate,attrs:u.attrs,uri:u.uri,urlId:u.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(T.LEVEL_SWITCHING,f);var v=u.details;if(!v||v.live){var p=this.switchParams(u.uri,l==null?void 0:l.details);this.loadPlaylist(p)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}]),n}(g);function k(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 D(s){var n={};s.forEach(function(e){var t=e.groupId||"";e.id=n[t]=n[t]||0,n[t]++})}var w="NOT_LOADED",x="APPENDING",G="PARTIAL",M="OK",Y=function(){function s(e){this.mainFragEntity=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var n=s.prototype;return n._registerListeners=function(){var e=this.hls;e.on(T.BUFFER_APPENDED,this.onBufferAppended,this),e.on(T.FRAG_BUFFERED,this.onFragBuffered,this),e.on(T.FRAG_LOADED,this.onFragLoaded,this)},n._unregisterListeners=function(){var e=this.hls;e.off(T.BUFFER_APPENDED,this.onBufferAppended,this),e.off(T.FRAG_BUFFERED,this.onFragBuffered,this),e.off(T.FRAG_LOADED,this.onFragLoaded,this)},n.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.mainFragEntity=this.activeParts=null},n.getAppendedFrag=function(e,t){if(t===qe){var r=this.mainFragEntity,i=this.activeParts;if(r){if(r&&i)for(var a=i.length;a--;){var o=i[a],l=o?o.end:r.appendedPTS;if(o.start<=e&&l!==null&&e<=l)return a>9&&(this.activeParts=i.slice(a-9)),o}else if(r.body.start<=e&&r.appendedPTS!==null&&e<=r.appendedPTS)return r.body}}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){var i=this;this.timeRanges&&(this.timeRanges[e]=t),Object.keys(this.fragments).forEach(function(a){var o=i.fragments[a];if(o)if(o.buffered||o.loaded){var l=o.range[e];l&&l.time.some(function(d){var u=!i.isTimeBuffered(d.startPTS,d.endPTS,t);return u&&i.removeFragment(o.body),u})}else o.body.type===r&&i.removeFragment(o.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];l&&(Object.keys(r).forEach(function(d){var u=i.elementaryStreams[d];if(u){var c=r[d],f=a!==null||u.partial===!0;l.range[d]=t.getBufferedTimes(i,a,f,c)}}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,l.body.endList&&(this.endListFragments[l.body.type]=l)):this.removeFragment(l.body))}},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=t?t.start:e.start,l=t?t.end:e.end,d=e.minEndPTS||l,u=e.maxStartPTS||o,c=0;c<i.length;c++){var f=i.start(c)-this.bufferPadding,v=i.end(c)+this.bufferPadding;if(u>=f&&d<=v){a.time.push({startPTS:Math.max(o,i.start(c)),endPTS:Math.min(l,i.end(c))});break}if(o<v&&l>f)a.partial=!0,a.time.push({startPTS:Math.max(o,i.start(c)),endPTS:Math.min(l,i.end(c))});else if(l<=f)break}return a},n.getPartialFragment=function(e){var t,r,i,a=null,o=0,l=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(u){var c=d[u];c&&Se(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||Se(t))},n.getState=function(e){var t=ae(e),r=this.fragments[t];return r?r.buffered?Se(r)?G:M:x: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&&!i){var a=ae(r);this.fragments[a]={body:r,appendedPTS:null,loaded:t,buffered:!1,range:Object.create(null)}}},n.onBufferAppended=function(e,t){var r=this,i=t.frag,a=t.part,o=t.timeRanges,l=this.mainFragEntity;if(i.type===qe){var d=l?l.body:null;if(d!==i){l&&d&&d.sn!==i.sn&&(l.buffered=!0,this.fragments[ae(d)]=l);var u=ae(i);l=this.mainFragEntity=this.fragments[u]||{body:i,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)}}if(a){var c=this.activeParts;c||(this.activeParts=c=[]),c.push(a)}else this.activeParts=null}this.timeRanges=o,Object.keys(o).forEach(function(f){var v=o[f];if(r.detectEvictedFragments(f,v),!a&&l){var p=i.elementaryStreams[f];if(!p)return;for(var E=0;E<v.length;E++){var A=v.end(E);A<=p.endPTS&&A>p.startPTS?l.appendedPTS=Math.max(A,l.appendedPTS||0):l.appendedPTS=p.endPTS}}})},n.onFragBuffered=function(e,t){this.detectPartialFragments(t)},n.hasFragment=function(e){var t=ae(e);return!!this.fragments[t]},n.removeFragmentsInRange=function(e,t,r,i,a){var o=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach(function(l){var d=o.fragments[l];if(d){var u=d.body;u.type!==r||i&&!u.gap||u.start<t&&u.end>e&&(d.buffered||a)&&o.removeFragment(u)}})},n.removeFragment=function(e){var t=ae(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),this.mainFragEntity===this.fragments[t]&&(this.mainFragEntity=null),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.mainFragEntity=null,this.activeParts=null,this.hasGaps=!1},s}();function Se(s){var n,e;return s.buffered&&(s.body.gap||((n=s.range.video)==null?void 0:n.partial)||((e=s.range.audio)==null?void 0:e.partial))}function ae(s){return s.type+"_"+s.level+"_"+s.urlId+"_"+s.sn}var me=Math.pow(2,17),oe=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 Ze({type:Z.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();var a=this.config,o=a.fLoader,l=a.loader;return new Promise(function(d,u){if(r.loader&&r.loader.destroy(),e.gap)u(Be(e));else{var c=r.loader=e.loader=o?new o(a):new l(a),f=pe(e),v=Pn(a.fragLoadPolicy.default),p={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:me};e.stats=c.stats,c.load(f,p,{onSuccess:function(E,A,y,b){r.resetLoader(e,c);var C=E.data;y.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(C.slice(0,16)),C=C.slice(16)),d({frag:e,part:null,payload:C,networkDetails:b})},onError:function(E,A,y,b){r.resetLoader(e,c),u(new Ze({type:Z.NETWORK_ERROR,details:N.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:H({url:i,data:void 0},E),error:new Error("HTTP Error "+E.code+" "+E.text),networkDetails:y,stats:b}))},onAbort:function(E,A,y){r.resetLoader(e,c),u(new Ze({type:Z.NETWORK_ERROR,details:N.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:y,stats:E}))},onTimeout:function(E,A,y){r.resetLoader(e,c),u(new Ze({type:Z.NETWORK_ERROR,details:N.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+p.timeout+"ms"),networkDetails:y,stats:E}))},onProgress:function(E,A,y,b){t&&t({frag:e,part:null,payload:y,networkDetails:b})}})}})},n.loadPart=function(e,t,r){var i=this;this.abort();var a=this.config,o=a.fLoader,l=a.loader;return new Promise(function(d,u){if(i.loader&&i.loader.destroy(),e.gap||t.gap)u(Be(e,t));else{var c=i.loader=e.loader=o?new o(a):new l(a),f=pe(e,t),v=Pn(a.fragLoadPolicy.default),p={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:me};t.stats=c.stats,c.load(f,p,{onSuccess:function(E,A,y,b){i.resetLoader(e,c),i.updateStatsFromPart(e,t);var C={frag:e,part:t,payload:E.data,networkDetails:b};r(C),d(C)},onError:function(E,A,y,b){i.resetLoader(e,c),u(new Ze({type:Z.NETWORK_ERROR,details:N.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:H({url:f.url,data:void 0},E),error:new Error("HTTP Error "+E.code+" "+E.text),networkDetails:y,stats:b}))},onAbort:function(E,A,y){e.stats.aborted=t.stats.aborted,i.resetLoader(e,c),u(new Ze({type:Z.NETWORK_ERROR,details:N.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:y,stats:E}))},onTimeout:function(E,A,y){i.resetLoader(e,c),u(new Ze({type:Z.NETWORK_ERROR,details:N.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+p.timeout+"ms"),networkDetails:y,stats:E}))}})}})},n.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,a=i.total;if(r.loaded+=i.loaded,a){var o=Math.round(e.duration/t.duration),l=Math.min(Math.round(r.loaded/a),o),d=(o-l)*Math.round(r.loaded/l);r.total=r.loaded+d}else r.total=Math.max(r.loaded,r.total);var u=r.loading,c=i.loading;u.start?u.first+=c.first-c.start:(u.start=c.start,u.first=c.first),u.end=c.end},n.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},s}();function pe(s,n){n===void 0&&(n=null);var e=n||s,t={frag:s,part:n,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},r=e.byteRangeStartOffset,i=e.byteRangeEndOffset;if(ie(r)&&ie(i)){var a,o=r,l=i;if(s.sn==="initSegment"&&((a=s.decryptdata)==null?void 0:a.method)==="AES-128"){var d=i-r;d%16&&(l=i+(16-d%16)),r!==0&&(t.resetIV=!0,o=r-16)}t.rangeStart=o,t.rangeEnd=l}return t}function Be(s,n){var e=new Error("GAP "+(s.gap?"tag":"attribute")+" found"),t={type:Z.MEDIA_ERROR,details:N.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return n&&(t.part=n),(n||s).stats.aborted=!0,new Ze(t)}var Ze=function(s){function n(e){var t;return(t=s.call(this,e.error.message)||this).data=void 0,t.data=e,t}return de(n,s),n}(Pe(Error)),gt=function(){function s(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var n=s.prototype;return n.abort=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.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=N.KEY_LOAD_ERROR),new Ze({type:Z.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:r,networkDetails:i})},n.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,a=e.cc,o=function(){var d=t[l];if(a<=d.cc&&(i==="initSegment"||d.sn==="initSegment"||i<d.sn))return r.emeController.selectKeySystemFormat(d).then(function(u){d.setKeyFormat(u)}),"break"},l=0;l<t.length&&o()!=="break";l++);},n.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(r){return t.loadInternal(e,r)}):this.loadInternal(e)},n.loadInternal=function(e,t){var r,i;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var o=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,N.KEY_LOAD_ERROR,o))}var l=a.uri;if(!l)return Promise.reject(this.createKeyLoadError(e,N.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+l+'"')));var d,u=this.keyUriToKeyInfo[l];if((r=u)!=null&&r.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if((i=u)!=null&&i.keyLoadPromise)switch((d=u.mediaKeySessionContext)==null?void 0:d.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise.then(function(c){return a.key=c.keyInfo.decryptdata.key,{frag:e,keyInfo:u}})}switch(u=this.keyUriToKeyInfo[l]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return a.keyFormat==="identity"?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,N.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+a.method+'"')))}},n.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then(function(a){return e.mediaKeySessionContext=a,r})).catch(function(a){throw e.keyLoadPromise=null,a})}return Promise.resolve(r)},n.loadKeyHTTP=function(e,t){var r=this,i=this.config,a=new i.loader(i);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise(function(o,l){var d={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},u=i.keyLoadPolicy.default,c={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:function(v,p,E,A){var y=E.frag,b=E.keyInfo,C=E.url;if(!y.decryptdata||b!==r.keyUriToKeyInfo[C])return l(r.createKeyLoadError(y,N.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),A));b.decryptdata.key=y.decryptdata.key=new Uint8Array(v.data),y.keyLoader=null,b.loader=null,o({frag:y,keyInfo:b})},onError:function(v,p,E,A){r.resetLoader(p),l(r.createKeyLoadError(t,N.KEY_LOAD_ERROR,new Error("HTTP Error "+v.code+" loading key "+v.text),E,H({url:d.url,data:void 0},v)))},onTimeout:function(v,p,E){r.resetLoader(p),l(r.createKeyLoadError(t,N.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),E))},onAbort:function(v,p,E){r.resetLoader(p),l(r.createKeyLoadError(t,N.INTERNAL_ABORTED,new Error("key loading aborted"),E))}};a.load(d,c,f)})},n.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url,a=r.loader;t.keyLoader===a&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],a&&a.destroy()},s}(),Lt=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}(),Ct={length:0,start:function(){return 0},end:function(){return 0}},ce=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(E,A){var y=E.start-A.start;return y||A.end-E.end});var r=[];if(t)for(var i=0;i<n.length;i++){var a=r.length;if(a){var o=r[a-1].end;n[i].start-o<t?n[i].end>o&&(r[a-1].end=n[i].end):r.push(n[i])}else r.push(n[i])}else r=n;for(var l,d=0,u=e,c=e,f=0;f<r.length;f++){var v=r[f].start,p=r[f].end;if(e+t>=v&&e<p)u=v,d=(c=p)-e;else if(e+t<v){l=v;break}}return{len:d,start:u||0,end:c||0,nextStart:l}},s.getBuffered=function(n){try{return n.buffered}catch(e){return P.log("failed to get media.buffered",e),Ct}},s}(),et=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 Ge(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 $(s,n){if(s){var e=s.start+n;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function he(s,n){for(var e=n.fragments,t=0,r=e.length;t<r;t++)$(e[t],s);n.fragmentHint&&$(n.fragmentHint,s),n.alignedSliding=!0}function te(s,n,e){n&&(function(t,r,i){if(function(o,l,d){return!(!l.details||!(d.endCC>d.startCC||o&&o.cc<d.startCC))}(t,i,r)){var a=function(o,l,d){var u=o.fragments,c=l.fragments;if(c.length&&u.length){var f=Ge(u,c[0].cc);if(f&&(!f||f.startPTS))return f;P.log("No frag in previous level to align on")}else P.log("No fragments to align")}(i.details,r);a&&ie(a.start)&&(P.log("Adjusting PTS using last level due to CC increase within current level "+r.url),he(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)&&(P.log("Adjusting PTS using programDateTime delta "+(a-i)+"ms, sliding:"+o.toFixed(3)+" "+t.url+" "),he(o,t))}}(e,n.details),e.alignedSliding||!n.details||e.skippedSegments||Cn(n.details,e))}function we(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=Ge(e,r.cc)||e[Math.round(e.length/2)-1],a=r.programDateTime,o=i.programDateTime;a!==null&&o!==null&&he((o-a)/1e3-(i.start-r.start),s)}}}var Me=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}(),st=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}(),Rt=function(){function s(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var n=s.prototype;return n.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},n.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],o=r[2],l=r[3],d=this.invSubMix,u=d[0],c=d[1],f=d[2],v=d[3],p=new Uint32Array(256),E=0,A=0,y=0;for(y=0;y<256;y++)p[y]=y<128?y<<1:y<<1^283;for(y=0;y<256;y++){var b=A^A<<1^A<<2^A<<3^A<<4;b=b>>>8^255&b^99,e[E]=b,t[b]=E;var C=p[E],I=p[C],O=p[I],B=257*p[b]^16843008*b;i[E]=B<<24|B>>>8,a[E]=B<<16|B>>>16,o[E]=B<<8|B>>>24,l[E]=B,B=16843009*O^65537*I^257*C^16843008*E,u[b]=B<<24|B>>>8,c[b]=B<<16|B>>>16,f[b]=B<<8|B>>>24,v[b]=B,E?(E=C^p[p[p[O^C]]],A^=p[p[A]]):E=A=1}},n.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var a=this.keySize=t.length;if(a!==4&&a!==6&&a!==8)throw new Error("Invalid aes key size="+a);var o,l,d,u,c=this.ksRows=4*(a+6+1),f=this.keySchedule=new Uint32Array(c),v=this.invKeySchedule=new Uint32Array(c),p=this.sBox,E=this.rcon,A=this.invSubMix,y=A[0],b=A[1],C=A[2],I=A[3];for(o=0;o<c;o++)o<a?d=f[o]=t[o]:(u=d,o%a==0?(u=p[(u=u<<8|u>>>24)>>>24]<<24|p[u>>>16&255]<<16|p[u>>>8&255]<<8|p[255&u],u^=E[o/a|0]<<24):a>6&&o%a==4&&(u=p[u>>>24]<<24|p[u>>>16&255]<<16|p[u>>>8&255]<<8|p[255&u]),f[o]=d=(f[o-a]^u)>>>0);for(l=0;l<c;l++)o=c-l,u=3&l?f[o]:f[o-4],v[l]=l<4||o<=4?u:y[p[u>>>24]]^b[p[u>>>16&255]]^C[p[u>>>8&255]]^I[p[255&u]],v[l]=v[l]>>>0}},n.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},n.decrypt=function(e,t,r){for(var i,a,o,l,d,u,c,f,v,p,E,A,y,b,C=this.keySize+6,I=this.invKeySchedule,O=this.invSBox,B=this.invSubMix,K=B[0],X=B[1],j=B[2],V=B[3],ee=this.uint8ArrayToUint32Array_(r),J=ee[0],ue=ee[1],ke=ee[2],le=ee[3],Te=new Int32Array(e),Ae=new Int32Array(Te.length),be=this.networkToHostOrderSwap;t<Te.length;){for(v=be(Te[t]),p=be(Te[t+1]),E=be(Te[t+2]),A=be(Te[t+3]),d=v^I[0],u=A^I[1],c=E^I[2],f=p^I[3],y=4,b=1;b<C;b++)i=K[d>>>24]^X[u>>16&255]^j[c>>8&255]^V[255&f]^I[y],a=K[u>>>24]^X[c>>16&255]^j[f>>8&255]^V[255&d]^I[y+1],o=K[c>>>24]^X[f>>16&255]^j[d>>8&255]^V[255&u]^I[y+2],l=K[f>>>24]^X[d>>16&255]^j[u>>8&255]^V[255&c]^I[y+3],d=i,u=a,c=o,f=l,y+=4;i=O[d>>>24]<<24^O[u>>16&255]<<16^O[c>>8&255]<<8^O[255&f]^I[y],a=O[u>>>24]<<24^O[c>>16&255]<<16^O[f>>8&255]<<8^O[255&d]^I[y+1],o=O[c>>>24]<<24^O[f>>16&255]<<16^O[d>>8&255]<<8^O[255&u]^I[y+2],l=O[f>>>24]<<24^O[d>>16&255]<<16^O[u>>8&255]<<8^O[255&c]^I[y+3],Ae[t]=be(i^J),Ae[t+1]=be(l^ue),Ae[t+2]=be(o^ke),Ae[t+3]=be(a^le),J=v,ue=p,ke=E,le=A,t+=4}return Ae.buffer},s}(),lt=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))?Kt(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=sr(o,e),this.remainderData=null);var l=this.getValidChunk(e);if(!l.length)return null;i&&(r=i);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new Rt),d.expandKey(t);var u=a;return this.currentResult=d.decrypt(l.buffer,0,r),this.currentIV=Kt(l,-16).buffer,u||null},n.webCryptoDecrypt=function(e,t,r){var i=this,a=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new st(a,t)),this.fastAesKey.expandKey().then(function(o){return a?(i.logOnce("WebCrypto AES decrypt"),new Me(a,new Uint8Array(r)).decrypt(e.buffer,o)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(o){return P.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=Kt(e,0,r),this.remainderData=Kt(e,r)),t},n.logOnce=function(e){this.logEnabled&&(P.log("[decrypter]: "+e),this.logEnabled=!1)},s}(),Et=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},Ve="STOPPED",fe="IDLE",Wt="KEY_LOADING",zt="FRAG_LOADING",Pt="FRAG_LOADING_WAITING_RETRY",tt="WAITING_TRACK",It="PARSING",hi="PARSED",qr="ENDED",Dr="ERROR",Gi="WAITING_INIT_PTS",fi="WAITING_LEVEL",ca=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=Ve,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=P.log.bind(P,a+":"),l.warn=P.warn.bind(P,a+":"),l.hls=t,l.fragmentLoader=new oe(t.config),l.keyLoader=i,l.fragmentTracker=r,l.config=t.config,l.decrypter=new lt(t.config),t.on(T.MANIFEST_LOADED,l.onManifestLoaded,function(d){if(d===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d}(l)),l}de(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();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=Ve},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 ce.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===Ve&&this.startLoad(a.startPosition)},e.onMediaDetaching=function(){var t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},e.onMediaSeeking=function(){var t=this.config,r=this.fragCurrent,i=this.media,a=this.mediaBuffer,o=this.state,l=i?i.currentTime:0,d=ce.bufferInfo(a||i,l,t.maxBufferHole);if(this.log("media seeking to "+(ie(l)?l.toFixed(3):l)+", state: "+o),this.state===qr)this.resetLoadingState();else if(r){var u=t.maxFragLookUpTolerance,c=r.start-u,f=r.start+r.duration+u;if(!d.len||f<d.start||c>d.end){var v=l>f;(l<c||v)&&(v&&r.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests()),this.resetLoadingState())}}i&&(this.fragmentTracker.removeFragmentsInRange(l,1/0,this.playlistType,!0),this.lastCurrentTime=l),this.loadedmetadata||d.len||(this.nextLoadPosition=this.startPosition=l),this.tickImmediate()},e.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},e.onManifestLoaded=function(t,r){this.startTimeOffset=r.startTimeOffset,this.initPTS=[]},e.onHandlerDestroying=function(){this.stopLoad(),s.prototype.onHandlerDestroying.call(this)},e.onHandlerDestroyed=function(){this.state=Ve,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===zt||!a.fragCurrent&&l===It)&&(a.fragmentTracker.removeFragment(t),a.state=fe):("payload"in o&&(a.log("Loaded fragment "+t.sn+" of level "+t.level),a.hls.trigger(T.FRAG_LOADED,o)),a._handleFragmentLoadComplete(o))}}).catch(function(o){a.state!==Ve&&a.state!==Dr&&(a.warn(o),a.resetFragmentLoading(t))})},e.clearTrackerIfNeeded=function(t){var r;if(this.fragmentTracker.getState(t)===x){var i=t.type,a=this.getFwdBufferInfo(this.mediaBuffer,i),o=Math.max(t.duration,a?a.len:this.config.maxBufferLength);this.reduceMaxBufferLength(o)&&this.fragmentTracker.removeFragment(t)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},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(T.BUFFER_FLUSHING,a)}},e._loadInitSegment=function(t,r){var i=this;this._doFragLoad(t,r).then(function(a){if(!a||i.fragContextChanged(t)||!i.levels)throw new Error("init load aborted");return a}).then(function(a){var o=i.hls,l=a.payload,d=t.decryptdata;if(l&&l.byteLength>0&&d&&d.key&&d.iv&&d.method==="AES-128"){var u=self.performance.now();return i.decrypter.decrypt(new Uint8Array(l),d.key.buffer,d.iv.buffer).catch(function(c){throw o.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:N.FRAG_DECRYPT_ERROR,fatal:!1,error:c,reason:c.message,frag:t}),c}).then(function(c){var f=self.performance.now();return o.trigger(T.FRAG_DECRYPTED,{frag:t,payload:c,stats:{tstart:u,tdecrypt:f}}),a.payload=c,a})}return a}).then(function(a){var o=i.fragCurrent,l=i.hls;if(!i.levels)throw new Error("init load aborted, missing levels");var d=t.stats;i.state=fe,r.fragmentError=0,t.data=new Uint8Array(a.payload),d.parsing.start=d.buffering.start=self.performance.now(),d.parsing.end=d.buffering.end=self.performance.now(),a.frag===o&&l.trigger(T.FRAG_BUFFERED,{stats:d,frag:o,part:null,id:t.type}),i.tick()}).catch(function(a){i.state!==Ve&&i.state!==Dr&&(i.warn(a),i.resetFragmentLoading(t))})},e.fragContextChanged=function(t){var r=this.fragCurrent;return!t||!r||t.level!==r.level||t.sn!==r.sn||t.urlId!==r.urlId},e.fragBufferedComplete=function(t,r){var i,a,o,l,d=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level+" (frag:["+((i=t.startPTS)!=null?i:NaN).toFixed(3)+"-"+((a=t.endPTS)!=null?a:NaN).toFixed(3)+"] > buffer:"+(d?Et(ce.getBuffered(d)):"(detached)")+")"),this.state=fe,d&&(!this.loadedmetadata&&t.type==qe&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},e.seekToStartPos=function(){},e._handleFragmentLoadComplete=function(t){var r=this.transmuxer;if(r){var i=t.frag,a=t.part,o=t.partsLoaded,l=!o||o.length===0||o.some(function(u){return!u}),d=new et(i.level,i.sn,i.stats.chunkCount+1,0,a?a.index:-1,!l);r.flush(d)}},e._handleFragmentLoadProgress=function(t){},e._doFragLoad=function(t,r,i,a){var o,l=this;i===void 0&&(i=null);var d=r==null?void 0:r.details;if(!this.levels||!d)throw new Error("frag load aborted, missing level"+(d?"":" detail")+"s");var u=null;if(!t.encrypted||(o=t.decryptdata)!=null&&o.key?!t.encrypted&&d.encryptedFragments.length&&this.keyLoader.loadClear(t,d.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+d.startSN+"-"+d.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=Wt,this.fragCurrent=t,u=this.keyLoader.load(t).then(function(y){if(!l.fragContextChanged(y.frag))return l.hls.trigger(T.KEY_LOADED,y),l.state===Wt&&(l.state=fe),y}),this.hls.trigger(T.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(u=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),i=Math.max(t.start,i||0),this.config.lowLatencyMode){var c=d.partList;if(c&&a){i>t.end&&d.fragmentHint&&(t=d.fragmentHint);var f=this.getNextPart(c,t,i);if(f>-1){var v,p=c[f];return this.log("Loading part sn: "+t.sn+" p: "+p.index+" cc: "+t.cc+" of playlist ["+d.startSN+"-"+d.endSN+"] parts [0-"+f+"-"+(c.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=p.start+p.duration,this.state=zt,v=u?u.then(function(y){return!y||l.fragContextChanged(y.frag)?null:l.doFragPartsLoad(t,p,r,a)}).catch(function(y){return l.handleFragLoadError(y)}):this.doFragPartsLoad(t,p,r,a).catch(function(y){return l.handleFragLoadError(y)}),this.hls.trigger(T.FRAG_LOADING,{frag:t,part:p,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):v}if(!t.url||this.loadedEndOfParts(c,i))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(d?"of ["+d.startSN+"-"+d.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),ie(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=zt;var E,A=this.config.progressive;return E=A&&u?u.then(function(y){return!y||l.fragContextChanged(y==null?void 0:y.frag)?null:l.fragmentLoader.load(t,a)}).catch(function(y){return l.handleFragLoadError(y)}):Promise.all([this.fragmentLoader.load(t,A?a:void 0),u]).then(function(y){var b=y[0];return!A&&b&&a&&a(b),b}).catch(function(y){return l.handleFragLoadError(y)}),this.hls.trigger(T.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):E},e.doFragPartsLoad=function(t,r,i,a){var o=this;return new Promise(function(l,d){var u,c=[],f=(u=i.details)==null?void 0:u.partList;(function v(p){o.fragmentLoader.loadPart(t,p,a).then(function(E){c[p.index]=E;var A=E.part;o.hls.trigger(T.FRAG_LOADED,E);var y=Gr(i,t.sn,p.index+1)||oi(f,t.sn,p.index+1);if(!y)return l({frag:t,part:A,partsLoaded:c});v(y)}).catch(d)})(r)})},e.handleFragLoadError=function(t){if("data"in t){var r=t.data;t.data&&r.details===N.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(T.ERROR,r)}else this.hls.trigger(T.ERROR,{type:Z.OTHER_ERROR,details:N.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},e._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(r&&this.state===It){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===Ve||this.state===Dr||(this.state=fe)},e.getCurrentContext=function(t){var r=this.levels,i=this.fragCurrent,a=t.level,o=t.sn,l=t.part;if(r==null||!r[a])return this.warn("Levels object was unset while buffering fragment "+o+" of level "+a+". The current chunk will not be buffered."),null;var d=r[a],u=l>-1?Gr(d,o,l):null,c=u?u.fragment:function(f,v,p){if(f==null||!f.details)return null;var E=f.details,A=E.fragments[v-E.startSN];return A||((A=E.fragmentHint)&&A.sn===v?A:v<E.startSN&&p&&p.sn===v?p:null)}(d,o,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:u,level:d}):null},e.bufferFragmentData=function(t,r,i,a){var o;if(t&&this.state===It){var l=t.data1,d=t.data2,u=l;if(l&&d&&(u=sr(l,d)),(o=u)!=null&&o.length){var c={type:t.type,frag:r,part:i,chunkMeta:a,parent:r.type,data:u};this.hls.trigger(T.BUFFER_APPENDING,c),t.dropped&&t.independent&&!i&&this.flushBufferGap(r)}}},e.flushBufferGap=function(t){var r=this.media;if(r)if(ce.isBuffered(r,r.currentTime)){var i=r.currentTime,a=ce.bufferInfo(r,i,0),o=t.duration,l=Math.min(2*this.config.maxFragLookUpTolerance,.25*o),d=Math.max(Math.min(t.start-l,a.end-l),i+l);t.start-d>l&&this.flushMainBuffer(d,t.start)}else this.flushMainBuffer(0,t.start)},e.getFwdBufferInfo=function(t,r){var i=this.getLoadPosition();return ie(i)?this.getFwdBufferInfoAtPos(t,i,r):null},e.getFwdBufferInfoAtPos=function(t,r,i){var a=this.config.maxBufferHole,o=ce.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 ce.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.getNextFragment=function(t,r){var i=r.fragments,a=i.length;if(!a)return null;var o,l=this.config,d=i[0].start;if(r.live){var u=l.initialLiveManifestSize;if(a<u)return this.warn("Not enough fragments to start playback (have: "+a+", need: "+u+")"),null;r.PTSKnown||this.startFragRequested||this.startPosition!==-1||(o=this.getInitialLiveFragment(r,i),this.startPosition=o?this.hls.liveSyncPosition||o.start:t)}else t<=d&&(o=i[0]);if(!o){var c=l.lowLatencyMode?r.partEnd:r.fragmentEnd;o=this.getFragmentAtPosition(t,c,r)}return this.mapToInitFragWhenRequired(o)},e.isLoopLoading=function(t,r){var i=this.fragmentTracker.getState(t);return(i===M||i===G&&!!t.gap)&&this.nextLoadPosition>r},e.getNextFragmentLoopLoading=function(t,r,i,a,o){var l=t.gap,d=this.getNextFragment(this.nextLoadPosition,r);if(d===null)return d;if(t=d,l&&t&&!t.gap&&i.nextStart){var u=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,a);if(u!==null&&i.len+u.len>=o)return this.log('buffer full after gaps in "'+a+'" playlist starting at sn: '+t.sn),null}return t},e.mapToInitFragWhenRequired=function(t){return t==null||!t.initSegment||t!=null&&t.initSegment.data||this.bitrateTest?t:t.initSegment},e.getNextPart=function(t,r,i){for(var a=-1,o=!1,l=!0,d=0,u=t.length;d<u;d++){var c=t[d];if(l=l&&!c.independent,a>-1&&i<c.start)break;var f=c.loaded;f?a=-1:(o||c.independent||l)&&c.fragment===r&&(a=d),o=f}return a},e.loadedEndOfParts=function(t,r){var i=t[t.length-1];return i&&r>i.start&&i.loaded},e.getInitialLiveFragment=function(t,r){var i=this.fragPrevious,a=null;if(i){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),a=function(u,c,f){if(c===null||!Array.isArray(u)||!u.length||!ie(c)||c<(u[0].programDateTime||0)||c>=(u[u.length-1].endProgramDateTime||0))return null;f=f||0;for(var v=0;v<u.length;++v){var p=u[v];if(ua(c,f,p))return p}return null}(r,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!a){var o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){var l=r[o-t.startSN];i.cc===l.cc&&(a=l,this.log("Live playlist, switching playlist, load frag with next SN: "+a.sn))}a||(a=function(u,c){return xn(u,function(f){return f.cc<c?1:f.cc>c?-1:0})}(r,i.cc),a&&this.log("Live playlist, switching playlist, load frag with same CC: "+a.sn))}}else{var d=this.hls.liveSyncPosition;d!==null&&(a=this.getFragmentAtPosition(d,this.bitrateTest?t.fragmentEnd:t.edge,t))}return a},e.getFragmentAtPosition=function(t,r,i){var a,o=this.config,l=this.fragPrevious,d=i.fragments,u=i.endSN,c=i.fragmentHint,f=o.maxFragLookUpTolerance,v=!!(o.lowLatencyMode&&i.partList&&c);if(v&&c&&!this.bitrateTest&&(d=d.concat(c),u=c.sn),a=t<r?Kr(l,d,t,t>r-f?0:f):d[d.length-1]){var p=a.sn-i.startSN,E=this.fragmentTracker.getState(a);if((E===M||E===G&&a.gap)&&(l=a),l&&a.sn===l.sn&&!v&&l&&a.level===l.level){var A=d[p+1];a=a.sn<u&&this.fragmentTracker.getState(A)!==M?A:null}}return a},e.synchronizeToLiveEdge=function(t){var r=this.config,i=this.media;if(i){var a=this.hls.liveSyncPosition,o=i.currentTime,l=t.fragments[0].start,d=t.edge,u=o>=l-r.maxFragLookUpTolerance&&o<=d;if(a!==null&&i.duration>a&&(o<a||!u)){var c=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;(!u&&i.readyState<4||o<d-c)&&(this.loadedmetadata||(this.nextLoadPosition=a),i.readyState&&(this.warn("Playback: "+o.toFixed(3)+" is located too far from the end of live sliding playlist: "+d+", reset currentTime to : "+a.toFixed(3)),i.currentTime=a))}}},e.alignPlaylists=function(t,r){var i=this.levels,a=this.levelLastLoaded,o=this.fragPrevious,l=a!==null?i[a]:null,d=t.fragments.length;if(!d)return this.warn("No fragments in live playlist"),0;var u=t.fragments[0].start,c=!r,f=t.alignedSliding&&ie(u);if(c||!f&&!u){te(o,l,t);var v=t.fragments[0].start;return this.log("Live playlist sliding: "+v.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+t.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+d),v}return u},e.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},e.setStartPosition=function(t,r){var i=this.startPosition;if(i<r&&(i=-1),i===-1||this.lastCurrentTime===-1){var a=this.startTimeOffset!==null,o=a?this.startTimeOffset:t.startTimeOffset;o!==null&&ie(o)?(i=r+o,o<0&&(i+=t.totalduration),i=Math.min(Math.max(r,i),r+t.totalduration),this.log("Start time offset "+o+" found in "+(a?"multivariant":"media")+" playlist, adjust startPosition to "+i),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||r:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i},e.getLoadPosition=function(){var t=this.media,r=0;return this.loadedmetadata&&t?r=t.currentTime:this.nextLoadPosition&&(r=this.nextLoadPosition),r},e.handleFragLoadAborted=function(t,r){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(r?" part"+r.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},e.resetFragmentLoading=function(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===Pt)||(this.state=fe)},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===N.FRAG_GAP;l&&this.fragmentTracker.fragBuffered(a,!0);var d=r.errorAction,u=d||{},c=u.action,f=u.retryCount,v=f===void 0?0:f,p=u.retryConfig;if(d&&c===ur&&p){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var E=Ni(p,v);this.warn("Fragment "+a.sn+" of "+t+" "+a.level+" errored with "+r.details+", retrying loading "+(v+1)+"/"+p.maxNumRetry+" in "+E+"ms"),d.resolved=!0,this.retryDate=self.performance.now()+E,this.state=Pt}else p&&d?(this.resetFragmentErrors(t),v<p.maxNumRetry?l||(d.resolved=!0):P.warn(r.details+" reached or exceeded max retry ("+v+")")):this.state=Dr;this.tickImmediate()}},e.reduceLengthAndFlushBuffer=function(t){if(this.state===It||this.state===hi){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===Vt&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Ve&&(this.state=fe)},e.afterBufferFlushed=function(t,r,i){if(t){var a=ce.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,a,i),this.state===qr&&this.resetLoadingState()}},e.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=fe},e.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var r=this.levels?this.levels[t].details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},e.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(t.level),this.resetLoadingState()},e.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},e.updateLevelTiming=function(t,r,i,a){var o,l=this,d=i.details;if(d){if(Object.keys(t.elementaryStreams).reduce(function(c,f){var v=t.elementaryStreams[f];if(v){var p=v.endPTS-v.startPTS;if(p<=0)return l.warn("Could not parse fragment "+t.sn+" "+f+" duration reliably ("+p+")"),c||!1;var E=a?0:In(d,t,v.startPTS,v.endPTS,v.startDTS,v.endDTS);return l.hls.trigger(T.LEVEL_PTS_UPDATED,{details:d,level:i,drift:E,type:f,frag:t,start:v.startPTS,end:v.endPTS}),!0}return c},!1))i.fragmentError=0;else if(((o=this.transmuxer)==null?void 0:o.error)===null){var u=new Error("Found no media in fragment "+t.sn+" of level "+i.id+" resetting transmuxer to fallback to playlist timing");if(this.warn(u.message),this.hls.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:N.FRAG_PARSING_ERROR,fatal:!1,error:u,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+i.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=hi,this.hls.trigger(T.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}(Lt);function ha(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}function gs(){return self.SourceBuffer||self.WebKitSourceBuffer}function dr(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 ms=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=sr(this.cachedData,e),this.cachedData=null);var r,i=Zt(e,0),a=i?i.length:0,o=this._audioTrack,l=this._id3Track,d=i?function(v){for(var p=ln(v),E=0;E<p.length;E++){var A=p[E];if(Fr(A))return dn(A)}}(i):void 0,u=e.length;for((this.basePTS===null||this.frameIndex===0&&ie(d))&&(this.basePTS=al(d,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:or,duration:Number.POSITIVE_INFINITY});a<u;){if(this.canParse(e,a)){var c=this.appendFrame(o,e,a);c?(this.frameIndex++,this.lastPTS=c.sample.pts,r=a+=c.length):a=u}else Mr(e,a)?(i=Zt(e,a),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:or,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===u&&r!==u){var f=Kt(e,r);this.cachedData?this.cachedData=sr(this.cachedData,f):this.cachedData=f}}return{audioTrack:o,videoTrack:dr(),id3Track:l,textTrack:dr()}},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:dr(),id3Track:this._id3Track,textTrack:dr()}},n.destroy=function(){},s}(),al=function(s,n,e){return ie(s)?90*s:9e4*n+(e?9e4*e.baseTime/e.timescale:0)};function ps(s,n){return s[n]===255&&(246&s[n+1])==240}function ys(s,n){return 1&s[n+1]?7:9}function fa(s,n){return(3&s[n+3])<<11|s[n+4]<<3|(224&s[n+5])>>>5}function On(s,n){return n+1<s.length&&ps(s,n)}function sl(s,n){if(On(s,n)){var e=ys(s,n);if(n+e>=s.length)return!1;var t=fa(s,n);if(t<=e)return!1;var r=n+t;return r===s.length||On(s,r)}return!1}function Es(s,n,e,t,r){if(!s.samplerate){var i=function(a,o,l,d){var u,c,f,v,p=navigator.userAgent.toLowerCase(),E=d,A=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];u=1+((192&o[l+2])>>>6);var y=(60&o[l+2])>>>2;if(!(y>A.length-1))return f=(1&o[l+2])<<2,f|=(192&o[l+3])>>>6,P.log("manifest codec:"+d+", ADTS type:"+u+", samplingIndex:"+y),/firefox/i.test(p)?y>=6?(u=5,v=new Array(4),c=y-3):(u=2,v=new Array(2),c=y):p.indexOf("android")!==-1?(u=2,v=new Array(2),c=y):(u=5,v=new Array(4),d&&(d.indexOf("mp4a.40.29")!==-1||d.indexOf("mp4a.40.5")!==-1)||!d&&y>=6?c=y-3:((d&&d.indexOf("mp4a.40.2")!==-1&&(y>=6&&f===1||/vivaldi/i.test(p))||!d&&f===1)&&(u=2,v=new Array(2)),c=y)),v[0]=u<<3,v[0]|=(14&y)>>1,v[1]|=(1&y)<<7,v[1]|=f<<3,u===5&&(v[1]|=(14&c)>>1,v[2]=(1&c)<<7,v[2]|=8,v[3]=0),{config:v,samplerate:A[y],channelCount:f,codec:"mp4a.40."+u,manifestCodec:E};a.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:N.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,P.log("parsed codec:"+s.codec+", rate:"+i.samplerate+", channels:"+i.channelCount)}}function Ts(s){return 9216e4/s}function bs(s,n,e,t,r){var i,a=t+r*Ts(s.samplerate),o=function(p,E){var A=ys(p,E);if(E+A<=p.length){var y=fa(p,E)-A;if(y>0)return{headerLength:A,frameLength:y}}}(n,e);if(o){var l=o.frameLength,d=o.headerLength,u=d+l,c=Math.max(0,e+u-n.length);c?(i=new Uint8Array(u-d)).set(n.subarray(e+d,n.length),0):i=n.subarray(e+d,e+u);var f={unit:i,pts:a};return c||s.samples.push(f),{sample:f,length:u,missing:c}}var v=n.length-e;return(i=new Uint8Array(v)).set(n.subarray(e,n.length),0),{sample:{unit:i,pts:a},length:v,missing:-1}}var ol=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}de(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=(Zt(t,0)||[]).length,i=t.length;r<i;r++)if(sl(t,r))return P.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)&&ps(i,a)&&fa(i,a)<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){Es(t,this.observer,r,i,t.manifestCodec);var a=bs(t,r,i,this.basePTS,this.frameIndex);if(a&&a.missing===0)return a},n}(ms),ll=/\/emsg[-/]ID3/i,ul=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=dr("video",1),o=this.audioTrack=dr("audio",1),l=this.txtTrack=dr("text",1);if(this.id3Track=dr("id3",1),this.timeOffset=0,e!=null&&e.byteLength){var d=ki(e);if(d.video){var u=d.video,c=u.id,f=u.timescale,v=u.codec;a.id=c,a.timescale=l.timescale=f,a.codec=v}if(d.audio){var p=d.audio,E=p.id,A=p.timescale,y=p.codec;o.id=E,o.timescale=A,o.codec=y}l.id=Si.text,a.sampleDuration=0,a.duration=o.duration=i}},n.resetContiguity=function(){},s.probe=function(e){return Ue(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=sr(this.remainderData,e));var o=function(d){var u={valid:null,remainder:null},c=Ue(d,["moof"]);if(!c)return u;if(c.length<2)return u.remainder=d,u;var f=c[c.length-1];return u.valid=Kt(d,0,f.byteOffset-8),u.remainder=Kt(d,f.byteOffset-8),u}(r);this.remainderData=o.remainder,i.samples=o.valid||new Uint8Array}else i.samples=r;var l=this.extractID3Track(i,t);return a.samples=gn(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=gn(e,t),{videoTrack:t,audioTrack:dr(),id3Track:i,textTrack:dr()}},n.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=Ue(e.samples,["emsg"]);i&&i.forEach(function(a){var o=function(c){var f=c[0],v="",p="",E=0,A=0,y=0,b=0,C=0,I=0;if(f===0){for(;vt(c.subarray(I,I+1))!=="\0";)v+=vt(c.subarray(I,I+1)),I+=1;for(v+=vt(c.subarray(I,I+1)),I+=1;vt(c.subarray(I,I+1))!=="\0";)p+=vt(c.subarray(I,I+1)),I+=1;p+=vt(c.subarray(I,I+1)),I+=1,E=Re(c,12),A=Re(c,16),b=Re(c,20),C=Re(c,24),I=28}else if(f===1){E=Re(c,I+=4);var O=Re(c,I+=4),B=Re(c,I+=4);for(I+=4,y=Math.pow(2,32)*O+B,Number.isSafeInteger(y)||(y=Number.MAX_SAFE_INTEGER,P.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),b=Re(c,I),C=Re(c,I+=4),I+=4;vt(c.subarray(I,I+1))!=="\0";)v+=vt(c.subarray(I,I+1)),I+=1;for(v+=vt(c.subarray(I,I+1)),I+=1;vt(c.subarray(I,I+1))!=="\0";)p+=vt(c.subarray(I,I+1)),I+=1;p+=vt(c.subarray(I,I+1)),I+=1}return{schemeIdUri:v,value:p,timeScale:E,presentationTime:y,presentationTimeDelta:A,eventDuration:b,id:C,payload:c.subarray(I,c.byteLength)}}(a);if(ll.test(o.schemeIdUri)){var l=ie(o.presentationTime)?o.presentationTime/o.timeScale:t+o.presentationTimeDelta/o.timeScale,d=o.eventDuration===4294967295?Number.POSITIVE_INFINITY:o.eventDuration/o.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);var u=o.payload;r.samples.push({data:u,len:u.byteLength,dts:l,pts:l,type:Ur,duration:d})}})}return r},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},n.destroy=function(){},s}(),Mn=null,dl=[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],cl=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],hl=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],fl=[0,1,1,4];function _s(s,n,e,t,r){if(!(e+24>n.length)){var i=Ss(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 Ss(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*dl[14*(e===3?3-t:t===3?3:4)+r-1],d=cl[3*(e===3?0:e===2?1:2)+i],u=o===3?1:2,c=hl[e][t],f=fl[t],v=8*c*f,p=Math.floor(c*l/d+a)*f;if(Mn===null){var E=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Mn=E?parseInt(E[1]):0}return!!Mn&&Mn<=87&&t===2&&l>=224e3&&o===0&&(s[n+3]=128|s[n+3]),{sampleRate:d,channelCount:u,frameLength:p,samplesPerFrame:v}}}function va(s,n){return s[n]===255&&(224&s[n+1])==224&&(6&s[n+1])!=0}function As(s,n){return n+1<s.length&&va(s,n)}function vl(s,n){if(n+1<s.length&&va(s,n)){var e=Ss(s,n),t=4;e!=null&&e.frameLength&&(t=e.frameLength);var r=n+t;return r===s.length||As(s,r)}return!1}var ks=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&&P.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},n.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!=0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},n.skipUEG=function(){this.skipBits(1+this.skipLZ())},n.skipEG=function(){this.skipBits(1+this.skipLZ())},n.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},n.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},n.readBoolean=function(){return this.readBits(1)===1},n.readUByte=function(){return this.readBits(8)},n.readUShort=function(){return this.readBits(16)},n.readUInt=function(){return this.readBits(32)},n.skipScalingList=function(e){for(var t=8,r=8,i=0;i<e;i++)r!==0&&(r=(t+this.readEG()+256)%256),t=r===0?t:r},n.readSPS=function(){var e,t,r,i=0,a=0,o=0,l=0,d=this.readUByte.bind(this),u=this.readBits.bind(this),c=this.readUEG.bind(this),f=this.readBoolean.bind(this),v=this.skipBits.bind(this),p=this.skipEG.bind(this),E=this.skipUEG.bind(this),A=this.skipScalingList.bind(this);d();var y=d();if(u(5),v(3),d(),E(),y===100||y===110||y===122||y===244||y===44||y===83||y===86||y===118||y===128){var b=c();if(b===3&&v(1),E(),E(),v(1),f())for(t=b!==3?8:12,r=0;r<t;r++)f()&&A(r<6?16:64)}E();var C=c();if(C===0)c();else if(C===1)for(v(1),p(),p(),e=c(),r=0;r<e;r++)p();E(),v(1);var I=c(),O=c(),B=u(1);B===0&&v(1),v(1),f()&&(i=c(),a=c(),o=c(),l=c());var K=[1,1];if(f()&&f())switch(d()){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=[d()<<8|d(),d()<<8|d()]}return{width:Math.ceil(16*(I+1)-2*i-2*a),height:(2-B)*(O+1)*16-(B?2:4)*(o+l),pixelRatio:K}},n.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},s}(),gl=function(){function s(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new lt(t,{removePKCS7Padding:!1})}var n=s.prototype;return n.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},n.decryptAacSample=function(e,t,r){var i=this,a=e[t].unit;if(!(a.length<=16)){var o=a.subarray(16,a.length-a.length%16),l=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(l).then(function(d){var u=new Uint8Array(d);a.set(u,16),i.decrypter.isSync()||i.decryptAacSamples(e,t+1,r)})}},n.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},n.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r},n.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)e.set(r.subarray(i,i+16),a);return e},n.decryptAvcSample=function(e,t,r,i,a){var o=this,l=wi(a.data),d=this.getAvcEncryptedData(l);this.decryptBuffer(d.buffer).then(function(u){a.data=o.getAvcDecryptedUnit(l,u),o.decrypter.isSync()||o.decryptAvcSamples(e,t,r+1,i)})},n.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var o=a[r];if(!(o.data.length<=48||o.type!==1&&o.type!==5||(this.decryptAvcSample(e,t,r,i,o),this.decrypter.isSync())))return}}},s}(),Ut=188,ml=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&&P.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-Ut)+1,i=0;i<r;){for(var a=!1,o=i;o<t&&e[o]===71;o+=Ut)if(a||ga(e,o)!==0||(a=!0),a&&o+Ut>r)return i;i++}return-1},s.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Si[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var n=s.prototype;return n.resetInitSegment=function(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=s.createTrack("video"),this._audioTrack=s.createTrack("audio",i),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=i},n.resetTimeStamp=function(){},n.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},n.demux=function(e,t,r,i){var a;r===void 0&&(r=!1),i===void 0&&(i=!1),r||(this.sampleAes=null);var o=this._avcTrack,l=this._audioTrack,d=this._id3Track,u=this._txtTrack,c=o.pid,f=o.pesData,v=l.pid,p=d.pid,E=l.pesData,A=d.pesData,y=null,b=this.pmtParsed,C=this._pmtId,I=e.length;if(this.remainderData&&(I=(e=sr(this.remainderData,e)).length,this.remainderData=null),I<Ut&&!i)return this.remainderData=e,{audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};var O=Math.max(0,s.syncOffset(e));(I-=(I-O)%Ut)<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,I,e.buffer.byteLength-I));for(var B=0,K=O;K<I;K+=Ut)if(e[K]===71){var X=!!(64&e[K+1]),j=ga(e,K),V=void 0;if((48&e[K+3])>>4>1){if((V=K+5+e[K+4])===K+Ut)continue}else V=K+4;switch(j){case c:X&&(f&&(a=vi(f))&&this.parseAVCPES(o,u,a,!1),f={data:[],size:0}),f&&(f.data.push(e.subarray(V,K+Ut)),f.size+=K+Ut-V);break;case v:if(X){if(E&&(a=vi(E)))switch(l.segmentCodec){case"aac":this.parseAACPES(l,a);break;case"mp3":this.parseMPEGPES(l,a)}E={data:[],size:0}}E&&(E.data.push(e.subarray(V,K+Ut)),E.size+=K+Ut-V);break;case p:X&&(A&&(a=vi(A))&&this.parseID3PES(d,a),A={data:[],size:0}),A&&(A.data.push(e.subarray(V,K+Ut)),A.size+=K+Ut-V);break;case 0:X&&(V+=e[V]+1),C=this._pmtId=pl(e,V);break;case C:X&&(V+=e[V]+1);var ee=yl(e,V,this.typeSupported,r);(c=ee.avc)>0&&(o.pid=c),(v=ee.audio)>0&&(l.pid=v,l.segmentCodec=ee.segmentCodec),(p=ee.id3)>0&&(d.pid=p),y===null||b||(P.warn("MPEG-TS PMT found at "+K+" after unknown PID '"+y+"'. Backtracking to sync byte @"+O+" to parse all TS packets."),y=null,K=O-188),b=this.pmtParsed=!0;break;case 17:case 8191:break;default:y=j}}else B++;if(B>0){var J=new Error("Found "+B+" TS packet/s that do not start with 0x47");this.observer.emit(T.ERROR,T.ERROR,{type:Z.MEDIA_ERROR,details:N.FRAG_PARSING_ERROR,fatal:!1,error:J,reason:J.message})}o.pesData=f,l.pesData=E,d.pesData=A;var ue={audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};return i&&this.extractRemainingSamples(ue),ue},n.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},n.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,a=e.id3Track,o=e.textTrack,l=i.pesData,d=r.pesData,u=a.pesData;if(l&&(t=vi(l))?(this.parseAVCPES(i,o,t,!0),i.pesData=null):i.pesData=l,d&&(t=vi(d))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else d!=null&&d.size&&P.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=d;u&&(t=vi(u))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=u},n.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),a=this.sampleAes=new gl(this.observer,this.config,t);return this.decrypt(i,a)},n.decrypt=function(e,t){return new Promise(function(r){var i=e.audioTrack,a=e.videoTrack;i.samples&&i.segmentCodec==="aac"?t.decryptAacSamples(i.samples,0,function(){a.samples?t.decryptAvcSamples(a.samples,0,0,function(){r(e)}):r(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,function(){r(e)})})},n.destroy=function(){this._duration=0},n.parseAVCPES=function(e,t,r,i){var a,o=this,l=this.parseAVCNALu(e,r.data),d=this.avcSample,u=!1;r.data=null,d&&l.length&&!e.audFound&&(ma(d,e),d=this.avcSample=Fn(!1,r.pts,r.dts,"")),l.forEach(function(c){switch(c.type){case 1:a=!0,d||(d=o.avcSample=Fn(!0,r.pts,r.dts,"")),d.frame=!0;var f=c.data;if(u&&f.length>4){var v=new ks(f).readSliceType();v!==2&&v!==4&&v!==7&&v!==9||(d.key=!0)}break;case 5:a=!0,d||(d=o.avcSample=Fn(!0,r.pts,r.dts,"")),d.key=!0,d.frame=!0;break;case 6:a=!0,Ri(c.data,1,r.pts,t.samples);break;case 7:if(a=!0,u=!0,!e.sps){var p=c.data,E=new ks(p).readSPS();e.width=E.width,e.height=E.height,e.pixelRatio=E.pixelRatio,e.sps=[p],e.duration=o._duration;for(var A=p.subarray(1,4),y="avc1.",b=0;b<3;b++){var C=A[b].toString(16);C.length<2&&(C="0"+C),y+=C}e.codec=y}break;case 8:a=!0,e.pps||(e.pps=[c.data]);break;case 9:a=!1,e.audFound=!0,d&&ma(d,e),d=o.avcSample=Fn(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,d&&(d.debug+="unknown NAL "+c.type+" ")}d&&a&&d.units.push(c)}),i&&d&&(ma(d,e),this.avcSample=null)},n.getLastNalUnit=function(e){var t,r,i=this.avcSample;if(i&&i.units.length!==0||(i=e[e.length-1]),(t=i)!=null&&t.units){var a=i.units;r=a[a.length-1]}return r},n.parseAVCNALu=function(e,t){var r,i,a=t.byteLength,o=e.naluState||0,l=o,d=[],u=0,c=-1,f=0;for(o===-1&&(c=0,f=31&t[0],o=0,u=1);u<a;)if(r=t[u++],o)if(o!==1)if(r)if(r===1){if(c>=0){var v={data:t.subarray(c,u-o-1),type:f};d.push(v)}else{var p=this.getLastNalUnit(e.samples);if(p&&(l&&u<=4-l&&p.state&&(p.data=p.data.subarray(0,p.data.byteLength-l)),(i=u-o-1)>0)){var E=new Uint8Array(p.data.byteLength+i);E.set(p.data,0),E.set(t.subarray(0,i),p.data.byteLength),p.data=E,p.state=0}}u<a?(c=u,f=31&t[u],o=0):o=-1}else o=0;else o=3;else o=r?0:2;else o=r?0:1;if(c>=0&&o>=0){var A={data:t.subarray(c,a),type:f,state:o};d.push(A)}if(d.length===0){var y=this.getLastNalUnit(e.samples);if(y){var b=new Uint8Array(y.data.byteLength+t.byteLength);b.set(y.data,0),b.set(t,y.data.byteLength),y.data=b}}return e.naluState=o,d},n.parseAACPES=function(e,t){var r,i,a,o=0,l=this.aacOverFlow,d=t.data;if(l){this.aacOverFlow=null;var u=l.missing,c=l.sample.unit.byteLength;if(u===-1){var f=new Uint8Array(c+d.byteLength);f.set(l.sample.unit,0),f.set(d,c),d=f}else{var v=c-u;l.sample.unit.set(d.subarray(0,u),v),e.samples.push(l.sample),o=l.missing}}for(r=o,i=d.length;r<i-1&&!On(d,r);r++);if(r!==o){var p,E=r<i-1;p=E?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES";var A=new Error(p);if(P.warn("parsing error: "+p),this.observer.emit(T.ERROR,T.ERROR,{type:Z.MEDIA_ERROR,details:N.FRAG_PARSING_ERROR,fatal:!1,levelRetry:E,error:A,reason:p}),!E)return}if(Es(e,this.observer,d,r,this.audioCodec),t.pts!==void 0)a=t.pts;else{if(!l)return void P.warn("[tsdemuxer]: AAC PES unknown PTS");var y=Ts(e.samplerate);a=l.sample.pts+y}for(var b,C=0;r<i;){if(r+=(b=bs(e,d,r,a,C)).length,b.missing){this.aacOverFlow=b;break}for(C++;r<i-1&&!On(d,r);r++);}},n.parseMPEGPES=function(e,t){var r=t.data,i=r.length,a=0,o=0,l=t.pts;if(l!==void 0)for(;o<i;)if(As(r,o)){var d=_s(e,r,o,l,a);if(!d)break;o+=d.length,a++}else o++;else P.warn("[tsdemuxer]: MPEG PES unknown PTS")},n.parseID3PES=function(e,t){if(t.pts!==void 0){var r=W({},t,{type:this._avcTrack?Ur:or,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else P.warn("[tsdemuxer]: ID3 PES unknown PTS")},s}();function Fn(s,n,e,t){return{key:s,frame:!1,pts:n,dts:e,units:[],debug:t,length:0}}function ga(s,n){return((31&s[n+1])<<8)+s[n+2]}function pl(s,n){return(31&s[n+10])<<8|s[n+11]}function yl(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=ga(s,n);switch(s[n]){case 207:if(!t){P.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){P.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?P.log("MPEG audio found, not supported in this browser"):r.audio===-1&&(r.audio=a,r.segmentCodec="mp3");break;case 36:P.warn("Unsupported HEVC stream type found")}n+=5+((15&s[n+3])<<8|s[n+4])}return r}function vi(s){var n,e,t,r,i,a=0,o=s.data;if(!s||s.size===0)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(((n=o[0])[0]<<16)+(n[1]<<8)+n[2]===1){if((e=(n[4]<<8)+n[5])&&e>s.size-6)return null;var d=n[7];192&d&&(r=536870912*(14&n[9])+4194304*(255&n[10])+16384*(254&n[11])+128*(255&n[12])+(254&n[13])/2,64&d?r-(i=536870912*(14&n[14])+4194304*(255&n[15])+16384*(254&n[16])+128*(255&n[17])+(254&n[18])/2)>54e5&&(P.warn(Math.round((r-i)/9e4)+"s delta between PTS and DTS, align them"),r=i):i=r);var u=(t=n[8])+9;if(s.size<=u)return null;s.size-=u;for(var c=new Uint8Array(s.size),f=0,v=o.length;f<v;f++){var p=(n=o[f]).byteLength;if(u){if(u>p){u-=p;continue}n=n.subarray(u),p-=u,u=0}c.set(n,a),a+=p}return e&&(e-=t+3),{data:c,pts:r,dts:i,len:e}}return null}function ma(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&&P.log(s.pts+"/"+s.dts+":"+s.debug)}var El=function(s){function n(){return s.apply(this,arguments)||this}de(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=(Zt(t,0)||[]).length,i=t.length;r<i;r++)if(vl(t,r))return P.log("MPEG Audio sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return va(i,a)&&4<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){if(this.basePTS!==null)return _s(t,r,i,this.basePTS,this.frameIndex)},n}(ms),Ls=function(){function s(){}return s.getSilentFrame=function(n,e){if(n==="mp4a.40.2"){if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},s}(),Ir=Math.pow(2,32)-1,Tt=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/(Ir+1)),r=Math.floor(e%(Ir+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/(Ir+1)),r=Math.floor(e%(Ir+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return s.box(s.types.mvhd,i)},s.sdtp=function(n){var e,t,r=n.samples||[],i=new Uint8Array(4+r.length);for(e=0;e<r.length;e++)t=r[e].flags,i[e+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return s.box(s.types.sdtp,i)},s.stbl=function(n){return s.box(s.types.stbl,s.stsd(n),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))},s.avc1=function(n){var e,t,r,i=[],a=[];for(e=0;e<n.sps.length;e++)r=(t=n.sps[e]).byteLength,i.push(r>>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(e=0;e<n.pps.length;e++)r=(t=n.pps[e]).byteLength,a.push(r>>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(t));var o=s.box(s.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|n.sps.length].concat(i).concat([n.pps.length]).concat(a))),l=n.width,d=n.height,u=n.pixelRatio[0],c=n.pixelRatio[1];return s.box(s.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,d>>8&255,255&d,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,c>>24,c>>16&255,c>>8&255,255&c])))},s.esds=function(n){var e=n.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(n.config).concat([6,1,2]))},s.mp4a=function(n){var e=n.samplerate;return s.box(s.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),s.box(s.types.esds,s.esds(n)))},s.mp3=function(n){var e=n.samplerate;return s.box(s.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))},s.stsd=function(n){return n.type==="audio"?n.segmentCodec==="mp3"&&n.codec==="mp3"?s.box(s.types.stsd,s.STSD,s.mp3(n)):s.box(s.types.stsd,s.STSD,s.mp4a(n)):s.box(s.types.stsd,s.STSD,s.avc1(n))},s.tkhd=function(n){var e=n.id,t=n.duration*n.timescale,r=n.width,i=n.height,a=Math.floor(t/(Ir+1)),o=Math.floor(t%(Ir+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/(Ir+1)),a=Math.floor(e%(Ir+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a])),s.trun(n,t.length+16+20+8+16+8+8),t)},s.trak=function(n){return n.duration=n.duration||4294967295,s.box(s.types.trak,s.tkhd(n),s.mdia(n))},s.trex=function(n){var e=n.id;return s.box(s.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},s.trun=function(n,e){var t,r,i,a,o,l,d=n.samples||[],u=d.length,c=12+16*u,f=new Uint8Array(c);for(e+=8+c,f.set([n.type==="video"?1:0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),t=0;t<u;t++)i=(r=d[t]).duration,a=r.size,o=r.flags,l=r.cts,f.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*t);return s.box(s.types.trun,f)},s.initSegment=function(n){s.types||s.init();var e=s.moov(n),t=new Uint8Array(s.FTYP.byteLength+e.byteLength);return t.set(s.FTYP),t.set(e,s.FTYP.byteLength),t},s}();function pa(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 Hi(s,n){return n===void 0&&(n=!1),pa(s,1e3,1/9e4,n)}Tt.types=void 0,Tt.HDLR_TYPES=void 0,Tt.STTS=void 0,Tt.STSC=void 0,Tt.STCO=void 0,Tt.STSZ=void 0,Tt.VMHD=void 0,Tt.SMHD=void 0,Tt.STSD=void 0,Tt.FTYP=void 0,Tt.DINF=void 0;var Nn=null,ya=null,Ea=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,Nn===null){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Nn=a?parseInt(a[1]):0}if(ya===null){var o=navigator.userAgent.match(/Safari\/(\d+)/i);ya=o?parseInt(o[1]):0}}var n=s.prototype;return n.destroy=function(){},n.resetTimeStamp=function(e){P.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},n.resetNextTimestamp=function(){P.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},n.resetInitSegment=function(){P.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},n.getVideoStartPts=function(e){var t=!1,r=e.reduce(function(i,a){var o=a.pts-i;return o<-4294967296?(t=!0,Xt(i,a.pts)):o>0?i:a.pts},e[0].pts);return t&&P.debug("PTS rollover detected"),r},n.remux=function(e,t,r,i,a,o,l,d){var u,c,f,v,p,E,A=a,y=a,b=e.pid>-1,C=t.pid>-1,I=t.samples.length,O=e.samples.length>0,B=l&&I>0||I>1;if((!b||O)&&(!C||B)||this.ISGenerated||l){this.ISGenerated||(f=this.generateIS(e,t,a,o));var K,X=this.isVideoContiguous,j=-1;if(B&&(j=function(ke){for(var le=0;le<ke.length;le++)if(ke[le].key)return le;return-1}(t.samples),!X&&this.config.forceKeyFrameOnDiscontinuity))if(E=!0,j>0){P.warn("[mp4-remuxer]: Dropped "+j+" out of "+I+" video samples due to a missing keyframe");var V=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(j),t.dropped+=j,K=y+=(t.samples[0].pts-V)/t.inputTimeScale}else j===-1&&(P.warn("[mp4-remuxer]: No keyframe found out of "+I+" video samples"),E=!1);if(this.ISGenerated){if(O&&B){var ee=this.getVideoStartPts(t.samples),J=(Xt(e.samples[0].pts,ee)-ee)/t.inputTimeScale;A+=Math.max(0,J),y+=Math.max(0,-J)}if(O){if(e.samplerate||(P.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),f=this.generateIS(e,t,a,o)),c=this.remuxAudio(e,A,this.isAudioContiguous,o,C||B||d===Vt?y:void 0),B){var ue=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(P.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),f=this.generateIS(e,t,a,o)),u=this.remuxVideo(t,y,X,ue)}}else B&&(u=this.remuxVideo(t,y,X,0));u&&(u.firstKeyFrame=j,u.independent=j!==-1,u.firstKeyFramePTS=K)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(p=Rs(r,a,this._initPTS,this._initDTS)),i.samples.length&&(v=ws(i,a,this._initPTS))),{audio:c,video:u,initSegment:f,independent:E,text:v,id3:p}},n.generateIS=function(e,t,r,i){var a,o,l,d=e.samples,u=t.samples,c=this.typeSupported,f={},v=this._initPTS,p=!v||i,E="audio/mp4";if(p&&(a=o=1/0),e.config&&d.length&&(e.timescale=e.samplerate,e.segmentCodec==="mp3"&&(c.mpeg?(E="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3")),f.audio={id:"audio",container:E,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&c.mpeg?new Uint8Array(0):Tt.initSegment([e]),metadata:{channelCount:e.channelCount}},p&&(l=e.inputTimeScale,v&&l===v.timescale?p=!1:a=o=d[0].pts-Math.round(l*r))),t.sps&&t.pps&&u.length&&(t.timescale=t.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Tt.initSegment([t]),metadata:{width:t.width,height:t.height}},p))if(l=t.inputTimeScale,v&&l===v.timescale)p=!1;else{var A=this.getVideoStartPts(u),y=Math.round(l*r);o=Math.min(o,Xt(u[0].dts,A)-y),a=Math.min(a,A-y)}if(Object.keys(f).length)return this.ISGenerated=!0,p?(this._initPTS={baseTime:a,timescale:l},this._initDTS={baseTime:o,timescale:l}):a=l=void 0,{tracks:f,initPTS:a,timescale:l}},n.remuxVideo=function(e,t,r,i){var a,o,l=e.inputTimeScale,d=e.samples,u=[],c=d.length,f=this._initPTS,v=this.nextAvcDts,p=8,E=this.videoSampleDuration,A=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,b=!1;r&&v!==null||(v=t*l-(d[0].pts-Xt(d[0].dts,d[0].pts)));for(var C=f.baseTime*l/f.timescale,I=0;I<c;I++){var O=d[I];O.pts=Xt(O.pts-C,v),O.dts=Xt(O.dts-C,v),O.dts<d[I>0?I-1:I].dts&&(b=!0)}b&&d.sort(function(jn,uo){var pu=jn.dts-uo.dts,yu=jn.pts-uo.pts;return pu||yu}),a=d[0].dts;var B=(o=d[d.length-1].dts)-a,K=B?Math.round(B/(c-1)):E||e.inputTimeScale/30;if(r){var X=a-v,j=X>K,V=X<-1;if((j||V)&&(j?P.warn("AVC: "+Hi(X,!0)+" ms ("+X+"dts) hole between fragments detected, filling it"):P.warn("AVC: "+Hi(-X,!0)+" ms ("+X+"dts) overlapping between fragments detected"),!V||v>d[0].pts)){a=v;var ee=d[0].pts-X;d[0].dts=a,d[0].pts=ee,P.log("Video: First PTS/DTS adjusted: "+Hi(ee,!0)+"/"+Hi(a,!0)+", delta: "+Hi(X,!0)+" ms")}}a=Math.max(0,a);for(var J=0,ue=0,ke=0;ke<c;ke++){for(var le=d[ke],Te=le.units,Ae=Te.length,be=0,Ie=0;Ie<Ae;Ie++)be+=Te[Ie].data.length;ue+=be,J+=Ae,le.length=be,le.dts=Math.max(le.dts,a),A=Math.min(le.pts,A),y=Math.max(le.pts,y)}o=d[c-1].dts;var Fe,He=ue+4*J+8;try{Fe=new Uint8Array(He)}catch(jn){return void this.observer.emit(T.ERROR,T.ERROR,{type:Z.MUX_ERROR,details:N.REMUX_ALLOC_ERROR,fatal:!1,error:jn,bytes:He,reason:"fail allocating video mdat "+He})}var We=new DataView(Fe.buffer);We.setUint32(0,He),Fe.set(Tt.types.mdat,4);for(var xt=!1,mt=Number.POSITIVE_INFINITY,rr=Number.POSITIVE_INFINITY,Jt=Number.NEGATIVE_INFINITY,$t=Number.NEGATIVE_INFINITY,pt=0;pt<c;pt++){for(var bt=d[pt],cr=bt.units,Cr=0,Bt=0,Ki=cr.length;Bt<Ki;Bt++){var qi=cr[Bt],qn=qi.data,pi=qi.data.byteLength;We.setUint32(p,pi),p+=4,Fe.set(qn,p),p+=pi,Cr+=4+pi}var Wr=void 0;if(pt<c-1)E=d[pt+1].dts-bt.dts,Wr=d[pt+1].pts-bt.pts;else{var ji=this.config,br=pt>0?bt.dts-d[pt-1].dts:K;if(Wr=pt>0?bt.pts-d[pt-1].pts:K,ji.stretchShortVideoTrack&&this.nextAudioPts!==null){var hu=Math.floor(ji.maxBufferHole*l),Ga=(i?A+i*l:this.nextAudioPts)-bt.pts;Ga>hu?((E=Ga-br)<0?E=br:xt=!0,P.log("[mp4-remuxer]: It is approximately "+Ga/90+" ms to the next segment; using duration "+E/90+" ms for the last video frame.")):E=br}else E=br}var fu=Math.round(bt.pts-bt.dts);mt=Math.min(mt,E),Jt=Math.max(Jt,E),rr=Math.min(rr,Wr),$t=Math.max($t,Wr),u.push(new Ds(bt.key,E,Cr,fu))}if(u.length){if(Nn){if(Nn<70){var so=u[0].flags;so.dependsOn=2,so.isNonSync=0}}else if(ya&&$t-rr<Jt-mt&&K/Jt<.025&&u[0].cts===0){P.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Ha=a,ir=0,oo=u.length;ir<oo;ir++){var lo=Ha+u[ir].duration,vu=Ha+u[ir].cts;if(ir<oo-1){var gu=lo+u[ir+1].cts;u[ir].duration=gu-vu}else u[ir].duration=ir?u[ir-1].duration:K;u[ir].cts=0,Ha=lo}}}E=xt||!E?K:E,this.nextAvcDts=v=o+E,this.videoSampleDuration=E,this.isVideoContiguous=!0;var mu={data1:Tt.moof(e.sequenceNumber++,a,W({},e,{samples:u})),data2:Fe,startPTS:A/l,endPTS:(y+E)/l,startDTS:a/l,endDTS:v/l,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,mu},n.remuxAudio=function(e,t,r,i,a){var o=e.inputTimeScale,l=o/(e.samplerate?e.samplerate:o),d=e.segmentCodec==="aac"?1024:1152,u=d*l,c=this._initPTS,f=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,v=[],p=a!==void 0,E=e.samples,A=f?0:8,y=this.nextAudioPts||-1,b=t*o,C=c.baseTime*o/c.timescale;if(this.isAudioContiguous=r=r||E.length&&y>0&&(i&&Math.abs(b-y)<9e3||Math.abs(Xt(E[0].pts-C,b)-y)<20*u),E.forEach(function(Bt){Bt.pts=Xt(Bt.pts-C,b)}),!r||y<0){if(E=E.filter(function(Bt){return Bt.pts>=0}),!E.length)return;y=a===0?0:i&&!p?Math.max(0,b):E[0].pts}if(e.segmentCodec==="aac")for(var I=this.config.maxAudioFramesDrift,O=0,B=y;O<E.length;O++){var K=E[O],X=K.pts,j=X-B,V=Math.abs(1e3*j/o);if(j<=-I*u&&p)O===0&&(P.warn("Audio frame @ "+(X/o).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*j/o)+" ms."),this.nextAudioPts=y=B=X);else if(j>=I*u&&V<1e4&&p){var ee=Math.round(j/u);(B=X-ee*u)<0&&(ee--,B+=u),O===0&&(this.nextAudioPts=y=B),P.warn("[mp4-remuxer]: Injecting "+ee+" audio frame @ "+(B/o).toFixed(3)+"s due to "+Math.round(1e3*j/o)+" ms gap.");for(var J=0;J<ee;J++){var ue=Math.max(B,0),ke=Ls.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);ke||(P.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ke=K.unit.subarray()),E.splice(O,0,{unit:ke,pts:ue}),B+=u,O++}}K.pts=B,B+=u}for(var le,Te=null,Ae=null,be=0,Ie=E.length;Ie--;)be+=E[Ie].unit.byteLength;for(var Fe=0,He=E.length;Fe<He;Fe++){var We=E[Fe],xt=We.unit,mt=We.pts;if(Ae!==null)v[Fe-1].duration=Math.round((mt-Ae)/l);else{if(r&&e.segmentCodec==="aac"&&(mt=y),Te=mt,!(be>0))return;be+=A;try{le=new Uint8Array(be)}catch(Bt){return void this.observer.emit(T.ERROR,T.ERROR,{type:Z.MUX_ERROR,details:N.REMUX_ALLOC_ERROR,fatal:!1,error:Bt,bytes:be,reason:"fail allocating audio mdat "+be})}f||(new DataView(le.buffer).setUint32(0,be),le.set(Tt.types.mdat,4))}le.set(xt,A);var rr=xt.byteLength;A+=rr,v.push(new Ds(!0,d,rr,0)),Ae=mt}var Jt=v.length;if(Jt){var $t=v[v.length-1];this.nextAudioPts=y=Ae+l*$t.duration;var pt=f?new Uint8Array(0):Tt.moof(e.sequenceNumber++,Te/l,W({},e,{samples:v}));e.samples=[];var bt=Te/o,cr=y/o,Cr={data1:pt,data2:le,startPTS:bt,endPTS:cr,startDTS:bt,endDTS:cr,type:"audio",hasAudio:!0,hasVideo:!1,nb:Jt};return this.isAudioContiguous=!0,Cr}},n.remuxEmptyAudio=function(e,t,r,i){var a=e.inputTimeScale,o=a/(e.samplerate?e.samplerate:a),l=this.nextAudioPts,d=this._initDTS,u=9e4*d.baseTime/d.timescale,c=(l!==null?l:i.startDTS*a)+u,f=i.endDTS*a+u,v=1024*o,p=Math.ceil((f-c)/v),E=Ls.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(P.warn("[mp4-remuxer]: remux empty Audio"),E){for(var A=[],y=0;y<p;y++){var b=c+y*v;A.push({unit:E,pts:b,dts:b})}return e.samples=A,this.remuxAudio(e,t,r,!1)}P.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},s}();function Xt(s,n){var e;if(n===null)return s;for(e=n<s?-8589934592:8589934592;Math.abs(s-n)>4294967296;)s+=e;return s}function Rs(s,n,e,t){var r=s.samples.length;if(r){for(var i=s.inputTimeScale,a=0;a<r;a++){var o=s.samples[a];o.pts=Xt(o.pts-9e4*e.baseTime/e.timescale,n*i)/i,o.dts=Xt(o.dts-9e4*t.baseTime/t.timescale,n*i)/i}var l=s.samples;return s.samples=[],{samples:l}}}function ws(s,n,e){var t=s.samples.length;if(t){for(var r=s.inputTimeScale,i=0;i<t;i++){var a=s.samples[i];a.pts=Xt(a.pts-9e4*e.baseTime/e.timescale,n*r)/r}s.samples.sort(function(l,d){return l.pts-d.pts});var o=s.samples;return s.samples=[],{samples:o}}}var Er,Ds=function(s,n,e,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=n,this.size=e,this.cts=t,this.flags=new Tl(s)},Tl=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},bl=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&&Ue(a,["moov","trak"]).forEach(function(d){var u=Ue(d,["mdia","minf","stbl","stsd"])[0].subarray(8),c=Ue(u,["enca"]),f=c.length>0;f||(c=Ue(u,["encv"])),c.forEach(function(v){Ue(f?v.subarray(28):v.subarray(78),["sinf"]).forEach(function(p){var E=Li(p);if(E){var A=E.subarray(8,24);A.some(function(y){return y!==0})||(P.log("[eme] Patching keyId in 'enc"+(f?"a":"v")+">sinf>>tenc' box: "+Nt(A)+" -> "+Nt(l)),E.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=ki(e);t||(t=Is(i.audio,De)),r||(r=Is(i.video,Je));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"}:P.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},n.remux=function(e,t,r,i,a,o){var l,d,u=this.initPTS,c=this.lastEndTime,f={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};ie(c)||(c=this.lastEndTime=a||0);var v=t.samples;if(v==null||!v.length)return f;var p={initPTS:void 0,timescale:1},E=this.initData;if((l=E)!=null&&l.length||(this.generateInitSegment(v),E=this.initData),(d=E)==null||!d.length)return P.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),f;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1);var A=function(j,V){return Ue(V,["moof","traf"]).reduce(function(ee,J){var ue=Ue(J,["tfdt"])[0],ke=ue[0],le=Ue(J,["tfhd"]).reduce(function(Te,Ae){var be=Re(Ae,4),Ie=j[be];if(Ie){var Fe=Re(ue,4);if(ke===1){if(Fe===Jr)return P.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),Te;Fe*=Jr+1,Fe+=Re(ue,8)}var He=Fe/(Ie.timescale||9e4);if(isFinite(He)&&(Te===null||He<Te))return He}return Te},null);return le!==null&&isFinite(le)&&(ee===null||le<ee)?le:ee},null)}(E,v),y=A===null?a:A;(function(j,V,ee){if(j===null)return!0;var J=V-j.baseTime/j.timescale;return J<0&&Math.abs(J-ee)>1}(u,y,a)||p.timescale!==u.timescale&&o)&&(p.initPTS=y-a,this.initPTS=u={baseTime:p.initPTS,timescale:1});var b=function(j,V){for(var ee=0,J=0,ue=0,ke=Ue(j,["moof","traf"]),le=0;le<ke.length;le++){var Te=ke[le],Ae=Ue(Te,["tfhd"])[0],be=V[Re(Ae,4)];if(be){var Ie=be.default,Fe=Re(Ae,0)|(Ie==null?void 0:Ie.flags),He=Ie==null?void 0:Ie.duration;8&Fe&&(He=Re(Ae,2&Fe?12:8));for(var We=be.timescale||9e4,xt=Ue(Te,["trun"]),mt=0;mt<xt.length;mt++)!(ee=vn(xt[mt]))&&He&&(ee=He*Re(xt[mt],4)),be.type===Je?J+=ee/We:be.type===De&&(ue+=ee/We)}}if(J===0&&ue===0){for(var rr=0,Jt=Ue(j,["sidx"]),$t=0;$t<Jt.length;$t++){var pt=ta(Jt[$t]);pt!=null&&pt.references&&(rr+=pt.references.reduce(function(bt,cr){return bt+cr.info.duration||0},0))}return rr}return J||ue}(v,E),C=e?y-u.baseTime/u.timescale:c,I=C+b;(function(j,V,ee){Ue(V,["moof","traf"]).forEach(function(J){Ue(J,["tfhd"]).forEach(function(ue){var ke=Re(ue,4),le=j[ke];if(le){var Te=le.timescale||9e4;Ue(J,["tfdt"]).forEach(function(Ae){var be=Ae[0],Ie=Re(Ae,4);if(be===0)Ie-=ee*Te,Ai(Ae,4,Ie=Math.max(Ie,0));else{Ie*=Math.pow(2,32),Ie+=Re(Ae,8),Ie-=ee*Te,Ie=Math.max(Ie,0);var Fe=Math.floor(Ie/(Jr+1)),He=Math.floor(Ie%(Jr+1));Ai(Ae,4,Fe),Ai(Ae,8,He)}})}})})})(E,v,u.baseTime/u.timescale),b>0?this.lastEndTime=I:(P.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var O=!!E.audio,B=!!E.video,K="";O&&(K+="audio"),B&&(K+="video");var X={data1:v,startPTS:C,startDTS:C,endPTS:I,endDTS:I,type:K,hasAudio:O,hasVideo:B,nb:1,dropped:0};return f.audio=X.type==="audio"?X:void 0,f.video=X.type!=="audio"?X:void 0,f.initSegment=p,f.id3=Rs(r,a,u,u),i.samples.length&&(f.text=ws(i,a,u)),f},s}();function Is(s,n){var e=s==null?void 0:s.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.c.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||n===Je?"avc1.42e01e":"mp4a.40.5"}try{Er=self.performance.now.bind(self.performance)}catch{P.debug("Unable to use Performance API on this environment"),Er=typeof self!="undefined"&&self.Date.now}var Ta=[{demux:ul,remux:bl},{demux:ml,remux:Ea},{demux:ol,remux:Ea},{demux:El,remux:Ea}],ba=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=Er();var l=new Uint8Array(e),d=this.currentTransmuxState,u=this.transmuxConfig;i&&(this.currentTransmuxState=i);var c=i||d,f=c.contiguous,v=c.discontinuity,p=c.trackSwitch,E=c.accurateTimeOffset,A=c.timeOffset,y=c.initSegmentChange,b=u.audioCodec,C=u.videoCodec,I=u.defaultInitPts,O=u.duration,B=u.initSegmentData,K=function(ke,le){var Te=null;return ke.byteLength>0&&le!=null&&le.key!=null&&le.iv!==null&&le.method!=null&&(Te=le),Te}(l,t);if(K&&K.method==="AES-128"){var X=this.getDecrypter();if(!X.isSync())return this.decryptionPromise=X.webCryptoDecrypt(l,K.key.buffer,K.iv.buffer).then(function(ke){var le=a.push(ke,null,r);return a.decryptionPromise=null,le}),this.decryptionPromise;var j=X.softwareDecrypt(l,K.key.buffer,K.iv.buffer);if(r.part>-1&&(j=X.flush()),!j)return o.executeEnd=Er(),_a(r);l=new Uint8Array(j)}var V=this.needsProbing(v,p);if(V){var ee=this.configureTransmuxer(l);if(ee)return P.warn("[transmuxer] "+ee.message),this.observer.emit(T.ERROR,T.ERROR,{type:Z.MEDIA_ERROR,details:N.FRAG_PARSING_ERROR,fatal:!1,error:ee,reason:ee.message}),o.executeEnd=Er(),_a(r)}(v||p||y||V)&&this.resetInitSegment(B,b,C,O,t),(v||y||V)&&this.resetInitialTimestamp(I),f||this.resetContiguity();var J=this.transmux(l,K,A,E,r),ue=this.currentTransmuxState;return ue.contiguous=!0,ue.discontinuity=!1,ue.trackSwitch=!1,o.executeEnd=Er(),J},n.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=Er();var i=this.decrypter,a=this.currentTransmuxState,o=this.decryptionPromise;if(o)return o.then(function(){return t.flush(e)});var l=[],d=a.timeOffset;if(i){var u=i.flush();u&&l.push(this.push(u,null,e))}var c=this.demuxer,f=this.remuxer;if(!c||!f)return r.executeEnd=Er(),[_a(e)];var v=c.flush(d);return jr(v)?v.then(function(p){return t.flushRemux(l,p,e),l}):(this.flushRemux(l,v,e),l)},n.flushRemux=function(e,t,r){var i=t.audioTrack,a=t.videoTrack,o=t.id3Track,l=t.textTrack,d=this.currentTransmuxState,u=d.accurateTimeOffset,c=d.timeOffset;P.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var f=this.remuxer.remux(i,a,o,l,c,u,!0,this.id);e.push({remuxResult:f,chunkMeta:r}),r.transmuxing.executeEnd=Er()},n.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},n.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},n.resetInitSegment=function(e,t,r,i,a){var o=this.demuxer,l=this.remuxer;o&&l&&(o.resetInitSegment(e,t,r,i),l.resetInitSegment(e,t,r,a))},n.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},n.transmux=function(e,t,r,i,a){return t&&t.method==="SAMPLE-AES"?this.transmuxSampleAes(e,t,r,i,a):this.transmuxUnencrypted(e,r,i,a)},n.transmuxUnencrypted=function(e,t,r,i){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),o=a.audioTrack,l=a.videoTrack,d=a.id3Track,u=a.textTrack;return{remuxResult:this.remuxer.remux(o,l,d,u,t,r,!1,this.id),chunkMeta:i}},n.transmuxSampleAes=function(e,t,r,i,a){var o=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(l){return{remuxResult:o.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,r,i,!1,o.id),chunkMeta:a}})},n.configureTransmuxer=function(e){for(var t,r=this.config,i=this.observer,a=this.typeSupported,o=this.vendor,l=0,d=Ta.length;l<d;l++)if(Ta[l].demux.probe(e)){t=Ta[l];break}if(!t)return new Error("Failed to find demuxer by probing fragment data");var u=this.demuxer,c=this.remuxer,f=t.remux,v=t.demux;c&&c instanceof f||(this.remuxer=new f(i,r,a,o)),u&&u instanceof v||(this.demuxer=new v(i,r,a),this.probe=v.probe)},n.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},n.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new lt(this.config)),e},s}(),_a=function(s){return{remuxResult:{},chunkMeta:s}};function jr(s){return"then"in s&&s.then instanceof Function}var _l=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},Sl=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},Sa={};(function(s){var n=Object.prototype.hasOwnProperty,e="~";function t(){}function r(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function i(l,d,u,c,f){if(typeof u!="function")throw new TypeError("The listener must be a function");var v=new r(u,c||l,f),p=e?e+d:d;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],v]:l._events[p].push(v):(l._events[p]=v,l._eventsCount++),l}function a(l,d){--l._eventsCount==0?l._events=new t:delete l._events[d]}function o(){this._events=new t,this._eventsCount=0}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1)),o.prototype.eventNames=function(){var l,d,u=[];if(this._eventsCount===0)return u;for(d in l=this._events)n.call(l,d)&&u.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(l)):u},o.prototype.listeners=function(l){var d=e?e+l:l,u=this._events[d];if(!u)return[];if(u.fn)return[u.fn];for(var c=0,f=u.length,v=new Array(f);c<f;c++)v[c]=u[c].fn;return v},o.prototype.listenerCount=function(l){var d=e?e+l:l,u=this._events[d];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,d,u,c,f,v){var p=e?e+l:l;if(!this._events[p])return!1;var E,A,y=this._events[p],b=arguments.length;if(y.fn){switch(y.once&&this.removeListener(l,y.fn,void 0,!0),b){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,u),!0;case 4:return y.fn.call(y.context,d,u,c),!0;case 5:return y.fn.call(y.context,d,u,c,f),!0;case 6:return y.fn.call(y.context,d,u,c,f,v),!0}for(A=1,E=new Array(b-1);A<b;A++)E[A-1]=arguments[A];y.fn.apply(y.context,E)}else{var C,I=y.length;for(A=0;A<I;A++)switch(y[A].once&&this.removeListener(l,y[A].fn,void 0,!0),b){case 1:y[A].fn.call(y[A].context);break;case 2:y[A].fn.call(y[A].context,d);break;case 3:y[A].fn.call(y[A].context,d,u);break;case 4:y[A].fn.call(y[A].context,d,u,c);break;default:if(!E)for(C=1,E=new Array(b-1);C<b;C++)E[C-1]=arguments[C];y[A].fn.apply(y[A].context,E)}}return!0},o.prototype.on=function(l,d,u){return i(this,l,d,u,!1)},o.prototype.once=function(l,d,u){return i(this,l,d,u,!0)},o.prototype.removeListener=function(l,d,u,c){var f=e?e+l:l;if(!this._events[f])return this;if(!d)return a(this,f),this;var v=this._events[f];if(v.fn)v.fn!==d||c&&!v.once||u&&v.context!==u||a(this,f);else{for(var p=0,E=[],A=v.length;p<A;p++)(v[p].fn!==d||c&&!v[p].once||u&&v[p].context!==u)&&E.push(v[p]);E.length?this._events[f]=E.length===1?E[0]:E:a(this,f)}return this},o.prototype.removeAllListeners=function(l){var d;return l?(d=e?e+l:l,this._events[d]&&a(this,d)):(this._events=new t,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,s.exports=o})({get exports(){return Sa},set exports(s){Sa=s}});var Un=Sa;function Aa(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&&Cs(t,i),a&&Cs(t,a),s.postMessage({event:"transmuxComplete",data:n},t),!0}function Cs(s,n){n.data1&&s.push(n.data1.buffer),n.data2&&s.push(n.data2.buffer)}function Ps(s,n,e){n.reduce(function(t,r){return Aa(s,r)||t},!1)||s.postMessage({event:"transmuxComplete",data:n[0]}),s.postMessage({event:"flush",data:e})}L!==void 0&&L&&function(s){var n=new Un,e=function(r,i){s.postMessage({event:r,data:i})};n.on(T.FRAG_DECRYPTED,e),n.on(T.ERROR,e);var t=function(){var r=function(a){var o=function(l){e("workerLog",{logType:a,message:l})};P[a]=o};for(var i in P)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 ba(n,i.typeSupported,a,i.vendor,i.id),ut(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);jr(o)?(s.transmuxer.async=!0,o.then(function(u){Aa(s,u)}).catch(function(u){e(T.ERROR,{type:Z.MEDIA_ERROR,details:N.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker push error"})})):(s.transmuxer.async=!1,Aa(s,o));break;case"flush":var l=i.chunkMeta,d=s.transmuxer.flush(l);jr(d)||s.transmuxer.async?(jr(d)||(d=Promise.resolve(d)),d.then(function(u){Ps(s,u,l)}).catch(function(u){e(T.ERROR,{type:Z.MEDIA_ERROR,details:N.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker flush error"})})):Ps(s,d,l)}})}(self);var ka=ha()||{isTypeSupported:function(){return!1}},xs=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(A,y){(y=y||{}).frag=a.frag,y.id=a.id,A===T.ERROR&&(a.error=y.error),a.hls.trigger(A,y)};this.observer=new Un,this.observer.on(T.FRAG_DECRYPTED,l),this.observer.on(T.ERROR,l);var d,u,c,f,v={mp4:ka.isTypeSupported("video/mp4"),mpeg:ka.isTypeSupported("audio/mpeg"),mp3:ka.isTypeSupported('audio/mp4; codecs="mp3"')},p=navigator.vendor;if(!this.useWorker||typeof Worker=="undefined"||(o.workerPath,0))this.transmuxer=new ba(this.observer,v,o,p,t);else try{o.workerPath?(P.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})):(P.log('injecting Web Worker for "'+t+'"'),this.workerContext=(d=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+R.toString()+")(true);"],{type:"text/javascript"}),u=self.URL.createObjectURL(d),{worker:new self.Worker(u),objectURL:u})),this.onwmsg=function(A){return a.onWorkerMessage(A)};var E=this.workerContext.worker;E.addEventListener("message",this.onwmsg),E.onerror=function(A){var y=new Error(A.message+" ("+A.filename+":"+A.lineno+")");o.enableWorker=!1,P.warn('Error in "'+t+'" Web Worker, fallback to inline'),a.hls.trigger(T.ERROR,{type:Z.OTHER_ERROR,details:N.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:y})},E.postMessage({cmd:"init",typeSupported:v,vendor:p,id:t,config:JSON.stringify(o)})}catch(A){P.warn('Error setting up "'+t+'" Web Worker, fallback to inline',A),this.resetWorker(),this.error=null,this.transmuxer=new ba(this.observer,v,o,p,t)}}var n=s.prototype;return n.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},n.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},n.push=function(e,t,r,i,a,o,l,d,u,c){var f,v,p=this;u.transmuxing.start=self.performance.now();var E=this.transmuxer,A=o?o.start:a.start,y=a.decryptdata,b=this.frag,C=!(b&&a.cc===b.cc),I=!(b&&u.level===b.level),O=b?u.sn-b.sn:-1,B=this.part?u.part-this.part.index:-1,K=O===0&&u.id>1&&u.id===(b==null?void 0:b.stats.chunkCount),X=!I&&(O===1||O===0&&(B===1||K&&B<=0)),j=self.performance.now();(I||O||a.stats.parsing.start===0)&&(a.stats.parsing.start=j),!o||!B&&X||(o.stats.parsing.start=j);var V=!(b&&((f=a.initSegment)==null?void 0:f.url)===((v=b.initSegment)==null?void 0:v.url)),ee=new Sl(C,X,d,I,A,V);if(!X||C||V){P.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
|
21
|
+
discontinuity: `+C+`
|
|
22
|
+
trackSwitch: `+I+`
|
|
23
|
+
contiguous: `+X+`
|
|
24
|
+
accurateTimeOffset: `+d+`
|
|
25
|
+
timeOffset: `+A+`
|
|
26
|
+
initSegmentChange: `+V);var J=new _l(r,i,t,l,c);this.configureTransmuxer(J)}if(this.frag=a,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:u,state:ee},e instanceof ArrayBuffer?[e]:[]);else if(E){var ue=E.push(e,y,u,ee);jr(ue)?(E.async=!0,ue.then(function(ke){p.handleTransmuxComplete(ke)}).catch(function(ke){p.transmuxerError(ke,u,"transmuxer-interface push error")})):(E.async=!1,this.handleTransmuxComplete(ue))}},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);jr(i)||r.async?(jr(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(T.ERROR,{type:Z.MEDIA_ERROR,details:N.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":P[t.data.logType]&&P[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}(),Al=function(){function s(e,t,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i}var n=s.prototype;return n.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},n.poll=function(e,t){var r=this.config,i=this.media,a=this.stalled;if(i!==null){var o=i.currentTime,l=i.seeking,d=this.seeking&&!l,u=!this.seeking&&l;if(this.seeking=l,o===e){if(u||d)this.stalled=null;else if(!(i.paused&&!l||i.ended||i.playbackRate===0)&&ce.getBuffered(i).length){var c=ce.bufferInfo(i,o,0),f=c.len>0,v=c.nextStart||0;if(f||v){if(l){var p=c.len>2,E=!v||t&&t.start<=o||v-o>2&&!this.fragmentTracker.getPartialFragment(o);if(p||E)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var A,y=Math.max(v,c.start||0)-o,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,C=!(b==null||(A=b.details)==null)&&A.live?2*b.details.targetduration:2,I=this.fragmentTracker.getPartialFragment(o);if(y>0&&(y<=C||I))return void this._trySkipBufferHole(I)}var O=self.performance.now();if(a!==null){var B=O-a;if(l||!(B>=250)||(this._reportStall(c),this.media)){var K=ce.bufferInfo(i,o,r.maxBufferHole);this._tryFixBufferStall(K,B)}}else this.stalled=O}}}else if(this.moved=!0,a!==null){if(this.stallReported){var X=self.performance.now()-a;P.warn("playback not stuck anymore @"+o+", after "+Math.round(X)+"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&&(P.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)+")");P.warn(i.message),t.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:N.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=ce.bufferInfo(i,a,0),l=a<o.start?o.start:o.nextStart;if(l){var d=o.len<=t.maxBufferHole,u=o.len>0&&o.len<1&&i.readyState<3,c=l-a;if(c>0&&(d||u)){if(c>t.maxBufferHole){var f=this.fragmentTracker,v=!1;if(a===0){var p=f.getAppendedFrag(0,qe);p&&l<p.end&&(v=!0)}if(!v){var E=e||f.getAppendedFrag(a,qe);if(E){for(var A=!1,y=E.end;y<l;){var b=f.getPartialFragment(y);if(!b){A=!0;break}y+=b.duration}if(A)return 0}}}var C=Math.max(l+.05,a+.1);if(P.warn("skipping hole, adjusting currentTime from "+a+" to "+C),this.moved=!0,this.stalled=null,i.currentTime=C,e&&!e.gap){var I=new Error("fragment loaded with buffer holes, seeking from "+a+" to "+C);r.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:N.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:I,reason:I.message,frag:e})}return C}}return 0},n._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(r!==null){var a=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var o=a+(i+1)*e.nudgeOffset,l=new Error("Nudging 'currentTime' from "+a+" to "+o);P.warn(l.message),r.currentTime=o,t.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:N.BUFFER_NUDGE_ON_STALL,error:l,fatal:!1})}else{var d=new Error("Playhead still not moving while enough data buffered @"+a+" after "+e.nudgeMaxRetry+" nudges");P.error(d.message),t.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:N.BUFFER_STALLED_ERROR,error:d,fatal:!0})}}},s}(),kl=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[stream-controller]",qe)||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}de(n,s);var e=n.prototype;return e._registerListeners=function(){var t=this.hls;t.on(T.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(T.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(T.MANIFEST_LOADING,this.onManifestLoading,this),t.on(T.MANIFEST_PARSED,this.onManifestParsed,this),t.on(T.LEVEL_LOADING,this.onLevelLoading,this),t.on(T.LEVEL_LOADED,this.onLevelLoaded,this),t.on(T.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(T.ERROR,this.onError,this),t.on(T.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(T.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(T.BUFFER_CREATED,this.onBufferCreated,this),t.on(T.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(T.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(T.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(T.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(T.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(T.MANIFEST_LOADING,this.onManifestLoading,this),t.off(T.MANIFEST_PARSED,this.onManifestParsed,this),t.off(T.LEVEL_LOADED,this.onLevelLoaded,this),t.off(T.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(T.ERROR,this.onError,this),t.off(T.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(T.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(T.BUFFER_CREATED,this.onBufferCreated,this),t.off(T.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(T.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(T.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=fe,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Ve},e.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},e.doTick=function(){switch(this.state){case fi: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=fe;break}break;case Pt:var o,l=self.performance.now(),d=this.retryDate;(!d||l>=d||(o=this.media)!=null&&o.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=fe)}this.state===fe&&this.doTickIdle(),this.onTickEnd()},e.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},e.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,i=this.levels,a=this.media,o=t.config,l=t.nextLoadLevel;if(r!==null&&(a||!this.startFragRequested&&o.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&i!=null&&i[l]){var d=i[l],u=this.getMainFwdBufferInfo();if(u!==null){var c=this.getLevelDetails();if(c&&this._streamEnded(u,c)){var f={};return this.altAudio&&(f.type="video"),this.hls.trigger(T.BUFFER_EOS,f),void(this.state=qr)}t.loadLevel!==l&&t.manualLevel===-1&&this.log("Adapting to level "+l+" from level "+this.level),this.level=t.nextLoadLevel=l;var v=d.details;if(!v||this.state===fi||v.live&&this.levelLastLoaded!==l)return this.level=l,void(this.state=fi);var p=u.len,E=this.getMaxBufferLength(d.maxBitrate);if(!(p>=E)){this.backtrackFragment&&this.backtrackFragment.start>u.end&&(this.backtrackFragment=null);var A=this.backtrackFragment?this.backtrackFragment.start:u.end,y=this.getNextFragment(A,v);if(this.couldBacktrack&&!this.fragPrevious&&y&&y.sn!=="initSegment"&&this.fragmentTracker.getState(y)!==M){var b,C=((b=this.backtrackFragment)!=null?b:y).sn-v.startSN,I=v.fragments[C-1];I&&y.cc===I.cc&&(y=I,this.fragmentTracker.removeFragment(I))}else this.backtrackFragment&&u.len&&(this.backtrackFragment=null);if(y&&this.isLoopLoading(y,A)){if(!y.gap){var O=this.audioOnly&&!this.altAudio?De:Je,B=(O===Je?this.videoBuffer:this.mediaBuffer)||this.media;B&&this.afterBufferFlushed(B,O,qe)}y=this.getNextFragmentLoopLoading(y,v,u,qe,E)}y&&(!y.initSegment||y.initSegment.data||this.bitrateTest||(y=y.initSegment),this.loadFragment(y,d,A))}}}},e.loadFragment=function(t,r,i){var a=this.fragmentTracker.getState(t);this.fragCurrent=t,a===w?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.getAppendedFrag=function(t){var r=this.fragmentTracker.getAppendedFrag(t,qe);return r&&"fragment"in r?r.fragment:r},e.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,qe)},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);if(a&&a.start>1&&this.flushMainBuffer(0,a.start-1),!r.paused&&t){var o=t[this.hls.nextLoadLevel],l=this.fragLastKbps;i=l&&this.fragCurrent?this.fragCurrent.duration*o.maxBitrate/(1e3*l)+1:0}else i=0;var d=this.getBufferedFrag(r.currentTime+i);if(d){var u=this.followingBufferedFrag(d);if(u){this.abortCurrentFrag();var c=u.maxStartPTS?u.maxStartPTS:u.start,f=u.duration,v=Math.max(d.end,c+Math.min(Math.max(f-this.config.maxFragLookUpTolerance,.5*f),.75*f));this.flushMainBuffer(v,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 Wt:case zt:case Pt:case It:case hi:this.state=fe}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 Al(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(T.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},e.onManifestParsed=function(t,r){var i,a,o,l=!1,d=!1;r.levels.forEach(function(u){(i=u.audioCodec)&&(i.indexOf("mp4a.40.2")!==-1&&(l=!0),i.indexOf("mp4a.40.5")!==-1&&(d=!0))}),this.audioCodecSwitch=l&&d&&typeof((o=gs())==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===fe){var a=i[r.level];(!a.details||a.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(a.details))&&(this.state=fi)}},e.onLevelLoaded=function(t,r){var i,a=this.levels,o=r.level,l=r.details,d=l.totalduration;if(a){this.log("Level "+o+" loaded ["+l.startSN+","+l.endSN+"], cc ["+l.startCC+", "+l.endCC+"] duration:"+d);var u=a[o],c=this.fragCurrent;!c||this.state!==zt&&this.state!==Pt||c.level===r.level&&c.urlId===u.urlId||!c.loader||this.abortCurrentFrag();var f=0;if(l.live||(i=u.details)!=null&&i.live){if(l.fragments[0]||(l.deltaUpdateFailed=!0),l.deltaUpdateFailed)return;f=this.alignPlaylists(l,u.details)}if(u.details=l,this.levelLastLoaded=o,this.hls.trigger(T.LEVEL_UPDATED,{details:l,level:o}),this.state===fi){if(this.waitForCdnTuneIn(l))return;this.state=fe}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,f),this.tick()}else this.warn("Levels were reset while loading level "+o)},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.levels;if(l){var d=l[i.level],u=d.details;if(!u)return this.warn("Dropping fragment "+i.sn+" of level "+i.level+" after level details were reset"),void this.fragmentTracker.removeFragment(i);var c=d.videoCodec,f=u.PTSKnown||!u.live,v=(r=i.initSegment)==null?void 0:r.data,p=this._getAudioCodec(d),E=this.transmuxer=this.transmuxer||new xs(this.hls,qe,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),A=a?a.index:-1,y=A!==-1,b=new et(i.level,i.sn,i.stats.chunkCount,o.byteLength,A,y),C=this.initPTS[i.cc];E.push(o,v,p,c,i,a,u.totalduration,f,b,C)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},e.onAudioTrackSwitching=function(t,r){var i=this.altAudio;if(!r.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;i&&(o.trigger(T.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),o.trigger(T.AUDIO_TRACK_SWITCHED,r)}},e.onAudioTrackSwitched=function(t,r){var i=r.id,a=!!this.hls.audioTracks[i].url;if(a){var o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=a,this.tick()},e.onBufferCreated=function(t,r){var i,a,o=r.tracks,l=!1;for(var d in o){var u=o[d];if(u.id==="main"){if(a=d,i=u,d==="video"){var c=o[d];c&&(this.videoBuffer=c.buffer)}}else l=!0}l&&i?(this.log("Alternate track found, use "+a+".buffered to schedule main fragment loading"),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media},e.onFragBuffered=function(t,r){var i=r.frag,a=r.part;if(!i||i.type===qe){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===hi&&(this.state=fe));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=Dr;else switch(r.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(qe,r);break;case N.LEVEL_LOAD_ERROR:case N.LEVEL_LOAD_TIMEOUT:case N.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==fi||((i=r.context)==null?void 0:i.type)!==pr||(this.state=fe);break;case N.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case N.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.checkBuffer=function(){var t=this.media,r=this.gapController;if(t&&r&&t.readyState){if(this.loadedmetadata||!ce.getBuffered(t).length){var i=this.state!==fe?this.fragCurrent:null;r.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}},e.onFragLoadEmergencyAborted=function(){this.state=fe,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},e.onBufferFlushed=function(t,r){var i=r.type;if(i!==De||this.audioOnly&&!this.altAudio){var a=(i===Je?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,i,qe)}},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=ce.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=fe,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(T.FRAG_LOADED,a),t.bitrateTest=!1}})},e._handleTransmuxComplete=function(t){var r,i="main",a=this.hls,o=t.remuxResult,l=t.chunkMeta,d=this.getCurrentContext(l);if(d){var u=d.frag,c=d.part,f=d.level,v=o.video,p=o.text,E=o.id3,A=o.initSegment,y=f.details,b=this.altAudio?void 0:o.audio;if(this.fragContextChanged(u))this.fragmentTracker.removeFragment(u);else{if(this.state=It,A){A.tracks&&(this._bufferInitSegment(f,A.tracks,u,l),a.trigger(T.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:i,tracks:A.tracks}));var C=A.initPTS,I=A.timescale;ie(C)&&(this.initPTS[u.cc]={baseTime:C,timescale:I},a.trigger(T.INIT_PTS_FOUND,{frag:u,id:i,initPTS:C,timescale:I}))}if(v&&o.independent!==!1){if(y){var O=v.startPTS,B=v.endPTS,K=v.startDTS,X=v.endDTS;if(c)c.elementaryStreams[v.type]={startPTS:O,endPTS:B,startDTS:K,endDTS:X};else if(v.firstKeyFrame&&v.independent&&l.id===1&&(this.couldBacktrack=!0),v.dropped&&v.independent){var j=this.getMainFwdBufferInfo();if((j?j.end:this.getLoadPosition())+this.config.maxBufferHole<(v.firstKeyFramePTS?v.firstKeyFramePTS:O)-this.config.maxBufferHole)return void this.backtrack(u);u.setElementaryStreamInfo(v.type,u.start,B,u.start,X,!0)}u.setElementaryStreamInfo(v.type,O,B,K,X),this.backtrackFragment&&(this.backtrackFragment=u),this.bufferFragmentData(v,u,c,l)}}else if(o.independent===!1)return void this.backtrack(u);if(b){var V=b.startPTS,ee=b.endPTS,J=b.startDTS,ue=b.endDTS;c&&(c.elementaryStreams[De]={startPTS:V,endPTS:ee,startDTS:J,endDTS:ue}),u.setElementaryStreamInfo(De,V,ee,J,ue),this.bufferFragmentData(b,u,c,l)}if(y&&E!=null&&(r=E.samples)!=null&&r.length){var ke={id:i,frag:u,details:y,samples:E.samples};a.trigger(T.FRAG_PARSING_METADATA,ke)}if(y&&p){var le={id:i,frag:u,details:y,samples:p.samples};a.trigger(T.FRAG_PARSING_USERDATA,le)}}}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i,a){var o=this;if(this.state===It){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var l=r.audio,d=r.video,u=r.audiovideo;if(l){var c=t.audioCodec,f=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(c&&(c=c.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),l.metadata.channelCount!==1&&f.indexOf("firefox")===-1&&(c="mp4a.40.5")),f.indexOf("android")!==-1&&l.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log("Android: force audio codec to "+c)),t.audioCodec&&t.audioCodec!==c&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+c+'"'),l.levelCodec=c,l.id="main",this.log("Init audio buffer, container:"+l.container+", codecs[selected/level/parsed]=["+(c||"")+"/"+(t.audioCodec||"")+"/"+l.codec+"]")}d&&(d.levelCodec=t.videoCodec,d.id="main",this.log("Init video buffer, container:"+d.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+d.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(T.BUFFER_CODECS,r),Object.keys(r).forEach(function(v){var p=r[v].initSegment;p!=null&&p.byteLength&&o.hls.trigger(T.BUFFER_APPENDING,{type:v,data:p,frag:i,part:null,chunkMeta:a,parent:i.type})}),this.tick()}},e.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,qe)},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=fe},e.checkFragmentChanged=function(){var t=this.media,r=null;if(t&&t.readyState>1&&t.seeking===!1){var i=t.currentTime;if(ce.isBuffered(t,i)?r=this.getAppendedFrag(i):ce.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(T.FRAG_CHANGED,{frag:r}),a&&a.level===o||this.hls.trigger(T.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}(ca),gi=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}(),Ll=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 gi(e),this.fast_=new gi(t),this.defaultTTFB_=i,this.ttfb_=new gi(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 gi(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new gi(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new gi(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}(),Rl=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 Ll(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(T.FRAG_LOADING,this.onFragLoading,this),e.on(T.FRAG_LOADED,this.onFragLoaded,this),e.on(T.FRAG_BUFFERED,this.onFragBuffered,this),e.on(T.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(T.LEVEL_LOADED,this.onLevelLoaded,this)},n.unregisterListeners=function(){var e=this.hls;e.off(T.FRAG_LOADING,this.onFragLoading,this),e.off(T.FRAG_LOADED,this.onFragLoaded,this),e.off(T.FRAG_BUFFERED,this.onFragBuffered,this),e.off(T.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(T.LEVEL_LOADED,this.onLevelLoaded,this)},n.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},n.onFragLoading=function(e,t){var r,i=t.frag;this.ignoreFragment(i)||(this.fragCurrent=i,this.partCurrent=(r=t.part)!=null?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},n.onLevelSwitching=function(e,t){this.clearTimer()},n.getTimeToLoadFrag=function(e,t,r,i){return e+r/t+(i?this.lastLevelLoadSec:0)},n.onLevelLoaded=function(e,t){var r=this.hls.config,i=t.stats,a=i.total,o=i.bwEstimate;ie(a)&&ie(o)&&(this.lastLevelLoadSec=8*a/o),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},n._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.autoLevelEnabled,a=r.media;if(e&&a){var o=performance.now(),l=t?t.stats:e.stats,d=t?t.duration:e.duration,u=o-l.loading.start;if(l.aborted||l.loaded&&l.loaded===l.total||e.level===0)return this.clearTimer(),void(this._nextAutoLevel=-1);if(i&&!a.paused&&a.playbackRate&&a.readyState){var c=r.mainForwardBufferInfo;if(c!==null){var f=this.bwEstimator.getEstimateTTFB(),v=Math.abs(a.playbackRate);if(!(u<=Math.max(f,d/(2*v)*1e3))){var p=c.len/v;if(!(p>=2*d/v)){var E=l.loading.first?l.loading.first-l.loading.start:-1,A=l.loaded&&E>-1,y=this.bwEstimator.getEstimate(),b=r.levels,C=r.minAutoLevel,I=b[e.level],O=l.total||Math.max(l.loaded,Math.round(d*I.maxBitrate/8)),B=u-E;B<1&&A&&(B=Math.min(u,8*l.loaded/y));var K=A?1e3*l.loaded/B:0,X=K?(O-l.loaded)/K:8*O/y+f/1e3;if(!(X<=p)){var j,V=K?8*K:y,ee=Number.POSITIVE_INFINITY;for(j=e.level-1;j>C;j--){var J=b[j].maxBitrate;if((ee=this.getTimeToLoadFrag(f/1e3,V,d*J,!b[j].details))<p)break}ee>=X||ee>10*d||(r.nextLoadLevel=j,A?this.bwEstimator.sample(u-Math.min(f,E),l.loaded):this.bwEstimator.sampleTTFB(u),this.clearTimer(),P.warn("[abr] Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+` is loading too slowly;
|
|
27
|
+
Time to underbuffer: `+p.toFixed(3)+` s
|
|
28
|
+
Estimated load time for current fragment: `+X.toFixed(3)+` s
|
|
29
|
+
Estimated load time for down switch fragment: `+ee.toFixed(3)+` s
|
|
30
|
+
TTFB estimate: `+E+`
|
|
31
|
+
Current BW estimate: `+(ie(y)?(y/1024).toFixed(3):"Unknown")+` Kb/s
|
|
32
|
+
New BW estimate: `+(this.bwEstimator.getEstimate()/1024).toFixed(3)+` Kb/s
|
|
33
|
+
Aborting and switching to level `+j),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),r.trigger(T.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===qe&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var o=i?i.duration:r.duration,l=this.hls.levels[r.level],d=(l.loaded?l.loaded.bytes:0)+a.loaded,u=(l.loaded?l.loaded.duration:0)+o;l.loaded={bytes:d,duration:u},l.realBitrate=Math.round(8*d/u)}if(r.bitrateTest){var c={stats:a,frag:r,part:i,id:r.type};this.onFragBuffered(T.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!==qe||e.sn==="initSegment"},n.clearTimer=function(){self.clearInterval(this.timer)},n.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.maxAutoLevel,a=r.config,o=r.minAutoLevel,l=r.media,d=t?t.duration:e?e.duration:0,u=l&&l.playbackRate!==0?Math.abs(l.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,f=r.mainForwardBufferInfo,v=(f?f.len:0)/u,p=this.findBestLevel(c,o,i,v,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(p>=0)return p;P.trace("[abr] "+(v?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var E=d?Math.min(d,a.maxStarvationDelay):a.maxStarvationDelay,A=a.abrBandWidthFactor,y=a.abrBandWidthUpFactor;if(!v){var b=this.bitrateTestDelay;b&&(E=(d?Math.min(d,a.maxLoadingDelay):a.maxLoadingDelay)-b,P.trace("[abr] bitrate test took "+Math.round(1e3*b)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*E)+" ms"),A=y=1)}return p=this.findBestLevel(c,o,i,v+E,A,y),Math.max(p,0)},n.findBestLevel=function(e,t,r,i,a,o){for(var l,d=this.fragCurrent,u=this.partCurrent,c=this.lastLoadedFragLevel,f=this.hls.levels,v=f[c],p=!(v==null||(l=v.details)==null||!l.live),E=v==null?void 0:v.codecSet,A=u?u.duration:d?d.duration:0,y=this.bwEstimator.getEstimateTTFB()/1e3,b=t,C=-1,I=r;I>=t;I--){var O=f[I];if(!O||E&&O.codecSet!==E)O&&(b=Math.min(I,b),C=Math.max(I,C));else{C!==-1&&P.trace("[abr] Skipped level(s) "+b+"-"+C+' with CODECS:"'+f[C].attrs.CODECS+'"; not compatible with "'+v.attrs.CODECS+'"');var B=O.details,K=(u?B==null?void 0:B.partTarget:B==null?void 0:B.averagetargetduration)||A,X=void 0;X=I<=c?a*e:o*e;var j=f[I].maxBitrate,V=this.getTimeToLoadFrag(y,X,j*K,B===void 0);if(P.trace("[abr] level:"+I+" adjustedbw-bitrate:"+Math.round(X-j)+" avgDuration:"+K.toFixed(1)+" maxFetchDuration:"+i.toFixed(1)+" fetchDuration:"+V.toFixed(1)),X>j&&(V===0||!ie(V)||p&&!this.bitrateTestDelay||V<i))return I}}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}(),Os=function(){function s(){this.chunks=[],this.dataLength=0}var n=s.prototype;return n.push=function(e){this.chunks.push(e),this.dataLength+=e.length},n.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=t.length===1?t[0]:function(i,a){for(var o=new Uint8Array(a),l=0,d=0;d<i.length;d++){var u=i[d];o.set(u,l),l+=u.length}return o}(t,r),this.reset(),e):new Uint8Array(0)},n.reset=function(){this.chunks.length=0,this.dataLength=0},s}(),wl=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[audio-stream-controller]",Vt)||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}de(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(T.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(T.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(T.MANIFEST_LOADING,this.onManifestLoading,this),t.on(T.LEVEL_LOADED,this.onLevelLoaded,this),t.on(T.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(T.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(T.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(T.ERROR,this.onError,this),t.on(T.BUFFER_RESET,this.onBufferReset,this),t.on(T.BUFFER_CREATED,this.onBufferCreated,this),t.on(T.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(T.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(T.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(T.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(T.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(T.MANIFEST_LOADING,this.onManifestLoading,this),t.off(T.LEVEL_LOADED,this.onLevelLoaded,this),t.off(T.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(T.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(T.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(T.ERROR,this.onError,this),t.off(T.BUFFER_RESET,this.onBufferReset,this),t.off(T.BUFFER_CREATED,this.onBufferCreated,this),t.off(T.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(T.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(T.FRAG_BUFFERED,this.onFragBuffered,this)},e.onInitPtsFound=function(t,r){var i=r.frag,a=r.id,o=r.initPTS,l=r.timescale;if(a==="main"){var d=i.cc;this.initPTS[i.cc]={baseTime:o,timescale:l},this.log("InitPTS for cc: "+d+" found from main: "+o),this.videoTrackCC=d,this.state===Gi&&this.tick()}},e.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=Ve);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=fe):(this.loadedmetadata=!1,this.state=tt),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.doTick=function(){switch(this.state){case fe:this.doTickIdle();break;case tt: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=Gi}break;case Pt:var o,l=performance.now(),d=this.retryDate;(!d||l>=d||(o=this.media)!=null&&o.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=fe);break;case Gi:var u=this.waitingData;if(u){var c=u.frag,f=u.part,v=u.cache,p=u.complete;if(this.initPTS[c.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=zt;var E={frag:c,part:f,payload:v.flush(),networkDetails:null};this._handleFragmentLoadProgress(E),p&&s.prototype._handleFragmentLoadComplete.call(this,E)}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 A=this.getLoadPosition(),y=ce.bufferInfo(this.mediaBuffer,A,this.config.maxBufferHole);Ui(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=fe}this.onTickEnd()},e.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=fe)},e.resetLoadingState=function(){this.clearWaitingFragment(),s.prototype.resetLoadingState.call(this)},e.onTickEnd=function(){var t=this.media;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)},e.doTickIdle=function(){var t=this.hls,r=this.levels,i=this.media,a=this.trackId,o=t.config;if(r!=null&&r[a]&&(i||!this.startFragRequested&&o.startFragPrefetch)){var l=r[a],d=l.details;if(!d||d.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(d))this.state=tt;else{var u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,De,Vt));var c=this.getFwdBufferInfo(u,Vt);if(c!==null){var f=this.bufferedTrack,v=this.switchingTrack;if(!v&&this._streamEnded(c,d))return t.trigger(T.BUFFER_EOS,{type:"audio"}),void(this.state=qr);var p=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,qe),E=c.len,A=this.getMaxBufferLength(p==null?void 0:p.len);if(!(E>=A)||v){var y=d.fragments[0].start,b=c.end;if(v&&i){var C=this.getLoadPosition();f&&v.attrs!==f.attrs&&(b=C),d.PTSKnown&&C<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 I=this.getNextFragment(b,d),O=!1;if(I&&this.isLoopLoading(I,b)&&(O=!!I.gap,I=this.getNextFragmentLoopLoading(I,d,c,qe,A)),I){var B=p&&I.start>p.end+d.targetduration;if(B||(p==null||!p.len)&&c.len){var K=this.fragmentTracker.getBufferedFrag(I.start,qe);if(K===null||(O||(O=!!K.gap||!!B&&p.len===0),B&&!O||O&&c.nextStart&&c.nextStart<K.end))return}this.loadFragment(I,l,b)}else this.bufferFlushed=!0}}}}},e.getMaxBufferLength=function(t){var r=s.prototype.getMaxBufferLength.call(this);return t?Math.min(Math.max(r,t),this.config.maxMaxBufferLength):r},e.onMediaDetaching=function(){this.videoBuffer=null,s.prototype.onMediaDetaching.call(this)},e.onAudioTracksUpdated=function(t,r){var i=r.audioTracks;this.resetTransmuxer(),this.levels=i.map(function(a){return new Br(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=fe):(this.switchingTrack=null,this.bufferedTrack=r,this.state=Ve),this.tick()},e.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.bufferedTrack=null,this.switchingTrack=null},e.onLevelLoaded=function(t,r){this.mainDetails=r.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(T.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+"],duration:"+o.totalduration);var d=a[l],u=0;if(o.live||(i=d.details)!=null&&i.live){var c=this.mainDetails;if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed||!c)return;!d.details&&o.hasProgramDateTime&&c.hasProgramDateTime?(we(o,c),u=o.fragments[0].start):u=this.alignPlaylists(o,d.details)}d.details=o,this.levelLastLoaded=l,this.startFragRequested||!this.mainDetails&&o.live||this.setStartPosition(d.details,u),this.state!==tt||this.waitForCdnTuneIn(o)||(this.state=fe),this.tick()}else this.warn("Audio tracks were reset while loading level "+l)}else this.cachedTrackLoadedData=r},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.config,d=this.trackId,u=this.levels;if(u){var c=u[d];if(c){var f=c.details;if(!f)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);var v=l.defaultAudioCodec||c.audioCodec||"mp4a.40.2",p=this.transmuxer;p||(p=this.transmuxer=new xs(this.hls,Vt,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var E=this.initPTS[i.cc],A=(r=i.initSegment)==null?void 0:r.data;if(E!==void 0){var y=a?a.index:-1,b=y!==-1,C=new et(i.level,i.sn,i.stats.chunkCount,o.byteLength,y,b);p.push(o,A,v,"",i,a,f.totalduration,!1,C,E)}else this.log("Unknown video PTS for cc "+i.cc+", waiting for video PTS before demuxing audio frag "+i.sn+" of ["+f.startSN+" ,"+f.endSN+"],track "+d),(this.waitingData=this.waitingData||{frag:i,part:a,cache:new Os,complete:!1}).cache.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=Gi}else this.warn("Audio track is undefined on fragment load progress")}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},e._handleFragmentLoadComplete=function(t){this.waitingData?this.waitingData.complete=!0:s.prototype._handleFragmentLoadComplete.call(this,t)},e.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},e.onBufferCreated=function(t,r){var i=r.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),r.tracks.video&&(this.videoBuffer=r.tracks.video.buffer||null)},e.onFragBuffered=function(t,r){var i,a=r.frag,o=r.part;if(a.type===Vt)if(this.fragContextChanged(a))this.warn("Fragment "+a.sn+(o?" p: "+o.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+(this.switchingTrack?this.switchingTrack.name:"false"));else{if(a.sn!=="initSegment"){this.fragPrevious=a;var l=this.switchingTrack;l&&(this.bufferedTrack=l,this.switchingTrack=null,this.hls.trigger(T.AUDIO_TRACK_SWITCHED,H({},l)))}this.fragBufferedComplete(a,o)}else this.loadedmetadata||a.type!==qe||(i=this.videoBuffer||this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)},e.onError=function(t,r){var i;if(r.fatal)this.state=Dr;else switch(r.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(Vt,r);break;case N.AUDIO_TRACK_LOAD_ERROR:case N.AUDIO_TRACK_LOAD_TIMEOUT:case N.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==tt||((i=r.context)==null?void 0:i.type)!==qt||(this.state=fe);break;case N.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 N.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.onBufferFlushed=function(t,r){r.type===De&&(this.bufferFlushed=!0,this.state===qr&&(this.state=fe))},e._handleTransmuxComplete=function(t){var r,i="audio",a=this.hls,o=t.remuxResult,l=t.chunkMeta,d=this.getCurrentContext(l);if(d){var u=d.frag,c=d.part,f=d.level.details,v=o.audio,p=o.text,E=o.id3,A=o.initSegment;if(!this.fragContextChanged(u)&&f){if(this.state=It,this.switchingTrack&&v&&this.completeAudioSwitch(this.switchingTrack),A!=null&&A.tracks&&(this._bufferInitSegment(A.tracks,u,l),a.trigger(T.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:i,tracks:A.tracks})),v){var y=v.startPTS,b=v.endPTS,C=v.startDTS,I=v.endDTS;c&&(c.elementaryStreams[De]={startPTS:y,endPTS:b,startDTS:C,endDTS:I}),u.setElementaryStreamInfo(De,y,b,C,I),this.bufferFragmentData(v,u,c,l)}if(E!=null&&(r=E.samples)!=null&&r.length){var O=W({id:i,frag:u,details:f},E);a.trigger(T.FRAG_PARSING_METADATA,O)}if(p){var B=W({id:i,frag:u,details:f},p);a.trigger(T.FRAG_PARSING_USERDATA,B)}}else this.fragmentTracker.removeFragment(u)}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i){if(this.state===It){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(T.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(T.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===G?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=Gi):(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(T.AUDIO_TRACK_SWITCHED,H({},t))},n}(ca),Dl=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}de(n,s);var e=n.prototype;return e.registerListeners=function(){var t=this.hls;t.on(T.MANIFEST_LOADING,this.onManifestLoading,this),t.on(T.MANIFEST_PARSED,this.onManifestParsed,this),t.on(T.LEVEL_LOADING,this.onLevelLoading,this),t.on(T.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(T.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(T.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(T.MANIFEST_LOADING,this.onManifestLoading,this),t.off(T.MANIFEST_PARSED,this.onManifestParsed,this),t.off(T.LEVEL_LOADING,this.onLevelLoading,this),t.off(T.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(T.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(T.ERROR,this.onError,this)},e.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,s.prototype.destroy.call(this)},e.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0},e.onManifestParsed=function(t,r){this.tracks=r.audioTracks||[]},e.onAudioTrackLoaded=function(t,r){var i=r.id,a=r.groupId,o=r.details,l=this.tracksInGroup[i];if(l&&l.groupId===a){var d=l.details;l.details=r.details,this.log("audio-track "+i+' "'+l.name+'" lang:'+l.lang+" group:"+a+" loaded ["+o.startSN+"-"+o.endSN+"]"),i===this.trackId&&this.playlistLoaded(i,r,d)}else this.warn("Track with id:"+i+" and group:"+a+" not found in active group "+l.groupId)},e.onLevelLoading=function(t,r){this.switchLevel(r.level)},e.onLevelSwitching=function(t,r){this.switchLevel(r.level)},e.switchLevel=function(t){var r=this.hls.levels[t];if(r!=null&&r.audioGroupIds){var i=r.audioGroupIds[r.urlId];if(this.groupId!==i){this.groupId=i||null;var a=this.tracks.filter(function(l){return!i||l.groupId===i});this.selectDefaultTrack&&!a.some(function(l){return l.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=a;var o={audioTracks:a};this.log("Updating audio tracks, "+a.length+" track(s) found in group:"+i),this.hls.trigger(T.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===qt&&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(T.AUDIO_TRACK_SWITCHING,H({},a)),!a.details||a.details.live){var d=this.switchParams(a.url,i==null?void 0:i.details);this.loadPlaylist(d)}}},e.selectInitialTrack=function(){var t=this.tracksInGroup,r=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(r!==-1)this.setAudioTrack(r);else{var i=new Error("No track found for running audio group-ID: "+this.groupId+" track count: "+t.length);this.warn(i.message),this.hls.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:N.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"]===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(T.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}(g);function Ms(s,n){if(s.length!==n.length)return!1;for(var e=0;e<s.length;e++)if(!Il(s[e].attrs,n[e].attrs))return!1;return!0}function Il(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 Cl=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[subtitle-stream-controller]",Yt)||this).levels=[],a.currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a._registerListeners(),a}de(n,s);var e=n.prototype;return e.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},e._registerListeners=function(){var t=this.hls;t.on(T.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(T.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(T.MANIFEST_LOADING,this.onManifestLoading,this),t.on(T.LEVEL_LOADED,this.onLevelLoaded,this),t.on(T.ERROR,this.onError,this),t.on(T.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(T.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(T.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(T.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(T.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(T.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(T.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(T.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(T.MANIFEST_LOADING,this.onManifestLoading,this),t.off(T.LEVEL_LOADED,this.onLevelLoaded,this),t.off(T.ERROR,this.onError,this),t.off(T.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(T.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(T.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(T.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(T.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(T.FRAG_BUFFERED,this.onFragBuffered,this)},e.startLoad=function(t){this.stopLoad(),this.state=fe,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=fe,a){var o=this.tracksBuffered[this.currentTrackId];if(o){for(var l,d=i.start,u=0;u<o.length;u++)if(d>=o[u].start&&d<=o[u].end){l=o[u];break}var c=i.start+i.duration;l?l.end=c:(l={start:d,end:c},o.push(l)),this.fragmentTracker.fragBuffered(i)}}},e.onBufferFlushing=function(t,r){var i=r.startOffset,a=r.endOffset;if(i===0&&a!==Number.POSITIVE_INFINITY){var o=this.currentTrackId,l=this.levels;if(!l.length||!l[o]||!l[o].details)return;var d=a-l[o].details.targetduration;if(d<=0)return;r.endOffsetSubtitles=Math.max(0,d),this.tracksBuffered.forEach(function(u){for(var c=0;c<u.length;)if(u[c].end<=d)u.shift();else{if(!(u[c].start<d))break;u[c].start=d,c++}}),this.fragmentTracker.removeFragmentsInRange(i,d,Yt)}},e.onFragBuffered=function(t,r){var i;this.loadedmetadata||r.frag.type!==qe||(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)===Yt&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Ve&&(this.state=fe))},e.onSubtitleTracksUpdated=function(t,r){var i=this,a=r.subtitleTracks;Ms(this.levels,a)?this.levels=a.map(function(o){return new Br(o)}):(this.tracksBuffered=[],this.levels=a.map(function(o){var l=new Br(o);return i.tracksBuffered[l.id]=[],l}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Yt),this.fragPrevious=null,this.mediaBuffer=null)},e.onSubtitleTrackSwitch=function(t,r){if(this.currentTrackId=r.id,this.levels.length&&this.currentTrackId!==-1){var i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(500)}else this.clearInterval()},e.onSubtitleTrackLoaded=function(t,r){var i,a=r.details,o=r.id,l=this.currentTrackId,d=this.levels;if(d.length){var u=d[l];if(!(o>=d.length||o!==l)&&u){this.mediaBuffer=this.mediaBufferTimeRanges;var c=0;if(a.live||(i=u.details)!=null&&i.live){var f=this.mainDetails;if(a.deltaUpdateFailed||!f)return;var v=f.fragments[0];u.details?(c=this.alignPlaylists(a,u.details))===0&&v&&Fi(a,c=v.start):a.hasProgramDateTime&&f.hasProgramDateTime?(we(a,f),c=a.fragments[0].start):v&&Fi(a,c=v.start)}u.details=a,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(u.details,c),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===fe&&(Kr(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),u.details=void 0))}}},e._handleFragmentLoadComplete=function(t){var r=this,i=t.frag,a=t.payload,o=i.decryptdata,l=this.hls;if(!this.fragContextChanged(i)&&a&&a.byteLength>0&&o&&o.key&&o.iv&&o.method==="AES-128"){var d=performance.now();this.decrypter.decrypt(new Uint8Array(a),o.key.buffer,o.iv.buffer).catch(function(u){throw l.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:N.FRAG_DECRYPT_ERROR,fatal:!1,error:u,reason:u.message,frag:i}),u}).then(function(u){var c=performance.now();l.trigger(T.FRAG_DECRYPTED,{frag:i,payload:u,stats:{tstart:d,tdecrypt:c}})}).catch(function(u){r.warn(u.name+": "+u.message),r.state=fe})}},e.doTick=function(){if(this.media){if(this.state===fe){var t=this.currentTrackId,r=this.levels,i=r[t];if(!r.length||!i||!i.details)return;var a=i.details,o=a.targetduration,l=this.config,d=this.getLoadPosition(),u=ce.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],d-o,l.maxBufferHole),c=u.end,f=u.len,v=this.getFwdBufferInfo(this.media,qe);if(f>this.getMaxBufferLength(v==null?void 0:v.len)+o)return;var p=a.fragments,E=p.length,A=a.edge,y=null,b=this.fragPrevious;if(c<A){var C=l.maxFragLookUpTolerance;!(y=Kr(b,p,Math.max(p[0].start,c),C))&&b&&b.start<p[0].start&&(y=p[0])}else y=p[E-1];if(!y)return;y=this.mapToInitFragWhenRequired(y),this.fragmentTracker.getState(y)===w&&this.loadFragment(y,i,c)}}else this.state=fe},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 Pl(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(ca),Pl=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)}}},xl=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}de(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(T.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(T.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(T.MANIFEST_LOADING,this.onManifestLoading,this),t.on(T.MANIFEST_PARSED,this.onManifestParsed,this),t.on(T.LEVEL_LOADING,this.onLevelLoading,this),t.on(T.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(T.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(T.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(T.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(T.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(T.MANIFEST_LOADING,this.onManifestLoading,this),t.off(T.MANIFEST_PARSED,this.onManifestParsed,this),t.off(T.LEVEL_LOADING,this.onLevelLoading,this),t.off(T.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(T.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(T.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),La(this.media.textTracks).forEach(function(t){Rr(t)}),this.subtitleTrack=-1,this.media=null)},e.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},e.onManifestParsed=function(t,r){this.tracks=r.subtitleTracks},e.onSubtitleTrackLoaded=function(t,r){var i=r.id,a=r.details,o=this.trackId,l=this.tracksInGroup[o];if(l){var d=l.details;l.details=r.details,this.log("subtitle track "+i+" loaded ["+a.startSN+"-"+a.endSN+"]"),i===this.trackId&&this.playlistLoaded(i,r,d)}else this.warn("Invalid subtitle track id "+i)},e.onLevelLoading=function(t,r){this.switchLevel(r.level)},e.onLevelSwitching=function(t,r){this.switchLevel(r.level)},e.switchLevel=function(t){var r=this.hls.levels[t];if(r!=null&&r.textGroupIds){var i=r.textGroupIds[r.urlId],a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){var o=this.tracks.filter(function(u){return!i||u.groupId===i});this.tracksInGroup=o;var l=this.findTrackId(a==null?void 0:a.name)||this.findTrackId();this.groupId=i||null;var d={subtitleTracks:o};this.log("Updating subtitle tracks, "+o.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(T.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.setSubtitleTrack(l,a)}else this.shouldReloadPlaylist(a)&&this.setSubtitleTrack(this.trackId,a)}},e.findTrackId=function(t){for(var r=this.tracksInGroup,i=0;i<r.length;i++){var a=r[i];if((!this.selectDefaultTrack||a.default)&&(!t||t===a.name))return a.id}return-1},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===jt&&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(T.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=La(i.textTracks),l=o.filter(function(c){return c.groupId===r.groupId});if(t===-1)[].slice.call(o).forEach(function(c){c.mode="disabled"});else{var d=l[a];d&&(d.mode="disabled")}var u=l[t];u&&(u.mode=this.subtitleDisplay?"showing":"hidden")}},e.setSubtitleTrack=function(t,r){var i,a=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(t===-1||(i=a[t])!=null&&i.details)||t<-1||t>=a.length)){this.clearTimer();var o=a[t];if(this.log("Switching to subtitle-track "+t+(o?' "'+o.name+'" lang:'+o.lang+" group:"+o.groupId:"")),this.trackId=t,o){var l=o.id,d=o.groupId,u=d===void 0?"":d,c=o.name,f=o.type,v=o.url;this.hls.trigger(T.SUBTITLE_TRACK_SWITCH,{id:l,groupId:u,name:c,type:f,url:v});var p=this.switchParams(o.url,r==null?void 0:r.details);this.loadPlaylist(p)}else this.hls.trigger(T.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=La(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}(g);function La(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 Ol=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){P.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}(),Fs=ha(),Ns=/([ha]vc.)(?:\.[^.,]+)+/,Ml=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;P.log("[buffer-controller]: Media source opened"),r&&(r.removeEventListener("emptied",t._onMediaEmptied),t.updateMediaElementDuration(),t.hls.trigger(T.MEDIA_ATTACHED,{media:r})),i&&i.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){P.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){P.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var r=t.media,i=t._objectUrl;r&&r.src!==i&&P.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(T.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(T.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(T.MANIFEST_PARSED,this.onManifestParsed,this),e.on(T.BUFFER_RESET,this.onBufferReset,this),e.on(T.BUFFER_APPENDING,this.onBufferAppending,this),e.on(T.BUFFER_CODECS,this.onBufferCodecs,this),e.on(T.BUFFER_EOS,this.onBufferEos,this),e.on(T.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(T.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(T.FRAG_PARSED,this.onFragParsed,this),e.on(T.FRAG_CHANGED,this.onFragChanged,this)},n.unregisterListeners=function(){var e=this.hls;e.off(T.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(T.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(T.MANIFEST_PARSED,this.onManifestParsed,this),e.off(T.BUFFER_RESET,this.onBufferReset,this),e.off(T.BUFFER_APPENDING,this.onBufferAppending,this),e.off(T.BUFFER_CODECS,this.onBufferCodecs,this),e.off(T.BUFFER_EOS,this.onBufferEos,this),e.off(T.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(T.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(T.FRAG_PARSED,this.onFragParsed,this),e.off(T.FRAG_CHANGED,this.onFragChanged,this)},n._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new Ol(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},n.onManifestParsed=function(e,t){var r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,P.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},n.onMediaAttaching=function(e,t){var r=this.media=t.media;if(r&&Fs){var i=this.mediaSource=new Fs;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(P.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(i){P.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()):P.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(T.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){P.warn("[buffer-controller]: Failed to reset the "+t+" buffer",i)}}),this._initSourceBuffer()},n.onBufferCodecs=function(e,t){var r=this,i=this.getSourceBufferTypes().length;Object.keys(t).forEach(function(a){if(i){var o=r.tracks[a];if(o&&typeof o.buffer.changeType=="function"){var l=t[a],d=l.id,u=l.codec,c=l.levelCodec,f=l.container,v=l.metadata,p=(o.levelCodec||o.codec).replace(Ns,"$1"),E=(c||u).replace(Ns,"$1");if(p!==E){var A=f+";codecs="+(c||u);r.appendChangeType(a,A),P.log("[buffer-controller]: switching codec "+p+" to "+E),r.tracks[a]={buffer:o.buffer,codec:u,container:f,levelCodec:c,metadata:v,id:d}}}}else r.pendingTracks[a]=t[a]}),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},n.appendChangeType=function(e,t){var r=this,i=this.operationQueue,a={execute:function(){var o=r.sourceBuffer[e];o&&(P.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),o.changeType(t)),i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(o){P.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",o)}};i.append(a,e)},n.onBufferAppending=function(e,t){var r=this,i=this.hls,a=this.operationQueue,o=this.tracks,l=t.data,d=t.type,u=t.frag,c=t.part,f=t.chunkMeta,v=f.buffering[d],p=self.performance.now();v.start=p;var E=u.stats.buffering,A=c?c.stats.buffering:null;E.start===0&&(E.start=p),A&&A.start===0&&(A.start=p);var y=o.audio,b=!1;d==="audio"&&(y==null?void 0:y.container)==="audio/mpeg"&&(b=!this.lastMpegAudioChunk||f.id===1||this.lastMpegAudioChunk.sn!==f.sn,this.lastMpegAudioChunk=f);var C=u.start,I={execute:function(){if(v.executeStart=self.performance.now(),b){var O=r.sourceBuffer[d];if(O){var B=C-O.timestampOffset;Math.abs(B)>=.1&&(P.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+C+" (delta: "+B+") sn: "+u.sn+")"),O.timestampOffset=C)}}r.appendExecutor(l,d)},onStart:function(){},onComplete:function(){var O=self.performance.now();v.executeEnd=v.end=O,E.first===0&&(E.first=O),A&&A.first===0&&(A.first=O);var B=r.sourceBuffer,K={};for(var X in B)K[X]=ce.getBuffered(B[X]);r.appendError=0,r.hls.trigger(T.BUFFER_APPENDED,{type:d,frag:u,part:c,chunkMeta:f,parent:u.type,timeRanges:K})},onError:function(O){P.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",O);var B={type:Z.MEDIA_ERROR,parent:u.type,details:N.BUFFER_APPEND_ERROR,frag:u,part:c,chunkMeta:f,error:O,err:O,fatal:!1};O.code===DOMException.QUOTA_EXCEEDED_ERR?B.details=N.BUFFER_FULL_ERROR:(r.appendError++,B.details=N.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(P.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),B.fatal=!0)),i.trigger(T.ERROR,B)}};a.append(I,d)},n.onBufferFlushing=function(e,t){var r=this,i=this.operationQueue,a=function(o){return{execute:r.removeExecutor.bind(r,o,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(T.BUFFER_FLUSHED,{type:o})},onError:function(l){P.warn("[buffer-controller]: Failed to remove from "+o+" SourceBuffer",l)}}};t.type?i.append(a(t.type),t.type):this.getSourceBufferTypes().forEach(function(o){i.append(a(o),o)})},n.onFragParsed=function(e,t){var r=this,i=t.frag,a=t.part,o=[],l=a?a.elementaryStreams:i.elementaryStreams;l[nr]?o.push("audiovideo"):(l[De]&&o.push("audio"),l[Je]&&o.push("video")),o.length===0&&P.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers(function(){var d=self.performance.now();i.stats.buffering.end=d,a&&(a.stats.buffering.end=d);var u=a?a.stats:i.stats;r.hls.trigger(T.FRAG_BUFFERED,{frag:i,part:a,stats:u,id:i.type})},o)},n.onFragChanged=function(e,t){this.flushBackBuffer()},n.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce(function(i,a){var o=r.sourceBuffer[a];return!o||t.type&&t.type!==a||(o.ending=!0,o.ended||(o.ended=!0,P.log("[buffer-controller]: "+a+" sourceBuffer now EOS"))),i&&!(o&&!o.ended)},!0)&&(P.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"?(P.log("[buffer-controller]: Calling mediaSource.endOfStream()"),i.endOfStream()):i&&P.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+i.readyState)}))},n.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},n.flushBackBuffer=function(){var e=this.hls,t=this.details,r=this.media,i=this.sourceBuffer;if(r&&t!==null){var a=this.getSourceBufferTypes();if(a.length){var o=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(ie(o)&&!(o<0)){var l=r.currentTime,d=t.levelTargetDuration,u=Math.max(o,d),c=Math.floor(l/d)*d-u;a.forEach(function(f){var v=i[f];if(v){var p=ce.getBuffered(v);if(p.length>0&&c>p.start(0)){if(e.trigger(T.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(T.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(v.ended&&p.end(p.length-1)-l<2*d)return void P.info("[buffer-controller]: Cannot flush "+f+" back buffer while SourceBuffer is in ended state");e.trigger(T.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?(P.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(e)):(a>l&&a>o||!ie(o))&&(P.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(T.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(T.ERROR,{type:Z.MEDIA_ERROR,details:N.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;P.log("[buffer-controller]: creating sourceBuffer("+l+")");try{var d=t[i]=r.addSourceBuffer(l),u=i;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.tracks[i]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(c){P.error("[buffer-controller]: error while trying to add sourceBuffer: "+c.message),this.hls.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:N.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");P.error("[buffer-controller]: "+r,t),this.hls.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:N.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 P.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(e);var d=ie(i.duration)?i.duration:1/0,u=ie(a.duration)?a.duration:1/0,c=Math.max(0,t),f=Math.min(r,d,u);f>c&&!l.ending?(l.ended=!1,P.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 P.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 P.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}(),Us={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},Bs=function(s){var n=s;return Us.hasOwnProperty(s)&&(n=Us[s]),String.fromCharCode(n)},Vr=15,Tr=100,Fl={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Nl={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Ul={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Bl={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Gl=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Hl=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;P.log(this.time+" ["+n+"] "+t)}},s}(),Yr=function(s){for(var n=[],e=0;e<s.length;e++)n.push(s[e].toString(16));return n},Gs=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}(),Kl=function(){function s(e,t,r,i,a,o){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new Gs(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}(),ql=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<Tr;t++)this.chars.push(new Kl);this.logger=e,this.pos=0,this.currPenState=new Gs}var n=s.prototype;return n.equals=function(e){for(var t=!0,r=0;r<Tr;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<Tr;t++)this.chars[t].copy(e.chars[t])},n.isEmpty=function(){for(var e=!0,t=0;t<Tr;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>Tr&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Tr)},n.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)},n.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},n.insertChar=function(e){var t=this;e>=144&&this.backSpace();var r=Bs(e);this.pos>=Tr?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<Tr;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<Tr;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}(),Ra=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<Vr;t++)this.rows.push(new ql(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<Vr;e++)this.rows[e].clear();this.currRow=14},n.equals=function(e){for(var t=!0,r=0;r<Vr;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<Vr;t++)this.rows[t].copy(e.rows[t])},n.isEmpty=function(){for(var e=!0,t=0;t<Vr;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<Vr;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var o=a.rows[i].cueStartTime,l=this.logger.time;if(o&&l!==null&&o<l)for(var d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[i+d])}}this.currRow=t;var u=this.rows[this.currRow];if(e.indent!==null){var c=e.indent,f=Math.max(c-1,0);u.setCursor(e.indent),e.color=u.chars[f].penState.foreground}var v={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(v)},n.setBkgData=function(e){this.logger.log(2,function(){return"bkgData = "+JSON.stringify(e)}),this.backSpace(),this.setPen(e),this.insertChar(32)},n.setRollUpRows=function(e){this.nrRollUpRows=e},n.rollUp=function(){var e=this;if(this.nrRollUpRows!==null){this.logger.log(1,function(){return e.getDisplayText()});var t=this.currRow+1-this.nrRollUpRows,r=this.rows.splice(t,1)[0];r.clear(),this.rows.splice(this.currRow,0,r),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")},n.getDisplayText=function(e){e=e||!1;for(var t=[],r="",i=-1,a=0;a<Vr;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}(),Hs=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 Ra(r),this.nonDisplayedMemory=new Ra(r),this.lastOutputScreen=new Ra(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}(),Ks=function(){function s(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new Hl;this.channels=[null,new Hs(e,t,i),new Hs(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,"["+Yr([t[l],t[l+1]])+"] -> ("+Yr([i,a])+")"),(r=this.parseCmd(i,a))||(r=this.parseMidrow(i,a)),r||(r=this.parsePAC(i,a)),r||(r=this.parseBackgroundAttributes(i,a)),!r&&(o=this.parseChars(i,a))){var d=this.currentChannel;d&&d>0?this.channels[d].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}r||o||this.logger.log(2,"Couldn't parse cleaned data "+Yr([i,a])+" orig: "+Yr([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(qs(e,t,r))return mi(null,null,r),this.logger.log(3,"Repeated command ("+Yr([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),mi(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 ("+Yr([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(qs(e,t,i))return mi(null,null,i),!0;var a=e<=23?1:2;r=t>=64&&t<=95?a===1?Fl[e]:Ul[e]:a===1?Nl[e]:Bl[e];var o=this.channels[a];return!!o&&(o.setPAC(this.interpretPAC(r,t)),mi(e,t,i),this.currentChannel=a,!0)},n.interpretPAC=function(e,t){var r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=(1&r)==1,r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},n.parseChars=function(e,t){var r,i,a=null,o=null;if(e>=25?(r=2,o=e-8):(r=1,o=e),o>=17&&o<=19?(i=o===17?t+80:o===18?t+112:t+144,this.logger.log(2,"Special char '"+Bs(i)+"' in channel "+r),a=[i]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var l=Yr(a);this.logger.log(3,"Char codes = "+l.join(",")),mi(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=Gl[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),mi(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 mi(s,n,e){e.a=s,e.b=n}function qs(s,n,e){return e.a===s&&e.b===n}var Bn=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}(),wa=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var s=["","lr","rl"],n=["start","middle","end","left","right"];function e(a,o){if(typeof o!="string"||!Array.isArray(a))return!1;var l=o.toLowerCase();return!!~a.indexOf(l)&&l}function t(a){return e(n,a)}function r(a){for(var o=arguments.length,l=new Array(o>1?o-1:0),d=1;d<o;d++)l[d-1]=arguments[d];for(var u=1;u<arguments.length;u++){var c=arguments[u];for(var f in c)a[f]=c[f]}return a}function i(a,o,l){var d=this,u={enumerable:!0};d.hasBeenReset=!1;var c="",f=!1,v=a,p=o,E=l,A=null,y="",b=!0,C="auto",I="start",O=50,B="middle",K=50,X="middle";Object.defineProperty(d,"id",r({},u,{get:function(){return c},set:function(j){c=""+j}})),Object.defineProperty(d,"pauseOnExit",r({},u,{get:function(){return f},set:function(j){f=!!j}})),Object.defineProperty(d,"startTime",r({},u,{get:function(){return v},set:function(j){if(typeof j!="number")throw new TypeError("Start time must be set to a number.");v=j,this.hasBeenReset=!0}})),Object.defineProperty(d,"endTime",r({},u,{get:function(){return p},set:function(j){if(typeof j!="number")throw new TypeError("End time must be set to a number.");p=j,this.hasBeenReset=!0}})),Object.defineProperty(d,"text",r({},u,{get:function(){return E},set:function(j){E=""+j,this.hasBeenReset=!0}})),Object.defineProperty(d,"region",r({},u,{get:function(){return A},set:function(j){A=j,this.hasBeenReset=!0}})),Object.defineProperty(d,"vertical",r({},u,{get:function(){return y},set:function(j){var V=function(ee){return e(s,ee)}(j);if(V===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=V,this.hasBeenReset=!0}})),Object.defineProperty(d,"snapToLines",r({},u,{get:function(){return b},set:function(j){b=!!j,this.hasBeenReset=!0}})),Object.defineProperty(d,"line",r({},u,{get:function(){return C},set:function(j){if(typeof j!="number"&&j!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");C=j,this.hasBeenReset=!0}})),Object.defineProperty(d,"lineAlign",r({},u,{get:function(){return I},set:function(j){var V=t(j);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");I=V,this.hasBeenReset=!0}})),Object.defineProperty(d,"position",r({},u,{get:function(){return O},set:function(j){if(j<0||j>100)throw new Error("Position must be between 0 and 100.");O=j,this.hasBeenReset=!0}})),Object.defineProperty(d,"positionAlign",r({},u,{get:function(){return B},set:function(j){var V=t(j);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");B=V,this.hasBeenReset=!0}})),Object.defineProperty(d,"size",r({},u,{get:function(){return K},set:function(j){if(j<0||j>100)throw new Error("Size must be between 0 and 100.");K=j,this.hasBeenReset=!0}})),Object.defineProperty(d,"align",r({},u,{get:function(){return X},set:function(j){var V=t(j);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");X=V,this.hasBeenReset=!0}})),d.displayState=void 0}return i.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},i}(),jl=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 js(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 Vl=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 Vs(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 Da=new wa(0,0,""),Gn=Da.align==="middle"?"middle":"center";function Yl(s,n,e){var t=s;function r(){var a=js(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 Vl;Vs(a,function(c,f){var v;switch(c){case"region":for(var p=e.length-1;p>=0;p--)if(e[p].id===f){l.set(c,e[p].region);break}break;case"vertical":l.alt(c,f,["rl","lr"]);break;case"line":v=f.split(","),l.integer(c,v[0]),l.percent(c,v[0])&&l.set("snapToLines",!1),l.alt(c,v[0],["auto"]),v.length===2&&l.alt("lineAlign",v[1],["start",Gn,"end"]);break;case"position":v=f.split(","),l.percent(c,v[0]),v.length===2&&l.alt("positionAlign",v[1],["start",Gn,"end","line-left","line-right","auto"]);break;case"size":l.percent(c,f);break;case"align":l.alt(c,f,["start",Gn,"end","left","right"])}},/:/,/\s/),o.region=l.get("region",null),o.vertical=l.get("vertical","");var d=l.get("line","auto");d==="auto"&&Da.line===-1&&(d=-1),o.line=d,o.lineAlign=l.get("lineAlign","start"),o.snapToLines=l.get("snapToLines",!0),o.size=l.get("size",100),o.align=l.get("align",Gn);var u=l.get("position","auto");u==="auto"&&Da.position===50&&(u=o.align==="start"||o.align==="left"?0:o.align==="end"||o.align==="right"?100:50),o.position=u}(s,n)}function Ys(s){return s.replace(/<br(?: \/)?>/gi,`
|
|
35
|
+
`)}var Wl=function(){function s(){this.state="INITIAL",this.buffer="",this.decoder=new jl,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var n=s.prototype;return n.parse=function(e){var t=this;function r(){var d=t.buffer,u=0;for(d=Ys(d);u<d.length&&d[u]!=="\r"&&d[u]!==`
|
|
36
|
+
`;)++u;var c=d.slice(0,u);return d[u]==="\r"&&++u,d[u]===`
|
|
37
|
+
`&&++u,t.buffer=d.slice(u),c}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var i="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;var a=(i=r()).match(/^()?WEBVTT([ \t].*)?$/);if(a==null||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var o=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!1:i=r(),t.state){case"HEADER":/:/.test(i)?Vs(i,function(d,u){},/:/):i||(t.state="ID");continue;case"NOTE":i||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){t.state="NOTE";break}if(!i)continue;if(t.cue=new wa(0,0,""),t.state="CUE",i.indexOf("-->")===-1){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Yl(i,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var l=i.indexOf("-->")!==-1;if(!i||l&&(o=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
|
|
38
|
+
`),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+=`
|
|
25
39
|
|
|
26
|
-
`,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},
|
|
27
|
-
`:(n=t.childNodes)!==null&&n!==void 0&&n.length?wa(t,o):o?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function jn(d,o,e){return d&&d.hasAttributeNS(o,e)?d.getAttributeNS(o,e):null}function Da(d){return new Error("Could not parse ttml timestamp "+d)}function Gn(d,o){if(!d)return null;var e=Lt(d);return e===null&&(zr.test(d)?e=function(t,i){var n=zr.exec(t),a=(0|n[4])+(0|n[5])/i.subFrameRate;return 3600*(0|n[1])+60*(0|n[2])+(0|n[3])+a/i.frameRate}(d,o):pn.test(d)&&(e=function(t,i){var n=pn.exec(t),a=Number(n[1]);switch(n[2]){case"h":return 3600*a;case"m":return 60*a;case"ms":return 1e3*a;case"f":return a/i.frameRate;case"t":return a/i.tickRate}return a}(d,o))),e}var ws=function(){function d(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.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={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 bt(this,"textTrack1"),i=new bt(this,"textTrack2"),n=new bt(this,"textTrack3"),a=new bt(this,"textTrack4");this.cea608Parser1=new ur(1,t,i),this.cea608Parser2=new ur(3,n,a)}e.on(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(g.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(g.Events.FRAG_LOADING,this.onFragLoading,this),e.on(g.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(g.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(g.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(g.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(g.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=d.prototype;return o.destroy=function(){var e=this.hls;e.off(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(g.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(g.Events.FRAG_LOADING,this.onFragLoading,this),e.off(g.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(g.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(g.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(g.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(g.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(e,t,i,n,a){for(var r,s,l,u,c=!1,v=a.length;v--;){var m=a[v],_=(r=m[0],s=m[1],l=t,u=i,Math.min(s,u)-Math.max(r,l));if(_>=0&&(m[0]=Math.min(m[0],t),m[1]=Math.max(m[1],i),c=!0,_/(i-t)>.5))return}if(c||a.push([t,i]),this.config.renderTextTracksNatively){var S=this.captionsTracks[e];this.Cues.newCue(S,t,i,n)}else{var F=this.Cues.newCue(null,t,i,n);this.hls.trigger(g.Events.CUES_PARSED,{type:"captions",cues:F,track:e})}},o.onInitPtsFound=function(e,t){var i=this,n=t.frag,a=t.id,r=t.initPTS,s=t.timescale,l=this.unparsedVttFrags;a==="main"&&(this.initPTS[n.cc]=r,this.timescale[n.cc]=s),l.length&&(this.unparsedVttFrags=[],l.forEach(function(u){i.onFragLoaded(g.Events.FRAG_LOADED,u)}))},o.getExistingTrack=function(e){var t=this.media;if(t)for(var i=0;i<t.textTracks.length;i++){var n=t.textTracks[i];if(n[e])return n}return null},o.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},o.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,i=this.captionsTracks,n=this.media,a=t[e],r=a.label,s=a.languageCode,l=this.getExistingTrack(e);if(l)i[e]=l,lt(i[e]),Xe(i[e],n);else{var u=this.createTextTrack("captions",r,s);u&&(u[e]=!0,i[e]=u)}}},o.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(g.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}},o.createTextTrack=function(e,t,i){var n=this.media;if(n)return n.addTextTrack(e,t,i)},o.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},o.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach(function(t){lt(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}},o.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.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var i=0;i<t.length;i++)lt(t[i])}},o.onSubtitleTracksUpdated=function(e,t){var i=this;this.textTracks=[];var n=t.subtitleTracks||[],a=n.some(function(u){return u.textCodec===Er});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var r=this.tracks&&n&&this.tracks.length===n.length;if(this.tracks=n||[],this.config.renderTextTracksNatively){var s=this.media?this.media.textTracks:[];this.tracks.forEach(function(u,c){var v;if(c<s.length){for(var m=null,_=0;_<s.length;_++)if(Ds(s[_],u)){m=s[_];break}m&&(v=m)}if(v)lt(v);else{var S=i._captionsOrSubtitlesFromCharacteristics(u);(v=i.createTextTrack(S,u.name,u.lang))&&(v.mode="disabled")}v&&(v.groupId=u.groupId,i.textTracks.push(v))})}else if(!r&&this.tracks&&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(g.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}},o._captionsOrSubtitlesFromCharacteristics=function(e){var t;if((t=e.attrs)!==null&&t!==void 0&&t.CHARACTERISTICS){var i=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),n=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(i&&n)return"captions"}return"subtitles"},o.onManifestLoaded=function(e,t){var i=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(function(n){var a=/(?:CC|SERVICE)([1-4])/.exec(n.instreamId);if(a){var r="textTrack"+a[1],s=i.captionsProperties[r];s&&(s.label=n.name,n.lang&&(s.languageCode=n.lang),s.media=n)}})},o.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]},o.onFragLoading=function(e,t){var i=this.cea608Parser1,n=this.cea608Parser2,a=this.lastSn,r=this.lastPartIndex;if(this.enabled&&i&&n&&t.frag.type===fe.PlaylistLevelType.MAIN){var s,l,u=t.frag.sn,c=(s=t==null||(l=t.part)===null||l===void 0?void 0:l.index)!=null?s:-1;u===a+1||u===a&&c===r+1||(i.reset(),n.reset()),this.lastSn=u,this.lastPartIndex=c}},o.onFragLoaded=function(e,t){var i=t.frag,n=t.payload,a=this.initPTS,r=this.unparsedVttFrags;if(i.type===fe.PlaylistLevelType.SUBTITLE)if(n.byteLength){if(!(0,R.isFiniteNumber)(a[i.cc]))return r.push(t),void(a.length&&this.hls.trigger(g.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Missing initial subtitle PTS")}));var s=i.decryptdata,l="stats"in t;if(s==null||!s.encrypted||l){var u=this.tracks[i.level],c=this.vttCCs;c[i.cc]||(c[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),u&&u.textCodec===Er?this._parseIMSC1(i,n):this._parseVTTs(i,n,c)}}else this.hls.trigger(g.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(e,t){var i=this,n=this.hls;Aa(t,this.initPTS[e.cc],this.timescale[e.cc],function(a){i._appendCues(a,e.level),n.trigger(g.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(a){L.logger.log("Failed to parse IMSC1: "+a),n.trigger(g.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:a})})},o._parseVTTs=function(e,t,i){var n,a=this,r=this.hls;(function(s,l,u,c,v,m,_,S){var F,P=new dr,X=(0,Rt.utf8ArrayToStr)(new Uint8Array(s)).trim().replace(cr,`
|
|
40
|
+
`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this},s}(),zl=/\r\n|\n\r|\n|\r/g,Ia=function(s,n,e){return e===void 0&&(e=0),s.slice(e,e+n.length)===n},Ca=function(s){for(var n=5381,e=s.length;e;)n=33*n^s.charCodeAt(--e);return(n>>>0).toString()};function Pa(s,n,e){return Ca(s.toString())+Ca(n.toString())+Ca(e)}function Xl(s,n,e,t,r,i,a){var o,l,d,u=new Wl,c=Ft(new Uint8Array(s)).trim().replace(zl,`
|
|
28
41
|
`).split(`
|
|
29
|
-
`),
|
|
30
|
-
`)}),P.flush()})((n=e.initSegment)!==null&&n!==void 0&&n.data?(0,z.appendUint8Array)(e.initSegment.data,new Uint8Array(t)):t,this.initPTS[e.cc],this.timescale[e.cc],i,e.cc,e.start,function(s){a._appendCues(s,e.level),r.trigger(g.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(s){a._fallbackToIMSC1(e,t),L.logger.log("Failed to parse VTT cue: "+s),r.trigger(g.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})},o._fallbackToIMSC1=function(e,t){var i=this,n=this.tracks[e.level];n.textCodec||Aa(t,this.initPTS[e.cc],this.timescale[e.cc],function(){n.textCodec=Er,i._parseIMSC1(e,t)},function(){n.textCodec="wvtt"})},o._appendCues=function(e,t){var i=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if(!n||n.mode==="disabled")return;e.forEach(function(s){return it(n,s)})}else{var a=this.tracks[t];if(!a)return;var r=a.default?"default":"subtitles"+t;i.trigger(g.Events.CUES_PARSED,{type:"subtitles",cues:e,track:r})}},o.onFragDecrypted=function(e,t){var i=t.frag;if(i.type===fe.PlaylistLevelType.SUBTITLE){if(!(0,R.isFiniteNumber)(this.initPTS[i.cc]))return void this.unparsedVttFrags.push(t);this.onFragLoaded(g.Events.FRAG_LOADED,t)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(e,t){var i=this.cea608Parser1,n=this.cea608Parser2;if(this.enabled&&i&&n){var a=t.frag,r=t.samples;if(a.type!==fe.PlaylistLevelType.MAIN||this.closedCaptionsForLevel(a)!=="NONE")for(var s=0;s<r.length;s++){var l=r[s].bytes;if(l){var u=this.extractCea608Data(l);i.addData(r[s].pts,u[0]),n.addData(r[s].pts,u[1])}}}},o.onBufferFlushing=function(e,t){var i=t.startOffset,n=t.endOffset,a=t.endOffsetSubtitles,r=t.type,s=this.media;if(s&&!(s.currentTime<n)){if(!r||r==="video"){var l=this.captionsTracks;Object.keys(l).forEach(function(c){return Ct(l[c],i,n)})}if(this.config.renderTextTracksNatively&&i===0&&a!==void 0){var u=this.textTracks;Object.keys(u).forEach(function(c){return Ct(u[c],i,a)})}}},o.extractCea608Data=function(e){for(var t=[[],[]],i=31&e[0],n=2,a=0;a<i;a++){var r=e[n++],s=127&e[n++],l=127&e[n++];if((s!==0||l!==0)&&(4&r)!=0){var u=3&r;u!==0&&u!==1||(t[u].push(s),t[u].push(l))}}return t},d}();function Ds(d,o){return d&&d.label===o.name&&!(d.textTrack1||d.textTrack2)}function Ls(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}let Rs=function(){function d(i){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=i,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var o,e,t=d.prototype;return t.setStreamController=function(i){this.streamController=i},t.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},t.registerListeners=function(){var i=this.hls;i.on(g.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),i.on(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.on(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.on(g.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var i=this.hls;i.off(g.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),i.off(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.off(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.off(g.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},t.onFpsDropLevelCapping=function(i,n){d.isLevelAllowed(n.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(n.droppedLevel)},t.onMediaAttaching=function(i,n){this.media=n.media instanceof HTMLVideoElement?n.media:null,this.clientRect=null},t.onManifestParsed=function(i,n){var a=this.hls;this.restrictedLevels=[],this.firstLevel=n.firstLevel,a.config.capLevelToPlayerSize&&n.video&&this.startCapping()},t.onBufferCodecs=function(i,n){this.hls.config.capLevelToPlayerSize&&n.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping()},t.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var i=this.hls.levels;if(i.length){var n=this.hls;n.autoLevelCapping=this.getMaxLevel(i.length-1),n.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=n.autoLevelCapping}}},t.getMaxLevel=function(i){var n=this,a=this.hls.levels;if(!a.length)return-1;var r=a.filter(function(s,l){return d.isLevelAllowed(l,n.restrictedLevels)&&l<=i});return this.clientRect=null,d.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)},t.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())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var i=this.media,n={width:0,height:0};if(i){var a=i.getBoundingClientRect();n.width=a.width,n.height=a.height,n.width||n.height||(n.width=a.right-a.left||i.width||0,n.height=a.bottom-a.top||i.height||0)}return this.clientRect=n,n},d.isLevelAllowed=function(i,n){return n===void 0&&(n=[]),n.indexOf(i)===-1},d.getMaxLevelByMediaSize=function(i,n,a){if(!i||!i.length)return-1;for(var r,s,l=i.length-1,u=0;u<i.length;u+=1){var c=i[u];if((c.width>=n||c.height>=a)&&(r=c,!(s=i[u+1])||r.width!==s.width||r.height!==s.height)){l=u;break}}return l},o=d,(e=[{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 i=1;if(!this.hls.config.ignoreDevicePixelRatio)try{i=self.devicePixelRatio}catch{}return i}}])&&Ls(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}(),Is=function(){function d(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 o=d.prototype;return o.setStreamController=function(e){this.streamController=e},o.registerListeners=function(){this.hls.on(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},o.unregisterListeners=function(){this.hls.off(g.Events.MEDIA_ATTACHING,this.onMediaAttaching)},o.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},o.onMediaAttaching=function(e,t){var i=this.hls.config;if(i.capLevelOnFPSDrop){var n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}},o.checkFPS=function(e,t,i){var n=performance.now();if(t){if(this.lastTime){var a=n-this.lastTime,r=i-this.lastDroppedFrames,s=t-this.lastDecodedFrames,l=1e3*r/a,u=this.hls;if(u.trigger(g.Events.FPS_DROP,{currentDropped:r,currentDecoded:s,totalDroppedFrames:i}),l>0&&r>u.config.fpsDroppedMonitoringThreshold*s){var c=u.currentLevel;L.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(u.autoLevelCapping===-1||u.autoLevelCapping>=c)&&(c-=1,u.trigger(g.Events.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:u.currentLevel}),u.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=t}},o.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)},d}();var ai=B(300);function Kn(d){var o=typeof Map=="function"?new Map:void 0;return Kn=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(o!==void 0){if(o.has(e))return o.get(e);o.set(e,i)}function i(){return Hn(e,arguments,qn(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ni(i,e)},Kn(d)}function Hn(d,o,e){return Hn=Cs()?Reflect.construct.bind():function(t,i,n){var a=[null];a.push.apply(a,i);var r=new(Function.bind.apply(t,a));return n&&Ni(r,n.prototype),r},Hn.apply(null,arguments)}function Cs(){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 Ni(d,o){return Ni=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ni(d,o)}function qn(d){return qn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},qn(d)}var gn="[eme]",La=function(){function d(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=d.CDMCleanupPromise?[d.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=L.logger.debug.bind(L.logger,gn),this.log=L.logger.log.bind(L.logger,gn),this.warn=L.logger.warn.bind(L.logger,gn),this.error=L.logger.error.bind(L.logger,gn),this.hls=e,this.config=e.config,this.registerListeners()}var o=d.prototype;return o.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null},o.registerListeners=function(){this.hls.on(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(g.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(g.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},o.unregisterListeners=function(){this.hls.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(g.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(g.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},o.getLicenseServerUrl=function(e){var t=this.config,i=t.drmSystems,n=t.widevineLicenseUrl,a=i[e];if(a)return a.licenseUrl;if(e===K.WIDEVINE&&n)return n;throw new Error('no license server URL configured for key-system "'+e+'"')},o.getServerCertificateUrl=function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},o.attemptKeySystemAccess=function(e){var t=this,i=this.hls.levels,n=function(s,l,u){return!!s&&u.indexOf(s)===l},a=i.map(function(s){return s.audioCodec}).filter(n),r=i.map(function(s){return s.videoCodec}).filter(n);return a.length+r.length===0&&r.push("avc1.42e01e"),new Promise(function(s,l){(function u(c){var v=c.shift();t.getMediaKeysPromise(v,a,r).then(function(m){return s({keySystem:v,mediaKeys:m})}).catch(function(m){c.length?u(c):l(m instanceof Rr?m:new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:m,fatal:!0},m.message))})})(e)})},o.requestMediaKeySystemAccess=function(e,t){var i=this.config.requestMediaKeySystemAccessFunc;if(typeof i!="function"){var n="Configured requestMediaKeySystemAccess is not a function "+i;return Se===null&&self.location.protocol==="http:"&&(n="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(n))}return i(e,t)},o.getMediaKeysPromise=function(e,t,i){var n=this,a=function(u,c,v,m){var _;switch(u){case K.FAIRPLAY:_=["cenc","sinf"];break;case K.WIDEVINE:case K.PLAYREADY:_=["cenc"];break;case K.CLEARKEY:_=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+u)}return function(S,F,P,X){return[{initDataTypes:S,persistentState:X.persistentState||"not-allowed",distinctiveIdentifier:X.distinctiveIdentifier||"not-allowed",sessionTypes:X.sessionTypes||[X.sessionType||"temporary"],audioCapabilities:F.map(function(ue){return{contentType:'audio/mp4; codecs="'+ue+'"',robustness:X.audioRobustness||"",encryptionScheme:X.audioEncryptionScheme||null}}),videoCapabilities:P.map(function(ue){return{contentType:'video/mp4; codecs="'+ue+'"',robustness:X.videoRobustness||"",encryptionScheme:X.videoEncryptionScheme||null}})}]}(_,c,v,m)}(e,t,i,this.config.drmSystemOptions),r=this.keySystemAccessPromises[e],s=r==null?void 0:r.keySystemAccess;if(!s){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(a)),s=this.requestMediaKeySystemAccess(e,a);var l=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch(function(u){n.log('Failed to obtain access to key-system "'+e+'": '+u)}),s.then(function(u){n.log('Access for key-system "'+u.keySystem+'" obtained');var c=n.fetchServerCertificate(e);return n.log('Create media-keys for "'+e+'"'),l.mediaKeys=u.createMediaKeys().then(function(v){return n.log('Media-keys created for "'+e+'"'),c.then(function(m){return m?n.setMediaKeysServerCertificate(v,e,m):v})}),l.mediaKeys.catch(function(v){n.error('Failed to create media-keys for "'+e+'"}: '+v)}),l.mediaKeys})}return s.then(function(){return r.mediaKeys})},o.createMediaKeySessionContext=function(e){var t=e.decryptdata,i=e.keySystem,n=e.mediaKeys;this.log('Creating key-system session "'+i+'" keyId: '+ai.default.hexDump(t.keyId||[]));var a=n.createSession(),r={decryptdata:t,keySystem:i,mediaKeys:n,mediaKeysSession:a,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r},o.renewKeySession=function(e){var t=e.decryptdata;if(t.pssh){var i=this.createMediaKeySessionContext(e),n=this.getKeyIdString(t);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,"cenc",t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},o.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 ai.default.hexDump(e.keyId)},o.updateKeySession=function(e,t){var i,n=e.mediaKeysSession;return this.log('Updating key-session "'+n.sessionId+'" for keyID '+ai.default.hexDump(((i=e.decryptdata)===null||i===void 0?void 0:i.keyId)||[])+`
|
|
31
|
-
} (data length: `+(t&&t.byteLength)+")"),n.update(t)},o.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},o.getKeyFormatPromise=function(e){var t=this;return new Promise(function(i,n){var a=de(t.config),r=e.map(U).filter(function(s){return!!s&&a.indexOf(s)!==-1});return t.getKeySystemSelectionPromise(r).then(function(s){var l=s.keySystem,u=D(l);u?i(u):n(new Error('Unable to find format for key-system "'+l+'"'))}).catch(n)})},o.loadKey=function(e){var t=this,i=e.keyInfo.decryptdata,n=this.getKeyIdString(i),a="(keyId: "+n+' format: "'+i.keyFormat+'" method: '+i.method+" uri: "+i.uri+")";this.log("Starting session for key "+a);var r=this.keyIdToKeySessionPromise[n];return r||(r=this.keyIdToKeySessionPromise[n]=this.getKeySystemForKeyPromise(i).then(function(s){var l=s.keySystem,u=s.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+a),t.attemptSetMediaKeys(l,u).then(function(){t.throwIfDestroyed();var c=t.createMediaKeySessionContext({keySystem:l,mediaKeys:u,decryptdata:i});return t.generateRequestWithPreferredKeySession(c,"cenc",i.pssh,"playlist-key")})})).catch(function(s){return t.handleError(s)}),r},o.throwIfDestroyed=function(e){if(e===void 0&&(e="Invalid state"),!this.hls)throw new Error("invalid state")},o.handleError=function(e){this.hls&&(this.error(e.message),e instanceof Rr?this.hls.trigger(g.Events.ERROR,e.data):this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},o.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){var n=U(e.keyFormat),a=n?[n]:de(this.config);return this.attemptKeySystemAccess(a)}return i},o.getKeySystemSelectionPromise=function(e){if(e.length||(e=de(this.config)),e.length===0)throw new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},o._onMediaEncrypted=function(e){var t=this,i=e.initDataType,n=e.initData;if(this.debug('"'+e.type+'" event: init data type: "'+i+'"'),n!==null){var a,r;if(i==="sinf"&&this.config.drmSystems[K.FAIRPLAY]){var s=(0,z.bin2str)(new Uint8Array(n));try{var l=V(JSON.parse(s).sinf),u=(0,z.parseSinf)(new Uint8Array(l));if(!u)return;a=u.subarray(8,24),r=K.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var c=(0,z.parsePssh)(n);if(c===null)return;c.version===0&&c.systemId===ke.WIDEVINE&&c.data&&(a=c.data.subarray(8,24)),r=function(ue){if(ue===ke.WIDEVINE)return K.WIDEVINE}(c.systemId)}if(r&&a){for(var v=ai.default.hexDump(a),m=this.keyIdToKeySessionPromise,_=this.mediaKeySessions,S=m[v],F=function(ue){var _e=_[ue],ge=_e.decryptdata;if(ge.pssh||!ge.keyId)return"continue";var De=ai.default.hexDump(ge.keyId);return v===De||ge.uri.replace(/-/g,"").indexOf(v)!==-1?(S=m[De],delete m[De],ge.pssh=new Uint8Array(n),ge.keyId=a,S=m[v]=S.then(function(){return t.generateRequestWithPreferredKeySession(_e,i,n,"encrypted-event-key-match")}),"break"):void 0},P=0;P<_.length;P++){var X=F(P);if(X!=="continue"&&X==="break")break}S||(S=m[v]=this.getKeySystemSelectionPromise([r]).then(function(ue){var _e,ge=ue.keySystem,De=ue.mediaKeys;t.throwIfDestroyed();var He=new Le("ISO-23001-7",v,(_e=D(ge))!=null?_e:"");return He.pssh=new Uint8Array(n),He.keyId=a,t.attemptSetMediaKeys(ge,De).then(function(){t.throwIfDestroyed();var Je=t.createMediaKeySessionContext({decryptdata:He,keySystem:ge,mediaKeys:De});return t.generateRequestWithPreferredKeySession(Je,i,n,"encrypted-event-no-match")})})),S.catch(function(ue){return t.handleError(ue)})}}},o._onWaitingForKey=function(e){this.log('"'+e.type+'" event')},o.attemptSetMediaKeys=function(e,t){var i=this,n=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var a=Promise.all(n).then(function(){if(!i.media)throw new Error("Attempted to set mediaKeys without media element attached");return i.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(a),a.then(function(){i.log('Media-keys set for "'+e+'"'),n.push(a),i.setMediaKeysQueue=i.setMediaKeysQueue.filter(function(r){return n.indexOf(r)===-1})})},o.generateRequestWithPreferredKeySession=function(e,t,i,n){var a,r,s=this,l=(a=this.config.drmSystems)===null||a===void 0||(r=a[e.keySystem])===null||r===void 0?void 0:r.generateRequest;if(l)try{var u=l.call(this.hls,t,i,e);if(!u)throw new Error("Invalid response from configured generateRequest filter");t=u.initDataType,i=e.decryptdata.pssh=u.initData?new Uint8Array(u.initData):null}catch(S){var c;if(this.warn(S.message),(c=this.hls)!==null&&c!==void 0&&c.config.debug)throw S}if(i===null)return this.log('Skipping key-session request for "'+n+'" (no initData)'),Promise.resolve(e);var v=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'+n+'": '+v+" (init data type: "+t+" length: "+(i?i.byteLength:null)+")");var m=new(ti());e.mediaKeysSession.onmessage=function(S){var F=e.mediaKeysSession;if(F){var P=S.messageType,X=S.message;s.log('"'+P+'" message event for session "'+F.sessionId+'" message size: '+X.byteLength),P==="license-request"||P==="license-renewal"?s.renewLicense(e,X).catch(function(ue){s.handleError(ue),m.emit("error",ue)}):P==="license-release"?e.keySystem===K.FAIRPLAY&&(s.updateKeySession(e,E("acknowledged")),s.removeSession(e)):s.warn('unhandled media key message type "'+P+'"')}else m.emit("error",new Error("invalid state"))},e.mediaKeysSession.onkeystatuseschange=function(S){if(e.mediaKeysSession){s.onKeyStatusChange(e);var F=e.keyStatus;m.emit("keyStatus",F),F==="expired"&&(s.warn(e.keySystem+" expired for key "+v),s.renewKeySession(e))}else m.emit("error",new Error("invalid state"))};var _=new Promise(function(S,F){m.on("error",F),m.on("keyStatus",function(P){P.startsWith("usable")?S():P==="output-restricted"?F(new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):P==="internal-error"?F(new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+P+'"')):P==="expired"?F(new Error("key expired while generating request")):s.warn('unhandled key status change "'+P+'"')})});return e.mediaKeysSession.generateRequest(t,i).then(function(){var S;s.log('Request generated for key-session "'+((S=e.mediaKeysSession)===null||S===void 0?void 0:S.sessionId)+'" keyId: '+v)}).catch(function(S){throw new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_NO_SESSION,error:S,fatal:!1},"Error generating key-session request: "+S)}).then(function(){return _}).catch(function(S){throw m.removeAllListeners(),s.removeSession(e),S}).then(function(){return m.removeAllListeners(),e})},o.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach(function(i,n){t.log('key status change "'+i+'" for keyStatuses keyId: '+ai.default.hexDump("buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n))+" session keyId: "+ai.default.hexDump(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=i})},o.fetchServerCertificate=function(e){var t=this;return new Promise(function(i,n){var a=t.getServerCertificateUrl(e);if(!a)return i();t.log('Fetching serverCertificate for "'+e+'"');var r=new XMLHttpRequest;r.open("GET",a,!0),r.responseType="arraybuffer",r.onreadystatechange=function(){r.readyState===XMLHttpRequest.DONE&&(r.status===200?i(r.response):n(new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r},'"'+e+'" certificate request XHR failed ('+a+"). Status: "+r.status+" ("+r.statusText+")")))},r.send()})},o.setMediaKeysServerCertificate=function(e,t,i){var n=this;return new Promise(function(a,r){e.setServerCertificate(i).then(function(s){n.log("setServerCertificate "+(s?"success":"not supported by CDM")+" ("+(i==null?void 0:i.byteLength)+') on "'+t+'"'),a(e)}).catch(function(s){r(new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:s,fatal:!0},s.message))})})},o.renewLicense=function(e,t){var i=this;return this.requestLicense(e,new Uint8Array(t)).then(function(n){return i.updateKeySession(e,new Uint8Array(n)).catch(function(a){throw new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:a,fatal:!0},a.message)})})},o.setupLicenseXHR=function(e,t,i,n){var a=this,r=this.config.licenseXhrSetup;return r?Promise.resolve().then(function(){if(!i.decryptdata)throw new Error("Key removed");return r.call(a.hls,e,t,i,n)}).catch(function(s){if(!i.decryptdata)throw s;return e.open("POST",t,!0),r.call(a.hls,e,t,i,n)}).then(function(s){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:s||n}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))},o.requestLicense=function(e,t){var i=this;return new Promise(function(n,a){var r=i.getLicenseServerUrl(e.keySystem);i.log("Sending license request to URL: "+r);var s=new XMLHttpRequest;s.responseType="arraybuffer",s.onreadystatechange=function(){if(!i.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(s.readyState===4)if(s.status===200){i._requestLicenseFailureCount=0;var l=s.response;i.log("License received "+(l instanceof ArrayBuffer?l.byteLength:l));var u=i.config.licenseResponseCallback;if(u)try{l=u.call(i.hls,s,r,e)}catch(v){i.error(v)}n(l)}else if(i._requestLicenseFailureCount++,i._requestLicenseFailureCount>3||s.status>=400&&s.status<500)a(new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:s},"License Request XHR failed ("+r+"). Status: "+s.status+" ("+s.statusText+")"));else{var c=3-i._requestLicenseFailureCount+1;i.warn("Retrying license request, "+c+" attempts left"),i.requestLicense(e,t).then(n,a)}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=s,i.setupLicenseXHR(s,r,e,t).then(function(l){var u=l.xhr,c=l.licenseChallenge;u.send(c)})})},o.onMediaAttached=function(e,t){if(this.config.emeEnabled){var i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}},o.onMediaDetached=function(){var e=this,t=this.media,i=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={},Le.clearKeyUriToKeyIdMap();var n=i.length;d.CDMCleanupPromise=Promise.all(i.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(){n&&(e.log("finished closing key sessions and clearing media keys"),i.length=0)}).catch(function(a){e.log("Could not close sessions and clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))})},o.onManifestLoaded=function(e,t){var i=t.sessionKeys;if(i&&this.config.emeEnabled&&!this.keyFormatPromise){var n=i.reduce(function(a,r){return a.indexOf(r.keyFormat)===-1&&a.push(r.keyFormat),a},[]);this.log("Selecting key-system from session-keys "+n.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(n)}},o.removeSession=function(e){var t=this,i=e.mediaKeysSession,n=e.licenseXhr;if(i){this.log("Remove licenses and keys and close session "+i.sessionId),i.onmessage=null,i.onkeystatuseschange=null,n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);return a>-1&&this.mediaKeySessions.splice(a,1),i.remove().catch(function(r){t.log("Could not remove session: "+r)}).then(function(){return i.close()}).catch(function(r){t.log("Could not close session: "+r)})}},d}();La.CDMCleanupPromise=void 0;var Rr=function(d){var o,e;function t(i,n){var a;return(a=d.call(this,n)||this).data=void 0,a.data=i,i.err=i.error,a}return e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ni(o,e),t}(Kn(Error));let Ps=La;var fr,Vn,Ra;function Ia(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Ca(d,o,e){return o&&Ia(d.prototype,o),e&&Ia(d,e),Object.defineProperty(d,"prototype",{writable:!1}),d}function Pa(d,o){var e=typeof Symbol!="undefined"&&d[Symbol.iterator]||d["@@iterator"];if(e)return(e=e.call(d)).next.bind(e);if(Array.isArray(d)||(e=function(i,n){if(i){if(typeof i=="string")return Oa(i,n);var a=Object.prototype.toString.call(i).slice(8,-1);return a==="Object"&&i.constructor&&(a=i.constructor.name),a==="Map"||a==="Set"?Array.from(i):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?Oa(i,n):void 0}}(d))||o&&d&&typeof d.length=="number"){e&&(d=e);var t=0;return function(){return t>=d.length?{done:!0}:{done:!1,value:d[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
32
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oa(d,o){(o==null||o>d.length)&&(o=d.length);for(var e=0,t=new Array(o);e<o;e++)t[e]=d[e];return t}function mn(){return mn=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},mn.apply(this,arguments)}(function(d){d.MANIFEST="m",d.AUDIO="a",d.VIDEO="v",d.MUXED="av",d.INIT="i",d.CAPTION="c",d.TIMED_TEXT="tt",d.KEY="k",d.OTHER="o"})(fr||(fr={})),function(d){d.DASH="d",d.HLS="h",d.SMOOTH="s",d.OTHER="o"}(Vn||(Vn={})),function(d){d.VOD="v",d.LIVE="l"}(Ra||(Ra={}));var Os=function(){function d(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:fr.MANIFEST,su:!t.initialized})}catch(r){L.logger.warn("Could not generate manifest CMCD data.",r)}},this.applyFragmentData=function(a){try{var r=a.frag,s=t.hls.levels[r.level],l=t.getObjectType(r),u={d:1e3*r.duration,ot:l};l!==fr.VIDEO&&l!==fr.AUDIO&&l!=fr.MUXED||(u.br=s.bitrate/1e3,u.tb=t.getTopBandwidth(l)/1e3,u.bl=t.getBufferLength(l)),t.apply(a,u)}catch(c){L.logger.warn("Could not generate segment CMCD data.",c)}},this.hls=e;var i=this.config=e.config,n=i.cmcd;n!=null&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||d.uuid(),this.cid=n.contentId,this.useHeaders=n.useHeaders===!0,this.registerListeners())}var o=d.prototype;return o.registerListeners=function(){var e=this.hls;e.on(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(g.Events.BUFFER_CREATED,this.onBufferCreated,this)},o.unregisterListeners=function(){var e=this.hls;e.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(g.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},o.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},o.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},o.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},o.onBufferCreated=function(e,t){var i,n;this.audioBuffer=(i=t.tracks.audio)===null||i===void 0?void 0:i.buffer,this.videoBuffer=(n=t.tracks.video)===null||n===void 0?void 0:n.buffer},o.createData=function(){var e;return{v:1,sf:Vn.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},o.apply=function(e,t){t===void 0&&(t={}),mn(t,this.createData());var i=t.ot===fr.INIT||t.ot===fr.VIDEO||t.ot===fr.MUXED;if(this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){var n=d.toHeaders(t);if(!Object.keys(n).length)return;e.headers||(e.headers={}),mn(e.headers,n)}else{var a=d.toQuery(t);if(!a)return;e.url=d.appendQueryToUri(e.url,a)}},o.getObjectType=function(e){var t=e.type;return t==="subtitle"?fr.TIMED_TEXT:e.sn==="initSegment"?fr.INIT:t==="audio"?fr.AUDIO:t==="main"?this.hls.audioTracks.length?fr.VIDEO:fr.MUXED:void 0},o.getTopBandwidth=function(e){var t,i=0,n=this.hls;if(e===fr.AUDIO)t=n.audioTracks;else{var a=n.maxAutoLevel,r=a>-1?a+1:n.levels.length;t=n.levels.slice(0,r)}for(var s,l=Pa(t);!(s=l()).done;){var u=s.value;u.bitrate>i&&(i=u.bitrate)}return i>0?i:NaN},o.getBufferLength=function(e){var t=this.hls.media,i=e===fr.AUDIO?this.audioBuffer:this.videoBuffer;return i&&t?1e3*Gt.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN},o.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,i=e||this.config.loader;return function(){function n(r){this.loader=void 0,this.loader=new i(r)}var a=n.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(r,s,l){t(r),this.loader.load(r,s,l)},Ca(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},o.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,i=e||this.config.loader;return function(){function n(r){this.loader=void 0,this.loader=new i(r)}var a=n.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(r,s,l){t(r),this.loader.load(r,s,l)},Ca(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},d.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)},d.serialize=function(e){for(var t,i=[],n=function(S){return!Number.isNaN(S)&&S!=null&&S!==""&&S!==!1},a=function(S){return Math.round(S)},r=function(S){return 100*a(S/100)},s={br:a,d:a,bl:r,dl:r,mtp:r,nor:function(S){return encodeURIComponent(S)},rtp:r,tb:a},l=Pa(Object.keys(e||{}).sort());!(t=l()).done;){var u=t.value,c=e[u];if(n(c)&&!(u==="v"&&c===1||u=="pr"&&c===1)){var v=s[u];v&&(c=v(c));var m,_=typeof c;m=u==="ot"||u==="sf"||u==="st"?u+"="+c:_==="boolean"?u:_==="number"?u+"="+c:u+"="+JSON.stringify(c),i.push(m)}}return i.join(",")},d.toHeaders=function(e){for(var t={},i=["Object","Request","Session","Status"],n=[{},{},{},{}],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},r=0,s=Object.keys(e);r<s.length;r++){var l=s[r];n[a[l]!=null?a[l]:1][l]=e[l]}for(var u=0;u<n.length;u++){var c=d.serialize(n[u]);c&&(t["CMCD-"+i[u]]=c)}return t},d.toQuery=function(e){return"CMCD="+encodeURIComponent(d.serialize(e))},d.appendQueryToUri=function(e,t){if(!t)return e;var i=e.includes("?")?"&":"?";return""+e+i+t},d}(),xa=B(408),xs=/^age:\s*[\d.]+\s*$/m;let Ma=function(){function d(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 xa.LoadStats,this.retryDelay=0}var o=d.prototype;return o.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},o.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()))},o.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!==null&&e!==void 0&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},o.load=function(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.retryDelay=t.retryDelay,this.loadInternal()},o.loadInternal=function(){var e=this.config,t=this.context;if(e){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0;var a=this.xhrSetup;try{if(a)try{a(i,t.url)}catch{i.open("GET",t.url,!0),a(i,t.url)}i.readyState||i.open("GET",t.url,!0);var r=this.context.headers;if(r)for(var s in r)i.setRequestHeader(s,r[s])}catch(l){return void this.callbacks.onError({code:i.status,text:l.message},t,i)}t.rangeEnd&&i.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),i.onreadystatechange=this.readystatechange.bind(this),i.onprogress=this.loadprogress.bind(this),i.responseType=t.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout),i.send()}},o.readystatechange=function(){var e=this.context,t=this.loader,i=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!i.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start)),n===4){t.onreadystatechange=null,t.onprogress=null;var r=t.status,s=t.responseType==="arraybuffer";if(r>=200&&r<300&&(s&&t.response||t.responseText!==null)){var l,u;if(i.loading.end=Math.max(self.performance.now(),i.loading.first),u=s?(l=t.response).byteLength:(l=t.responseText).length,i.loaded=i.total=u,!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(i,e,l,t),!this.callbacks)return;var v={url:t.responseURL,data:l};this.callbacks.onSuccess(v,i,e,t)}else i.retry>=a.maxRetry||r>=400&&r<499?(L.logger.error(r+" while loading "+e.url),this.callbacks.onError({code:r,text:t.statusText},e,t)):(L.logger.warn(r+" while loading "+e.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),i.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)}},o.loadtimeout=function(){L.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},o.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},o.getCacheAge=function(){var e=null;if(this.loader&&xs.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},d}();function Yn(d){var o=typeof Map=="function"?new Map:void 0;return Yn=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(o!==void 0){if(o.has(e))return o.get(e);o.set(e,i)}function i(){return Wn(e,arguments,Xn(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ui(i,e)},Yn(d)}function Wn(d,o,e){return Wn=Ms()?Reflect.construct.bind():function(t,i,n){var a=[null];a.push.apply(a,i);var r=new(Function.bind.apply(t,a));return n&&Ui(r,n.prototype),r},Wn.apply(null,arguments)}function Ms(){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 Ui(d,o){return Ui=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ui(d,o)}function Xn(d){return Xn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},Xn(d)}function zn(){return zn=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},zn.apply(this,arguments)}var Fs=function(){function d(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||Ns,this.controller=new self.AbortController,this.stats=new xa.LoadStats}var o=d.prototype;return o.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},o.abortInternal=function(){var e=this.response;e&&e.ok||(this.stats.aborted=!0,this.controller.abort())},o.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!==null&&e!==void 0&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},o.load=function(e,t,i){var n=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var r=function(c,v){var m={method:"GET",mode:"cors",credentials:"same-origin",signal:v,headers:new self.Headers(zn({},c.headers))};return c.rangeEnd&&m.headers.set("Range","bytes="+c.rangeStart+"-"+String(c.rangeEnd-1)),m}(e,this.controller.signal),s=i.onProgress,l=e.responseType==="arraybuffer",u=l?"byteLength":"length";this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){n.abortInternal(),i.onTimeout(a,e,n.response)},t.timeout),self.fetch(this.request).then(function(c){if(n.response=n.loader=c,!c.ok){var v=c.status,m=c.statusText;throw new Us(m||"fetch, bad network response",v,c)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(c.headers.get("Content-Length")||"0"),s&&(0,R.isFiniteNumber)(t.highWaterMark)?n.loadProgressively(c,a,e,t.highWaterMark,s):l?c.arrayBuffer():c.text()}).then(function(c){var v=n.response;self.clearTimeout(n.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var m=c[u];m&&(a.loaded=a.total=m);var _={url:v.url,data:c};s&&!(0,R.isFiniteNumber)(t.highWaterMark)&&s(a,e,c,v),i.onSuccess(_,a,e,v)}).catch(function(c){if(self.clearTimeout(n.requestTimeout),!a.aborted){var v=c&&c.code||0,m=c?c.message:null;i.onError({code:v,text:m},e,c?c.details:null)}})},o.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},o.loadProgressively=function(e,t,i,n,a){n===void 0&&(n=0);var r=new hn,s=e.body.getReader();return function l(){return s.read().then(function(u){if(u.done)return r.dataLength&&a(t,i,r.flush(),e),Promise.resolve(new ArrayBuffer(0));var c=u.value,v=c.length;return t.loaded+=v,v<n||r.dataLength?(r.push(c),r.dataLength>=n&&a(t,i,r.flush(),e)):a(t,i,c,e),l()}).catch(function(){return Promise.reject()})}()},d}();function Ns(d,o){return new self.Request(d.url,o)}var Us=function(d){var o,e;function t(i,n,a){var r;return(r=d.call(this,i)||this).code=void 0,r.details=void 0,r.code=n,r.details=a,r}return e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ui(o,e),t}(Yn(Error));let Fa=Fs;var Bs=/\s/;function Qn(){return Qn=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},Qn.apply(this,arguments)}function Na(d,o){var e=Object.keys(d);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(d);o&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(d,i).enumerable})),e.push.apply(e,t)}return e}function Ua(d){for(var o=1;o<arguments.length;o++){var e=arguments[o]!=null?arguments[o]:{};o%2?Na(Object(e),!0).forEach(function(t){js(d,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(e)):Na(Object(e)).forEach(function(t){Object.defineProperty(d,t,Object.getOwnPropertyDescriptor(e,t))})}return d}function js(d,o,e){return(o=function(t){var i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t,"string");return typeof i=="symbol"?i:String(i)}(o))in d?Object.defineProperty(d,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):d[o]=e,d}var Gs=Ua(Ua({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,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Ma,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Cn,bufferController:Un,capLevelController:Rs,fpsController:Is,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:Se,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},{cueHandler:{newCue:function(d,o,e,t){for(var i,n,a,r,s,l=[],u=self.VTTCue||self.TextTrackCue,c=0;c<t.rows.length;c++)if(a=!0,r=0,s="",!(i=t.rows[c]).isEmpty()){for(var v=0;v<i.chars.length;v++)Bs.test(i.chars[v].uchar)&&a?r++:(s+=i.chars[v].uchar,a=!1);i.cueStartTime=o,o===e&&(e+=1e-4),r>=16?r--:r++;var m=Xt(s.trim()),_=hr(o,e,m);d&&d.cues&&d.cues.getCueById(_)||((n=new u(o,e,m)).id=_,n.line=c+1,n.align="left",n.position=10+Math.min(80,10*Math.floor(8*r/32)),l.push(n))}return d&&l.length&&(l.sort(function(S,F){return S.line==="auto"||F.line==="auto"?0:S.line>8&&F.line>8?F.line-S.line:S.line-F.line}),l.forEach(function(S){return it(d,S)})),l}},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:xn,subtitleTrackController:Nn,timelineController:ws,audioStreamController:Oi,audioTrackController:Pn,emeController:Ps,cmcdController:Os});function Ba(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var ja=function(){function d(n){n===void 0&&(n={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Ri.EventEmitter,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var a=this.config=function(Ae,Ke){if((Ke.liveSyncDurationCount||Ke.liveMaxLatencyDurationCount)&&(Ke.liveSyncDuration||Ke.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(Ke.liveMaxLatencyDurationCount!==void 0&&(Ke.liveSyncDurationCount===void 0||Ke.liveMaxLatencyDurationCount<=Ke.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(Ke.liveMaxLatencyDuration!==void 0&&(Ke.liveSyncDuration===void 0||Ke.liveMaxLatencyDuration<=Ke.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return Qn({},Ae,Ke)}(d.DefaultConfig,n);this.userConfig=n,(0,L.enableLogs)(a.debug,"Hls instance"),this._autoLevelCapping=-1,a.progressive&&function(Ae){var Ke=Ae.loader;Ke!==Fa&&Ke!==Ma?(L.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),Ae.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}()&&(Ae.loader=Fa,Ae.progressive=!0,Ae.enableSoftwareAES=!0,L.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}(a);var r=a.abrController,s=a.bufferController,l=a.capLevelController,u=a.fpsController,c=this.abrController=new r(this),v=this.bufferController=new s(this),m=this.capLevelController=new l(this),_=new u(this),S=new Ve(this),F=new tt(this),P=this.levelController=new ht(this),X=new Dt(this),ue=new pr(this.config),_e=this.streamController=new Ln(this,X,ue);m.setStreamController(_e),_.setStreamController(_e);var ge=[S,P,_e];this.networkControllers=ge;var De=[c,v,m,_,F,X];this.audioTrackController=this.createController(a.audioTrackController,ge);var He=a.audioStreamController;He&&ge.push(new He(this,X,ue)),this.subtitleTrackController=this.createController(a.subtitleTrackController,ge);var Je=a.subtitleStreamController;Je&&ge.push(new Je(this,X,ue)),this.createController(a.timelineController,De),ue.emeController=this.emeController=this.createController(a.emeController,De),this.cmcdController=this.createController(a.cmcdController,De),this.latencyController=this.createController(Ut,De),this.coreComponents=De}d.isSupported=function(){return function(){var n=fi();if(!n)return!1;var a=vi(),r=n&&typeof n.isTypeSupported=="function"&&n.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),s=!a||a.prototype&&typeof a.prototype.appendBuffer=="function"&&typeof a.prototype.remove=="function";return!!r&&!!s}()};var o,e,t,i=d.prototype;return i.createController=function(n,a){if(n){var r=new n(this);return a&&a.push(r),r}return null},i.on=function(n,a,r){r===void 0&&(r=this),this._emitter.on(n,a,r)},i.once=function(n,a,r){r===void 0&&(r=this),this._emitter.once(n,a,r)},i.removeAllListeners=function(n){this._emitter.removeAllListeners(n)},i.off=function(n,a,r,s){r===void 0&&(r=this),this._emitter.off(n,a,r,s)},i.listeners=function(n){return this._emitter.listeners(n)},i.emit=function(n,a,r){return this._emitter.emit(n,a,r)},i.trigger=function(n,a){if(this.config.debug)return this.emit(n,n,a);try{return this.emit(n,n,a)}catch(r){L.logger.error("An internal error happened while handling event "+n+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(g.Events.ERROR,{type:k.ErrorTypes.OTHER_ERROR,details:k.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:n,error:r})}return!1},i.listenerCount=function(n){return this._emitter.listenerCount(n)},i.destroy=function(){L.logger.log("destroy"),this.trigger(g.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(n){return n.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(n){return n.destroy()}),this.coreComponents.length=0},i.attachMedia=function(n){L.logger.log("attachMedia"),this._media=n,this.trigger(g.Events.MEDIA_ATTACHING,{media:n})},i.detachMedia=function(){L.logger.log("detachMedia"),this.trigger(g.Events.MEDIA_DETACHING,void 0),this._media=null},i.loadSource=function(n){this.stopLoad();var a=this.media,r=this.url,s=this.url=re.buildAbsoluteURL(self.location.href,n,{alwaysNormalize:!0});L.logger.log("loadSource:"+s),a&&r&&r!==s&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(a)),this.trigger(g.Events.MANIFEST_LOADING,{url:n})},i.startLoad=function(n){n===void 0&&(n=-1),L.logger.log("startLoad("+n+")"),this.networkControllers.forEach(function(a){a.startLoad(n)})},i.stopLoad=function(){L.logger.log("stopLoad"),this.networkControllers.forEach(function(n){n.stopLoad()})},i.swapAudioCodec=function(){L.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},i.recoverMediaError=function(){L.logger.log("recoverMediaError");var n=this._media;this.detachMedia(),n&&this.attachMedia(n)},i.removeLevel=function(n,a){a===void 0&&(a=0),this.levelController.removeLevel(n,a)},o=d,t=[{key:"version",get:function(){return"1.3.1"}},{key:"Events",get:function(){return g.Events}},{key:"ErrorTypes",get:function(){return k.ErrorTypes}},{key:"ErrorDetails",get:function(){return k.ErrorDetails}},{key:"DefaultConfig",get:function(){return d.defaultConfig?d.defaultConfig:Gs},set:function(n){d.defaultConfig=n}}],(e=[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(n){L.logger.log("set currentLevel:"+n),this.loadLevel=n,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(n){L.logger.log("set nextLevel:"+n),this.levelController.manualLevel=n,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(n){L.logger.log("set loadLevel:"+n),this.levelController.manualLevel=n}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(n){this.levelController.nextLoadLevel=n}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(n){L.logger.log("set firstLevel:"+n),this.levelController.firstLevel=n}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(n){L.logger.log("set startLevel:"+n),n!==-1&&(n=Math.max(n,this.minAutoLevel)),this.levelController.startLevel=n}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(n){var a=!!n;a!==this.config.capLevelToPlayerSize&&(a?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=a)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(n){this._autoLevelCapping!==n&&(L.logger.log("set autoLevelCapping:"+n),this._autoLevelCapping=n)}},{key:"bandwidthEstimate",get:function(){var n=this.abrController.bwEstimator;return n?n.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(n){ar.indexOf(n)>-1&&(this._maxHdcpLevel=n)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var n=this.levels,a=this.config.minAutoBitrate;if(!n)return 0;for(var r=n.length,s=0;s<r;s++)if(n[s].maxBitrate>=a)return s;return 0}},{key:"maxAutoLevel",get:function(){var n,a=this.levels,r=this.autoLevelCapping,s=this.maxHdcpLevel;if(n=r===-1&&a&&a.length?a.length-1:r,s)for(var l=n;l--;){var u=a[l].attrs["HDCP-LEVEL"];if(u&&u<=s)return l}return n}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(n){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,n)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var n=this.audioTrackController;return n?n.audioTracks:[]}},{key:"audioTrack",get:function(){var n=this.audioTrackController;return n?n.audioTrack:-1},set:function(n){var a=this.audioTrackController;a&&(a.audioTrack=n)}},{key:"subtitleTracks",get:function(){var n=this.subtitleTrackController;return n?n.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var n=this.subtitleTrackController;return n?n.subtitleTrack:-1},set:function(n){var a=this.subtitleTrackController;a&&(a.subtitleTrack=n)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var n=this.subtitleTrackController;return!!n&&n.subtitleDisplay},set:function(n){var a=this.subtitleTrackController;a&&(a.subtitleDisplay=n)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(n){this.config.lowLatencyMode=n}},{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}}])&&Ba(o.prototype,e),t&&Ba(o,t),Object.defineProperty(o,"prototype",{writable:!1}),d}();ja.defaultConfig=void 0},923:(ae,W,B)=>{"use strict";B.r(W),B.d(W,{BaseSegment:()=>ce,ElementaryStreamTypes:()=>j,Fragment:()=>we,Part:()=>q});var j,re=B(965),R=B(945),g=B(408);function k(ye,J){ye.prototype=Object.create(J.prototype),ye.prototype.constructor=ye,L(ye,J)}function L(ye,J){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(oe,K){return oe.__proto__=K,oe},L(ye,J)}function me(ye,J){for(var oe=0;oe<J.length;oe++){var K=J[oe];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(ye,typeof(Ee=function(ke,Ne){if(typeof ke!="object"||ke===null)return ke;var V=ke[Symbol.toPrimitive];if(V!==void 0){var E=V.call(ke,Ne);if(typeof E!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(ke)}(K.key,"string"))=="symbol"?Ee:String(Ee),K)}var Ee}function ne(ye,J,oe){return J&&me(ye.prototype,J),oe&&me(ye,oe),Object.defineProperty(ye,"prototype",{writable:!1}),ye}(function(ye){ye.AUDIO="audio",ye.VIDEO="video",ye.AUDIOVIDEO="audiovideo"})(j||(j={}));var ce=function(){function ye(J){var oe;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((oe={})[j.AUDIO]=null,oe[j.VIDEO]=null,oe[j.AUDIOVIDEO]=null,oe),this.baseurl=J}return ye.prototype.setByteRange=function(J,oe){var K=J.split("@",2),Ee=[];K.length===1?Ee[0]=oe?oe.byteRangeEndOffset:0:Ee[0]=parseInt(K[1]),Ee[1]=parseInt(K[0])+Ee[0],this._byteRange=Ee},ne(ye,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=(0,R.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(J){this._url=J}}]),ye}(),we=function(ye){function J(K,Ee){var ke;return(ke=ye.call(this,Ee)||this)._decryptdata=null,ke.rawProgramDateTime=null,ke.programDateTime=null,ke.tagList=[],ke.duration=0,ke.sn=0,ke.levelkeys=void 0,ke.type=void 0,ke.loader=null,ke.keyLoader=null,ke.level=-1,ke.cc=0,ke.startPTS=void 0,ke.endPTS=void 0,ke.appendedPTS=void 0,ke.startDTS=void 0,ke.endDTS=void 0,ke.start=0,ke.deltaPTS=void 0,ke.maxStartPTS=void 0,ke.minEndPTS=void 0,ke.stats=new g.LoadStats,ke.urlId=0,ke.data=void 0,ke.bitrateTest=!1,ke.title=null,ke.initSegment=null,ke.endList=void 0,ke.type=K,ke}k(J,ye);var oe=J.prototype;return oe.setKeyFormat=function(K){if(this.levelkeys){var Ee=this.levelkeys[K];Ee&&!this._decryptdata&&(this._decryptdata=Ee.getDecryptData(this.sn))}},oe.abortRequests=function(){var K,Ee;(K=this.loader)===null||K===void 0||K.abort(),(Ee=this.keyLoader)===null||Ee===void 0||Ee.abort()},oe.setElementaryStreamInfo=function(K,Ee,ke,Ne,V,E){E===void 0&&(E=!1);var U=this.elementaryStreams,D=U[K];D?(D.startPTS=Math.min(D.startPTS,Ee),D.endPTS=Math.max(D.endPTS,ke),D.startDTS=Math.min(D.startDTS,Ne),D.endDTS=Math.max(D.endDTS,V)):U[K]={startPTS:Ee,endPTS:ke,startDTS:Ne,endDTS:V,partial:E}},oe.clearElementaryStreamInfo=function(){var K=this.elementaryStreams;K[j.AUDIO]=null,K[j.VIDEO]=null,K[j.AUDIOVIDEO]=null},ne(J,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var K=this.levelkeys.identity;if(K)this._decryptdata=K.getDecryptData(this.sn);else{var Ee=Object.keys(this.levelkeys);if(Ee.length===1)return this._decryptdata=this.levelkeys[Ee[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!(0,re.isFiniteNumber)(this.programDateTime))return null;var K=(0,re.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*K}},{key:"encrypted",get:function(){var K;if((K=this._decryptdata)!==null&&K!==void 0&&K.encrypted)return!0;if(this.levelkeys){var Ee=Object.keys(this.levelkeys),ke=Ee.length;if(ke>1||ke===1&&this.levelkeys[Ee[0]].encrypted)return!0}return!1}}]),J}(ce),q=function(ye){function J(oe,K,Ee,ke,Ne){var V;(V=ye.call(this,Ee)||this).fragOffset=0,V.duration=0,V.gap=!1,V.independent=!1,V.relurl=void 0,V.fragment=void 0,V.index=void 0,V.stats=new g.LoadStats,V.duration=oe.decimalFloatingPoint("DURATION"),V.gap=oe.bool("GAP"),V.independent=oe.bool("INDEPENDENT"),V.relurl=oe.enumeratedString("URI"),V.fragment=K,V.index=ke;var E=oe.enumeratedString("BYTERANGE");return E&&V.setByteRange(E,Ne),Ne&&(V.fragOffset=Ne.fragOffset+Ne.duration),V}return k(J,ye),ne(J,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var oe=this.elementaryStreams;return!!(oe.audio||oe.video||oe.audiovideo)}}]),J}(ce)},408:(ae,W,B)=>{"use strict";B.r(W),B.d(W,{LoadStats:()=>j});var j=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}}},965:(ae,W,B)=>{"use strict";B.r(W),B.d(W,{MAX_SAFE_INTEGER:()=>re,isFiniteNumber:()=>j});var j=Number.isFinite||function(R){return typeof R=="number"&&isFinite(R)},re=Number.MAX_SAFE_INTEGER||9007199254740991},524:(ae,W,B)=>{"use strict";B.r(W),B.d(W,{default:()=>oe,flushTextTrackMetadataCueSamples:()=>Ee,flushTextTrackUserdataCueSamples:()=>ke,normalizePts:()=>K});var j=B(965);let re=function(){function E(){}return E.getSilentFrame=function(U,D){if(U==="mp4a.40.2"){if(D===1)return new Uint8Array([0,200,0,128,35,128]);if(D===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(D===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(D===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(D===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(D===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(D===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(D===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(D===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])}},E}();var R=Math.pow(2,32)-1,g=function(){function E(){}return E.init=function(){var U;for(U in E.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:[]},E.types)E.types.hasOwnProperty(U)&&(E.types[U]=[U.charCodeAt(0),U.charCodeAt(1),U.charCodeAt(2),U.charCodeAt(3)]);var D=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),de=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]);E.HDLR_TYPES={video:D,audio:de};var Se=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),z=new Uint8Array([0,0,0,0,0,0,0,0]);E.STTS=E.STSC=E.STCO=z,E.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),E.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),E.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),E.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var $=new Uint8Array([105,115,111,109]),Le=new Uint8Array([97,118,99,49]),Oe=new Uint8Array([0,0,0,1]);E.FTYP=E.box(E.types.ftyp,$,Oe,$,Le),E.DINF=E.box(E.types.dinf,E.box(E.types.dref,Se))},E.box=function(U){for(var D=8,de=arguments.length,Se=new Array(de>1?de-1:0),z=1;z<de;z++)Se[z-1]=arguments[z];for(var $=Se.length,Le=$;$--;)D+=Se[$].byteLength;var Oe=new Uint8Array(D);for(Oe[0]=D>>24&255,Oe[1]=D>>16&255,Oe[2]=D>>8&255,Oe[3]=255&D,Oe.set(U,4),$=0,D=8;$<Le;$++)Oe.set(Se[$],D),D+=Se[$].byteLength;return Oe},E.hdlr=function(U){return E.box(E.types.hdlr,E.HDLR_TYPES[U])},E.mdat=function(U){return E.box(E.types.mdat,U)},E.mdhd=function(U,D){D*=U;var de=Math.floor(D/(R+1)),Se=Math.floor(D%(R+1));return E.box(E.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,255&U,de>>24,de>>16&255,de>>8&255,255&de,Se>>24,Se>>16&255,Se>>8&255,255&Se,85,196,0,0]))},E.mdia=function(U){return E.box(E.types.mdia,E.mdhd(U.timescale,U.duration),E.hdlr(U.type),E.minf(U))},E.mfhd=function(U){return E.box(E.types.mfhd,new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,255&U]))},E.minf=function(U){return U.type==="audio"?E.box(E.types.minf,E.box(E.types.smhd,E.SMHD),E.DINF,E.stbl(U)):E.box(E.types.minf,E.box(E.types.vmhd,E.VMHD),E.DINF,E.stbl(U))},E.moof=function(U,D,de){return E.box(E.types.moof,E.mfhd(U),E.traf(de,D))},E.moov=function(U){for(var D=U.length,de=[];D--;)de[D]=E.trak(U[D]);return E.box.apply(null,[E.types.moov,E.mvhd(U[0].timescale,U[0].duration)].concat(de).concat(E.mvex(U)))},E.mvex=function(U){for(var D=U.length,de=[];D--;)de[D]=E.trex(U[D]);return E.box.apply(null,[E.types.mvex].concat(de))},E.mvhd=function(U,D){D*=U;var de=Math.floor(D/(R+1)),Se=Math.floor(D%(R+1)),z=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,255&U,de>>24,de>>16&255,de>>8&255,255&de,Se>>24,Se>>16&255,Se>>8&255,255&Se,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 E.box(E.types.mvhd,z)},E.sdtp=function(U){var D,de,Se=U.samples||[],z=new Uint8Array(4+Se.length);for(D=0;D<Se.length;D++)de=Se[D].flags,z[D+4]=de.dependsOn<<4|de.isDependedOn<<2|de.hasRedundancy;return E.box(E.types.sdtp,z)},E.stbl=function(U){return E.box(E.types.stbl,E.stsd(U),E.box(E.types.stts,E.STTS),E.box(E.types.stsc,E.STSC),E.box(E.types.stsz,E.STSZ),E.box(E.types.stco,E.STCO))},E.avc1=function(U){var D,de,Se,z=[],$=[];for(D=0;D<U.sps.length;D++)Se=(de=U.sps[D]).byteLength,z.push(Se>>>8&255),z.push(255&Se),z=z.concat(Array.prototype.slice.call(de));for(D=0;D<U.pps.length;D++)Se=(de=U.pps[D]).byteLength,$.push(Se>>>8&255),$.push(255&Se),$=$.concat(Array.prototype.slice.call(de));var Le=E.box(E.types.avcC,new Uint8Array([1,z[3],z[4],z[5],255,224|U.sps.length].concat(z).concat([U.pps.length]).concat($))),Oe=U.width,xe=U.height,be=U.pixelRatio[0],qe=U.pixelRatio[1];return E.box(E.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,Oe>>8&255,255&Oe,xe>>8&255,255&xe,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]),Le,E.box(E.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),E.box(E.types.pasp,new Uint8Array([be>>24,be>>16&255,be>>8&255,255&be,qe>>24,qe>>16&255,qe>>8&255,255&qe])))},E.esds=function(U){var D=U.config.length;return new Uint8Array([0,0,0,0,3,23+D,0,1,0,4,15+D,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([D]).concat(U.config).concat([6,1,2]))},E.mp4a=function(U){var D=U.samplerate;return E.box(E.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U.channelCount,0,16,0,0,0,0,D>>8&255,255&D,0,0]),E.box(E.types.esds,E.esds(U)))},E.mp3=function(U){var D=U.samplerate;return E.box(E.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U.channelCount,0,16,0,0,0,0,D>>8&255,255&D,0,0]))},E.stsd=function(U){return U.type==="audio"?U.segmentCodec==="mp3"&&U.codec==="mp3"?E.box(E.types.stsd,E.STSD,E.mp3(U)):E.box(E.types.stsd,E.STSD,E.mp4a(U)):E.box(E.types.stsd,E.STSD,E.avc1(U))},E.tkhd=function(U){var D=U.id,de=U.duration*U.timescale,Se=U.width,z=U.height,$=Math.floor(de/(R+1)),Le=Math.floor(de%(R+1));return E.box(E.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,D>>24&255,D>>16&255,D>>8&255,255&D,0,0,0,0,$>>24,$>>16&255,$>>8&255,255&$,Le>>24,Le>>16&255,Le>>8&255,255&Le,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,Se>>8&255,255&Se,0,0,z>>8&255,255&z,0,0]))},E.traf=function(U,D){var de=E.sdtp(U),Se=U.id,z=Math.floor(D/(R+1)),$=Math.floor(D%(R+1));return E.box(E.types.traf,E.box(E.types.tfhd,new Uint8Array([0,0,0,0,Se>>24,Se>>16&255,Se>>8&255,255&Se])),E.box(E.types.tfdt,new Uint8Array([1,0,0,0,z>>24,z>>16&255,z>>8&255,255&z,$>>24,$>>16&255,$>>8&255,255&$])),E.trun(U,de.length+16+20+8+16+8+8),de)},E.trak=function(U){return U.duration=U.duration||4294967295,E.box(E.types.trak,E.tkhd(U),E.mdia(U))},E.trex=function(U){var D=U.id;return E.box(E.types.trex,new Uint8Array([0,0,0,0,D>>24,D>>16&255,D>>8&255,255&D,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},E.trun=function(U,D){var de,Se,z,$,Le,Oe,xe=U.samples||[],be=xe.length,qe=12+16*be,at=new Uint8Array(qe);for(D+=8+qe,at.set([U.type==="video"?1:0,0,15,1,be>>>24&255,be>>>16&255,be>>>8&255,255&be,D>>>24&255,D>>>16&255,D>>>8&255,255&D],0),de=0;de<be;de++)z=(Se=xe[de]).duration,$=Se.size,Le=Se.flags,Oe=Se.cts,at.set([z>>>24&255,z>>>16&255,z>>>8&255,255&z,$>>>24&255,$>>>16&255,$>>>8&255,255&$,Le.isLeading<<2|Le.dependsOn,Le.isDependedOn<<6|Le.hasRedundancy<<4|Le.paddingValue<<1|Le.isNonSync,61440&Le.degradPrio,15&Le.degradPrio,Oe>>>24&255,Oe>>>16&255,Oe>>>8&255,255&Oe],12+16*de);return E.box(E.types.trun,at)},E.initSegment=function(U){E.types||E.init();var D=E.moov(U),de=new Uint8Array(E.FTYP.byteLength+D.byteLength);return de.set(E.FTYP),de.set(D,E.FTYP.byteLength),de},E}();g.types=void 0,g.HDLR_TYPES=void 0,g.STTS=void 0,g.STSC=void 0,g.STCO=void 0,g.STSZ=void 0,g.VMHD=void 0,g.SMHD=void 0,g.STSD=void 0,g.FTYP=void 0,g.DINF=void 0;let k=g;var L=B(851),me=B(973),ne=B(93),ce=B(308),we=B(673);function q(){return q=Object.assign?Object.assign.bind():function(E){for(var U=1;U<arguments.length;U++){var D=arguments[U];for(var de in D)Object.prototype.hasOwnProperty.call(D,de)&&(E[de]=D[de])}return E},q.apply(this,arguments)}var ye=null,J=null,oe=function(){function E(D,de,Se,z){if(z===void 0&&(z=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=D,this.config=de,this.typeSupported=Se,this.ISGenerated=!1,ye===null){var $=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ye=$?parseInt($[1]):0}if(J===null){var Le=navigator.userAgent.match(/Safari\/(\d+)/i);J=Le?parseInt(Le[1]):0}}var U=E.prototype;return U.destroy=function(){},U.resetTimeStamp=function(D){ne.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=D},U.resetNextTimestamp=function(){ne.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},U.resetInitSegment=function(){ne.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},U.getVideoStartPts=function(D){var de=!1,Se=D.reduce(function(z,$){var Le=$.pts-z;return Le<-4294967296?(de=!0,K(z,$.pts)):Le>0?z:$.pts},D[0].pts);return de&&ne.logger.debug("PTS rollover detected"),Se},U.remux=function(D,de,Se,z,$,Le,Oe,xe){var be,qe,at,ie,pe,se,Ue=$,H=$,ve=D.pid>-1,Ie=de.pid>-1,Fe=de.samples.length,fe=D.samples.length>0,Ce=Oe&&Fe>0||Fe>1;if((!ve||fe)&&(!Ie||Ce)||this.ISGenerated||Oe){this.ISGenerated||(at=this.generateIS(D,de,$));var Ve,Xe=this.isVideoContiguous,it=-1;if(Ce&&(it=function(wt){for(var gt=0;gt<wt.length;gt++)if(wt[gt].key)return gt;return-1}(de.samples),!Xe&&this.config.forceKeyFrameOnDiscontinuity))if(se=!0,it>0){ne.logger.warn("[mp4-remuxer]: Dropped "+it+" out of "+Fe+" video samples due to a missing keyframe");var lt=this.getVideoStartPts(de.samples);de.samples=de.samples.slice(it),de.dropped+=it,Ve=H+=(de.samples[0].pts-lt)/de.inputTimeScale}else it===-1&&(ne.logger.warn("[mp4-remuxer]: No keyframe found out of "+Fe+" video samples"),se=!1);if(this.ISGenerated){if(fe&&Ce){var Ct=this.getVideoStartPts(de.samples),Rt=(K(D.samples[0].pts,Ct)-Ct)/de.inputTimeScale;Ue+=Math.max(0,Rt),H+=Math.max(0,-Rt)}if(fe){if(D.samplerate||(ne.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),at=this.generateIS(D,de,$)),qe=this.remuxAudio(D,Ue,this.isAudioContiguous,Le,Ie||Ce||xe===ce.PlaylistLevelType.AUDIO?H:void 0),Ce){var St=qe?qe.endPTS-qe.startPTS:0;de.inputTimeScale||(ne.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),at=this.generateIS(D,de,$)),be=this.remuxVideo(de,H,Xe,St)}}else Ce&&(be=this.remuxVideo(de,H,Xe,0));be&&(be.firstKeyFrame=it,be.independent=it!==-1,be.firstKeyFramePTS=Ve)}}return this.ISGenerated&&(Se.samples.length&&(pe=Ee(Se,$,this._initPTS,this._initDTS)),z.samples.length&&(ie=ke(z,$,this._initPTS))),{audio:qe,video:be,initSegment:at,independent:se,text:ie,id3:pe}},U.generateIS=function(D,de,Se){var z,$,Le,Oe=D.samples,xe=de.samples,be=this.typeSupported,qe={},at=!(0,j.isFiniteNumber)(this._initPTS),ie="audio/mp4";if(at&&(z=$=1/0),D.config&&Oe.length&&(D.timescale=D.samplerate,D.segmentCodec==="mp3"&&(be.mpeg?(ie="audio/mpeg",D.codec=""):be.mp3&&(D.codec="mp3")),qe.audio={id:"audio",container:ie,codec:D.codec,initSegment:D.segmentCodec==="mp3"&&be.mpeg?new Uint8Array(0):k.initSegment([D]),metadata:{channelCount:D.channelCount}},at&&(Le=D.inputTimeScale,z=$=Oe[0].pts-Math.round(Le*Se))),de.sps&&de.pps&&xe.length&&(de.timescale=de.inputTimeScale,qe.video={id:"main",container:"video/mp4",codec:de.codec,initSegment:k.initSegment([de]),metadata:{width:de.width,height:de.height}},at)){Le=de.inputTimeScale;var pe=this.getVideoStartPts(xe),se=Math.round(Le*Se);$=Math.min($,K(xe[0].dts,pe)-se),z=Math.min(z,pe-se)}if(Object.keys(qe).length)return this.ISGenerated=!0,at&&(this._initPTS=z,this._initDTS=$),{tracks:qe,initPTS:z,timescale:Le}},U.remuxVideo=function(D,de,Se,z){var $,Le,Oe=D.inputTimeScale,xe=D.samples,be=[],qe=xe.length,at=this._initPTS,ie=this.nextAvcDts,pe=8,se=this.videoSampleDuration,Ue=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY,ve=!1;Se&&ie!==null||(ie=de*Oe-(xe[0].pts-K(xe[0].dts,xe[0].pts)));for(var Ie=0;Ie<qe;Ie++){var Fe=xe[Ie];Fe.pts=K(Fe.pts-at,ie),Fe.dts=K(Fe.dts-at,ie),Fe.dts<xe[Ie>0?Ie-1:Ie].dts&&(ve=!0)}ve&&xe.sort(function(Jt,pr){var Cr=Jt.dts-pr.dts,vr=Jt.pts-pr.pts;return Cr||vr}),$=xe[0].dts;var fe=xe[xe.length-1].dts-$,Ce=fe?Math.round(fe/(qe-1)):se||D.inputTimeScale/30;if(Se){var Ve=$-ie,Xe=Ve>Ce,it=Ve<-1;if((Xe||it)&&(Xe?ne.logger.warn("AVC: "+(0,we.toMsFromMpegTsClock)(Ve,!0)+" ms ("+Ve+"dts) hole between fragments detected, filling it"):ne.logger.warn("AVC: "+(0,we.toMsFromMpegTsClock)(-Ve,!0)+" ms ("+Ve+"dts) overlapping between fragments detected"),!it||ie>xe[0].pts)){$=ie;var lt=xe[0].pts-Ve;xe[0].dts=$,xe[0].pts=lt,ne.logger.log("Video: First PTS/DTS adjusted: "+(0,we.toMsFromMpegTsClock)(lt,!0)+"/"+(0,we.toMsFromMpegTsClock)($,!0)+", delta: "+(0,we.toMsFromMpegTsClock)(Ve,!0)+" ms")}}$=Math.max(0,$);for(var Ct=0,Rt=0,St=0;St<qe;St++){for(var wt=xe[St],gt=wt.units,dt=gt.length,tt=0,It=0;It<dt;It++)tt+=gt[It].data.length;Rt+=tt,Ct+=dt,wt.length=tt,wt.dts=Math.max(wt.dts,$),Ue=Math.min(wt.pts,Ue),H=Math.max(wt.pts,H)}Le=xe[qe-1].dts;var Ut,Wt=Rt+4*Ct+8;try{Ut=new Uint8Array(Wt)}catch{return void this.observer.emit(L.Events.ERROR,L.Events.ERROR,{type:me.ErrorTypes.MUX_ERROR,details:me.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Wt,reason:"fail allocating video mdat "+Wt})}var Bt=new DataView(Ut.buffer);Bt.setUint32(0,Wt),Ut.set(k.types.mdat,4);for(var ar=!1,te=Number.POSITIVE_INFINITY,N=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,O=Number.NEGATIVE_INFINITY,C=0;C<qe;C++){for(var G=xe[C],Q=G.units,Z=0,Te=0,Re=Q.length;Te<Re;Te++){var Pe=Q[Te],Be=Pe.data,We=Pe.data.byteLength;Bt.setUint32(pe,We),pe+=4,Ut.set(Be,pe),pe+=We,Z+=4+We}var Ge=void 0;if(C<qe-1)se=xe[C+1].dts-G.dts,Ge=xe[C+1].pts-G.pts;else{var $e=this.config,ht=C>0?G.dts-xe[C-1].dts:Ce;if(Ge=C>0?G.pts-xe[C-1].pts:Ce,$e.stretchShortVideoTrack&&this.nextAudioPts!==null){var Dt=Math.floor($e.maxBufferHole*Oe),ze=(z?Ue+z*Oe:this.nextAudioPts)-G.pts;ze>Dt?((se=ze-ht)<0?se=ht:ar=!0,ne.logger.log("[mp4-remuxer]: It is approximately "+ze/90+" ms to the next segment; using duration "+se/90+" ms for the last video frame.")):se=ht}else se=ht}var Pt=Math.round(G.pts-G.dts);te=Math.min(te,se),T=Math.max(T,se),N=Math.min(N,Ge),O=Math.max(O,Ge),be.push(new Ne(G.key,se,Z,Pt))}if(be.length){if(ye){if(ye<70){var tr=be[0].flags;tr.dependsOn=2,tr.isNonSync=0}}else if(J&&O-N<T-te&&Ce/T<.025&&be[0].cts===0){ne.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var jt=$,Ft=0,Ht=be.length;Ft<Ht;Ft++){var rt=jt+be[Ft].duration,lr=jt+be[Ft].cts;if(Ft<Ht-1){var Ar=rt+be[Ft+1].cts;be[Ft].duration=Ar-lr}else be[Ft].duration=Ft?be[Ft-1].duration:Ce;be[Ft].cts=0,jt=rt}}}se=ar||!se?Ce:se,this.nextAvcDts=ie=Le+se,this.videoSampleDuration=se,this.isVideoContiguous=!0;var Kt={data1:k.moof(D.sequenceNumber++,$,q({},D,{samples:be})),data2:Ut,startPTS:Ue/Oe,endPTS:(H+se)/Oe,startDTS:$/Oe,endDTS:ie/Oe,type:"video",hasAudio:!1,hasVideo:!0,nb:be.length,dropped:D.dropped};return D.samples=[],D.dropped=0,Kt},U.remuxAudio=function(D,de,Se,z,$){var Le=D.inputTimeScale,Oe=Le/(D.samplerate?D.samplerate:Le),xe=D.segmentCodec==="aac"?1024:1152,be=xe*Oe,qe=this._initPTS,at=D.segmentCodec==="mp3"&&this.typeSupported.mpeg,ie=[],pe=$!==void 0,se=D.samples,Ue=at?0:8,H=this.nextAudioPts||-1,ve=de*Le;if(this.isAudioContiguous=Se=Se||se.length&&H>0&&(z&&Math.abs(ve-H)<9e3||Math.abs(K(se[0].pts-qe,ve)-H)<20*be),se.forEach(function(Te){Te.pts=K(Te.pts-qe,ve)}),!Se||H<0){if(se=se.filter(function(Te){return Te.pts>=0}),!se.length)return;H=$===0?0:z&&!pe?Math.max(0,ve):se[0].pts}if(D.segmentCodec==="aac")for(var Ie=this.config.maxAudioFramesDrift,Fe=0,fe=H;Fe<se.length;Fe++){var Ce=se[Fe],Ve=Ce.pts,Xe=Ve-fe,it=Math.abs(1e3*Xe/Le);if(Xe<=-Ie*be&&pe)Fe===0&&(ne.logger.warn("Audio frame @ "+(Ve/Le).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Xe/Le)+" ms."),this.nextAudioPts=H=fe=Ve);else if(Xe>=Ie*be&&it<1e4&&pe){var lt=Math.round(Xe/be);(fe=Ve-lt*be)<0&&(lt--,fe+=be),Fe===0&&(this.nextAudioPts=H=fe),ne.logger.warn("[mp4-remuxer]: Injecting "+lt+" audio frame @ "+(fe/Le).toFixed(3)+"s due to "+Math.round(1e3*Xe/Le)+" ms gap.");for(var Ct=0;Ct<lt;Ct++){var Rt=Math.max(fe,0),St=re.getSilentFrame(D.manifestCodec||D.codec,D.channelCount);St||(ne.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),St=Ce.unit.subarray()),se.splice(Fe,0,{unit:St,pts:Rt}),fe+=be,Fe++}}Ce.pts=fe,fe+=be}for(var wt,gt=null,dt=null,tt=0,It=se.length;It--;)tt+=se[It].unit.byteLength;for(var Ut=0,Wt=se.length;Ut<Wt;Ut++){var Bt=se[Ut],ar=Bt.unit,te=Bt.pts;if(dt!==null)ie[Ut-1].duration=Math.round((te-dt)/Oe);else{if(Se&&D.segmentCodec==="aac"&&(te=H),gt=te,!(tt>0))return;tt+=Ue;try{wt=new Uint8Array(tt)}catch{return void this.observer.emit(L.Events.ERROR,L.Events.ERROR,{type:me.ErrorTypes.MUX_ERROR,details:me.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:tt,reason:"fail allocating audio mdat "+tt})}at||(new DataView(wt.buffer).setUint32(0,tt),wt.set(k.types.mdat,4))}wt.set(ar,Ue);var N=ar.byteLength;Ue+=N,ie.push(new Ne(!0,xe,N,0)),dt=te}var T=ie.length;if(T){var O=ie[ie.length-1];this.nextAudioPts=H=dt+Oe*O.duration;var C=at?new Uint8Array(0):k.moof(D.sequenceNumber++,gt/Oe,q({},D,{samples:ie}));D.samples=[];var G=gt/Le,Q=H/Le,Z={data1:C,data2:wt,startPTS:G,endPTS:Q,startDTS:G,endDTS:Q,type:"audio",hasAudio:!0,hasVideo:!1,nb:T};return this.isAudioContiguous=!0,Z}},U.remuxEmptyAudio=function(D,de,Se,z){var $=D.inputTimeScale,Le=$/(D.samplerate?D.samplerate:$),Oe=this.nextAudioPts,xe=(Oe!==null?Oe:z.startDTS*$)+this._initDTS,be=z.endDTS*$+this._initDTS,qe=1024*Le,at=Math.ceil((be-xe)/qe),ie=re.getSilentFrame(D.manifestCodec||D.codec,D.channelCount);if(ne.logger.warn("[mp4-remuxer]: remux empty Audio"),ie){for(var pe=[],se=0;se<at;se++){var Ue=xe+se*qe;pe.push({unit:ie,pts:Ue,dts:Ue})}return D.samples=pe,this.remuxAudio(D,de,Se,!1)}ne.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},E}();function K(E,U){var D;if(U===null)return E;for(D=U<E?-8589934592:8589934592;Math.abs(E-U)>4294967296;)E+=D;return E}function Ee(E,U,D,de){var Se=E.samples.length;if(Se){for(var z=E.inputTimeScale,$=0;$<Se;$++){var Le=E.samples[$];Le.pts=K(Le.pts-D,U*z)/z,Le.dts=K(Le.dts-de,U*z)/z}var Oe=E.samples;return E.samples=[],{samples:Oe}}}function ke(E,U,D){var de=E.samples.length;if(de){for(var Se=E.inputTimeScale,z=0;z<de;z++){var $=E.samples[z];$.pts=K($.pts-D,U*Se)/Se}E.samples.sort(function(Oe,xe){return Oe.pts-xe.pts});var Le=E.samples;return E.samples=[],{samples:Le}}}var Ne=function(E,U,D,de){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=U,this.size=D,this.cts=de,this.flags=new V(E)},V=function(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}},856:(ae,W,B)=>{"use strict";var j;B.r(W),B.d(W,{MetadataSchema:()=>j}),function(re){re.audioId3="org.id3",re.dateRange="com.apple.quicktime.HLS",re.emsg="https://aomedia.org/emsg/ID3"}(j||(j={}))},308:(ae,W,B)=>{"use strict";var j,re;B.r(W),B.d(W,{PlaylistContextType:()=>j,PlaylistLevelType:()=>re}),function(R){R.MANIFEST="manifest",R.LEVEL="level",R.AUDIO_TRACK="audioTrack",R.SUBTITLE_TRACK="subtitleTrack"}(j||(j={})),function(R){R.MAIN="main",R.AUDIO="audio",R.SUBTITLE="subtitle"}(re||(re={}))},300:(ae,W,B)=>{"use strict";B.r(W),B.d(W,{default:()=>j});let j={hexDump:function(re){for(var R="",g=0;g<re.length;g++){var k=re[g].toString(16);k.length<2&&(k="0"+k),R+=k}return R}}},93:(ae,W,B)=>{"use strict";B.r(W),B.d(W,{enableLogs:()=>k,logger:()=>L});var j=function(){},re={trace:j,debug:j,log:j,warn:j,info:j,error:j},R=re;function g(me){var ne=self.console[me];return ne?ne.bind(self.console,"["+me+"] >"):j}function k(me,ne){if(self.console&&me===!0||typeof me=="object"){(function(ce){for(var we=arguments.length,q=new Array(we>1?we-1:0),ye=1;ye<we;ye++)q[ye-1]=arguments[ye];q.forEach(function(J){R[J]=ce[J]?ce[J].bind(ce):g(J)})})(me,"debug","log","info","warn","error");try{R.log('Debug logs enabled for "'+ne+'"')}catch{R=re}}else R=re}var L=re},63:(ae,W,B)=>{"use strict";B.r(W),B.d(W,{RemuxerTrackIdConfig:()=>ne,appendUint8Array:()=>Se,bin2str:()=>ce,computeRawDurationFromSamples:()=>U,discardEPB:()=>Oe,findBox:()=>oe,getDuration:()=>E,getStartDTS:()=>V,mp4Box:()=>be,mp4pssh:()=>qe,offsetStartDTS:()=>D,parseEmsg:()=>xe,parseInitSegment:()=>Ee,parsePssh:()=>at,parseSEIMessageFromNALu:()=>Le,parseSamples:()=>z,parseSegmentIndex:()=>K,parseSinf:()=>Ne,patchEncyptionData:()=>ke,readSint32:()=>ye,readUint16:()=>we,readUint32:()=>q,segmentValidRange:()=>de,writeUint32:()=>J});var j=B(923),re=B(145),R=B(181),g=B(93),k=B(300),L=Math.pow(2,32)-1,me=[].push,ne={video:1,audio:2,id3:3,text:4};function ce(ie){return String.fromCharCode.apply(null,ie)}function we(ie,pe){var se=ie[pe]<<8|ie[pe+1];return se<0?65536+se:se}function q(ie,pe){var se=ye(ie,pe);return se<0?4294967296+se:se}function ye(ie,pe){return ie[pe]<<24|ie[pe+1]<<16|ie[pe+2]<<8|ie[pe+3]}function J(ie,pe,se){ie[pe]=se>>24,ie[pe+1]=se>>16&255,ie[pe+2]=se>>8&255,ie[pe+3]=255&se}function oe(ie,pe){var se=[];if(!pe.length)return se;for(var Ue=ie.byteLength,H=0;H<Ue;){var ve=q(ie,H),Ie=ve>1?H+ve:Ue;if(ce(ie.subarray(H+4,H+8))===pe[0])if(pe.length===1)se.push(ie.subarray(H+8,Ie));else{var Fe=oe(ie.subarray(H+8,Ie),pe.slice(1));Fe.length&&me.apply(se,Fe)}H=Ie}return se}function K(ie){var pe=[],se=ie[0],Ue=8,H=q(ie,Ue);Ue+=4,Ue+=se===0?8:16,Ue+=2;var ve=ie.length+0,Ie=we(ie,Ue);Ue+=2;for(var Fe=0;Fe<Ie;Fe++){var fe=Ue,Ce=q(ie,fe);fe+=4;var Ve=2147483647&Ce;if((2147483648&Ce)>>>31==1)return console.warn("SIDX has hierarchical references (not supported)"),null;var Xe=q(ie,fe);fe+=4,pe.push({referenceSize:Ve,subsegmentDuration:Xe,info:{duration:Xe/H,start:ve,end:ve+Ve-1}}),ve+=Ve,Ue=fe+=4}return{earliestPresentationTime:0,timescale:H,version:se,referencesCount:Ie,references:pe}}function Ee(ie){for(var pe=[],se=oe(ie,["moov","trak"]),Ue=0;Ue<se.length;Ue++){var H=se[Ue],ve=oe(H,["tkhd"])[0];if(ve){var Ie=ve[0],Fe=Ie===0?12:20,fe=q(ve,Fe),Ce=oe(H,["mdia","mdhd"])[0];if(Ce){var Ve=q(Ce,Fe=(Ie=Ce[0])===0?12:20),Xe=oe(H,["mdia","hdlr"])[0];if(Xe){var it=ce(Xe.subarray(8,12)),lt={soun:j.ElementaryStreamTypes.AUDIO,vide:j.ElementaryStreamTypes.VIDEO}[it];if(lt){var Ct=oe(H,["mdia","minf","stbl","stsd"])[0],Rt=void 0;Ct&&(Rt=ce(Ct.subarray(12,16))),pe[fe]={timescale:Ve,type:lt},pe[lt]={timescale:Ve,id:fe,codec:Rt}}}}}}return oe(ie,["moov","mvex","trex"]).forEach(function(St){var wt=q(St,4),gt=pe[wt];gt&&(gt.default={duration:q(St,12),flags:q(St,20)})}),pe}function ke(ie,pe){if(!ie||!pe)return ie;var se=pe.keyId;return se&&pe.isCommonEncryption&&oe(ie,["moov","trak"]).forEach(function(Ue){var H=oe(Ue,["mdia","minf","stbl","stsd"])[0].subarray(8),ve=oe(H,["enca"]),Ie=ve.length>0;Ie||(ve=oe(H,["encv"])),ve.forEach(function(Fe){oe(Ie?Fe.subarray(28):Fe.subarray(78),["sinf"]).forEach(function(fe){var Ce=Ne(fe);if(Ce){var Ve=Ce.subarray(8,24);Ve.some(function(Xe){return Xe!==0})||(g.logger.log("[eme] Patching keyId in 'enc"+(Ie?"a":"v")+">sinf>>tenc' box: "+k.default.hexDump(Ve)+" -> "+k.default.hexDump(se)),Ce.set(se,8))}})})}),ie}function Ne(ie){var pe=oe(ie,["schm"])[0];if(pe){var se=ce(pe.subarray(4,8));if(se==="cbcs"||se==="cenc")return oe(ie,["schi","tenc"])[0]}return g.logger.error("[eme] missing 'schm' box"),null}function V(ie,pe){return oe(pe,["moof","traf"]).reduce(function(se,Ue){var H=oe(Ue,["tfdt"])[0],ve=H[0],Ie=oe(Ue,["tfhd"]).reduce(function(Fe,fe){var Ce=q(fe,4),Ve=ie[Ce];if(Ve){var Xe=q(H,4);ve===1&&(Xe*=Math.pow(2,32),Xe+=q(H,8));var it=Xe/(Ve.timescale||9e4);if(isFinite(it)&&(Fe===null||it<Fe))return it}return Fe},null);return Ie!==null&&isFinite(Ie)&&(se===null||Ie<se)?Ie:se},null)||0}function E(ie,pe){for(var se=0,Ue=0,H=0,ve=oe(ie,["moof","traf"]),Ie=0;Ie<ve.length;Ie++){var Fe=ve[Ie],fe=oe(Fe,["tfhd"])[0],Ce=pe[q(fe,4)];if(Ce){var Ve=Ce.default,Xe=q(fe,0)|(Ve==null?void 0:Ve.flags),it=Ve==null?void 0:Ve.duration;8&Xe&&(it=q(fe,2&Xe?12:8));for(var lt=Ce.timescale||9e4,Ct=oe(Fe,["trun"]),Rt=0;Rt<Ct.length;Rt++)!(se=U(Ct[Rt]))&&it&&(se=it*q(Ct[Rt],4)),Ce.type===j.ElementaryStreamTypes.VIDEO?Ue+=se/lt:Ce.type===j.ElementaryStreamTypes.AUDIO&&(H+=se/lt)}}if(Ue===0&&H===0){for(var St=0,wt=oe(ie,["sidx"]),gt=0;gt<wt.length;gt++){var dt=K(wt[gt]);dt!=null&&dt.references&&(St+=dt.references.reduce(function(tt,It){return tt+It.info.duration||0},0))}return St}return Ue||H}function U(ie){var pe=q(ie,0),se=8;1&pe&&(se+=4),4&pe&&(se+=4);for(var Ue=0,H=q(ie,4),ve=0;ve<H;ve++)256&pe&&(Ue+=q(ie,se),se+=4),512&pe&&(se+=4),1024&pe&&(se+=4),2048&pe&&(se+=4);return Ue}function D(ie,pe,se){oe(pe,["moof","traf"]).forEach(function(Ue){oe(Ue,["tfhd"]).forEach(function(H){var ve=q(H,4),Ie=ie[ve];if(Ie){var Fe=Ie.timescale||9e4;oe(Ue,["tfdt"]).forEach(function(fe){var Ce=fe[0],Ve=q(fe,4);if(Ce===0)Ve-=se*Fe,J(fe,4,Ve=Math.max(Ve,0));else{Ve*=Math.pow(2,32),Ve+=q(fe,8),Ve-=se*Fe,Ve=Math.max(Ve,0);var Xe=Math.floor(Ve/(L+1)),it=Math.floor(Ve%(L+1));J(fe,4,Xe),J(fe,8,it)}})}})})}function de(ie){var pe={valid:null,remainder:null},se=oe(ie,["moof"]);if(!se)return pe;if(se.length<2)return pe.remainder=ie,pe;var Ue=se[se.length-1];return pe.valid=(0,re.sliceUint8)(ie,0,Ue.byteOffset-8),pe.remainder=(0,re.sliceUint8)(ie,Ue.byteOffset-8),pe}function Se(ie,pe){var se=new Uint8Array(ie.length+pe.length);return se.set(ie),se.set(pe,ie.length),se}function z(ie,pe){var se=[],Ue=pe.samples,H=pe.timescale,ve=pe.id,Ie=!1;return oe(Ue,["moof"]).map(function(Fe){var fe=Fe.byteOffset-8;oe(Fe,["traf"]).map(function(Ce){var Ve=oe(Ce,["tfdt"]).map(function(Xe){var it=Xe[0],lt=q(Xe,4);return it===1&&(lt*=Math.pow(2,32),lt+=q(Xe,8)),lt/H})[0];return Ve!==void 0&&(ie=Ve),oe(Ce,["tfhd"]).map(function(Xe){var it=q(Xe,4),lt=16777215&q(Xe,0),Ct=0,Rt=(16<)!=0,St=0,wt=(32<)!=0,gt=8;it===ve&&((1<)!=0&&(gt+=8),(2<)!=0&&(gt+=4),(8<)!=0&&(Ct=q(Xe,gt),gt+=4),Rt&&(St=q(Xe,gt),gt+=4),wt&&(gt+=4),pe.type==="video"&&(Ie=function(dt){if(!dt)return!1;var tt=dt.indexOf("."),It=tt<0?dt:dt.substring(0,tt);return It==="hvc1"||It==="hev1"||It==="dvh1"||It==="dvhe"}(pe.codec)),oe(Ce,["trun"]).map(function(dt){var tt=dt[0],It=16777215&q(dt,0),Ut=(1&It)!=0,Wt=0,Bt=(4&It)!=0,ar=(256&It)!=0,te=0,N=(512&It)!=0,T=0,O=(1024&It)!=0,C=(2048&It)!=0,G=0,Q=q(dt,4),Z=8;Ut&&(Wt=q(dt,Z),Z+=4),Bt&&(Z+=4);for(var Te=Wt+fe,Re=0;Re<Q;Re++){if(ar?(te=q(dt,Z),Z+=4):te=Ct,N?(T=q(dt,Z),Z+=4):T=St,O&&(Z+=4),C&&(G=tt===0?q(dt,Z):ye(dt,Z),Z+=4),pe.type===j.ElementaryStreamTypes.VIDEO)for(var Pe=0;Pe<T;){var Be=q(Ue,Te);$(Ie,Ue[Te+=4])&&Le(Ue.subarray(Te,Te+Be),Ie?2:1,ie+G/H,se),Te+=Be,Pe+=Be+4}ie+=te/H}}))})})}),se}function $(ie,pe){if(ie){var se=pe>>1&63;return se===39||se===40}return(31&pe)==6}function Le(ie,pe,se,Ue){var H=Oe(ie),ve=0;ve+=pe;for(var Ie=0,Fe=0,fe=!1,Ce=0;ve<H.length;){Ie=0;do{if(ve>=H.length)break;Ie+=Ce=H[ve++]}while(Ce===255);Fe=0;do{if(ve>=H.length)break;Fe+=Ce=H[ve++]}while(Ce===255);var Ve=H.length-ve;if(!fe&&Ie===4&&ve<H.length){if(fe=!0,H[ve++]===181){var Xe=we(H,ve);if(ve+=2,Xe===49){var it=q(H,ve);if(ve+=4,it===1195456820){var lt=H[ve++];if(lt===3){var Ct=H[ve++],Rt=64&Ct,St=Rt?2+3*(31&Ct):0,wt=new Uint8Array(St);if(Rt){wt[0]=Ct;for(var gt=1;gt<St;gt++)wt[gt]=H[ve++]}Ue.push({type:lt,payloadType:Ie,pts:se,bytes:wt})}}}}}else if(Ie===5&&Fe<Ve){if(fe=!0,Fe>16){for(var dt=[],tt=0;tt<16;tt++){var It=H[ve++].toString(16);dt.push(It.length==1?"0"+It:It),tt!==3&&tt!==5&&tt!==7&&tt!==9||dt.push("-")}for(var Ut=Fe-16,Wt=new Uint8Array(Ut),Bt=0;Bt<Ut;Bt++)Wt[Bt]=H[ve++];Ue.push({payloadType:Ie,pts:se,uuid:dt.join(""),userData:(0,R.utf8ArrayToStr)(Wt),userDataBytes:Wt})}}else if(Fe<Ve)ve+=Fe;else if(Fe>Ve)break}}function Oe(ie){for(var pe=ie.byteLength,se=[],Ue=1;Ue<pe-2;)ie[Ue]===0&&ie[Ue+1]===0&&ie[Ue+2]===3?(se.push(Ue+2),Ue+=2):Ue++;if(se.length===0)return ie;var H=pe-se.length,ve=new Uint8Array(H),Ie=0;for(Ue=0;Ue<H;Ie++,Ue++)Ie===se[0]&&(Ie++,se.shift()),ve[Ue]=ie[Ie];return ve}function xe(ie){var pe=ie[0],se="",Ue="",H=0,ve=0,Ie=0,Fe=0,fe=0,Ce=0;if(pe===0){for(;ce(ie.subarray(Ce,Ce+1))!=="\0";)se+=ce(ie.subarray(Ce,Ce+1)),Ce+=1;for(se+=ce(ie.subarray(Ce,Ce+1)),Ce+=1;ce(ie.subarray(Ce,Ce+1))!=="\0";)Ue+=ce(ie.subarray(Ce,Ce+1)),Ce+=1;Ue+=ce(ie.subarray(Ce,Ce+1)),Ce+=1,H=q(ie,12),ve=q(ie,16),Fe=q(ie,20),fe=q(ie,24),Ce=28}else if(pe===1){H=q(ie,Ce+=4);var Ve=q(ie,Ce+=4),Xe=q(ie,Ce+=4);for(Ce+=4,Ie=Math.pow(2,32)*Ve+Xe,Number.isSafeInteger(Ie)||(Ie=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),Fe=q(ie,Ce),fe=q(ie,Ce+=4),Ce+=4;ce(ie.subarray(Ce,Ce+1))!=="\0";)se+=ce(ie.subarray(Ce,Ce+1)),Ce+=1;for(se+=ce(ie.subarray(Ce,Ce+1)),Ce+=1;ce(ie.subarray(Ce,Ce+1))!=="\0";)Ue+=ce(ie.subarray(Ce,Ce+1)),Ce+=1;Ue+=ce(ie.subarray(Ce,Ce+1)),Ce+=1}return{schemeIdUri:se,value:Ue,timeScale:H,presentationTime:Ie,presentationTimeDelta:ve,eventDuration:Fe,id:fe,payload:ie.subarray(Ce,ie.byteLength)}}function be(ie){for(var pe=arguments.length,se=new Array(pe>1?pe-1:0),Ue=1;Ue<pe;Ue++)se[Ue-1]=arguments[Ue];for(var H=se.length,ve=8,Ie=H;Ie--;)ve+=se[Ie].byteLength;var Fe=new Uint8Array(ve);for(Fe[0]=ve>>24&255,Fe[1]=ve>>16&255,Fe[2]=ve>>8&255,Fe[3]=255&ve,Fe.set(ie,4),Ie=0,ve=8;Ie<H;Ie++)Fe.set(se[Ie],ve),ve+=se[Ie].byteLength;return Fe}function qe(ie,pe,se){if(ie.byteLength!==16)throw new RangeError("Invalid system id");var Ue,H,ve;if(pe){Ue=1,H=new Uint8Array(16*pe.length);for(var Ie=0;Ie<pe.length;Ie++){var Fe=pe[Ie];if(Fe.byteLength!==16)throw new RangeError("Invalid key");H.set(Fe,16*Ie)}}else Ue=0,H=new Uint8Array;Ue>0?(ve=new Uint8Array(4),pe.length>0&&new DataView(ve.buffer).setUint32(0,pe.length,!1)):ve=new Uint8Array;var fe=new Uint8Array(4);return se&&se.byteLength>0&&new DataView(fe.buffer).setUint32(0,se.byteLength,!1),be([112,115,115,104],new Uint8Array([Ue,0,0,0]),ie,ve,H,fe,se||new Uint8Array)}function at(ie){if(!(ie instanceof ArrayBuffer)||ie.byteLength<32)return null;var pe={version:0,systemId:"",kids:null,data:null},se=new DataView(ie),Ue=se.getUint32(0);if(ie.byteLength!==Ue&&Ue>44||se.getUint32(4)!==1886614376||(pe.version=se.getUint32(8)>>>24,pe.version>1))return null;pe.systemId=k.default.hexDump(new Uint8Array(ie,12,16));var H=se.getUint32(28);if(pe.version===0){if(Ue-32<H)return null;pe.data=new Uint8Array(ie,32,H)}else if(pe.version===1){pe.kids=[];for(var ve=0;ve<H;ve++)pe.kids.push(new Uint8Array(ie,32+16*ve,16))}return pe}},673:(ae,W,B)=>{"use strict";function j(k,L,me,ne){me===void 0&&(me=1),ne===void 0&&(ne=!1);var ce=k*L*me;return ne?Math.round(ce):ce}function re(k,L,me,ne){return me===void 0&&(me=1),ne===void 0&&(ne=!1),j(k,L,1/me,ne)}function R(k,L){return L===void 0&&(L=!1),j(k,1e3,11111111111111112e-21,L)}function g(k,L){return L===void 0&&(L=1),j(k,9e4,1/L)}B.r(W),B.d(W,{toMpegTsClockFromTimescale:()=>g,toMsFromMpegTsClock:()=>R,toTimescaleFromBase:()=>j,toTimescaleFromScale:()=>re})},145:(ae,W,B)=>{"use strict";function j(re,R,g){return Uint8Array.prototype.slice?re.slice(R,g):new Uint8Array(Array.prototype.slice.call(re,R,g))}B.r(W),B.d(W,{sliceUint8:()=>j})},729:ae=>{"use strict";var W=Object.prototype.hasOwnProperty,B="~";function j(){}function re(L,me,ne){this.fn=L,this.context=me,this.once=ne||!1}function R(L,me,ne,ce,we){if(typeof ne!="function")throw new TypeError("The listener must be a function");var q=new re(ne,ce||L,we),ye=B?B+me:me;return L._events[ye]?L._events[ye].fn?L._events[ye]=[L._events[ye],q]:L._events[ye].push(q):(L._events[ye]=q,L._eventsCount++),L}function g(L,me){--L._eventsCount==0?L._events=new j:delete L._events[me]}function k(){this._events=new j,this._eventsCount=0}Object.create&&(j.prototype=Object.create(null),new j().__proto__||(B=!1)),k.prototype.eventNames=function(){var L,me,ne=[];if(this._eventsCount===0)return ne;for(me in L=this._events)W.call(L,me)&&ne.push(B?me.slice(1):me);return Object.getOwnPropertySymbols?ne.concat(Object.getOwnPropertySymbols(L)):ne},k.prototype.listeners=function(L){var me=B?B+L:L,ne=this._events[me];if(!ne)return[];if(ne.fn)return[ne.fn];for(var ce=0,we=ne.length,q=new Array(we);ce<we;ce++)q[ce]=ne[ce].fn;return q},k.prototype.listenerCount=function(L){var me=B?B+L:L,ne=this._events[me];return ne?ne.fn?1:ne.length:0},k.prototype.emit=function(L,me,ne,ce,we,q){var ye=B?B+L:L;if(!this._events[ye])return!1;var J,oe,K=this._events[ye],Ee=arguments.length;if(K.fn){switch(K.once&&this.removeListener(L,K.fn,void 0,!0),Ee){case 1:return K.fn.call(K.context),!0;case 2:return K.fn.call(K.context,me),!0;case 3:return K.fn.call(K.context,me,ne),!0;case 4:return K.fn.call(K.context,me,ne,ce),!0;case 5:return K.fn.call(K.context,me,ne,ce,we),!0;case 6:return K.fn.call(K.context,me,ne,ce,we,q),!0}for(oe=1,J=new Array(Ee-1);oe<Ee;oe++)J[oe-1]=arguments[oe];K.fn.apply(K.context,J)}else{var ke,Ne=K.length;for(oe=0;oe<Ne;oe++)switch(K[oe].once&&this.removeListener(L,K[oe].fn,void 0,!0),Ee){case 1:K[oe].fn.call(K[oe].context);break;case 2:K[oe].fn.call(K[oe].context,me);break;case 3:K[oe].fn.call(K[oe].context,me,ne);break;case 4:K[oe].fn.call(K[oe].context,me,ne,ce);break;default:if(!J)for(ke=1,J=new Array(Ee-1);ke<Ee;ke++)J[ke-1]=arguments[ke];K[oe].fn.apply(K[oe].context,J)}}return!0},k.prototype.on=function(L,me,ne){return R(this,L,me,ne,!1)},k.prototype.once=function(L,me,ne){return R(this,L,me,ne,!0)},k.prototype.removeListener=function(L,me,ne,ce){var we=B?B+L:L;if(!this._events[we])return this;if(!me)return g(this,we),this;var q=this._events[we];if(q.fn)q.fn!==me||ce&&!q.once||ne&&q.context!==ne||g(this,we);else{for(var ye=0,J=[],oe=q.length;ye<oe;ye++)(q[ye].fn!==me||ce&&!q[ye].once||ne&&q[ye].context!==ne)&&J.push(q[ye]);J.length?this._events[we]=J.length===1?J[0]:J:g(this,we)}return this},k.prototype.removeAllListeners=function(L){var me;return L?(me=B?B+L:L,this._events[me]&&g(this,me)):(this._events=new j,this._eventsCount=0),this},k.prototype.off=k.prototype.removeListener,k.prototype.addListener=k.prototype.on,k.prefixed=B,k.EventEmitter=k,ae.exports=k},945:function(ae){var W,B,j,re,R;W=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,B=/^(?=([^\/?#]*))\1([^]*)$/,j=/(?:\/|^)\.(?=\/)/g,re=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,R={buildAbsoluteURL:function(g,k,L){if(L=L||{},g=g.trim(),!(k=k.trim())){if(!L.alwaysNormalize)return g;var me=R.parseURL(g);if(!me)throw new Error("Error trying to parse base URL.");return me.path=R.normalizePath(me.path),R.buildURLFromParts(me)}var ne=R.parseURL(k);if(!ne)throw new Error("Error trying to parse relative URL.");if(ne.scheme)return L.alwaysNormalize?(ne.path=R.normalizePath(ne.path),R.buildURLFromParts(ne)):k;var ce=R.parseURL(g);if(!ce)throw new Error("Error trying to parse base URL.");if(!ce.netLoc&&ce.path&&ce.path[0]!=="/"){var we=B.exec(ce.path);ce.netLoc=we[1],ce.path=we[2]}ce.netLoc&&!ce.path&&(ce.path="/");var q={scheme:ce.scheme,netLoc:ne.netLoc,path:null,params:ne.params,query:ne.query,fragment:ne.fragment};if(!ne.netLoc&&(q.netLoc=ce.netLoc,ne.path[0]!=="/"))if(ne.path){var ye=ce.path,J=ye.substring(0,ye.lastIndexOf("/")+1)+ne.path;q.path=R.normalizePath(J)}else q.path=ce.path,ne.params||(q.params=ce.params,ne.query||(q.query=ce.query));return q.path===null&&(q.path=L.alwaysNormalize?R.normalizePath(ne.path):ne.path),R.buildURLFromParts(q)},parseURL:function(g){var k=W.exec(g);return k?{scheme:k[1]||"",netLoc:k[2]||"",path:k[3]||"",params:k[4]||"",query:k[5]||"",fragment:k[6]||""}:null},normalizePath:function(g){for(g=g.split("").reverse().join("").replace(j,"");g.length!==(g=g.replace(re,"")).length;);return g.split("").reverse().join("")},buildURLFromParts:function(g){return g.scheme+g.netLoc+g.path+g.params+g.query+g.fragment}},ae.exports=R}},w={};function A(ae){var W=w[ae];if(W!==void 0)return W.exports;var B=w[ae]={exports:{}};return x[ae].call(B.exports,B,B.exports,A),B.exports}A.m=x,A.n=ae=>{var W=ae&&ae.__esModule?()=>ae.default:()=>ae;return A.d(W,{a:W}),W},A.d=(ae,W)=>{for(var B in W)A.o(W,B)&&!A.o(ae,B)&&Object.defineProperty(ae,B,{enumerable:!0,get:W[B]})},A.o=(ae,W)=>Object.prototype.hasOwnProperty.call(ae,W),A.r=ae=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(ae,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(ae,"__esModule",{value:!0})};var le=A(76);return le.default})())});var bi=class{addEventListener(){}removeEventListener(){}dispatchEvent(w){return!0}};if(typeof DocumentFragment=="undefined"){class x extends bi{}globalThis.DocumentFragment=x}var Hi=class extends bi{},ea=class extends bi{},zs={get(x){},define(x,w,A){},upgrade(x){},whenDefined(x){return Promise.resolve(Hi)}},qi,ta=class{constructor(w,A={}){_t(this,qi,void 0);Nt(this,qi,A==null?void 0:A.detail)}get detail(){return Ye(this,qi)}initCustomEvent(){}};qi=new WeakMap;function Qs(x,w){return new Hi}var Ha={document:{createElement:Qs},DocumentFragment,customElements:zs,CustomEvent:ta,EventTarget:bi,HTMLElement:Hi,HTMLVideoElement:ea},qa=typeof window=="undefined"||typeof globalThis.customElements=="undefined",xr=qa?Ha:globalThis,ra=qa?Ha.document:globalThis.document;var bn=Ka(Va(),1),$a=Ka(Ya(),1),Js=$a.default,Sr=Js,Yi=class extends Error{constructor(x,w=Yi.MEDIA_ERR_CUSTOM,A){var le;super(x),this.name="MediaError",this.code=w,this.fatal=A!=null?A:w>=Yi.MEDIA_ERR_NETWORK&&w<=Yi.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(le=Yi.defaultMessages[this.code])!=null?le:"")}},Tr=Yi;Tr.MEDIA_ERR_ABORTED=1,Tr.MEDIA_ERR_NETWORK=2,Tr.MEDIA_ERR_DECODE=3,Tr.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Tr.MEDIA_ERR_ENCRYPTED=5,Tr.MEDIA_ERR_CUSTOM=100,Tr.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 $s=x=>x==null,Za=(x,w)=>$s(w)?!1:x in w,sa={ANY:"any",MUTED:"muted"},Tn={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},oi={MSE:"mse",NATIVE:"native"},oa={HEADER:"header",QUERY:"query",NONE:"none"},da=Object.values(oa),_i={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},la={HLS:_i.M3U8},Io=Object.keys(la),Co=[...Object.values(_i),"hls","HLS"],si=(x,w,A,le,ae=x)=>{ae.addEventListener(w,A,le),x.addEventListener("teardown",()=>{ae.removeEventListener(w,A)},{once:!0})};function Zs(x,w,A){w&&A>w&&(A=w);for(let le=0;le<x.length;le++)if(x.start(le)<=A&&x.end(le)>=A)return!0;return!1}var eo=x=>{let w=x.indexOf("?");if(w<0)return[x];let A=x.slice(0,w),le=x.slice(w);return[A,le]},es=x=>{let w=x.type;if(w){let le=w.toUpperCase();return Za(le,la)?la[le]:w}let{src:A}=x;return A?to(A):""},to=x=>{let w="";try{w=new URL(x).pathname}catch{console.error("invalid url")}let A=w.lastIndexOf(".");if(A<0)return"";let le=w.slice(A+1).toUpperCase();return Za(le,_i)?_i[le]:""},ro=Object.values(sa),Wa=x=>typeof x=="boolean"||typeof x=="string"&&ro.includes(x),io=({autoplay:x},w,A)=>{let le=!1,ae=!1,W=Wa(x)?x:!!x,B=()=>{le||si(w,"playing",()=>{le=!0},{once:!0})};if(B(),si(w,"loadstart",()=>{le=!1,B(),aa(w,W)},{once:!0}),si(w,"loadstart",()=>{A||(ae=!Number.isFinite(w.duration)),aa(w,W)},{once:!0}),A&&A.once(Sr.Events.LEVEL_LOADED,(j,re)=>{var R;ae=(R=re.details.live)!=null?R:!1}),!W){let j=()=>{!ae||(A!=null&&A.liveSyncPosition?w.currentTime=A.liveSyncPosition:Number.isFinite(w.seekable.end(0))&&(w.currentTime=w.seekable.end(0)))};A&&si(w,"play",()=>{w.preload==="metadata"?A.once(Sr.Events.LEVEL_UPDATED,j):j()},{once:!0})}return j=>{le||(W=Wa(j)?j:!!j,aa(w,W))}},aa=(x,w)=>{if(!w)return;let A=x.muted,le=()=>x.muted=A;switch(w){case sa.ANY:x.play().catch(()=>{x.muted=!0,x.play().catch(le)});break;case sa.MUTED:x.muted=!0,x.play().catch(le);break;default:x.play().catch(()=>{});break}},no=({preload:x,src:w},A,le)=>{let ae=k=>{k!=null&&["","none","metadata","auto"].includes(k)?A.setAttribute("preload",k):A.removeAttribute("preload")};if(!le)return ae(x),ae;let W=!1,B=!1,j=le.config.maxBufferLength,re=le.config.maxBufferSize,R=k=>{ae(k);let L=k!=null?k:A.preload;B||L==="none"||(L==="metadata"?(le.config.maxBufferLength=1,le.config.maxBufferSize=1):(le.config.maxBufferLength=j,le.config.maxBufferSize=re),g())},g=()=>{!W&&w&&(W=!0,le.loadSource(w))};return si(A,"play",()=>{B=!0,le.config.maxBufferLength=j,le.config.maxBufferSize=re,g()},{once:!0}),R(x),R};function ao(x,w){w.on(Sr.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(ae,{tracks:W})=>{W.forEach(B=>{var j;let re=(j=B.subtitleTrack)!=null?j:B.closedCaptions,R=w.subtitleTracks.findIndex(({lang:g,name:k,type:L})=>g==(re==null?void 0:re.lang)&&k===B.label&&L.toLowerCase()===B.kind);ts(x,B.kind,B.label,re==null?void 0:re.lang,`${B.kind}${R}`)})});let A=()=>{var ae;if(!w.subtitleTracks.length)return;let W=Array.from(x.textTracks).find(j=>j.id&&j.mode==="showing"&&["subtitles","captions"].includes(j.kind)),B=`${(ae=w.subtitleTracks[w.subtitleTrack])==null?void 0:ae.type.toLowerCase()}${w.subtitleTrack}`;if(W&&(w.subtitleTrack<0||(W==null?void 0:W.id)!==B)){let j=w.subtitleTracks.findIndex(({lang:re,name:R,type:g})=>re==W.language&&R===W.label&&g.toLowerCase()===W.kind);w.subtitleTrack=j}W&&(W==null?void 0:W.id)===B&&W.cues&&Array.from(W.cues).forEach(j=>{W.addCue(j)})};x.textTracks.addEventListener("change",A),w.on(Sr.Events.CUES_PARSED,(ae,{track:W,cues:B})=>{let j=x.textTracks.getTrackById(W);if(!j)return;let re=j.mode==="disabled";re&&(j.mode="hidden"),B.forEach(R=>{var g;(g=j.cues)!=null&&g.getCueById(R.id)||j.addCue(R)}),re&&(j.mode="disabled")}),w.once(Sr.Events.DESTROYING,()=>{x.textTracks.removeEventListener("change",A),x.querySelectorAll("track[data-removeondestroy]").forEach(ae=>{ae.remove()})});let le=()=>{Array.from(x.textTracks).forEach(ae=>{var W,B;if(!["subtitles","caption"].includes(ae.kind)&&ae.label==="thumbnails"){if(!((W=ae.cues)!=null&&W.length)){let j=x.querySelector('track[label="thumbnails"]'),re=(B=j==null?void 0:j.getAttribute("src"))!=null?B:"";j==null||j.removeAttribute("src"),setTimeout(()=>{j==null||j.setAttribute("src",re)},0)}ae.mode!=="hidden"&&(ae.mode="hidden")}})};w.once(Sr.Events.MANIFEST_LOADED,le),w.once(Sr.Events.MEDIA_ATTACHED,le)}function ts(x,w,A,le,ae){let W=document.createElement("track");return W.kind=w,W.label=A,le&&(W.srclang=le),ae&&(W.id=ae),W.track.mode=["subtitles","captions"].includes(w)?"disabled":"hidden",W.setAttribute("data-removeondestroy",""),x.append(W),W.track}var Wi="cuepoints",ca=Object.freeze({label:Wi}),ha=(x,{label:w=Wi}=ca)=>{var A;return(A=Array.from(x.querySelectorAll("track")).find(le=>le.track.label===w&&le.track.kind==="metadata"))==null?void 0:A.track};async function fa(x,w,A=ca){let le=ha(x,A);if(!le){let{label:ae=Wi}=A;le=ts(x,"metadata",ae),le.mode="hidden",await new Promise(W=>setTimeout(()=>W(void 0),0))}return le.mode!=="hidden"&&(le.mode="hidden"),[...w].sort(({time:ae},{time:W})=>W-ae).forEach(({time:ae,value:W})=>{var B,j;let re=Array.prototype.findIndex.call(le==null?void 0:le.cues,me=>me.startTime>=ae),R=(B=le==null?void 0:le.cues)==null?void 0:B[re],g=R?R.startTime:Number.isFinite(x.duration)?x.duration:Number.MAX_SAFE_INTEGER,k=(j=le==null?void 0:le.cues)==null?void 0:j[re-1];k&&(k.endTime=ae);let L=new VTTCue(ae,g,JSON.stringify(W!=null?W:null));le.addCue(L)}),le}var rs=x=>({time:x.startTime,value:JSON.parse(x.text)});function is(x,w={label:Wi}){let A=ha(x,w);return A!=null&&A.cues?Array.from(A.cues,le=>rs(le)):[]}function va(x,w={label:Wi}){var A;let le=ha(x,w);if((A=le==null?void 0:le.activeCues)!=null&&A.length)return rs(le.activeCues[0])}async function so(x,w=ca){return new Promise(A=>{si(x,"loadstart",async()=>{let le=await fa(x,[],w);si(x,"cuechange",()=>{let ae=va(x);if(ae){let W=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:ae});x.dispatchEvent(W)}},{},le),A(le)})})}var Xa,za,oo=(za=(Xa=globalThis==null?void 0:globalThis.navigator)==null?void 0:Xa.userAgent)!=null?za:"",lo=oo.toLowerCase().indexOf("android")!==-1,Si=new WeakMap,ns="mux.com",Qa,Ja,as=(Ja=(Qa=Sr).isSupported)==null?void 0:Ja.call(Qa),uo=lo,ss=()=>bn.default.utils.now(),co=bn.default.utils.generateUUID,os=(x,{domain:w=ns,maxResolution:A=""}={})=>{if(!x)return;let[le,ae=""]=eo(x),W=new URL(`https://stream.${w}/${le}.m3u8${ae}`);return A&&W.searchParams.set("max_resolution",A),W.toString()},ho=x=>{if(!x)return;let[w]=x.split("?");return w||void 0},fo=x=>{if(!x||!x.startsWith("https://stream."))return;let[w]=new URL(x).pathname.slice(1).split(".m3u8");return w||void 0},vo=x=>{var w,A,le;return(w=x==null?void 0:x.metadata)!=null&&w.video_id?x.metadata.video_id:cs(x)&&(le=(A=ho(x.playbackId))!=null?A:fo(x.src))!=null?le:x.src},ls=x=>{var w;return(w=Si.get(x))==null?void 0:w.error},us=(x,w,A)=>{pa(w,A);let{metadata:le={}}=x,{view_session_id:ae=co()}=le,W=vo(x);le.view_session_id=ae,le.video_id=W,x.metadata=le,Si.set(w,{});let B=po(x,w);mo(x,w,B),yo(x,w,B),so(w);let j=io(x,w,B),re=no(x,w,B);return{engine:B,setAutoplay:j,setPreload:re}},pa=(x,w)=>{let A=w==null?void 0:w.engine;A&&(A.detachMedia(),A.destroy()),(x==null?void 0:x.mux)&&!x.mux.deleted&&(x.mux.destroy(),delete x.mux),x&&(x.removeAttribute("src"),x.load(),x.removeEventListener("error",fs),x.removeEventListener("error",ua),x.removeEventListener("durationchange",hs),Si.delete(x),x.dispatchEvent(new Event("teardown")))};function ds(x,w){var A;let le=es(x);if(le!==_i.M3U8)return!0;let ae=!le||((A=w.canPlayType(le))!=null?A:!0),{preferPlayback:W}=x,B=W===oi.MSE,j=W===oi.NATIVE;return ae&&(j||!(as&&(B||uo)))}var po=(x,w)=>{let{debug:A,streamType:le,startTime:ae=-1,metadata:W,preferCmcd:B}=x,j=es(x)===_i.M3U8,re=ds(x,w);if(j&&!re&&as){let R={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},g=go(le),k=B!==oa.NONE?{useHeaders:B===oa.HEADER,sessionId:W.view_session_id,contentId:W.video_id}:void 0;return new Sr({debug:A,startPosition:ae,cmcd:k,...R,...g})}},go=x=>[Tn.LIVE,Tn.DVR].includes(x)?{backBufferLength:8}:[Tn.LL_LIVE,Tn.LL_DVR].includes(x)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},cs=({playbackId:x,src:w,customDomain:A})=>{if(x)return!0;if(typeof w!="string")return!1;let le=window==null?void 0:window.location.href,ae=new URL(w,le).hostname.toLocaleLowerCase();return ae.includes(ns)||!!A&&ae.includes(A.toLocaleLowerCase())},mo=(x,w,A)=>{var le;let{envKey:ae}=x,W=cs(x);if(ae||W){let{playerInitTime:B,playerSoftwareName:j,playerSoftwareVersion:re,beaconCollectionDomain:R,debug:g,disableCookies:k}=x,L={...x.metadata,video_title:((le=x==null?void 0:x.metadata)==null?void 0:le.video_title)||void 0},me=ne=>typeof ne.player_error_code=="string"?!1:typeof x.errorTranslator=="function"?x.errorTranslator(ne):ne;bn.default.monitor(w,{debug:g,beaconCollectionDomain:R,hlsjs:A,Hls:A?Sr:void 0,automaticErrorTracking:!1,errorTranslator:me,disableCookies:k,data:{...ae?{env_key:ae}:{},player_software_name:j,player_software:j,player_software_version:re,player_init_time:B,...L}})}},yo=(x,w,A)=>{var le;let ae=ds(x,w),{src:W}=x;w&&ae?(typeof W=="string"?(w.setAttribute("src",W),x.startTime&&(((le=Si.get(w))!=null?le:{}).startTime=x.startTime,w.addEventListener("durationchange",hs,{once:!0}))):w.removeAttribute("src"),w.addEventListener("error",fs),w.addEventListener("error",ua),w.addEventListener("emptied",()=>{w.querySelectorAll("track[data-removeondestroy]").forEach(B=>{B.remove()})},{once:!0})):A&&W?(A.on(Sr.Events.ERROR,(B,j)=>{let re={[Sr.ErrorTypes.NETWORK_ERROR]:Tr.MEDIA_ERR_NETWORK,[Sr.ErrorTypes.MEDIA_ERROR]:Tr.MEDIA_ERR_DECODE},R=new Tr("",re[j.type]);R.fatal=j.fatal,R.data=j,w.dispatchEvent(new CustomEvent("error",{detail:R}))}),w.addEventListener("error",ua),ao(w,A),A.attachMedia(w)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function hs(x){var w;let A=x.target,le=(w=Si.get(A))==null?void 0:w.startTime;if(!!le&&Zs(A.seekable,A.duration,le)){let ae=A.preload==="auto";ae&&(A.preload="none"),A.currentTime=le,ae&&(A.preload="auto")}}async function fs(x){if(!x.isTrusted)return;x.stopImmediatePropagation();let w=x.target;if(!(w!=null&&w.error))return;let{message:A,code:le}=w.error,ae=new Tr(A,le);if(w.src&&(le!==Tr.MEDIA_ERR_DECODE||le!==void 0))try{let{status:W}=await fetch(w.src);ae.data={response:{code:W}}}catch{}w.dispatchEvent(new CustomEvent("error",{detail:ae}))}function ua(x){var w,A;if(!(x instanceof CustomEvent)||!(x.detail instanceof Tr))return;let le=x.target,ae=x.detail;!ae||!ae.fatal||(((w=Si.get(le))!=null?w:{}).error=ae,(A=le.mux)==null||A.emit("error",{player_error_code:ae.code,player_error_message:ae.message}))}var Eo=()=>{try{return"0.14.0"}catch{}return"UNKNOWN"},To=Eo(),vs=()=>To;var ga=class extends Set{add(w){super.add(new WeakRef(w))}forEach(w){super.forEach(A=>{let le=A.deref();le&&w(le)})}},bo=x=>{var w,A,le,ae,W,ps,j,_n,R,Mr,k,Sn,me,An,ce,gs,q,ms,J,ma,K,Ee,ke,Ne,V,E,U,Xi,de,ys,z,ya,Le,Es,xe,Ea,qe,Ts,ie,Ta;return w=class extends x{constructor(){super();_t(this,U);_t(this,de);_t(this,z);_t(this,Le);_t(this,xe);_t(this,qe);_t(this,ie);Ki(this,"castEnabled",!1);_t(this,K,{paused:!1});_t(this,Ee,void 0);_t(this,ke,{});_t(this,Ne,void 0);_t(this,V,void 0);_t(this,E,void 0);w.instances.add(this),zt(this,xe,Ea).call(this)}static get castElement(){return Ye(w,A)}static get castEnabled(){return Ye(w,le)}static get castState(){var H;return(H=Ye(w,R,Mr))==null?void 0:H.getCastState()}static async exitCast(){try{await Ye(w,R,Mr).endCurrentSession(!0)}catch(ve){console.error(ve);return}}get castPlayer(){if(w.castElement===this)return Ye(this,Ee)}attributeChangedCallback(H){if(!!this.castPlayer)switch(H){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(H={}){var ve;zt(ve=w,J,ma).call(ve,H),Nt(w,A,this),Object.entries(Ye(this,ke)).forEach(([Ie,Fe])=>{Ye(this,Ee).controller.addEventListener(Ie,Fe)});try{await Ye(w,R,Mr).requestSession()}catch{Nt(w,A,void 0);return}Ye(this,K).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(Ie){console.error(Ie)}}async load(){var Ce,Ve;if(!this.castPlayer)return super.load();let H=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),ve=[...this.querySelectorAll("track")].filter(({kind:Xe,src:it})=>it&&(Xe==="subtitles"||Xe==="captions")),Ie=[],Fe=0;ve.length&&(H.tracks=ve.map(Xe=>{let it=++Fe;Ie.length===0&&Xe.track.mode==="showing"&&Ie.push(it);let lt=new chrome.cast.media.Track(it,chrome.cast.media.TrackType.TEXT);return lt.trackContentId=Xe.src,lt.trackContentType="text/vtt",lt.subtype=Xe.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,lt.name=Xe.label,lt.language=Xe.srclang,lt})),this.castStreamType==="live"?H.streamType=chrome.cast.media.StreamType.LIVE:H.streamType=chrome.cast.media.StreamType.BUFFERED,H.metadata=new chrome.cast.media.GenericMediaMetadata,H.metadata.title=this.title,H.metadata.images=[{url:this.poster}];let fe=new chrome.cast.media.LoadRequest(H);fe.currentTime=(Ce=super.currentTime)!=null?Ce:0,fe.autoplay=!Ye(this,K).paused,fe.activeTrackIds=Ie,await((Ve=Ye(w,k,Sn))==null?void 0:Ve.loadMedia(fe)),this.dispatchEvent(new Event("volumechange"))}play(){var H;if(this.castPlayer){this.castPlayer.isPaused&&((H=this.castPlayer.controller)==null||H.playOrPause());return}return super.play()}pause(){var H;if(this.castPlayer){this.castPlayer.isPaused||(H=this.castPlayer.controller)==null||H.playOrPause();return}super.pause()}get castSrc(){var H,ve,Ie;return(Ie=(ve=this.getAttribute("cast-src"))!=null?ve:(H=this.querySelector("source"))==null?void 0:H.src)!=null?Ie:this.currentSrc}set castSrc(H){this.castSrc!=H&&this.setAttribute("cast-src",`${H}`)}get castContentType(){var H;return(H=this.getAttribute("cast-content-type"))!=null?H:void 0}set castContentType(H){this.setAttribute("cast-content-type",`${H}`)}get castStreamType(){var H;return(H=this.getAttribute("cast-stream-type"))!=null?H:void 0}set castStreamType(H){this.setAttribute("cast-stream-type",`${H}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var H;return this.castPlayer?(H=this.castPlayer)==null?void 0:H.isMuted:super.muted}set muted(H){var ve;if(this.castPlayer){(H&&!this.castPlayer.isMuted||!H&&this.castPlayer.isMuted)&&((ve=this.castPlayer.controller)==null||ve.muteOrUnmute());return}super.muted=H}get volume(){var H,ve;return this.castPlayer?(ve=(H=this.castPlayer)==null?void 0:H.volumeLevel)!=null?ve:1:super.volume}set volume(H){var ve;if(this.castPlayer){this.castPlayer.volumeLevel=H,(ve=this.castPlayer.controller)==null||ve.setVolumeLevel();return}super.volume=H}get duration(){var H,ve;return this.castPlayer&&Ye(this,U,Xi)?(ve=(H=this.castPlayer)==null?void 0:H.duration)!=null?ve:NaN:super.duration}get currentTime(){var H,ve;return this.castPlayer&&Ye(this,U,Xi)?(ve=(H=this.castPlayer)==null?void 0:H.currentTime)!=null?ve:0:super.currentTime}set currentTime(H){var ve;if(this.castPlayer){this.castPlayer.currentTime=H,(ve=this.castPlayer.controller)==null||ve.seek();return}super.currentTime=H}get onentercast(){return Ye(this,Ne)}set onentercast(H){Ye(this,Ne)&&(this.removeEventListener("entercast",Ye(this,Ne)),Nt(this,Ne,null)),typeof H=="function"&&(Nt(this,Ne,H),this.addEventListener("entercast",H))}get onleavecast(){return Ye(this,V)}set onleavecast(H){Ye(this,V)&&(this.removeEventListener("leavecast",Ye(this,V)),Nt(this,V,null)),typeof H=="function"&&(Nt(this,V,H),this.addEventListener("leavecast",H))}get oncastchange(){return Ye(this,E)}set oncastchange(H){Ye(this,E)&&(this.removeEventListener("castchange",Ye(this,E)),Nt(this,E,null)),typeof H=="function"&&(Nt(this,E,H),this.addEventListener("castchange",H))}},A=new WeakMap,le=new WeakMap,ae=new WeakMap,W=new WeakSet,ps=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},j=new WeakSet,_n=function(){return typeof cast!="undefined"&&cast.framework},R=new WeakSet,Mr=function(){if(Ye(w,j,_n))return cast.framework.CastContext.getInstance()},k=new WeakSet,Sn=function(){var H;return(H=Ye(w,R,Mr))==null?void 0:H.getCurrentSession()},me=new WeakSet,An=function(){var H;return(H=Ye(w,k,Sn))==null?void 0:H.getSessionObj().media[0]},ce=new WeakSet,gs=function(H){return new Promise((ve,Ie)=>{Ye(w,me,An).editTracksInfo(H,ve,Ie)})},q=new WeakSet,ms=function(H){return new Promise((ve,Ie)=>{Ye(w,me,An).getStatus(H,ve,Ie)})},J=new WeakSet,ma=function(H){return Ye(w,R,Mr).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...H})},K=new WeakMap,Ee=new WeakMap,ke=new WeakMap,Ne=new WeakMap,V=new WeakMap,E=new WeakMap,U=new WeakSet,Xi=function(){var H;return(H=this.castPlayer)==null?void 0:H.isMediaLoaded},de=new WeakSet,ys=function(){Ye(w,A)===this&&(Object.entries(Ye(this,ke)).forEach(([H,ve])=>{Ye(this,Ee).controller.removeEventListener(H,ve)}),Nt(w,A,void 0),this.muted=Ye(this,Ee).isMuted,this.currentTime=Ye(this,Ee).savedPlayerState.currentTime,Ye(this,Ee).savedPlayerState.isPaused===!1&&this.play())},z=new WeakSet,ya=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:Ye(w,R,Mr).getCastState()}))},Le=new WeakSet,Es=async function(){var ve,Ie;let{SESSION_RESUMED:H}=cast.framework.SessionState;if(Ye(w,R,Mr).getSessionState()===H&&this.castSrc===((ve=Ye(w,me,An))==null?void 0:ve.media.contentId)){Nt(w,A,this),Object.entries(Ye(this,ke)).forEach(([Fe,fe])=>{Ye(this,Ee).controller.addEventListener(Fe,fe)});try{await zt(Ie=w,q,ms).call(Ie,new chrome.cast.media.GetStatusRequest)}catch(Fe){console.error(Fe)}Ye(this,ke)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),Ye(this,ke)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},xe=new WeakSet,Ea=function(){var H;!Ye(w,j,_n)||this.castEnabled||(this.castEnabled=!0,zt(H=w,J,ma).call(H),this.textTracks.addEventListener("change",zt(this,ie,Ta).bind(this)),zt(this,z,ya).call(this),Nt(this,Ee,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(Ye(this,Ee)),Nt(this,ke,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:ve})=>{ve===!1&&zt(this,de,ys).call(this),this.dispatchEvent(new Event(ve?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!Ye(this,U,Xi)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var ve,Ie;((ve=this.castPlayer)==null?void 0:ve.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(Ie=this.castPlayer)==null?void 0:Ie.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!Ye(this,U,Xi)||(await Promise.resolve(),zt(this,qe,Ts).call(this))}}))},qe=new WeakSet,Ts=function(){zt(this,ie,Ta).call(this)},ie=new WeakSet,Ta=async function(){var Ct,Rt,St,wt,gt,dt;if(!this.castPlayer)return;let ve=((Rt=(Ct=Ye(this,Ee).mediaInfo)==null?void 0:Ct.tracks)!=null?Rt:[]).filter(({type:tt})=>tt===chrome.cast.media.TrackType.TEXT),Ie=[...this.textTracks].filter(({kind:tt})=>tt==="subtitles"||tt==="captions"),Fe=ve.map(({language:tt,name:It,trackId:Ut})=>{var Bt;let{mode:Wt}=(Bt=Ie.find(ar=>ar.language===tt&&ar.label===It))!=null?Bt:{};return Wt?{mode:Wt,trackId:Ut}:!1}).filter(Boolean),Ce=Fe.filter(({mode:tt})=>tt!=="showing").map(({trackId:tt})=>tt),Ve=Fe.find(({mode:tt})=>tt==="showing"),Xe=(gt=(wt=(St=Ye(w,k,Sn))==null?void 0:St.getSessionObj().media[0])==null?void 0:wt.activeTrackIds)!=null?gt:[],it=Xe;if(Xe.length&&(it=it.filter(tt=>!Ce.includes(tt))),Ve!=null&&Ve.trackId&&(it=[...it,Ve.trackId]),it=[...new Set(it)],!((tt,It)=>tt.length===It.length&&tt.every(Ut=>It.includes(Ut)))(Xe,it))try{let tt=new chrome.cast.media.EditTracksInfoRequest(it);await zt(dt=w,ce,gs).call(dt,tt)}catch(tt){console.error(tt)}},_t(w,W),_t(w,j),_t(w,R),_t(w,k),_t(w,me),_t(w,ce),_t(w,q),_t(w,J),Ki(w,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Ki(w,"instances",new ga),_t(w,A,void 0),_t(w,le,!1),Ki(w,"initCast",()=>{var H;Ye(w,W,ps)?Ye(w,j,_n)?Ye(H=w,ae).call(H,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var ve;return Ye(ve=w,ae).call(ve,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var ve;return Ye(ve=w,ae).call(ve,chrome.cast.isAvailable)})}}),_t(w,ae,H=>{if(H){Nt(w,le,!0);let{CAST_STATE_CHANGED:ve}=cast.framework.CastContextEventType;Ye(w,R,Mr).addEventListener(ve,Fe=>{w.instances.forEach(fe=>{var Ce;return zt(Ce=fe,z,ya).call(Ce,Fe)})});let{SESSION_STATE_CHANGED:Ie}=cast.framework.CastContextEventType;Ye(w,R,Mr).addEventListener(Ie,Fe=>{w.instances.forEach(fe=>{var Ce;return zt(Ce=fe,Le,Es).call(Ce,Fe)})}),w.instances.forEach(Fe=>{var fe;return zt(fe=Fe,xe,Ea).call(fe)})}}),w};if(globalThis.HTMLVideoElement&&globalThis.customElements){let x=bo(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",x,{extends:"video"}),globalThis.CastableVideoElement=x),x.initCast()}var bs=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],_s=ra.createElement("template");_s.innerHTML=`
|
|
42
|
+
`),f=[],v=(o=n.baseTime,(l=n.timescale)===void 0&&(l=1),pa(o,9e4,1/l)),p="00:00.000",E=0,A=0,y=!0;u.oncue=function(b){var C=e[t],I=e.ccOffset,O=(E-v)/9e4;C!=null&&C.new&&(A!==void 0?I=e.ccOffset=C.start:function(j,V,ee){var J=j[V],ue=j[J.prevCC];if(!ue||!ue.new&&J.new)return j.ccOffset=j.presentationOffset=J.start,void(J.new=!1);for(;(ke=ue)!=null&&ke.new;){var ke;j.ccOffset+=J.start-ue.start,J.new=!1,ue=j[(J=ue).prevCC]}j.presentationOffset=ee}(e,t,O)),O&&(I=O-e.presentationOffset);var B=b.endTime-b.startTime,K=Xt(9e4*(b.startTime+I-A),9e4*r)/9e4;b.startTime=Math.max(K,0),b.endTime=Math.max(K+B,0);var X=b.text.trim();b.text=decodeURIComponent(encodeURIComponent(X)),b.id||(b.id=Pa(b.startTime,b.endTime,X)),b.endTime>0&&f.push(b)},u.onparsingerror=function(b){d=b},u.onflush=function(){d?a(d):i(f)},c.forEach(function(b){if(y){if(Ia(b,"X-TIMESTAMP-MAP=")){y=!1,b.slice(16).split(",").forEach(function(C){Ia(C,"LOCAL:")?p=C.slice(6):Ia(C,"MPEGTS:")&&(E=parseInt(C.slice(7)))});try{A=function(C){var I=parseInt(C.slice(-3)),O=parseInt(C.slice(-6,-4)),B=parseInt(C.slice(-9,-7)),K=C.length>9?parseInt(C.substring(0,C.indexOf(":"))):0;if(!(ie(I)&&ie(O)&&ie(B)&&ie(K)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+C);return I+=1e3*O,(I+=6e4*B)+36e5*K}(p)/1e3}catch(C){d=C}return}b===""&&(y=!1)}u.parse(b+`
|
|
43
|
+
`)}),u.flush()}var xa="stpp.ttml.im1t",Ws=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,zs=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Ql={left:"start",center:"center",right:"end",start:"start",end:"end"};function Xs(s,n,e,t){var r=Ue(new Uint8Array(s),["mdat"]);if(r.length!==0){var i,a,o,l,d=r.map(function(c){return Ft(c)}),u=(i=n.baseTime,a=1,(o=n.timescale)===void 0&&(o=1),l===void 0&&(l=!1),pa(i,a,1/o,l));try{d.forEach(function(c){return e(function(f,v){var p=new DOMParser().parseFromString(f,"text/xml").getElementsByTagName("tt")[0];if(!p)throw new Error("Invalid ttml");var E={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},A=Object.keys(E).reduce(function(O,B){return O[B]=p.getAttribute("ttp:"+B)||E[B],O},{}),y=p.getAttribute("xml:space")!=="preserve",b=Qs(Oa(p,"styling","style")),C=Qs(Oa(p,"layout","region")),I=Oa(p,"body","[begin]");return[].map.call(I,function(O){var B=Js(O,y);if(!B||!O.hasAttribute("begin"))return null;var K=Fa(O.getAttribute("begin"),A),X=Fa(O.getAttribute("dur"),A),j=Fa(O.getAttribute("end"),A);if(K===null)throw $s(O);if(j===null){if(X===null)throw $s(O);j=K+X}var V=new wa(K-v,j-v,B);V.id=Pa(V.startTime,V.endTime,V.text);var ee=function(ke,le,Te){var Ae="http://www.w3.org/ns/ttml#styling",be=null,Ie=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],Fe=ke!=null&&ke.hasAttribute("style")?ke.getAttribute("style"):null;return Fe&&Te.hasOwnProperty(Fe)&&(be=Te[Fe]),Ie.reduce(function(He,We){var xt=Ma(le,Ae,We)||Ma(ke,Ae,We)||Ma(be,Ae,We);return xt&&(He[We]=xt),He},{})}(C[O.getAttribute("region")],b[O.getAttribute("style")],b),J=ee.textAlign;if(J){var ue=Ql[J];ue&&(V.lineAlign=ue),V.align=J}return W(V,ee),V}).filter(function(O){return O!==null})}(c,u))})}catch(c){t(c)}}else t(new Error("Could not parse IMSC1 mdat"))}function Oa(s,n,e){var t=s.getElementsByTagName(n)[0];return t?[].slice.call(t.querySelectorAll(e)):[]}function Qs(s){return s.reduce(function(n,e){var t=e.getAttribute("xml:id");return t&&(n[t]=e),n},{})}function Js(s,n){return[].slice.call(s.childNodes).reduce(function(e,t,r){var i;return t.nodeName==="br"&&r?e+`
|
|
44
|
+
`:(i=t.childNodes)!=null&&i.length?Js(t,n):n?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function Ma(s,n,e){return s&&s.hasAttributeNS(n,e)?s.getAttributeNS(n,e):null}function $s(s){return new Error("Could not parse ttml timestamp "+s)}function Fa(s,n){if(!s)return null;var e=js(s);return e===null&&(Ws.test(s)?e=function(t,r){var i=Ws.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):zs.test(s)&&(e=function(t,r){var i=zs.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 Jl=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 Bn(this,"textTrack1"),r=new Bn(this,"textTrack2"),i=new Bn(this,"textTrack3"),a=new Bn(this,"textTrack4");this.cea608Parser1=new Ks(1,t,r),this.cea608Parser2=new Ks(3,i,a)}e.on(T.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(T.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(T.MANIFEST_LOADING,this.onManifestLoading,this),e.on(T.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(T.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(T.FRAG_LOADING,this.onFragLoading,this),e.on(T.FRAG_LOADED,this.onFragLoaded,this),e.on(T.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(T.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(T.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(T.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(T.BUFFER_FLUSHING,this.onBufferFlushing,this)}var n=s.prototype;return n.destroy=function(){var e=this.hls;e.off(T.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(T.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(T.MANIFEST_LOADING,this.onManifestLoading,this),e.off(T.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(T.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(T.FRAG_LOADING,this.onFragLoading,this),e.off(T.FRAG_LOADED,this.onFragLoaded,this),e.off(T.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(T.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(T.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(T.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(T.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},n.addCues=function(e,t,r,i,a){for(var o,l,d,u,c=!1,f=a.length;f--;){var v=a[f],p=(o=v[0],l=v[1],d=t,u=r,Math.min(l,u)-Math.max(o,d));if(p>=0&&(v[0]=Math.min(v[0],t),v[1]=Math.max(v[1],r),c=!0,p/(r-t)>.5))return}if(c||a.push([t,r]),this.config.renderTextTracksNatively){var E=this.captionsTracks[e];this.Cues.newCue(E,t,r,i)}else{var A=this.Cues.newCue(null,t,r,i);this.hls.trigger(T.CUES_PARSED,{type:"captions",cues:A,track:e})}},n.onInitPtsFound=function(e,t){var r=this,i=t.frag,a=t.id,o=t.initPTS,l=t.timescale,d=this.unparsedVttFrags;a==="main"&&(this.initPTS[i.cc]={baseTime:o,timescale:l}),d.length&&(this.unparsedVttFrags=[],d.forEach(function(u){r.onFragLoaded(T.FRAG_LOADED,u)}))},n.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r<t.textTracks.length;r++){var i=t.textTracks[r];if(i[e])return i}return null},n.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},n.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,r=this.captionsTracks,i=this.media,a=t[e],o=a.label,l=a.languageCode,d=this.getExistingTrack(e);if(d)r[e]=d,Rr(r[e]),ni(r[e],i);else{var u=this.createTextTrack("captions",o,l);u&&(u[e]=!0,r[e]=u)}}},n.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(T.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){Rr(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++)Rr(t[r])}},n.onSubtitleTracksUpdated=function(e,t){var r=this,i=t.subtitleTracks||[],a=i.some(function(d){return d.textCodec===xa});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){if(Ms(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:null;this.tracks.forEach(function(d,u){var c;if(o&&u<o.length){for(var f=null,v=0;v<o.length;v++)if($l(o[v],d)){f=o[v];break}f&&(c=f)}if(c)Rr(c);else{var p=r._captionsOrSubtitlesFromCharacteristics(d);(c=r.createTextTrack(p,d.name,d.lang))&&(c.mode="disabled")}c&&(c.groupId=d.groupId,r.textTracks.push(c))})}else if(this.tracks.length){var l=this.tracks.map(function(d){return{label:d.name,kind:d.type.toLowerCase(),default:d.default,subtitleTrack:d}});this.hls.trigger(T.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===qe){var l,d,u=t.frag.sn,c=(l=t==null||(d=t.part)==null?void 0:d.index)!=null?l:-1;u===a+1||u===a&&c===o+1||(r.reset(),i.reset()),this.lastSn=u,this.lastPartIndex=c}},n.onFragLoaded=function(e,t){var r=t.frag,i=t.payload,a=this.initPTS,o=this.unparsedVttFrags;if(r.type===Yt)if(i.byteLength){if(!a[r.cc])return o.push(t),void(a.length&&this.hls.trigger(T.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")}));var l=r.decryptdata,d="stats"in t;if(l==null||!l.encrypted||d){var u=this.tracks[r.level],c=this.vttCCs;c[r.cc]||(c[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),u&&u.textCodec===xa?this._parseIMSC1(r,i):this._parseVTTs(r,i,c)}}else this.hls.trigger(T.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},n._parseIMSC1=function(e,t){var r=this,i=this.hls;Xs(t,this.initPTS[e.cc],function(a){r._appendCues(a,e.level),i.trigger(T.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(a){P.log("Failed to parse IMSC1: "+a),i.trigger(T.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:a})})},n._parseVTTs=function(e,t,r){var i,a=this,o=this.hls;Xl((i=e.initSegment)!=null&&i.data?sr(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(T.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(l){a._fallbackToIMSC1(e,t),P.log("Failed to parse VTT cue: "+l),o.trigger(T.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:l})})},n._fallbackToIMSC1=function(e,t){var r=this,i=this.tracks[e.level];i.textCodec||Xs(t,this.initPTS[e.cc],function(){i.textCodec=xa,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(T.CUES_PARSED,{type:"subtitles",cues:e,track:o})}},n.onFragDecrypted=function(e,t){var r=t.frag;if(r.type===Yt){if(!this.initPTS[r.cc])return void this.unparsedVttFrags.push(t);this.onFragLoaded(T.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!==qe||this.closedCaptionsForLevel(a)!=="NONE")for(var l=0;l<o.length;l++){var d=o[l].bytes;if(d){var u=this.extractCea608Data(d);r.addData(o[l].pts,u[0]),i.addData(o[l].pts,u[1])}}}},n.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.endOffsetSubtitles,o=t.type,l=this.media;if(l&&!(l.currentTime<i)){if(!o||o==="video"){var d=this.captionsTracks;Object.keys(d).forEach(function(c){return at(d[c],r,i)})}if(this.config.renderTextTracksNatively&&r===0&&a!==void 0){var u=this.textTracks;Object.keys(u).forEach(function(c){return at(u[c],r,a)})}}},n.extractCea608Data=function(e){for(var t=[[],[]],r=31&e[0],i=2,a=0;a<r;a++){var o=e[i++],l=127&e[i++],d=127&e[i++];if((l!==0||d!==0)&&(4&o)!=0){var u=3&o;u!==0&&u!==1||(t[u].push(l),t[u].push(d))}}return t},s}();function $l(s,n){return!!s&&s.label===n.name&&!(s.textTrack1||s.textTrack2)}var Zl=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(T.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(T.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(T.MANIFEST_PARSED,this.onManifestParsed,this),e.on(T.BUFFER_CODECS,this.onBufferCodecs,this),e.on(T.MEDIA_DETACHING,this.onMediaDetaching,this)},n.unregisterListener=function(){var e=this.hls;e.off(T.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(T.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(T.MANIFEST_PARSED,this.onManifestParsed,this),e.off(T.BUFFER_CODECS,this.onBufferCodecs,this),e.off(T.MEDIA_DETACHING,this.onMediaDetaching,this)},n.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},n.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null},n.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onMediaDetaching=function(){this.stopCapping()},n.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var e=this.hls.levels;if(e.length){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},n.getMaxLevel=function(e){var t=this,r=this.hls.levels;if(!r.length)return-1;var i=r.filter(function(a,o){return t.isLevelAllowed(a)&&o<=e});return this.clientRect=null,s.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},n.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},n.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},n.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},n.isLevelAllowed=function(e){return!this.restrictedLevels.some(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height})},s.getMaxLevelByMediaSize=function(e,t,r){if(e==null||!e.length)return-1;for(var i,a,o=e.length-1,l=0;l<e.length;l+=1){var d=e[l];if((d.width>=t||d.height>=r)&&(i=d,!(a=e[l+1])||i.width!==a.width||i.height!==a.height)){o=l;break}}return o},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}(),eu=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(T.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.unregisterListeners=function(){this.hls.off(T.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},n.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&typeof i.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},n.checkFPS=function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var a=i-this.lastTime,o=r-this.lastDroppedFrames,l=t-this.lastDecodedFrames,d=1e3*o/a,u=this.hls;if(u.trigger(T.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),d>0&&o>u.config.fpsDroppedMonitoringThreshold*l){var c=u.currentLevel;P.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(u.autoLevelCapping===-1||u.autoLevelCapping>=c)&&(c-=1,u.trigger(T.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:u.currentLevel}),u.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},n.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},s}(),Hn="[eme]",Zs=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=P.debug.bind(P,Hn),this.log=P.log.bind(P,Hn),this.warn=P.warn.bind(P,Hn),this.error=P.error.bind(P,Hn),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(T.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(T.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(T.MANIFEST_LOADED,this.onManifestLoaded,this)},n.unregisterListeners=function(){this.hls.off(T.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(T.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(T.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===Ce.WIDEVINE&&i)return i;throw new Error('no license server URL configured for key-system "'+e+'"')},n.getServerCertificateUrl=function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},n.attemptKeySystemAccess=function(e){var t=this,r=this.hls.levels,i=function(l,d,u){return!!l&&u.indexOf(l)===d},a=r.map(function(l){return l.audioCodec}).filter(i),o=r.map(function(l){return l.videoCodec}).filter(i);return a.length+o.length===0&&o.push("avc1.42e01e"),new Promise(function(l,d){(function u(c){var f=c.shift();t.getMediaKeysPromise(f,a,o).then(function(v){return l({keySystem:f,mediaKeys:v})}).catch(function(v){c.length?u(c):d(v instanceof Qt?v:new Qt({type:Z.KEY_SYSTEM_ERROR,details:N.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 Ar===null&&self.location.protocol==="http:"&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(i))}return r(e,t)},n.getMediaKeysPromise=function(e,t,r){var i=this,a=function(u,c,f,v){var p;switch(u){case Ce.FAIRPLAY:p=["cenc","sinf"];break;case Ce.WIDEVINE:case Ce.PLAYREADY:p=["cenc"];break;case Ce.CLEARKEY:p=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+u)}return function(E,A,y,b){return[{initDataTypes:E,persistentState:b.persistentState||"not-allowed",distinctiveIdentifier:b.distinctiveIdentifier||"not-allowed",sessionTypes:b.sessionTypes||[b.sessionType||"temporary"],audioCapabilities:A.map(function(C){return{contentType:'audio/mp4; codecs="'+C+'"',robustness:b.audioRobustness||"",encryptionScheme:b.audioEncryptionScheme||null}}),videoCapabilities:y.map(function(C){return{contentType:'video/mp4; codecs="'+C+'"',robustness:b.videoRobustness||"",encryptionScheme:b.videoEncryptionScheme||null}})}]}(p,c,f,v)}(e,t,r,this.config.drmSystemOptions),o=this.keySystemAccessPromises[e],l=o==null?void 0:o.keySystemAccess;if(!l){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(a)),l=this.requestMediaKeySystemAccess(e,a);var d=this.keySystemAccessPromises[e]={keySystemAccess:l};return l.catch(function(u){i.log('Failed to obtain access to key-system "'+e+'": '+u)}),l.then(function(u){i.log('Access for key-system "'+u.keySystem+'" obtained');var c=i.fetchServerCertificate(e);return i.log('Create media-keys for "'+e+'"'),d.mediaKeys=u.createMediaKeys().then(function(f){return i.log('Media-keys created for "'+e+'"'),c.then(function(v){return v?i.setMediaKeysServerCertificate(f,e,v):f})}),d.mediaKeys.catch(function(f){i.error('Failed to create media-keys for "'+e+'"}: '+f)}),d.mediaKeys})}return l.then(function(){return o.mediaKeys})},n.createMediaKeySessionContext=function(e){var t=e.decryptdata,r=e.keySystem,i=e.mediaKeys;this.log('Creating key-system session "'+r+'" keyId: '+Nt(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 Nt(e.keyId)},n.updateKeySession=function(e,t){var r,i=e.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+Nt(((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=Sr(t.config),o=e.map(ft).filter(function(l){return!!l&&a.indexOf(l)!==-1});return t.getKeySystemSelectionPromise(o).then(function(l){var d=l.keySystem,u=_r(d);u?r(u):i(new Error('Unable to find format for key-system "'+d+'"'))}).catch(i)})},n.loadKey=function(e){var t=this,r=e.keyInfo.decryptdata,i=this.getKeyIdString(r),a="(keyId: "+i+' format: "'+r.keyFormat+'" method: '+r.method+" uri: "+r.uri+")";this.log("Starting session for key "+a);var o=this.keyIdToKeySessionPromise[i];return o||(o=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(r).then(function(l){var d=l.keySystem,u=l.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+a),t.attemptSetMediaKeys(d,u).then(function(){t.throwIfDestroyed();var c=t.createMediaKeySessionContext({keySystem:d,mediaKeys:u,decryptdata:r});return t.generateRequestWithPreferredKeySession(c,"cenc",r.pssh,"playlist-key")})})).catch(function(l){return t.handleError(l)}),o},n.throwIfDestroyed=function(e){if(!this.hls)throw new Error("invalid state")},n.handleError=function(e){this.hls&&(this.error(e.message),e instanceof Qt?this.hls.trigger(T.ERROR,e.data):this.hls.trigger(T.ERROR,{type:Z.KEY_SYSTEM_ERROR,details:N.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=ft(e.keyFormat),a=i?[i]:Sr(this.config);return this.attemptKeySystemAccess(a)}return r},n.getKeySystemSelectionPromise=function(e){if(e.length||(e=Sr(this.config)),e.length===0)throw new Qt({type:Z.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)},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[Ce.FAIRPLAY]){var l=vt(new Uint8Array(i));try{var d=z(JSON.parse(l).sinf),u=Li(new Uint8Array(d));if(!u)return;a=u.subarray(8,24),o=Ce.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var c=function(C){if(!(C instanceof ArrayBuffer)||C.byteLength<32)return null;var I={version:0,systemId:"",kids:null,data:null},O=new DataView(C),B=O.getUint32(0);if(C.byteLength!==B&&B>44||O.getUint32(4)!==1886614376||(I.version=O.getUint32(8)>>>24,I.version>1))return null;I.systemId=Nt(new Uint8Array(C,12,16));var K=O.getUint32(28);if(I.version===0){if(B-32<K)return null;I.data=new Uint8Array(C,32,K)}else if(I.version===1){I.kids=[];for(var X=0;X<K;X++)I.kids.push(new Uint8Array(C,32+16*X,16))}return I}(i);if(c===null)return;c.version===0&&c.systemId===Ht&&c.data&&(a=c.data.subarray(8,24)),o=function(C){if(C===Ht)return Ce.WIDEVINE}(c.systemId)}if(o&&a){for(var f=Nt(a),v=this.keyIdToKeySessionPromise,p=this.mediaKeySessions,E=v[f],A=function(){var C=p[y],I=C.decryptdata;if(I.pssh||!I.keyId)return"continue";var O=Nt(I.keyId);return f===O||I.uri.replace(/-/g,"").indexOf(f)!==-1?(E=v[O],delete v[O],I.pssh=new Uint8Array(i),I.keyId=a,E=v[f]=E.then(function(){return t.generateRequestWithPreferredKeySession(C,r,i,"encrypted-event-key-match")}),"break"):void 0},y=0;y<p.length;y++){var b=A();if(b!=="continue"&&b==="break")break}E||(E=v[f]=this.getKeySystemSelectionPromise([o]).then(function(C){var I,O=C.keySystem,B=C.mediaKeys;t.throwIfDestroyed();var K=new Zr("ISO-23001-7",f,(I=_r(O))!=null?I:"");return K.pssh=new Uint8Array(i),K.keyId=a,t.attemptSetMediaKeys(O,B).then(function(){t.throwIfDestroyed();var X=t.createMediaKeySessionContext({decryptdata:K,keySystem:O,mediaKeys:B});return t.generateRequestWithPreferredKeySession(X,r,i,"encrypted-event-no-match")})})),E.catch(function(C){return t.handleError(C)})}}},n._onWaitingForKey=function(e){this.log('"'+e.type+'" event')},n.attemptSetMediaKeys=function(e,t){var r=this,i=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var a=Promise.all(i).then(function(){if(!r.media)throw new Error("Attempted to set mediaKeys without media element attached");return r.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(a),a.then(function(){r.log('Media-keys set for "'+e+'"'),i.push(a),r.setMediaKeysQueue=r.setMediaKeysQueue.filter(function(o){return i.indexOf(o)===-1})})},n.generateRequestWithPreferredKeySession=function(e,t,r,i){var a,o,l=this,d=(a=this.config.drmSystems)==null||(o=a[e.keySystem])==null?void 0:o.generateRequest;if(d)try{var u=d.call(this.hls,t,r,e);if(!u)throw new Error("Invalid response from configured generateRequest filter");t=u.initDataType,r=e.decryptdata.pssh=u.initData?new Uint8Array(u.initData):null}catch(E){var c;if(this.warn(E.message),(c=this.hls)!=null&&c.config.debug)throw E}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 Un;e.mediaKeysSession.onmessage=function(E){var A=e.mediaKeysSession;if(A){var y=E.messageType,b=E.message;l.log('"'+y+'" message event for session "'+A.sessionId+'" message size: '+b.byteLength),y==="license-request"||y==="license-renewal"?l.renewLicense(e,b).catch(function(C){l.handleError(C),v.emit("error",C)}):y==="license-release"?e.keySystem===Ce.FAIRPLAY&&(l.updateKeySession(e,Ye("acknowledged")),l.removeSession(e)):l.warn('unhandled media key message type "'+y+'"')}else v.emit("error",new Error("invalid state"))},e.mediaKeysSession.onkeystatuseschange=function(E){if(e.mediaKeysSession){l.onKeyStatusChange(e);var A=e.keyStatus;v.emit("keyStatus",A),A==="expired"&&(l.warn(e.keySystem+" expired for key "+f),l.renewKeySession(e))}else v.emit("error",new Error("invalid state"))};var p=new Promise(function(E,A){v.on("error",A),v.on("keyStatus",function(y){y.startsWith("usable")?E():y==="output-restricted"?A(new Qt({type:Z.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):y==="internal-error"?A(new Qt({type:Z.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+y+'"')):y==="expired"?A(new Error("key expired while generating request")):l.warn('unhandled key status change "'+y+'"')})});return e.mediaKeysSession.generateRequest(t,r).then(function(){var E;l.log('Request generated for key-session "'+((E=e.mediaKeysSession)==null?void 0:E.sessionId)+'" keyId: '+f)}).catch(function(E){throw new Qt({type:Z.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_NO_SESSION,error:E,fatal:!1},"Error generating key-session request: "+E)}).then(function(){return p}).catch(function(E){throw v.removeAllListeners(),l.removeSession(e),E}).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: '+Nt("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))+" session keyId: "+Nt(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=r})},n.fetchServerCertificate=function(e){var t=this.config,r=new t.loader(t),i=this.getServerCertificateUrl(e);return i?(this.log('Fetching serverCertificate for "'+e+'"'),new Promise(function(a,o){var l={responseType:"arraybuffer",url:i},d=t.certLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:function(f,v,p,E){a(f.data)},onError:function(f,v,p,E){o(new Qt({type:Z.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:p,response:H({url:l.url,data:void 0},f)},'"'+e+'" certificate request failed ('+i+"). Status: "+f.code+" ("+f.text+")"))},onTimeout:function(f,v,p){o(new Qt({type:Z.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:p,response:{url:l.url,data:void 0}},'"'+e+'" certificate request timed out ('+i+")"))},onAbort:function(f,v,p){o(new Error("aborted"))}};r.load(l,u,c)})):Promise.resolve()},n.setMediaKeysServerCertificate=function(e,t,r){var i=this;return new Promise(function(a,o){e.setServerCertificate(r).then(function(l){i.log("setServerCertificate "+(l?"success":"not supported by CDM")+" ("+(r==null?void 0:r.byteLength)+') on "'+t+'"'),a(e)}).catch(function(l){o(new Qt({type:Z.KEY_SYSTEM_ERROR,details:N.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 Qt({type:Z.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:a,fatal:!0},a.message)})})},n.setupLicenseXHR=function(e,t,r,i){var a=this,o=this.config.licenseXhrSetup;return o?Promise.resolve().then(function(){if(!r.decryptdata)throw new Error("Key removed");return o.call(a.hls,e,t,r,i)}).catch(function(l){if(!r.decryptdata)throw l;return e.open("POST",t,!0),o.call(a.hls,e,t,r,i)}).then(function(l){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:l||i}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))},n.requestLicense=function(e,t){var r=this,i=this.config.keyLoadPolicy.default;return new Promise(function(a,o){var l=r.getLicenseServerUrl(e.keySystem);r.log("Sending license request to URL: "+l);var d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=function(){if(!r.hls||!e.mediaKeysSession)return o(new Error("invalid state"));if(d.readyState===4)if(d.status===200){r._requestLicenseFailureCount=0;var u=d.response;r.log("License received "+(u instanceof ArrayBuffer?u.byteLength:u));var c=r.config.licenseResponseCallback;if(c)try{u=c.call(r.hls,d,l,e)}catch(E){r.error(E)}a(u)}else{var f=i.errorRetry,v=f?f.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>v||d.status>=400&&d.status<500)o(new Qt({type:Z.KEY_SYSTEM_ERROR,details:N.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:l,data:void 0,code:d.status,text:d.statusText}},"License Request XHR failed ("+l+"). Status: "+d.status+" ("+d.statusText+")"));else{var p=v-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+p+" attempts left"),r.requestLicense(e,t).then(a,o)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=d,r.setupLicenseXHR(d,l,e,t).then(function(u){var c=u.xhr,f=u.licenseChallenge;c.send(f)})})},n.onMediaAttached=function(e,t){if(this.config.emeEnabled){var r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}},n.onMediaDetached=function(){var e=this,t=this.media,r=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Zr.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.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}();Zs.CDMCleanupPromise=void 0;var Qt=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 de(n,s),n}(Pe(Error)),tu="m",Kn="a",Na="v",Ua="av",eo="i",ru="tt",iu=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:tu,su:!t.initialized})}catch(o){P.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=function(a){try{var o=a.frag,l=t.hls.levels[o.level],d=t.getObjectType(o),u={d:1e3*o.duration,ot:d};d!==Na&&d!==Kn&&d!=Ua||(u.br=l.bitrate/1e3,u.tb=t.getTopBandwidth(d)/1e3,u.bl=t.getBufferLength(d)),t.apply(a,u)}catch(c){P.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(T.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(T.MEDIA_DETACHED,this.onMediaDetached,this),e.on(T.BUFFER_CREATED,this.onBufferCreated,this)},n.unregisterListeners=function(){var e=this.hls;e.off(T.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(T.MEDIA_DETACHED,this.onMediaDetached,this),e.off(T.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={}),W(t,this.createData());var r=t.ot===eo||t.ot===Na||t.ot===Ua;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={}),W(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"?ru:e.sn==="initSegment"?eo:t==="audio"?Kn:t==="main"?this.hls.audioTracks.length?Na:Ua:void 0},n.getTopBandwidth=function(e){var t,r=0,i=this.hls;if(e===Kn)t=i.audioTracks;else{var a=i.maxAutoLevel,o=a>-1?a+1:i.levels.length;t=i.levels.slice(0,o)}for(var l,d=Le(t);!(l=d()).done;){var u=l.value;u.bitrate>r&&(r=u.bitrate)}return r>0?r:NaN},n.getBufferLength=function(e){var t=this.hls.media,r=e===Kn?this.audioBuffer:this.videoBuffer;return r&&t?1e3*ce.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN},n.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function i(o){this.loader=void 0,this.loader=new r(o)}var a=i.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(o,l,d){t(o),this.loader.load(o,l,d)},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,d){t(o),this.loader.load(o,l,d)},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(E){return!Number.isNaN(E)&&E!=null&&E!==""&&E!==!1},a=function(E){return Math.round(E)},o=function(E){return 100*a(E/100)},l={br:a,d:a,bl:o,dl:o,mtp:o,nor:function(E){return encodeURIComponent(E)},rtp:o,tb:a},d=Le(Object.keys(e||{}).sort());!(t=d()).done;){var u=t.value,c=e[u];if(i(c)&&!(u==="v"&&c===1||u=="pr"&&c===1)){var f=l[u];f&&(c=f(c));var v=typeof c,p=void 0;p=u==="ot"||u==="sf"||u==="st"?u+"="+c:v==="boolean"?u:v==="number"?u+"="+c:u+"="+JSON.stringify(c),r.push(p)}}return r.join(",")},s.toHeaders=function(e){for(var t={},r=["Object","Request","Session","Status"],i=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},o=0,l=Object.keys(e);o<l.length;o++){var d=l[o];i[a[d]!=null?a[d]:1][d]=e[d]}for(var u=0;u<i.length;u++){var c=s.serialize(i[u]);c&&(t["CMCD-"+r[u]]=c)}return t},s.toQuery=function(e){return"CMCD="+encodeURIComponent(s.serialize(e))},s.appendQueryToUri=function(e,t){if(!t)return e;var r=e.includes("?")?"&":"?";return""+e+r+t},s}(),nu=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=P.log.bind(P,"[content-steering]:"),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(T.MANIFEST_LOADING,this.onManifestLoading,this),e.on(T.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(T.MANIFEST_PARSED,this.onManifestParsed,this),e.on(T.ERROR,this.onError,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(T.MANIFEST_LOADING,this.onManifestLoading,this),e.off(T.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(T.MANIFEST_PARSED,this.onManifestParsed,this),e.off(T.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)===ct&&r.flags===ci){var i=this.pathwayPriority,a=this.pathwayId;this.penalizedPathways[a]||(this.penalizedPathways[a]=performance.now()),!i&&this.levels&&(i=this.levels.reduce(function(o,l){return o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o},[])),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==a)}},n.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t):e},n.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(t){return e===t.pathwayId})},n.updatePathwayPriority=function(e){var t;this.pathwayPriority=e;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(function(c){i-r[c]>3e5&&delete r[c]});for(var a=0;a<e.length;a++){var o=e[a];if(!r[o]){if(o===this.pathwayId)return;var l=this.hls.nextLoadLevel,d=this.hls.levels[l];if((t=this.getLevelsForPathway(o)).length>0){this.log('Setting Pathway to "'+o+'"'),this.pathwayId=o,this.hls.trigger(T.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[l];d&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==d.bitrate&&this.log("Unstable Pathways change from bitrate "+d.bitrate+" to "+u.bitrate),this.hls.nextLoadLevel=l);break}}}},n.clonePathways=function(e){var t=this,r=this.levels;if(r){var i={},a={};e.forEach(function(o){var l=o.ID,d=o["BASE-ID"],u=o["URI-REPLACEMENT"];if(!r.some(function(f){return f.pathwayId===l})){var c=t.getLevelsForPathway(d).map(function(f){var v=W({},f);v.details=void 0,v.url=ro(f.uri,f.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",u);var p=new ze(f.attrs);p["PATHWAY-ID"]=l;var E=p.AUDIO&&p.AUDIO+"_clone_"+l,A=p.SUBTITLES&&p.SUBTITLES+"_clone_"+l;E&&(i[p.AUDIO]=E,p.AUDIO=E),A&&(a[p.SUBTITLES]=A,p.SUBTITLES=A),v.attrs=p;var y=new Br(v);return k(y,"audio",E),k(y,"text",A),y});r.push.apply(r,c),to(t.audioTracks,i,u,l),to(t.subtitleTracks,a,u,l)}})}},n.loadSteeringManifest=function(e){var t,r=this,i=this.hls.config,a=i.loader;this.loader&&this.loader.destroy(),this.loader=new a(i);try{t=new self.URL(e)}catch{return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if(t.protocol!=="data:"){var o=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+o)}var l={responseType:"json",url:t.href},d=i.steeringManifestLoadPolicy.default,u=d.errorRetry||d.timeoutRetry||{},c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},f={onSuccess:function(v,p,E,A){r.log('Loaded steering manifest: "'+t+'"');var y=v.data;if(y.VERSION===1){r.updated=performance.now(),r.timeToLoad=y.TTL;var b=y["RELOAD-URI"],C=y["PATHWAY-CLONES"],I=y["PATHWAY-PRIORITY"];if(b)try{r.uri=new self.URL(b,t).href}catch{return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+b)}r.scheduleRefresh(r.uri||E.url),C&&r.clonePathways(C),I&&r.updatePathwayPriority(I)}else r.log("Steering VERSION "+y.VERSION+" not supported!")},onError:function(v,p,E,A){if(r.log("Error loading steering manifest: "+v.code+" "+v.text+" ("+p.url+")"),r.stopLoad(),v.code===410)return r.enabled=!1,void r.log("Steering manifest "+p.url+" no longer available");var y=1e3*r.timeToLoad;if(v.code!==429)r.scheduleRefresh(r.uri||p.url,y);else{var b=r.loader;if(typeof(b==null?void 0:b.getResponseHeader)=="function"){var C=b.getResponseHeader("Retry-After");C&&(y=1e3*parseFloat(C))}r.log("Steering manifest "+p.url+" rate limited")}},onTimeout:function(v,p,E){r.log("Timeout loading steering manifest ("+p.url+")"),r.scheduleRefresh(r.uri||p.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(l,c,f)},n.scheduleRefresh=function(e,t){var r=this;t===void 0&&(t=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(function(){r.loadSteeringManifest(e)},t)},s}();function to(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=W({},a);return o.details=void 0,o.attrs=new ze(o.attrs),o.url=o.attrs.URI=ro(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 ro(s,n,e,t){var r,i=t.HOST,a=t.PARAMS,o=t[e];n&&(r=o==null?void 0:o[n])&&(s=r);var l=new self.URL(s);return i&&!r&&(l.host=i),a&&Object.keys(a).sort().forEach(function(d){d&&l.searchParams.set(d,a[d])}),l.href}var au=/^age:\s*[\d.]+\s*$/im,io=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 yt,this.retryDelay=0}var n=s.prototype;return n.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},n.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},n.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},n.loadInternal=function(){var e=this,t=this.config,r=this.context;if(t){var i=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0;var o=this.xhrSetup;o?Promise.resolve().then(function(){if(!e.stats.aborted)return o(i,r.url)}).catch(function(l){return i.open("GET",r.url,!0),o(i,r.url)}).then(function(){e.stats.aborted||e.openAndSendXhr(i,r,t)}).catch(function(l){e.callbacks.onError({code:i.status,text:l.message},r,i,a)}):this.openAndSendXhr(i,r,t)}},n.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var i=this.context.headers,a=r.loadPolicy,o=a.maxTimeToFirstByteMs,l=a.maxLoadTimeMs;if(i)for(var d in i)e.setRequestHeader(d,i[d]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=o&&ie(o)?o:l,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},n.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,a=this.config;if(!r.aborted&&i>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),i===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var o=t.status,l=t.responseType!=="text";if(o>=200&&o<300&&(l&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var d=l?t.response:t.responseText,u=t.responseType==="arraybuffer"?d.byteLength:d.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(r,e,d,t),!this.callbacks)return;var f={url:t.responseURL,data:d,code:o};this.callbacks.onSuccess(f,r,e,t)}else{var v=a.loadPolicy.errorRetry;ui(v,r.retry,!1,o)?this.retry(v):(P.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(ui(t,this.stats.retry,!0))this.retry(t);else{P.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=Ni(e,r.retry),r.retry++,P.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&&au.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}(),su=/(\d+)-(\d+)\/(\d+)/,no=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||ou,this.controller=new self.AbortController,this.stats=new yt}var n=s.prototype;return n.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},n.abortInternal=function(){var e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},n.load=function(e,t,r){var i=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var o=function(p,E){var A={method:"GET",mode:"cors",credentials:"same-origin",signal:E,headers:new self.Headers(W({},p.headers))};return p.rangeEnd&&A.headers.set("Range","bytes="+p.rangeStart+"-"+String(p.rangeEnd-1)),A}(e,this.controller.signal),l=r.onProgress,d=e.responseType==="arraybuffer",u=d?"byteLength":"length",c=t.loadPolicy,f=c.maxTimeToFirstByteMs,v=c.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,o),self.clearTimeout(this.requestTimeout),t.timeout=f&&ie(f)?f:v,this.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(a,e,i.response)},t.timeout),self.fetch(this.request).then(function(p){i.response=i.loader=p;var E=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-(E-a.loading.start)),!p.ok){var A=p.status,y=p.statusText;throw new lu(y||"fetch, bad network response",A,p)}return a.loading.first=E,a.total=function(b){var C=b.get("Content-Range");if(C){var I=function(B){var K=su.exec(B);if(K)return parseInt(K[2])-parseInt(K[1])+1}(C);if(ie(I))return I}var O=b.get("Content-Length");if(O)return parseInt(O)}(p.headers)||a.total,l&&ie(t.highWaterMark)?i.loadProgressively(p,a,e,t.highWaterMark,l):d?p.arrayBuffer():e.responseType==="json"?p.json():p.text()}).then(function(p){var E=i.response;self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var A=p[u];A&&(a.loaded=a.total=A);var y={url:E.url,data:p,code:E.status};l&&!ie(t.highWaterMark)&&l(a,e,p,E),r.onSuccess(y,a,e,E)}).catch(function(p){if(self.clearTimeout(i.requestTimeout),!a.aborted){var E=p&&p.code||0,A=p?p.message:null;r.onError({code:E,text:A},e,p?p.details:null,a)}})},n.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},n.loadProgressively=function(e,t,r,i,a){i===void 0&&(i=0);var o=new Os,l=e.body.getReader();return function d(){return l.read().then(function(u){if(u.done)return o.dataLength&&a(t,r,o.flush(),e),Promise.resolve(new ArrayBuffer(0));var c=u.value,f=c.length;return t.loaded+=f,f<i||o.dataLength?(o.push(c),o.dataLength>=i&&a(t,r,o.flush(),e)):a(t,r,c,e),d()}).catch(function(){return Promise.reject()})}()},s}();function ou(s,n){return new self.Request(s.url,n)}var lu=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 de(n,s),n}(Pe(Error)),uu=/\s/,du=H(H({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:io,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Rl,bufferController:Ml,capLevelController:Zl,errorController:h,fpsController:eu,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:Ar,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:{newCue:function(s,n,e,t){for(var r,i,a,o,l,d=[],u=self.VTTCue||self.TextTrackCue,c=0;c<t.rows.length;c++)if(a=!0,o=0,l="",!(r=t.rows[c]).isEmpty()){for(var f,v=0;v<r.chars.length;v++)uu.test(r.chars[v].uchar)&&a?o++:(l+=r.chars[v].uchar,a=!1);r.cueStartTime=n,n===e&&(e+=1e-4),o>=16?o--:o++;var p=Ys(l.trim()),E=Pa(n,e,p);s!=null&&(f=s.cues)!=null&&f.getCueById(E)||((i=new u(n,e,p)).id=E,i.line=c+1,i.align="left",i.position=10+Math.min(80,10*Math.floor(8*o/32)),d.push(i))}return s&&d.length&&(d.sort(function(A,y){return A.line==="auto"||y.line==="auto"?0:A.line>8&&y.line>8?y.line-A.line:A.line-y.line}),d.forEach(function(A){return Rn(s,A)})),d}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:Cl,subtitleTrackController:xl,timelineController:Jl,audioStreamController:wl,audioTrackController:Dl,emeController:Zs,cmcdController:iu,contentSteeringController:nu});function Ba(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Ba):Object.keys(s).reduce(function(n,e){return n[e]=Ba(s[e]),n},{}):s}function cu(s){var n=s.loader;n!==no&&n!==io?(P.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=no,s.progressive=!0,s.enableSoftwareAES=!0,P.log("[config]: Progressive streaming enabled, using FetchLoader"))}var ao=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 Un,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,ut(e.debug||!1,"Hls instance");var t=this.config=function(ee,J){if((J.liveSyncDurationCount||J.liveMaxLatencyDurationCount)&&(J.liveSyncDuration||J.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(J.liveMaxLatencyDurationCount!==void 0&&(J.liveSyncDurationCount===void 0||J.liveMaxLatencyDurationCount<=J.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(J.liveMaxLatencyDuration!==void 0&&(J.liveSyncDuration===void 0||J.liveMaxLatencyDuration<=J.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var ue=Ba(ee),ke=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(le){var Te=(le==="level"?"playlist":le)+"LoadPolicy",Ae=J[Te]===void 0,be=[];ke.forEach(function(Ie){var Fe=le+"Loading"+Ie,He=J[Fe];if(He!==void 0&&Ae){be.push(Fe);var We=ue[Te].default;switch(J[Te]={default:We},Ie){case"TimeOut":We.maxLoadTimeMs=He,We.maxTimeToFirstByteMs=He;break;case"MaxRetry":We.errorRetry.maxNumRetry=He,We.timeoutRetry.maxNumRetry=He;break;case"RetryDelay":We.errorRetry.retryDelayMs=He,We.timeoutRetry.retryDelayMs=He;break;case"MaxRetryTimeout":We.errorRetry.maxRetryDelayMs=He,We.timeoutRetry.maxRetryDelayMs=He}}}),be.length&&P.warn('hls.js config: "'+be.join('", "')+'" setting(s) are deprecated, use "'+Te+'": '+JSON.stringify(J[Te]))}),H(H({},ue),J)}(s.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&cu(t);var r=t.abrController,i=t.bufferController,a=t.capLevelController,o=t.errorController,l=t.fpsController,d=new o(this),u=this.abrController=new r(this),c=this.bufferController=new i(this),f=this.capLevelController=new a(this),v=new l(this),p=new Ln(this),E=new Oi(this),A=t.contentSteeringController,y=A?new A(this):null,b=this.levelController=new _(this,y),C=new Y(this),I=new gt(this.config),O=this.streamController=new kl(this,C,I);f.setStreamController(O),v.setStreamController(O);var B=[p,b,O];y&&B.splice(1,0,y),this.networkControllers=B;var K=[u,c,f,v,E,C];this.audioTrackController=this.createController(t.audioTrackController,B);var X=t.audioStreamController;X&&B.push(new X(this,C,I)),this.subtitleTrackController=this.createController(t.subtitleTrackController,B);var j=t.subtitleStreamController;j&&B.push(new j(this,C,I)),this.createController(t.timelineController,K),I.emeController=this.emeController=this.createController(t.emeController,K),this.cmcdController=this.createController(t.cmcdController,K),this.latencyController=this.createController(wn,K),this.coreComponents=K,B.push(d);var V=d.onErrorOut;typeof V=="function"&&this.on(T.ERROR,V,d)}s.isSupported=function(){return function(){var e=ha();if(!e)return!1;var t=gs(),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){P.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(T.ERROR,{type:Z.OTHER_ERROR,details:N.INTERNAL_EXCEPTION,fatal:!1,event:e,error:r})}return!1},n.listenerCount=function(e){return this._emitter.listenerCount(e)},n.destroy=function(){P.log("destroy"),this.trigger(T.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){P.log("attachMedia"),this._media=e,this.trigger(T.MEDIA_ATTACHING,{media:e})},n.detachMedia=function(){P.log("detachMedia"),this.trigger(T.MEDIA_DETACHING,void 0),this._media=null},n.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=Ne.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});P.log("loadSource:"+i),t&&r&&r!==i&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(T.MANIFEST_LOADING,{url:e})},n.startLoad=function(e){e===void 0&&(e=-1),P.log("startLoad("+e+")"),this.networkControllers.forEach(function(t){t.startLoad(e)})},n.stopLoad=function(){P.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})},n.swapAudioCodec=function(){P.log("swapAudioCodec"),this.streamController.swapAudioCodec()},n.recoverMediaError=function(){P.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){P.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){P.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){P.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){P.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){P.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&&(P.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){si.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.0"}},{key:"Events",get:function(){return T}},{key:"ErrorTypes",get:function(){return Z}},{key:"ErrorDetails",get:function(){return N}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:du},set:function(e){s.defaultConfig=e}}]),s}();return ao.defaultConfig=void 0,ao},typeof mo=="object"&&typeof za!="undefined"?za.exports=F():typeof define=="function"&&define.amd?define(F):(S=typeof globalThis!="undefined"?globalThis:S||self).Hls=F()})(!1)});var yi=class{addEventListener(){}removeEventListener(){}dispatchEvent(L){return!0}};if(typeof DocumentFragment=="undefined"){class R extends yi{}globalThis.DocumentFragment=R}var Yi=class extends yi{},ja=class extends yi{},Lu={get(R){},define(R,L,S){},upgrade(R){},whenDefined(R){return Promise.resolve(Yi)}},Wi,Va=class{constructor(L,S={}){Oe(this,Wi,void 0);Xe(this,Wi,S==null?void 0:S.detail)}get detail(){return re(this,Wi)}initCustomEvent(){}};Wi=new WeakMap;function Ru(R,L){return new Yi}var fo={document:{createElement:Ru},DocumentFragment,customElements:Lu,CustomEvent:Va,EventTarget:yi,HTMLElement:Yi,HTMLVideoElement:ja},vo=typeof window=="undefined"||typeof globalThis.customElements=="undefined",hr=vo?fo:globalThis,Ya=vo?fo.document:globalThis.document;var Yn=ho(go(),1),Ao=ho(po(),1),wu=Ao.default,Mt=wu,zi=class extends Error{constructor(R,L=zi.MEDIA_ERR_CUSTOM,S,F){var U;super(R),this.name="MediaError",this.code=L,this.context=F,this.fatal=S!=null?S:L>=zi.MEDIA_ERR_NETWORK&&L<=zi.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(U=zi.defaultMessages[this.code])!=null?U:"")}},Ot=zi;Ot.MEDIA_ERR_ABORTED=1,Ot.MEDIA_ERR_NETWORK=2,Ot.MEDIA_ERR_DECODE=3,Ot.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Ot.MEDIA_ERR_ENCRYPTED=5,Ot.MEDIA_ERR_CUSTOM=100,Ot.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 Du=R=>R==null,ko=(R,L)=>Du(L)?!1:R in L,Qa={ANY:"any",MUTED:"muted"},zr={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},Xr={MSE:"mse",NATIVE:"native"},Ja={HEADER:"header",QUERY:"query",NONE:"none"},es=Object.values(Ja),Ei={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},$a={HLS:Ei.M3U8},ud=Object.keys($a),dd=[...Object.values(Ei),"hls","HLS"],Pr=(R,L,S,F,U=R)=>{U.addEventListener(L,S,F),R.addEventListener("teardown",()=>{U.removeEventListener(L,S)},{once:!0})};function Iu(R,L,S){L&&S>L&&(S=L);for(let F=0;F<R.length;F++)if(R.start(F)<=S&&R.end(F)>=S)return!0;return!1}var Cu=R=>{let L=R.indexOf("?");if(L<0)return[R];let S=R.slice(0,L),F=R.slice(L);return[S,F]},Lo=R=>{let L=R.type;if(L){let F=L.toUpperCase();return ko(F,$a)?$a[F]:L}let{src:S}=R;return S?Pu(S):""},Ro=R=>R==="VOD"?zr.ON_DEMAND:zr.LIVE,wo=R=>R==="EVENT"?Number.POSITIVE_INFINITY:R==="VOD"?Number.NaN:0,Pu=R=>{let L="";try{L=new URL(R).pathname}catch{console.error("invalid url")}let S=L.lastIndexOf(".");if(S<0)return"";let F=L.slice(S+1).toUpperCase();return ko(F,Ei)?Ei[F]:""},xu=Object.values(Qa),yo=R=>typeof R=="boolean"||typeof R=="string"&&xu.includes(R),Ou=({autoplay:R},L,S)=>{let F=!1,U=!1,H=yo(R)?R:!!R,Q=()=>{F||Pr(L,"playing",()=>{F=!0},{once:!0})};if(Q(),Pr(L,"loadstart",()=>{F=!1,Q(),Xa(L,H)},{once:!0}),Pr(L,"loadstart",()=>{S||(U=!Number.isFinite(L.duration)),Xa(L,H)},{once:!0}),S&&S.once(Mt.Events.LEVEL_LOADED,(q,ne)=>{var W;U=(W=ne.details.live)!=null?W:!1}),!H){let q=()=>{!U||(S!=null&&S.liveSyncPosition?L.currentTime=S.liveSyncPosition:Number.isFinite(L.seekable.end(0))&&(L.currentTime=L.seekable.end(0)))};S&&Pr(L,"play",()=>{L.preload==="metadata"?S.once(Mt.Events.LEVEL_UPDATED,q):q()},{once:!0})}return q=>{F||(H=yo(q)?q:!!q,Xa(L,H))}},Xa=(R,L)=>{if(!L)return;let S=R.muted,F=()=>R.muted=S;switch(L){case Qa.ANY:R.play().catch(()=>{R.muted=!0,R.play().catch(F)});break;case Qa.MUTED:R.muted=!0,R.play().catch(F);break;default:R.play().catch(()=>{});break}},Mu=({preload:R,src:L},S,F)=>{let U=ve=>{ve!=null&&["","none","metadata","auto"].includes(ve)?S.setAttribute("preload",ve):S.removeAttribute("preload")};if(!F)return U(R),U;let H=!1,Q=!1,q=F.config.maxBufferLength,ne=F.config.maxBufferSize,W=ve=>{U(ve);let ge=ve!=null?ve:S.preload;Q||ge==="none"||(ge==="metadata"?(F.config.maxBufferLength=1,F.config.maxBufferSize=1):(F.config.maxBufferLength=q,F.config.maxBufferSize=ne),de())},de=()=>{!H&&L&&(H=!0,F.loadSource(L))};return Pr(S,"play",()=>{Q=!0,F.config.maxBufferLength=q,F.config.maxBufferSize=ne,de()},{once:!0}),W(R),W};function Fu(R,L){L.on(Mt.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(U,{tracks:H})=>{H.forEach(Q=>{var q;let ne=(q=Q.subtitleTrack)!=null?q:Q.closedCaptions,W=L.subtitleTracks.findIndex(({lang:de,name:ve,type:ge})=>de==(ne==null?void 0:ne.lang)&&ve===Q.label&&ge.toLowerCase()===Q.kind);Do(R,Q.kind,Q.label,ne==null?void 0:ne.lang,`${Q.kind}${W}`)})});let S=()=>{var U;if(!L.subtitleTracks.length)return;let H=Array.from(R.textTracks).find(q=>q.id&&q.mode==="showing"&&["subtitles","captions"].includes(q.kind)),Q=`${(U=L.subtitleTracks[L.subtitleTrack])==null?void 0:U.type.toLowerCase()}${L.subtitleTrack}`;if(H&&(L.subtitleTrack<0||(H==null?void 0:H.id)!==Q)){let q=L.subtitleTracks.findIndex(({lang:ne,name:W,type:de})=>ne==H.language&&W===H.label&&de.toLowerCase()===H.kind);L.subtitleTrack=q}H&&(H==null?void 0:H.id)===Q&&H.cues&&Array.from(H.cues).forEach(q=>{H.addCue(q)})};R.textTracks.addEventListener("change",S),L.on(Mt.Events.CUES_PARSED,(U,{track:H,cues:Q})=>{let q=R.textTracks.getTrackById(H);if(!q)return;let ne=q.mode==="disabled";ne&&(q.mode="hidden"),Q.forEach(W=>{var de;(de=q.cues)!=null&&de.getCueById(W.id)||q.addCue(W)}),ne&&(q.mode="disabled")}),L.once(Mt.Events.DESTROYING,()=>{R.textTracks.removeEventListener("change",S),R.querySelectorAll("track[data-removeondestroy]").forEach(U=>{U.remove()})});let F=()=>{Array.from(R.textTracks).forEach(U=>{var H,Q;if(!["subtitles","caption"].includes(U.kind)&&U.label==="thumbnails"){if(!((H=U.cues)!=null&&H.length)){let q=R.querySelector('track[label="thumbnails"]'),ne=(Q=q==null?void 0:q.getAttribute("src"))!=null?Q:"";q==null||q.removeAttribute("src"),setTimeout(()=>{q==null||q.setAttribute("src",ne)},0)}U.mode!=="hidden"&&(U.mode="hidden")}})};L.once(Mt.Events.MANIFEST_LOADED,F),L.once(Mt.Events.MEDIA_ATTACHED,F)}function Do(R,L,S,F,U){let H=document.createElement("track");return H.kind=L,H.label=S,F&&(H.srclang=F),U&&(H.id=U),H.track.mode=["subtitles","captions"].includes(L)?"disabled":"hidden",H.setAttribute("data-removeondestroy",""),R.append(H),H.track}var Xi="cuepoints",ts=Object.freeze({label:Xi}),rs=(R,{label:L=Xi}=ts)=>{var S;return(S=Array.from(R.querySelectorAll("track")).find(F=>F.track.label===L&&F.track.kind==="metadata"))==null?void 0:S.track};async function is(R,L,S=ts){let F=rs(R,S);if(!F){let{label:U=Xi}=S;F=Do(R,"metadata",U),F.mode="hidden",await new Promise(H=>setTimeout(()=>H(void 0),0))}return F.mode!=="hidden"&&(F.mode="hidden"),[...L].sort(({time:U},{time:H})=>H-U).forEach(({time:U,value:H})=>{var Q,q;let ne=Array.prototype.findIndex.call(F==null?void 0:F.cues,Ee=>Ee.startTime>=U),W=(Q=F==null?void 0:F.cues)==null?void 0:Q[ne],de=W?W.startTime:Number.isFinite(R.duration)?R.duration:Number.MAX_SAFE_INTEGER,ve=(q=F==null?void 0:F.cues)==null?void 0:q[ne-1];ve&&(ve.endTime=U);let ge=new VTTCue(U,de,JSON.stringify(H!=null?H:null));F.addCue(ge)}),F}var Io=R=>({time:R.startTime,value:JSON.parse(R.text)});function Co(R,L={label:Xi}){let S=rs(R,L);return S!=null&&S.cues?Array.from(S.cues,F=>Io(F)):[]}function ns(R,L={label:Xi}){var S,F;let U=rs(R,L);if(!((S=U==null?void 0:U.activeCues)!=null&&S.length))return;let{currentTime:H}=R,Q=Array.prototype.find.call((F=U.activeCues)!=null?F:[],({startTime:q,endTime:ne})=>q<=H&&ne>H);return Io(Q)}async function Nu(R,L=ts){return new Promise(S=>{Pr(R,"loadstart",async()=>{let F=await is(R,[],L);Pr(R,"cuechange",()=>{let U=ns(R);if(U){let H=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:U});R.dispatchEvent(H)}},{},F),S(F)})})}function Po(R,L){if(L){let S=L.playingDate;if(S!=null)return new Date(S.getTime()-R.currentTime*1e3)}return typeof R.getStartDate=="function"?R.getStartDate():new Date(NaN)}function xo(R,L){if(L&&L.playingDate)return L.playingDate;if(typeof R.getStartDate=="function"){let S=R.getStartDate();return new Date(S.getTime()+R.currentTime*1e3)}return new Date(NaN)}var Uu=async R=>fetch(R).then(L=>L.text()).then(L=>{let S=L.split(`
|
|
46
|
+
`).find((F,U,H)=>U&&H[U-1].startsWith("#EXT-X-STREAM-INF"));return fetch(S).then(F=>F.text()).then(F=>F.split(`
|
|
47
|
+
`))}),Bu=R=>{var L,S;let F=(S=((L=R.find(q=>q.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?L:"").split(":")[1])==null?void 0:S.trim(),U=Ro(F),H=wo(F),Q;if(U===zr.LIVE){let q=R.find(ne=>ne.startsWith("#EXT-X-PART-INF"));q?Q=+q.split(":")[1].split("=")[1]*2:Q=+R.find(ne=>ne.startsWith("#EXT-X-TARGETDURATION")).split(":")[1]*3}return{streamType:U,targetLiveWindow:H,liveEdgeStartOffset:Q}},Eo=async(R,L)=>{var S,F,U;let H=await Uu(R),{streamType:Q,targetLiveWindow:q,liveEdgeStartOffset:ne}=Bu(H);((S=_t.get(L))!=null?S:{}).liveEdgeStartOffset=ne,((F=_t.get(L))!=null?F:{}).targetLiveWindow=q,L.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((U=_t.get(L))!=null?U:{}).streamType=Q,L.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Gu=R=>{var L;let S=R.type,F=Ro(S),U=wo(S),H,Q=!!((L=R.partList)!=null&&L.length);return F===zr.LIVE&&(H=Q?R.partTarget*2:R.targetduration*3),{streamType:F,targetLiveWindow:U,liveEdgeStartOffset:H,lowLatency:Q}},Hu=(R,L,S)=>{var F,U,H,Q,q,ne,W,de;let{streamType:ve,targetLiveWindow:ge,liveEdgeStartOffset:Ee,lowLatency:xe}=Gu(R);if(ve===zr.LIVE){xe?(S.config.backBufferLength=(F=S.userConfig.backBufferLength)!=null?F:4,S.config.maxFragLookUpTolerance=(U=S.userConfig.maxFragLookUpTolerance)!=null?U:.001,S.config.abrBandWidthUpFactor=(H=S.userConfig.abrBandWidthUpFactor)!=null?H:S.config.abrBandWidthFactor):S.config.backBufferLength=(Q=S.userConfig.backBufferLength)!=null?Q:8;let Pe=Object.freeze({get length(){return L.seekable.length},start(it){return L.seekable.start(it)},end(it){var Le;return it>this.length?L.seekable.end(it):(Le=S.liveSyncPosition)!=null?Le:L.seekable.end(it)}});((q=_t.get(L))!=null?q:{}).seekable=Pe}((ne=_t.get(L))!=null?ne:{}).liveEdgeStartOffset=Ee,((W=_t.get(L))!=null?W:{}).targetLiveWindow=ge,L.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((de=_t.get(L))!=null?de:{}).streamType=ve,L.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},To,bo,Ku=(bo=(To=globalThis==null?void 0:globalThis.navigator)==null?void 0:To.userAgent)!=null?bo:"",qu=Ku.toLowerCase().indexOf("android")!==-1,_t=new WeakMap,Oo="mux.com",_o,So,Mo=(So=(_o=Mt).isSupported)==null?void 0:So.call(_o),ju=qu,Fo=()=>Yn.default.utils.now(),Vu=Yn.default.utils.generateUUID,No=(R,{domain:L=Oo,maxResolution:S=""}={})=>{if(!R)return;let[F,U=""]=Cu(R),H=new URL(`https://stream.${L}/${F}.m3u8${U}`);return S&&H.searchParams.set("max_resolution",S),H.toString()},Yu=R=>{if(!R)return;let[L]=R.split("?");return L||void 0},Wu=R=>{if(!R||!R.startsWith("https://stream."))return;let[L]=new URL(R).pathname.slice(1).split(".m3u8");return L||void 0},zu=R=>{var L,S,F;return(L=R==null?void 0:R.metadata)!=null&&L.video_id?R.metadata.video_id:jo(R)&&(F=(S=Yu(R.playbackId))!=null?S:Wu(R.src))!=null?F:R.src},Uo=R=>{var L;return(L=_t.get(R))==null?void 0:L.error},Bo=R=>{var L,S;return(S=(L=_t.get(R))==null?void 0:L.streamType)!=null?S:zr.UNKNOWN},Go=R=>{var L,S;return(S=(L=_t.get(R))==null?void 0:L.targetLiveWindow)!=null?S:Number.NaN},as=R=>{var L,S;return(S=(L=_t.get(R))==null?void 0:L.seekable)!=null?S:R.seekable},Ho=R=>{var L;let S=(L=_t.get(R))==null?void 0:L.liveEdgeStartOffset;if(typeof S!="number")return Number.NaN;let F=as(R);return F.length?F.end(F.length-1)-S:Number.NaN},Ko=(R,L,S)=>{ss(L,S);let{metadata:F={}}=R,{view_session_id:U=Vu()}=F,H=zu(R);F.view_session_id=U,F.video_id=H,R.metadata=F,_t.set(L,{});let Q=Xu(R,L);Ju(R,L,Q),$u(R,L,Q),Nu(L);let q=Ou(R,L,Q),ne=Mu(R,L,Q);return{engine:Q,setAutoplay:q,setPreload:ne}},ss=(R,L)=>{let S=L==null?void 0:L.engine;S&&(S.detachMedia(),S.destroy()),(R==null?void 0:R.mux)&&!R.mux.deleted&&(R.mux.destroy(),delete R.mux),R&&(R.removeAttribute("src"),R.load(),R.removeEventListener("error",Yo),R.removeEventListener("error",Za),R.removeEventListener("durationchange",Vo),_t.delete(R),R.dispatchEvent(new Event("teardown")))};function qo(R,L){var S;let F=Lo(R);if(F!==Ei.M3U8)return!0;let U=!F||((S=L.canPlayType(F))!=null?S:!0),{preferPlayback:H}=R,Q=H===Xr.MSE,q=H===Xr.NATIVE;return U&&(q||!(Mo&&(Q||ju)))}var Xu=(R,L)=>{let{debug:S,streamType:F,startTime:U=-1,metadata:H,preferCmcd:Q}=R,q=Lo(R)===Ei.M3U8,ne=qo(R,L);if(q&&!ne&&Mo){let W={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},de=Qu(F),ve=Q!==Ja.NONE?{useHeaders:Q===Ja.HEADER,sessionId:H==null?void 0:H.view_session_id,contentId:H==null?void 0:H.video_id}:void 0;return new Mt({debug:S,startPosition:U,cmcd:ve,...W,...de})}},Qu=R=>R===zr.LIVE?{backBufferLength:8}:{},jo=({playbackId:R,src:L,customDomain:S})=>{if(R)return!0;if(typeof L!="string")return!1;let F=window==null?void 0:window.location.href,U=new URL(L,F).hostname.toLocaleLowerCase();return U.includes(Oo)||!!S&&U.includes(S.toLocaleLowerCase())},Ju=(R,L,S)=>{var F;let{envKey:U}=R,H=jo(R);if(U||H){let{playerInitTime:Q,playerSoftwareName:q,playerSoftwareVersion:ne,beaconCollectionDomain:W,debug:de,disableCookies:ve}=R,ge={...R.metadata,video_title:((F=R==null?void 0:R.metadata)==null?void 0:F.video_title)||void 0},Ee=xe=>typeof xe.player_error_code=="string"?!1:typeof R.errorTranslator=="function"?R.errorTranslator(xe):xe;Yn.default.monitor(L,{debug:de,beaconCollectionDomain:W,hlsjs:S,Hls:S?Mt:void 0,automaticErrorTracking:!1,errorTranslator:Ee,disableCookies:ve,data:{...U?{env_key:U}:{},player_software_name:q,player_software:q,player_software_version:ne,player_init_time:Q,...ge}})}},$u=(R,L,S)=>{var F;let U=qo(R,L),{src:H}=R;L&&U?(typeof H=="string"?(L.preload==="none"?Pr(L,"loadstart",()=>Eo(H,L)):Eo(H,L),L.setAttribute("src",H),R.startTime&&(((F=_t.get(L))!=null?F:{}).startTime=R.startTime,L.addEventListener("durationchange",Vo,{once:!0}))):L.removeAttribute("src"),L.addEventListener("error",Yo),L.addEventListener("error",Za),L.addEventListener("emptied",()=>{L.querySelectorAll("track[data-removeondestroy]").forEach(Q=>{Q.remove()})},{once:!0})):S&&H?(S.once(Mt.Events.LEVEL_LOADED,(Q,q)=>{Hu(q.details,L,S)}),S.on(Mt.Events.ERROR,(Q,q)=>{let ne={[Mt.ErrorTypes.NETWORK_ERROR]:Ot.MEDIA_ERR_NETWORK,[Mt.ErrorTypes.MEDIA_ERROR]:Ot.MEDIA_ERR_DECODE},W=new Ot("",ne[q.type]);W.fatal=q.fatal,W.data=q,L.dispatchEvent(new CustomEvent("error",{detail:W}))}),L.addEventListener("error",Za),Fu(L,S),S.attachMedia(L)):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 Vo(R){var L;let S=R.target,F=(L=_t.get(S))==null?void 0:L.startTime;if(!!F&&Iu(S.seekable,S.duration,F)){let U=S.preload==="auto";U&&(S.preload="none"),S.currentTime=F,U&&(S.preload="auto")}}async function Yo(R){if(!R.isTrusted)return;R.stopImmediatePropagation();let L=R.target;if(!(L!=null&&L.error))return;let{message:S,code:F}=L.error,U=new Ot(S,F);if(L.src&&(F!==Ot.MEDIA_ERR_DECODE||F!==void 0))try{let{status:H}=await fetch(L.src);U.data={response:{code:H}}}catch{}L.dispatchEvent(new CustomEvent("error",{detail:U}))}function Za(R){var L,S;if(!(R instanceof CustomEvent)||!(R.detail instanceof Ot))return;let F=R.target,U=R.detail;!U||!U.fatal||(((L=_t.get(F))!=null?L:{}).error=U,(S=F.mux)==null||S.emit("error",{player_error_code:U.code,player_error_message:U.message,player_error_context:U.context}))}var Zu=()=>{try{return"0.15.0"}catch{}return"UNKNOWN"},ed=Zu(),Wo=()=>ed;var zo=R=>{var L,S,F,U,H,Xo,q,Wn,W,fr,ve,zn,Ee,Xn,Pe,Qo,Le,Jo,Ne,os,T,Z,N,Ke,ot,_e,je,Qi,P,$o,nt,ls,wt,Zo,yt,us,Je,el,Gt,ds;return L=class extends R{constructor(){super();Oe(this,je);Oe(this,P);Oe(this,nt);Oe(this,wt);Oe(this,yt);Oe(this,Je);Oe(this,Gt);Vi(this,"castEnabled",!1);Oe(this,T,{paused:!1});Oe(this,Z,void 0);Oe(this,N,{});Oe(this,Ke,void 0);Oe(this,ot,void 0);Oe(this,_e,void 0);L.instances.add(this),rt(this,yt,us).call(this)}static get castElement(){return re(L,S)}static get castEnabled(){return re(L,F)}static get castState(){var z;return(z=re(L,W,fr))==null?void 0:z.getCastState()}static async exitCast(){try{await re(L,W,fr).endCurrentSession(!0)}catch(se){console.error(se);return}}get castPlayer(){if(L.castElement===this)return re(this,Z)}attributeChangedCallback(z){if(!!this.castPlayer)switch(z){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(z={}){var se;rt(se=L,Ne,os).call(se,z),Xe(L,S,this),Object.entries(re(this,N)).forEach(([Ye,Ce])=>{re(this,Z).controller.addEventListener(Ye,Ce)});try{await re(L,W,fr).requestSession()}catch{Xe(L,S,void 0);return}re(this,T).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(Ye){console.error(Ye)}}async load(){var At,Dt;if(!this.castPlayer)return super.load();let z=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),se=[...this.querySelectorAll("track")].filter(({kind:ht,src:ft})=>ft&&(ht==="subtitles"||ht==="captions")),Ye=[],Ce=0;se.length&&(z.tracks=se.map(ht=>{let ft=++Ce;Ye.length===0&&ht.track.mode==="showing"&&Ye.push(ft);let Ht=new chrome.cast.media.Track(ft,chrome.cast.media.TrackType.TEXT);return Ht.trackContentId=ht.src,Ht.trackContentType="text/vtt",Ht.subtype=ht.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,Ht.name=ht.label,Ht.language=ht.srclang,Ht})),this.castStreamType==="live"?z.streamType=chrome.cast.media.StreamType.LIVE:z.streamType=chrome.cast.media.StreamType.BUFFERED,z.metadata=new chrome.cast.media.GenericMediaMetadata,z.metadata.title=this.title,z.metadata.images=[{url:this.poster}];let dt=new chrome.cast.media.LoadRequest(z);dt.currentTime=(At=super.currentTime)!=null?At:0,dt.autoplay=!re(this,T).paused,dt.activeTrackIds=Ye,await((Dt=re(L,ve,zn))==null?void 0:Dt.loadMedia(dt)),this.dispatchEvent(new Event("volumechange"))}play(){var z;if(this.castPlayer){this.castPlayer.isPaused&&((z=this.castPlayer.controller)==null||z.playOrPause());return}return super.play()}pause(){var z;if(this.castPlayer){this.castPlayer.isPaused||(z=this.castPlayer.controller)==null||z.playOrPause();return}super.pause()}get castSrc(){var z,se,Ye;return(Ye=(se=this.getAttribute("cast-src"))!=null?se:(z=this.querySelector("source"))==null?void 0:z.src)!=null?Ye:this.currentSrc}set castSrc(z){this.castSrc!=z&&this.setAttribute("cast-src",`${z}`)}get castContentType(){var z;return(z=this.getAttribute("cast-content-type"))!=null?z:void 0}set castContentType(z){this.setAttribute("cast-content-type",`${z}`)}get castStreamType(){var z,se;return(se=(z=this.getAttribute("cast-stream-type"))!=null?z:this.streamType)!=null?se:void 0}set castStreamType(z){this.setAttribute("cast-stream-type",`${z}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var z;return this.castPlayer?(z=this.castPlayer)==null?void 0:z.isMuted:super.muted}set muted(z){var se;if(this.castPlayer){(z&&!this.castPlayer.isMuted||!z&&this.castPlayer.isMuted)&&((se=this.castPlayer.controller)==null||se.muteOrUnmute());return}super.muted=z}get volume(){var z,se;return this.castPlayer?(se=(z=this.castPlayer)==null?void 0:z.volumeLevel)!=null?se:1:super.volume}set volume(z){var se;if(this.castPlayer){this.castPlayer.volumeLevel=z,(se=this.castPlayer.controller)==null||se.setVolumeLevel();return}super.volume=z}get duration(){var z,se;return this.castPlayer&&re(this,je,Qi)?(se=(z=this.castPlayer)==null?void 0:z.duration)!=null?se:NaN:super.duration}get currentTime(){var z,se;return this.castPlayer&&re(this,je,Qi)?(se=(z=this.castPlayer)==null?void 0:z.currentTime)!=null?se:0:super.currentTime}set currentTime(z){var se;if(this.castPlayer){this.castPlayer.currentTime=z,(se=this.castPlayer.controller)==null||se.seek();return}super.currentTime=z}get onentercast(){return re(this,Ke)}set onentercast(z){re(this,Ke)&&(this.removeEventListener("entercast",re(this,Ke)),Xe(this,Ke,null)),typeof z=="function"&&(Xe(this,Ke,z),this.addEventListener("entercast",z))}get onleavecast(){return re(this,ot)}set onleavecast(z){re(this,ot)&&(this.removeEventListener("leavecast",re(this,ot)),Xe(this,ot,null)),typeof z=="function"&&(Xe(this,ot,z),this.addEventListener("leavecast",z))}get oncastchange(){return re(this,_e)}set oncastchange(z){re(this,_e)&&(this.removeEventListener("castchange",re(this,_e)),Xe(this,_e,null)),typeof z=="function"&&(Xe(this,_e,z),this.addEventListener("castchange",z))}},S=new WeakMap,F=new WeakMap,U=new WeakMap,H=new WeakSet,Xo=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},q=new WeakSet,Wn=function(){return typeof cast!="undefined"&&cast.framework},W=new WeakSet,fr=function(){if(re(L,q,Wn))return cast.framework.CastContext.getInstance()},ve=new WeakSet,zn=function(){var z;return(z=re(L,W,fr))==null?void 0:z.getCurrentSession()},Ee=new WeakSet,Xn=function(){var z;return(z=re(L,ve,zn))==null?void 0:z.getSessionObj().media[0]},Pe=new WeakSet,Qo=function(z){return new Promise((se,Ye)=>{re(L,Ee,Xn).editTracksInfo(z,se,Ye)})},Le=new WeakSet,Jo=function(z){return new Promise((se,Ye)=>{re(L,Ee,Xn).getStatus(z,se,Ye)})},Ne=new WeakSet,os=function(z){return re(L,W,fr).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...z})},T=new WeakMap,Z=new WeakMap,N=new WeakMap,Ke=new WeakMap,ot=new WeakMap,_e=new WeakMap,je=new WeakSet,Qi=function(){var z;return(z=this.castPlayer)==null?void 0:z.isMediaLoaded},P=new WeakSet,$o=function(){re(L,S)===this&&(Object.entries(re(this,N)).forEach(([z,se])=>{re(this,Z).controller.removeEventListener(z,se)}),Xe(L,S,void 0),this.muted=re(this,Z).isMuted,this.currentTime=re(this,Z).savedPlayerState.currentTime,re(this,Z).savedPlayerState.isPaused===!1&&this.play())},nt=new WeakSet,ls=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:re(L,W,fr).getCastState()}))},wt=new WeakSet,Zo=async function(){var se,Ye;let{SESSION_RESUMED:z}=cast.framework.SessionState;if(re(L,W,fr).getSessionState()===z&&this.castSrc===((se=re(L,Ee,Xn))==null?void 0:se.media.contentId)){Xe(L,S,this),Object.entries(re(this,N)).forEach(([Ce,dt])=>{re(this,Z).controller.addEventListener(Ce,dt)});try{await rt(Ye=L,Le,Jo).call(Ye,new chrome.cast.media.GetStatusRequest)}catch(Ce){console.error(Ce)}re(this,N)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),re(this,N)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},yt=new WeakSet,us=function(){var z;!re(L,q,Wn)||this.castEnabled||(this.castEnabled=!0,rt(z=L,Ne,os).call(z),this.textTracks.addEventListener("change",rt(this,Gt,ds).bind(this)),rt(this,nt,ls).call(this),Xe(this,Z,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(re(this,Z)),Xe(this,N,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:se})=>{se===!1&&rt(this,P,$o).call(this),this.dispatchEvent(new Event(se?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!re(this,je,Qi)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var se,Ye;((se=this.castPlayer)==null?void 0:se.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(Ye=this.castPlayer)==null?void 0:Ye.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!re(this,je,Qi)||(await Promise.resolve(),rt(this,Je,el).call(this))}}))},Je=new WeakSet,el=function(){rt(this,Gt,ds).call(this)},Gt=new WeakSet,ds=async function(){var _r,Sr,Ar,Kt,gr,kr;if(!this.castPlayer)return;let se=((Sr=(_r=re(this,Z).mediaInfo)==null?void 0:_r.tracks)!=null?Sr:[]).filter(({type:$e})=>$e===chrome.cast.media.TrackType.TEXT),Ye=[...this.textTracks].filter(({kind:$e})=>$e==="subtitles"||$e==="captions"),Ce=se.map(({language:$e,name:Zt,trackId:ar})=>{var Fr;let{mode:Mr}=(Fr=Ye.find(Nr=>Nr.language===$e&&Nr.label===Zt))!=null?Fr:{};return Mr?{mode:Mr,trackId:ar}:!1}).filter(Boolean),At=Ce.filter(({mode:$e})=>$e!=="showing").map(({trackId:$e})=>$e),Dt=Ce.find(({mode:$e})=>$e==="showing"),ht=(gr=(Kt=(Ar=re(L,ve,zn))==null?void 0:Ar.getSessionObj().media[0])==null?void 0:Kt.activeTrackIds)!=null?gr:[],ft=ht;if(ht.length&&(ft=ft.filter($e=>!At.includes($e))),Dt!=null&&Dt.trackId&&(ft=[...ft,Dt.trackId]),ft=[...new Set(ft)],!(($e,Zt)=>$e.length===Zt.length&&$e.every(ar=>Zt.includes(ar)))(ht,ft))try{let $e=new chrome.cast.media.EditTracksInfoRequest(ft);await rt(kr=L,Pe,Qo).call(kr,$e)}catch($e){console.error($e)}},Oe(L,H),Oe(L,q),Oe(L,W),Oe(L,ve),Oe(L,Ee),Oe(L,Pe),Oe(L,Le),Oe(L,Ne),Vi(L,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Vi(L,"instances",new Set),Oe(L,S,void 0),Oe(L,F,!1),Vi(L,"initCast",()=>{var z;re(L,H,Xo)?re(L,q,Wn)?re(z=L,U).call(z,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var se;return re(se=L,U).call(se,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var se;return re(se=L,U).call(se,chrome.cast.isAvailable)})}}),Oe(L,U,z=>{if(z){Xe(L,F,!0);let{CAST_STATE_CHANGED:se}=cast.framework.CastContextEventType;re(L,W,fr).addEventListener(se,Ce=>{L.instances.forEach(dt=>{var At;return rt(At=dt,nt,ls).call(At,Ce)})});let{SESSION_STATE_CHANGED:Ye}=cast.framework.CastContextEventType;re(L,W,fr).addEventListener(Ye,Ce=>{L.instances.forEach(dt=>{var At;return rt(At=dt,wt,Zo).call(At,Ce)})}),L.instances.forEach(Ce=>{var dt;return rt(dt=Ce,yt,us).call(dt)})}}),L},cs=globalThis.HTMLVideoElement?zo(HTMLVideoElement):zo(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",cs,{extends:"video"}),globalThis.CastableVideoElement=cs);cs.initCast();var tl=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],rl=Ya.createElement("template");rl.innerHTML=`
|
|
33
48
|
<style>
|
|
34
49
|
:host {
|
|
35
50
|
display: inline-block;
|
|
@@ -49,7 +64,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
49
64
|
</style>
|
|
50
65
|
<video is="castable-video" part="video" crossorigin></video>
|
|
51
66
|
<slot></slot>
|
|
52
|
-
`;var zi,Ai,kn,Qi,ba,$r=class extends xr.HTMLElement{constructor(){super();_t(this,Ai);_t(this,Qi);_t(this,zi,void 0);this.attachShadow({mode:"open"}),this.isConnected&&zt(this,Ai,kn).call(this)}static get observedAttributes(){let A=[],le=W=>W.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(W=>{let B=!1;try{typeof this.prototype[W]=="function"&&(B=!0)}catch{}!B&&W!==W.toUpperCase()&&A.push(W.toLowerCase(),le(W))});let ae=Object.getPrototypeOf(this).observedAttributes;return ae&&(A=A.concat(ae)),A}attributeChangedCallback(A,le,ae){zt(this,Ai,kn).call(this),zt(this,Qi,ba).call(this,A,le,ae)}connectedCallback(){zt(this,Ai,kn).call(this)}};zi=new WeakMap,Ai=new WeakSet,kn=function(){if(Ye(this,zi))return;Nt(this,zi,!0),this.shadowRoot.append(_s.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),bs.forEach(le=>{this.nativeEl.addEventListener(le,ae=>{this.dispatchEvent(new CustomEvent(ae.type,{detail:ae.detail}))})});let A=this.shadowRoot.querySelector("slot");A.addEventListener("slotchange",()=>{A.assignedElements().forEach(le=>{!["track","source"].includes(le.localName)||this.nativeEl.append(le)})}),Array.prototype.forEach.call(this.attributes,le=>{zt(this,Qi,ba).call(this,le.name,null,le.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},Qi=new WeakSet,ba=function(A,le,ae){let W=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),B=So(W,A),j=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;B&&!j?typeof this[B]=="boolean"?ae===null?this[B]=!1:this[B]=!0:this[B]=ae:ae===null?this.nativeEl.removeAttribute(A):["id","class"].indexOf(A)===-1&&this.nativeEl.setAttribute(A,ae)};var Ss=[],As=ra.createElement("video",{is:"castable-video"}),_o=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let x=Object.getPrototypeOf(As);x&&x!==xr.HTMLElement.prototype;x=Object.getPrototypeOf(x))Object.getOwnPropertyNames(x).forEach(w=>{_o.indexOf(w)===-1&&Ss.push(w)});Ss.forEach(x=>{if(x in $r.prototype)return;if(typeof As[x]=="function")$r.prototype[x]=function(){return this.nativeEl[x].apply(this.nativeEl,arguments)};else{let A={get(){return this.nativeEl[x]}};x!==x.toUpperCase()&&(A.set=function(le){this.nativeEl[x]=le}),Object.defineProperty($r.prototype,x,A)}});function So(x,w){let A=null;return x.forEach(le=>{le.toLowerCase()==w.toLowerCase()&&(A=le)}),A}xr.customElements.get("custom-video")||(xr.customElements.define("custom-video",$r),xr.CustomVideoElement=$r);var _a=$r;var mt={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TYPE:"type"},Ao=Object.values(mt),ko=vs(),wo="mux-video",Fr,ki,$i,wi,Zi,en,tn,rn,Sa,Ji=class extends _a{constructor(){super();_t(this,rn);_t(this,Fr,void 0);_t(this,ki,void 0);_t(this,$i,void 0);_t(this,wi,{});_t(this,Zi,void 0);_t(this,en,void 0);_t(this,tn,void 0);Nt(this,$i,ss())}static get observedAttributes(){var A;return[...Ao,...(A=_a.observedAttributes)!=null?A:[]]}get preferCmcd(){var A;return(A=this.getAttribute(mt.PREFER_CMCD))!=null?A:void 0}set preferCmcd(A){A!==this.preferCmcd&&(A?da.includes(A)?this.setAttribute(mt.PREFER_CMCD,A):console.warn(`Invalid value for preferCmcd. Must be one of ${da.join()}`):this.removeAttribute(mt.PREFER_CMCD))}get playerInitTime(){return Ye(this,$i)}get playerSoftwareName(){var A;return(A=Ye(this,en))!=null?A:wo}set playerSoftwareName(A){Nt(this,en,A)}get playerSoftwareVersion(){var A;return(A=Ye(this,Zi))!=null?A:ko}set playerSoftwareVersion(A){Nt(this,Zi,A)}get _hls(){var A;return(A=Ye(this,Fr))==null?void 0:A.engine}get mux(){return this.nativeEl.mux}get error(){var A;return(A=ls(this.nativeEl))!=null?A:null}get errorTranslator(){return Ye(this,tn)}set errorTranslator(A){Nt(this,tn,A)}get src(){return this.getAttribute("src")}set src(A){A!==this.src&&(A==null?this.removeAttribute("src"):this.setAttribute("src",A))}get type(){var A;return(A=this.getAttribute(mt.TYPE))!=null?A:void 0}set type(A){A!==this.type&&(A?this.setAttribute(mt.TYPE,A):this.removeAttribute(mt.TYPE))}get autoplay(){let A=this.getAttribute("autoplay");return A===null?!1:A===""?!0:A}set autoplay(A){let le=this.autoplay;A!==le&&(A?this.setAttribute("autoplay",typeof A=="string"?A:""):this.removeAttribute("autoplay"))}get preload(){let A=this.getAttribute("preload");return A===""?"auto":["none","metadata","auto"].includes(A)?A:super.preload}set preload(A){A!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(A)?this.setAttribute("preload",A):this.removeAttribute("preload"))}get debug(){return this.getAttribute(mt.DEBUG)!=null}set debug(A){A!==this.debug&&(A?this.setAttribute(mt.DEBUG,""):this.removeAttribute(mt.DEBUG))}get disableCookies(){return this.hasAttribute(mt.DISABLE_COOKIES)}set disableCookies(A){A!==this.disableCookies&&(A?this.setAttribute(mt.DISABLE_COOKIES,""):this.removeAttribute(mt.DISABLE_COOKIES))}get startTime(){let A=this.getAttribute(mt.START_TIME);if(A==null)return;let le=+A;return Number.isNaN(le)?void 0:le}set startTime(A){A!==this.startTime&&(A==null?this.removeAttribute(mt.START_TIME):this.setAttribute(mt.START_TIME,`${A}`))}get playbackId(){var A;return(A=this.getAttribute(mt.PLAYBACK_ID))!=null?A:void 0}set playbackId(A){A!==this.playbackId&&(A?this.setAttribute(mt.PLAYBACK_ID,A):this.removeAttribute(mt.PLAYBACK_ID))}get maxResolution(){var A;return(A=this.getAttribute(mt.MAX_RESOLUTION))!=null?A:void 0}set maxResolution(A){A!==this.maxResolution&&(A?this.setAttribute(mt.MAX_RESOLUTION,A):this.removeAttribute(mt.MAX_RESOLUTION))}get customDomain(){var A;return(A=this.getAttribute(mt.CUSTOM_DOMAIN))!=null?A:void 0}set customDomain(A){A!==this.customDomain&&(A?this.setAttribute(mt.CUSTOM_DOMAIN,A):this.removeAttribute(mt.CUSTOM_DOMAIN))}get envKey(){var A;return(A=this.getAttribute(mt.ENV_KEY))!=null?A:void 0}set envKey(A){A!==this.envKey&&(A?this.setAttribute(mt.ENV_KEY,A):this.removeAttribute(mt.ENV_KEY))}get beaconCollectionDomain(){var A;return(A=this.getAttribute(mt.BEACON_COLLECTION_DOMAIN))!=null?A:void 0}set beaconCollectionDomain(A){A!==this.beaconCollectionDomain&&(A?this.setAttribute(mt.BEACON_COLLECTION_DOMAIN,A):this.removeAttribute(mt.BEACON_COLLECTION_DOMAIN))}get streamType(){var A;return(A=this.getAttribute(mt.STREAM_TYPE))!=null?A:void 0}set streamType(A){A!==this.streamType&&(A?this.setAttribute(mt.STREAM_TYPE,A):this.removeAttribute(mt.STREAM_TYPE))}async addCuePoints(A){return fa(this.nativeEl,A)}get activeCuePoint(){return va(this.nativeEl)}get cuePoints(){return is(this.nativeEl)}get preferPlayback(){let A=this.getAttribute(mt.PREFER_PLAYBACK);if(A===oi.MSE||A===oi.NATIVE)return A}set preferPlayback(A){A!==this.preferPlayback&&(A===oi.MSE||A===oi.NATIVE?this.setAttribute(mt.PREFER_PLAYBACK,A):this.removeAttribute(mt.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(le=>le.startsWith("metadata-")&&![mt.METADATA_URL].includes(le)).reduce((le,ae)=>{let W=this.getAttribute(ae);return W!=null&&(le[ae.replace(/^metadata-/,"").replace(/-/g,"_")]=W),le},{}),...Ye(this,wi)}}set metadata(A){Nt(this,wi,A!=null?A:{}),this.mux&&this.mux.emit("hb",Ye(this,wi))}load(){Nt(this,Fr,us(this,this.nativeEl,Ye(this,Fr)))}unload(){pa(this.nativeEl,Ye(this,Fr)),Nt(this,Fr,void 0)}attributeChangedCallback(A,le,ae){var W,B;switch(super.attributeChangedCallback(A,le,ae),A){case mt.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=ae!=null?ae:void 0;break;case mt.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=ae!=null?ae:void 0;break;case"src":{let j=!!le,re=!!ae;!j&&re?zt(this,rn,Sa).call(this):j&&!re?this.unload():j&&re&&(this.unload(),zt(this,rn,Sa).call(this));break}case"autoplay":if(ae===le)break;(W=Ye(this,Fr))==null||W.setAutoplay(this.autoplay);break;case"preload":if(ae===le)break;(B=Ye(this,Fr))==null||B.setPreload(ae);break;case mt.PLAYBACK_ID:this.src=os(ae!=null?ae:void 0,{maxResolution:this.maxResolution,domain:this.customDomain});break;case mt.DEBUG:{let j=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=j);break}case mt.METADATA_URL:ae&&fetch(ae).then(j=>j.json()).then(j=>this.metadata=j).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${ae}!`));break;default:break}}disconnectedCallback(){this.unload()}};Fr=new WeakMap,ki=new WeakMap,$i=new WeakMap,wi=new WeakMap,Zi=new WeakMap,en=new WeakMap,tn=new WeakMap,rn=new WeakSet,Sa=async function(){Ye(this,ki)||(await Nt(this,ki,Promise.resolve()),Nt(this,ki,null),this.load())};xr.customElements.get("mux-video")||(xr.customElements.define("mux-video",Ji),xr.MuxVideoElement=Ji);var Xo=Ji;export{mt as Attributes,Tr as MediaError,bs as VideoEvents,Xo as default};
|
|
67
|
+
`;var Ji,Ti,Qn,$i,hs,xr=class extends hr.HTMLElement{constructor(){super();Oe(this,Ti);Oe(this,$i);Oe(this,Ji,void 0);this.attachShadow({mode:"open"}),this.isConnected&&rt(this,Ti,Qn).call(this)}static get observedAttributes(){let S=[],F=H=>H.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(H=>{let Q=!1;try{typeof this.prototype[H]=="function"&&(Q=!0)}catch{}!Q&&H!==H.toUpperCase()&&S.push(H.toLowerCase(),F(H))});let U=Object.getPrototypeOf(this).observedAttributes;return U&&(S=S.concat(U)),S}attributeChangedCallback(S,F,U){rt(this,Ti,Qn).call(this),rt(this,$i,hs).call(this,S,F,U)}connectedCallback(){rt(this,Ti,Qn).call(this)}};Ji=new WeakMap,Ti=new WeakSet,Qn=function(){if(re(this,Ji))return;Xe(this,Ji,!0),this.shadowRoot.append(rl.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),tl.forEach(F=>{this.nativeEl.addEventListener(F,U=>{this.dispatchEvent(new CustomEvent(U.type,{detail:U.detail}))})});let S=this.shadowRoot.querySelector("slot");S.addEventListener("slotchange",()=>{S.assignedElements().forEach(F=>{!["track","source"].includes(F.localName)||this.nativeEl.append(F)})}),Array.prototype.forEach.call(this.attributes,F=>{rt(this,$i,hs).call(this,F.name,null,F.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},$i=new WeakSet,hs=function(S,F,U){let H=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),Q=rd(H,S),q=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;Q&&!q?typeof this[Q]=="boolean"?U===null?this[Q]=!1:this[Q]=!0:this[Q]=U:U===null?this.nativeEl.removeAttribute(S):["id","class"].indexOf(S)===-1&&this.nativeEl.setAttribute(S,U)};var il=[],nl=Ya.createElement("video",{is:"castable-video"}),td=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let R=Object.getPrototypeOf(nl);R&&R!==hr.HTMLElement.prototype;R=Object.getPrototypeOf(R))Object.getOwnPropertyNames(R).forEach(L=>{td.indexOf(L)===-1&&il.push(L)});il.forEach(R=>{if(R in xr.prototype)return;if(typeof nl[R]=="function")xr.prototype[R]=function(){return this.nativeEl[R].apply(this.nativeEl,arguments)};else{let S={get(){return this.nativeEl[R]}};R!==R.toUpperCase()&&(S.set=function(F){this.nativeEl[R]=F}),Object.defineProperty(xr.prototype,R,S)}});function rd(R,L){let S=null;return R.forEach(F=>{F.toLowerCase()==L.toLowerCase()&&(S=F)}),S}hr.customElements.get("custom-video")||(hr.customElements.define("custom-video",xr),hr.CustomVideoElement=xr);var fs=xr;var ye={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},id=Object.values(ye),nd=Wo(),ad="mux-video",vr,bi,en,_i,tn,rn,nn,an,vs,Zi=class extends fs{constructor(){super();Oe(this,an);Oe(this,vr,void 0);Oe(this,bi,void 0);Oe(this,en,void 0);Oe(this,_i,{});Oe(this,tn,void 0);Oe(this,rn,void 0);Oe(this,nn,void 0);Xe(this,en,Fo())}static get observedAttributes(){var S;return[...id,...(S=fs.observedAttributes)!=null?S:[]]}get preferCmcd(){var S;return(S=this.getAttribute(ye.PREFER_CMCD))!=null?S:void 0}set preferCmcd(S){S!==this.preferCmcd&&(S?es.includes(S)?this.setAttribute(ye.PREFER_CMCD,S):console.warn(`Invalid value for preferCmcd. Must be one of ${es.join()}`):this.removeAttribute(ye.PREFER_CMCD))}get playerInitTime(){return re(this,en)}get playerSoftwareName(){var S;return(S=re(this,rn))!=null?S:ad}set playerSoftwareName(S){Xe(this,rn,S)}get playerSoftwareVersion(){var S;return(S=re(this,tn))!=null?S:nd}set playerSoftwareVersion(S){Xe(this,tn,S)}get _hls(){var S;return(S=re(this,vr))==null?void 0:S.engine}get mux(){return this.nativeEl.mux}get error(){var S;return(S=Uo(this.nativeEl))!=null?S:null}get errorTranslator(){return re(this,nn)}set errorTranslator(S){Xe(this,nn,S)}get src(){return this.getAttribute("src")}set src(S){S!==this.src&&(S==null?this.removeAttribute("src"):this.setAttribute("src",S))}get type(){var S;return(S=this.getAttribute(ye.TYPE))!=null?S:void 0}set type(S){S!==this.type&&(S?this.setAttribute(ye.TYPE,S):this.removeAttribute(ye.TYPE))}get autoplay(){let S=this.getAttribute("autoplay");return S===null?!1:S===""?!0:S}set autoplay(S){let F=this.autoplay;S!==F&&(S?this.setAttribute("autoplay",typeof S=="string"?S:""):this.removeAttribute("autoplay"))}get preload(){let S=this.getAttribute("preload");return S===""?"auto":["none","metadata","auto"].includes(S)?S:super.preload}set preload(S){S!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(S)?this.setAttribute("preload",S):this.removeAttribute("preload"))}get debug(){return this.getAttribute(ye.DEBUG)!=null}set debug(S){S!==this.debug&&(S?this.setAttribute(ye.DEBUG,""):this.removeAttribute(ye.DEBUG))}get disableCookies(){return this.hasAttribute(ye.DISABLE_COOKIES)}set disableCookies(S){S!==this.disableCookies&&(S?this.setAttribute(ye.DISABLE_COOKIES,""):this.removeAttribute(ye.DISABLE_COOKIES))}get startTime(){let S=this.getAttribute(ye.START_TIME);if(S==null)return;let F=+S;return Number.isNaN(F)?void 0:F}set startTime(S){S!==this.startTime&&(S==null?this.removeAttribute(ye.START_TIME):this.setAttribute(ye.START_TIME,`${S}`))}get playbackId(){var S;return(S=this.getAttribute(ye.PLAYBACK_ID))!=null?S:void 0}set playbackId(S){S!==this.playbackId&&(S?this.setAttribute(ye.PLAYBACK_ID,S):this.removeAttribute(ye.PLAYBACK_ID))}get maxResolution(){var S;return(S=this.getAttribute(ye.MAX_RESOLUTION))!=null?S:void 0}set maxResolution(S){S!==this.maxResolution&&(S?this.setAttribute(ye.MAX_RESOLUTION,S):this.removeAttribute(ye.MAX_RESOLUTION))}get customDomain(){var S;return(S=this.getAttribute(ye.CUSTOM_DOMAIN))!=null?S:void 0}set customDomain(S){S!==this.customDomain&&(S?this.setAttribute(ye.CUSTOM_DOMAIN,S):this.removeAttribute(ye.CUSTOM_DOMAIN))}get envKey(){var S;return(S=this.getAttribute(ye.ENV_KEY))!=null?S:void 0}set envKey(S){S!==this.envKey&&(S?this.setAttribute(ye.ENV_KEY,S):this.removeAttribute(ye.ENV_KEY))}get beaconCollectionDomain(){var S;return(S=this.getAttribute(ye.BEACON_COLLECTION_DOMAIN))!=null?S:void 0}set beaconCollectionDomain(S){S!==this.beaconCollectionDomain&&(S?this.setAttribute(ye.BEACON_COLLECTION_DOMAIN,S):this.removeAttribute(ye.BEACON_COLLECTION_DOMAIN))}get streamType(){var S;return(S=this.getAttribute(ye.STREAM_TYPE))!=null?S:Bo(this.nativeEl)}set streamType(S){S!==this.streamType&&(S?this.setAttribute(ye.STREAM_TYPE,S):this.removeAttribute(ye.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(ye.TARGET_LIVE_WINDOW)?+this.getAttribute(ye.TARGET_LIVE_WINDOW):Go(this.nativeEl)}set targetLiveWindow(S){S!=this.targetLiveWindow&&(S==null?this.removeAttribute(ye.TARGET_LIVE_WINDOW):this.setAttribute(ye.TARGET_LIVE_WINDOW,`${+S}`))}get liveEdgeStart(){var S,F;if(this.hasAttribute(ye.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:U}=this,H=(S=this.nativeEl.seekable.end(0))!=null?S:0,Q=(F=this.nativeEl.seekable.start(0))!=null?F:0;return Math.max(Q,H-U)}return Ho(this.nativeEl)}get liveEdgeOffset(){if(!!this.hasAttribute(ye.LIVE_EDGE_OFFSET))return+this.getAttribute(ye.LIVE_EDGE_OFFSET)}set liveEdgeOffset(S){S!=this.targetLiveWindow&&(S==null?this.removeAttribute(ye.LIVE_EDGE_OFFSET):this.setAttribute(ye.LIVE_EDGE_OFFSET,`${+S}`))}get seekable(){return as(this.nativeEl)}async addCuePoints(S){return is(this.nativeEl,S)}get activeCuePoint(){return ns(this.nativeEl)}get cuePoints(){return Co(this.nativeEl)}getStartDate(){return Po(this.nativeEl,this._hls)}get currentPdt(){return xo(this.nativeEl,this._hls)}get preferPlayback(){let S=this.getAttribute(ye.PREFER_PLAYBACK);if(S===Xr.MSE||S===Xr.NATIVE)return S}set preferPlayback(S){S!==this.preferPlayback&&(S===Xr.MSE||S===Xr.NATIVE?this.setAttribute(ye.PREFER_PLAYBACK,S):this.removeAttribute(ye.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(F=>F.startsWith("metadata-")&&![ye.METADATA_URL].includes(F)).reduce((F,U)=>{let H=this.getAttribute(U);return H!=null&&(F[U.replace(/^metadata-/,"").replace(/-/g,"_")]=H),F},{}),...re(this,_i)}}set metadata(S){Xe(this,_i,S!=null?S:{}),this.mux&&this.mux.emit("hb",re(this,_i))}load(){Xe(this,vr,Ko(this,this.nativeEl,re(this,vr)))}unload(){ss(this.nativeEl,re(this,vr)),Xe(this,vr,void 0)}attributeChangedCallback(S,F,U){var H,Q;switch(super.attributeChangedCallback(S,F,U),S){case ye.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=U!=null?U:void 0;break;case ye.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=U!=null?U:void 0;break;case"src":{let q=!!F,ne=!!U;!q&&ne?rt(this,an,vs).call(this):q&&!ne?this.unload():q&&ne&&(this.unload(),rt(this,an,vs).call(this));break}case"autoplay":if(U===F)break;(H=re(this,vr))==null||H.setAutoplay(this.autoplay);break;case"preload":if(U===F)break;(Q=re(this,vr))==null||Q.setPreload(U);break;case ye.PLAYBACK_ID:this.src=No(U!=null?U:void 0,{maxResolution:this.maxResolution,domain:this.customDomain});break;case ye.DEBUG:{let q=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=q);break}case ye.METADATA_URL:U&&fetch(U).then(q=>q.json()).then(q=>this.metadata=q).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${U}!`));break;case ye.STREAM_TYPE:(U==null||U!==F)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case ye.TARGET_LIVE_WINDOW:(U==null||U!==F)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}disconnectedCallback(){this.unload()}};vr=new WeakMap,bi=new WeakMap,en=new WeakMap,_i=new WeakMap,tn=new WeakMap,rn=new WeakMap,nn=new WeakMap,an=new WeakSet,vs=async function(){re(this,bi)||(await Xe(this,bi,Promise.resolve()),Xe(this,bi,null),this.load())};hr.customElements.get("mux-video")||(hr.customElements.define("mux-video",Zi),hr.MuxVideoElement=Zi);var wd=Zi;export{ye as Attributes,Ot as MediaError,tl as VideoEvents,wd as default};
|
|
53
68
|
/*!
|
|
54
69
|
* JavaScript Cookie v2.1.3
|
|
55
70
|
* https://github.com/js-cookie/js-cookie
|
|
@@ -59,7 +74,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
59
74
|
*/
|
|
60
75
|
/*!
|
|
61
76
|
* mux-embed
|
|
62
|
-
* @version 4.
|
|
63
|
-
* @copyright
|
|
77
|
+
* @version 4.24.0
|
|
78
|
+
* @copyright 2023 Mux, Inc
|
|
64
79
|
*/
|
|
65
80
|
//# sourceMappingURL=mux-video.mjs.map
|