@mux/mux-video 0.15.1 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/mux-video.js +37 -37
- package/dist/mux-video.js.map +4 -4
- package/dist/mux-video.mjs +37 -37
- package/dist/mux-video.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/mux-video.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
"use strict";(()=>{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
|
|
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(
|
|
6
|
-
`):"")+"".concat(
|
|
7
|
-
`):"")+"".concat(
|
|
8
|
-
`):"")+"".concat(
|
|
9
|
-
`):"")+"".concat(
|
|
10
|
-
`):"")+"".concat(
|
|
11
|
-
`):"")+"".concat(
|
|
12
|
-
`):"")+"".concat(
|
|
13
|
-
`):"");
|
|
14
|
-
`):"")+"".concat(
|
|
15
|
-
`):"");
|
|
16
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function
|
|
1
|
+
"use strict";(()=>{var _u=Object.create;var ja=Object.defineProperty;var Su=Object.getOwnPropertyDescriptor;var Au=Object.getOwnPropertyNames;var Lu=Object.getPrototypeOf,ku=Object.prototype.hasOwnProperty;var wu=(w,k,S)=>k in w?ja(w,k,{enumerable:!0,configurable:!0,writable:!0,value:S}):w[k]=S;var vo=(w,k)=>()=>(k||w((k={exports:{}}).exports,k),k.exports);var Ru=(w,k,S,M)=>{if(k&&typeof k=="object"||typeof k=="function")for(let N of Au(k))!ku.call(w,N)&&N!==S&&ja(w,N,{get:()=>k[N],enumerable:!(M=Su(k,N))||M.enumerable});return w};var go=(w,k,S)=>(S=w!=null?_u(Lu(w)):{},Ru(k||!w||!w.__esModule?ja(S,"default",{value:w,enumerable:!0}):S,w));var Xi=(w,k,S)=>(wu(w,typeof k!="symbol"?k+"":k,S),S),Va=(w,k,S)=>{if(!k.has(w))throw TypeError("Cannot "+S)};var ne=(w,k,S)=>(Va(w,k,"read from private field"),S?S.call(w):k.get(w)),Oe=(w,k,S)=>{if(k.has(w))throw TypeError("Cannot add the same private member more than once");k instanceof WeakSet?k.add(w):k.set(w,S)},ze=(w,k,S,M)=>(Va(w,k,"write to private field"),M?M.call(w,S):k.set(w,S),S);var Ze=(w,k,S)=>(Va(w,k,"access private method"),S);var yo=vo((Xn,Xa)=>{(function(){var w,k;w=this,k=function(){return function(){var S={80:function(G,Q,q){G.exports=q(728).default},728:function(G,Q,q){"use strict";q.d(Q,{default:function(){return Ki}});var ae=q(48),W=q.n(ae),fe=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(m){var h=16*Math.random()|0;return(m==="x"?h:3&h|8).toString(16)})},ge=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},me=function(m){return m&&m.nodeName!==void 0?(m.muxId||(m.muxId=m.id||ge()),m.muxId):m},Te=function(m){var h;m&&m.nodeName!==void 0?m=me(h=m):h=document.querySelector(m);var g=h&&h.nodeName?h.nodeName.toLowerCase():"";return[h,m,g]},Ce=q(640),Ie=q.n(Ce),et=Ie().methodFactory;Ie().methodFactory=function(m,h,g){var _=et(m,h,g);return function(){for(var L=["[mux]"],I=0;I<arguments.length;I++)L.push(arguments[I]);_.apply(void 0,L)}},Ie().setLevel(Ie().getLevel());var Le=Ie();function Lt(){return(W().doNotTrack||W().navigator&&W().navigator.doNotTrack)==="1"}var Ke={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(_)}},vt=function(m){return at(m)[0]},at=function(m){if(typeof m!="string"||m==="")return["localhost"];var h,g=(m.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return g&&(h=(g.match(/[^\.]+\.[^\.]+$/)||[])[0]),[g,h]},$={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 T(m,h,g){g=g===void 0?1:g,m[h]=m[h]||0,m[h]+=g}var Z=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],H=["x-cdn","content-type"].concat(Z);function ye(m){var h={};return(m=m||"").trim().split(/[\r\n]+/).forEach(function(g){if(g){var _=g.split(": "),L=_.shift();L&&(H.indexOf(L.toLowerCase())>=0||L.toLowerCase().indexOf("x-litix-")===0)&&(h[L]=_.join(": "))}}),h}function He(m){if(m){var h=Z.find(function(g){return m[g]!==void 0});return h?m[h]:void 0}}var Je=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 kt(m,h){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(m);h&&(_=_.filter(function(L){return Object.getOwnPropertyDescriptor(m,L).enumerable})),g.push.apply(g,_)}return g}function Ye(m){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?kt(Object(g),!0).forEach(function(_){P(m,_,g[_])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):kt(Object(g)).forEach(function(_){Object.defineProperty(m,_,Object.getOwnPropertyDescriptor(g,_))})}return m}function P(m,h,g){return h in m?Object.defineProperty(m,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[h]=g,m}var Tr=function(m){if(!m)return{};var h=$.navigationStart(),g=m.loading,_=g?g.start:m.trequest,L=g?g.first:m.tfirst,I=g?g.end:m.tload;return{bytesLoaded:m.total,requestStart:Math.round(h+_),responseStart:Math.round(h+L),responseEnd:Math.round(h+I)}},wt=function(m){if(m&&typeof m.getAllResponseHeaders=="function")return ye(m.getAllResponseHeaders())};function Xe(m,h){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(m);h&&(_=_.filter(function(L){return Object.getOwnPropertyDescriptor(m,L).enumerable})),g.push.apply(g,_)}return g}function Ct(m){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?Xe(Object(g),!0).forEach(function(_){Be(m,_,g[_])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):Xe(Object(g)).forEach(function(_){Object.defineProperty(m,_,Object.getOwnPropertyDescriptor(g,_))})}return m}function Be(m,h,g){return h in m?Object.defineProperty(m,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[h]=g,m}var st=function(m,h){if(!m||typeof m.getRequests!="function")return{};var g=m.getRequests({state:"executed"});if(g.length===0)return{};var _,L=g[g.length-1],I=vt(L.url),R=L.url,x=L.bytesLoaded,B=new Date(L.requestStartDate).getTime(),F=new Date(L.firstByteDate).getTime(),Y=new Date(L.requestEndDate).getTime(),Ae=isNaN(L.duration)?0:L.duration,se=typeof h.getMetricsFor=="function"?h.getMetricsFor(L.mediaType).HttpList:h.getDashMetrics().getHttpRequests(L.mediaType);return se.length>0&&(_=ye(se[se.length-1]._responseHeaders||"")),{requestStart:B,requestResponseStart:F,requestResponseEnd:Y,requestBytesLoaded:x,requestResponseHeaders:_,requestMediaDuration:Ae,requestHostname:I,requestUrl:R,requestId:_?He(_):void 0}},tt=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}:{}},rt=function(m){var h;return(h=m.match(/.*codecs\*?="(.*)"/))===null||h===void 0?void 0:h[1]};function ii(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 Si=0,ni=function(){function m(){(function(L,I){if(!(L instanceof I))throw new TypeError("Cannot call a class as a function")})(this,m)}var h,g,_;return h=m,g=[{key:"on",value:function(L,I,R){return I._eventEmitterGuid=I._eventEmitterGuid||++Si,this._listeners=this._listeners||{},this._listeners[L]=this._listeners[L]||[],R&&(I=I.bind(R)),this._listeners[L].push(I),I}},{key:"off",value:function(L,I){var R=this._listeners&&this._listeners[L];R&&R.forEach(function(x,B){x._eventEmitterGuid===I._eventEmitterGuid&&R.splice(B,1)})}},{key:"one",value:function(L,I,R){var x=this;I._eventEmitterGuid=I._eventEmitterGuid||++Si;var B=function F(){x.off(L,F),I.apply(R||this,arguments)};B._eventEmitterGuid=I._eventEmitterGuid,this.on(L,B)}},{key:"emit",value:function(L,I){var R=this;if(this._listeners){I=I||{};var x=this._listeners["before*"]||[],B=this._listeners[L]||[],F=this._listeners["after"+L]||[],Y=function(Ae,se){(Ae=Ae.slice()).forEach(function(ce){ce.call(R,{type:L},se)})};Y(x,I),Y(B,I),Y(F,I)}}}],g&&ii(h.prototype,g),_&&ii(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}(),X=ni;function oe(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 je=function(){function m(L){var I=this;(function(R,x){if(!(R instanceof x))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=L,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,L.on("playing",function(){I._playheadShouldBeProgressing=!0}),L.on("play",this._startPlaybackHeartbeatInterval.bind(this)),L.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),L.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),L.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),L.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),L.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),L.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),L.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),L.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),L.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),L.on("seeked",function(){L.data.player_is_paused?I._stopPlaybackHeartbeatInterval():I._startPlaybackHeartbeatInterval()}),L.on("timeupdate",function(){I._playbackHeartbeatInterval!==null&&L.emit("playbackheartbeat")}),L.on("devicesleep",function(R,x){I._playbackHeartbeatInterval!==null&&(W().clearInterval(I._playbackHeartbeatInterval),L.emit("playbackheartbeatend",{viewer_time:x.viewer_time}),I._playbackHeartbeatInterval=null)})}var h,g,_;return h=m,(g=[{key:"_startPlaybackHeartbeatInterval",value:function(){var L=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=W().setInterval(function(){L.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)}}])&&oe(h.prototype,g),_&&oe(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function it(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 gt(m,h,g){return h&&it(m.prototype,h),g&&it(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Fe=gt(function m(h){var g=this;(function(_,L){if(!(_ instanceof L))throw new TypeError("Cannot call a class as a function")})(this,m),h.on("viewinit",function(){g.viewErrored=!1}),h.on("error",function(_,L){try{var I=h.errorTranslator({player_error_code:L.player_error_code,player_error_message:L.player_error_message,player_error_context:L.player_error_context});I?(h.data.player_error_code=I.player_error_code||L.player_error_code,h.data.player_error_message=I.player_error_message||L.player_error_message,h.data.player_error_context=I.player_error_context||L.player_error_context,g.viewErrored=!0):(delete h.data.player_error_code,delete h.data.player_error_message,delete h.data.player_error_context)}catch(R){h.mux.log.warn("Exception in error translator callback.",R),g.viewErrored=!0}})});function Pt(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 Et=function(){function m(L){(function(I,R){if(!(I instanceof R))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=L,this._watchTimeTrackerLastCheckedTime=null,L.on("playbackheartbeat",this._updateWatchTime.bind(this)),L.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var h,g,_;return h=m,(g=[{key:"_updateWatchTime",value:function(L,I){var R=I.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=R),T(this.pm.data,"view_watch_time",R-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=R}},{key:"_clearWatchTimeState",value:function(L,I){this._updateWatchTime(L,I),this._watchTimeTrackerLastCheckedTime=null}}])&&Pt(h.prototype,g),_&&Pt(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function nt(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 xt=function(){function m(L){(function(I,R){if(!(I instanceof R))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=L,this._playbackTimeTrackerLastPlayheadPosition=-1,L.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),L.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),L.on("seeking",this._clearPlaybackTimeState.bind(this))}var h,g,_;return h=m,(g=[{key:"_updatePlaybackTime",value:function(){var L=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&L>this._playbackTimeTrackerLastPlayheadPosition){var I=L-this._playbackTimeTrackerLastPlayheadPosition;I<=1e3&&T(this.pm.data,"view_content_playback_time",I)}this._playbackTimeTrackerLastPlayheadPosition=L}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&nt(h.prototype,g),_&&nt(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function br(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 Mr=function(){function m(L){(function(R,x){if(!(R instanceof x))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=L;var I=this._updatePlayheadTime.bind(this);L.on("playbackheartbeat",I),L.on("playbackheartbeatend",I),L.on("timeupdate",I),L.on("destroy",function(){L.off("timeupdate",I)})}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(L,I){var R=this,x=function(){R.pm.currentFragmentPDT&&R.pm.currentFragmentStart&&(R.pm.data.player_program_time=R.pm.currentFragmentPDT+R.pm.data.player_playhead_time-R.pm.currentFragmentStart)};if(I&&I.player_playhead_time)this.pm.data.player_playhead_time=I.player_playhead_time,x(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var B=this.pm.getPlayheadTime();B!==void 0&&(this.pm.data.player_playhead_time=B,x(),this._updateMaxPlayheadPosition())}}}])&&br(h.prototype,g),_&&br(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,_)}}function Sr(m,h,g){return h&&_r(m.prototype,h),g&&_r(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Ar=3e5,jt=Sr(function m(h){if(function(I,R){if(!(I instanceof R))throw new TypeError("Cannot call a class as a function")}(this,m),!h.disableRebufferTracking){var g,_=function(I,R){L(R),g=void 0},L=function(I){if(g){var R=I.viewer_time-g;T(h.data,"view_rebuffer_duration",R),g=I.viewer_time,h.data.view_rebuffer_duration>Ar&&(h.emit("viewend"),h.send("viewend"),h.mux.log.warn("Ending view after rebuffering for longer than ".concat(Ar,"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(I,R){return L(R)}),h.on("rebufferstart",function(I,R){g||(T(h.data,"view_rebuffer_count",1),g=R.viewer_time,h.one("rebufferend",_))}),h.on("viewinit",function(){g=void 0,h.off("rebufferend",_)})}});function We(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 tr=function(){function m(L){var I=this;(function(R,x){if(!(R instanceof x))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=L,L.disableRebufferTracking||L.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,L.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),L.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),L.on("seeking",function(){I._cleanupRebufferTracker(null,{viewer_time:Ke.now()})}))}var h,g,_;return h=m,g=[{key:"_checkIfRebuffering",value:function(L,I){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(L,I);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var R=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&R>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=I.viewer_time}else this._cleanupRebufferTracker(L,I,!0);else this._prepareRebufferTrackerState(I.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(L){this._lastCheckedTime=L,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=L}},{key:"_cleanupRebufferTracker",value:function(L,I){var R=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:I.viewer_time});else{if(this._lastCheckedTime===null)return;var x=this.pm.data.player_playhead_time-this._lastPlayheadTime,B=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&x>0&&B-x>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+B-x}))}R?this._prepareRebufferTrackerState(I.viewer_time):this._clearRebufferTrackerState()}}],g&&We(h.prototype,g),_&&We(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}(),Lr=tr;function rr(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 ur=function(){function m(L){var I=this;(function(R,x){if(!(R instanceof x))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=L,L.on("viewinit",function(){var R=L.data,x=R.view_id;if(!R.view_program_changed){var B=function(F,Y){var Ae=Y.viewer_time;F.type==="playing"&&L.data.view_time_to_first_frame===void 0?I.calculateTimeToFirstFrame(Ae||Ke.now(),x):F.type!=="adplaying"||L.data.view_time_to_first_frame!==void 0&&!I._inPrerollPosition()||I.calculateTimeToFirstFrame(Ae||Ke.now(),x)};L.one("playing",B),L.one("adplaying",B),L.one("viewend",function(){L.off("playing",B),L.off("adplaying",B)})}})}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(L,I){I===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:L}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&rr(h.prototype,g),_&&rr(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();function Fr(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 dn(m,h,g){return h&&Fr(m.prototype,h),g&&Fr(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var ta=dn(function m(h){var g=this;(function(_,L){if(!(_ instanceof L))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 L=h.data.player_playhead_time-g._lastPlayheadPosition;if(L<0)return void(g._lastPlayheadPosition=-1);var I=Math.min(g._lastPlayerWidth/g._lastSourceWidth,g._lastPlayerHeight/g._lastSourceHeight),R=Math.max(0,I-1),x=Math.max(0,1-I);h.data.view_max_upscale_percentage=Math.max(h.data.view_max_upscale_percentage||0,R),h.data.view_max_downscale_percentage=Math.max(h.data.view_max_downscale_percentage||0,x),T(h.data,"view_total_content_playback_time",L),T(h.data,"view_total_upscaling",R*L),T(h.data,"view_total_downscaling",x*L)}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 Ai(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 ra(m,h,g){return h&&Ai(m.prototype,h),g&&Ai(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var ia=ra(function m(h){var g=this;(function(_,L){if(!(_ instanceof L))throw new TypeError("Cannot call a class as a function")})(this,m),this.isSeeking=!1,h.on("seeking",function(_,L){Object.assign(h.data,L),g._lastSeekingTime=Ke.now(),g.isSeeking===!1&&(g.isSeeking=!0,h.send("seeking"))}),h.on("seeked",function(){g.isSeeking=!1;var _=g._lastSeekingTime||Ke.now(),L=Ke.now()-_;T(h.data,"view_seek_count",1),T(h.data,"view_seek_duration",L);var I=h.data.view_max_seek_time||0;h.data.view_max_seek_time=Math.max(I,L)}),h.on("viewend",function(){g.isSeeking=!1})});function cn(m,h){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var I,R,x=[],B=!0,F=!1;try{for(L=L.call(g);!(B=(I=L.next()).done)&&(x.push(I.value),!_||x.length!==_);B=!0);}catch(Y){F=!0,R=Y}finally{try{B||L.return==null||L.return()}finally{if(F)throw R}}return x}}(m,h)||function(g,_){if(g){if(typeof g=="string")return hn(g,_);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?hn(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 hn(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 fn(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 Bt=function(m,h){m.push(h),m.sort(function(g,_){return g.viewer_time-_.viewer_time})},na=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Vt=function(){function m(L){var I=this;(function(x,B){if(!(x instanceof B))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=L,L.on("viewinit",function(){I.isAdBreak=!1,I._currentAdRequestNumber=0,I._currentAdResponseNumber=0,I._adRequests=[],I._adResponses=[],I._adHasPlayed=!1,I._wouldBeNewAdPlay=!0,I._prerollPlayTime=void 0}),na.forEach(function(x){return L.on(x,I._updateAdData.bind(I))});var R=function(){I.isAdBreak=!1};L.on("adbreakstart",function(){I.isAdBreak=!0}),L.on("play",R),L.on("playing",R),L.on("viewend",R),L.on("adrequest",function(x,B){B=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdRequestNumber++},B),Bt(I._adRequests,B),T(L.data,"view_ad_request_count"),I.inPrerollPosition()&&(L.data.view_preroll_requested=!0,I._adHasPlayed||T(L.data,"view_preroll_request_count"))}),L.on("adresponse",function(x,B){B=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdResponseNumber++},B),Bt(I._adResponses,B);var F=I.findAdRequest(B.ad_request_id);F&&T(L.data,"view_ad_request_time",Math.max(0,B.viewer_time-F.viewer_time))}),L.on("adplay",function(x,B){I._adHasPlayed=!0,I._wouldBeNewAdPlay&&(I._wouldBeNewAdPlay=!1,T(L.data,"view_ad_played_count")),I.inPrerollPosition()&&!L.data.view_preroll_played&&(L.data.view_preroll_played=!0,I._adRequests.length>0&&(L.data.view_preroll_request_time=Math.max(0,B.viewer_time-I._adRequests[0].viewer_time)),L.data.view_start&&(L.data.view_startup_preroll_request_time=Math.max(0,B.viewer_time-L.data.view_start)),I._prerollPlayTime=B.viewer_time)}),L.on("adplaying",function(x,B){I.inPrerollPosition()&&L.data.view_preroll_load_time===void 0&&I._prerollPlayTime!==void 0&&(L.data.view_preroll_load_time=B.viewer_time-I._prerollPlayTime,L.data.view_startup_preroll_load_time=B.viewer_time-I._prerollPlayTime)}),L.on("adended",function(){I._wouldBeNewAdPlay=!0}),L.on("aderror",function(){I._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(L){for(var I=0;I<this._adRequests.length;I++)if(this._adRequests[I].ad_request_id===L)return this._adRequests[I]}},{key:"_updateAdData",value:function(L,I){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&I.ad_tag_url){var R=cn(at(I.ad_tag_url),2),x=R[0],B=R[1];this.pm.data.view_preroll_ad_tag_domain=B,this.pm.data.view_preroll_ad_tag_hostname=x}if(!this.pm.data.view_preroll_ad_asset_hostname&&I.ad_asset_url){var F=cn(at(I.ad_asset_url),2),Y=F[0],Ae=F[1];this.pm.data.view_preroll_ad_asset_domain=Ae,this.pm.data.view_preroll_ad_asset_hostname=Y}}this.pm.data.ad_asset_url=I==null?void 0:I.ad_asset_url,this.pm.data.ad_tag_url=I==null?void 0:I.ad_tag_url,this.pm.data.ad_creative_id=I==null?void 0:I.ad_creative_id,this.pm.data.ad_id=I==null?void 0:I.ad_id,this.pm.data.ad_universal_id=I==null?void 0:I.ad_universal_id}}])&&fn(h.prototype,g),_&&fn(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 aa(m,h,g){return h&&Nr(m.prototype,h),g&&Nr(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var vn=aa(function m(h){var g,_;(function(x,B){if(!(x instanceof B))throw new TypeError("Cannot call a class as a function")})(this,m);var L=function(){h.disableRebufferTracking||g&&(T(h.data,"view_waiting_rebuffer_duration",Ke.now()-g),g=!1,W().clearInterval(_))},I=!1,R=function(){I=!1,L()};h.on("waiting",function(){I&&(h.disableRebufferTracking||(T(h.data,"view_waiting_rebuffer_count",1),g=Ke.now(),_=W().setInterval(function(){if(g){var x=Ke.now();T(h.data,"view_waiting_rebuffer_duration",x-g),g=x}},250)))}),h.on("playing",function(){L(),I=!0}),h.on("pause",R),h.on("seeking",R)});function ot(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 gn(m,h,g){return h&&ot(m.prototype,h),g&&ot(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var we=gn(function m(h){var g=this;(function(I,R){if(!(I instanceof R))throw new TypeError("Cannot call a class as a function")})(this,m);var _=function(){g.lastWallClockTime=Ke.now(),h.on("before*",L)},L=function(I){var R=Ke.now(),x=g.lastWallClockTime;g.lastWallClockTime=R,R-x>3e4&&(h.emit("devicesleep",{viewer_time:x}),Object.assign(h.data,{viewer_time:x}),h.send("devicesleep"),h.emit("devicewake",{viewer_time:R}),Object.assign(h.data,{viewer_time:R}),h.send("devicewake"))};h.one("playbackheartbeat",_),h.on("playbackheartbeatend",function(){h.off("before*",L),h.one("playbackheartbeat",_)})}),Li=q(375),ki=q(655),Ne=q.n(ki),mn="muxData",wi=function(){var m;try{m=Li.parse(Ne().get(mn)||"")}catch{m={}}return m},Ri=function(m){try{Ne().set(mn,Li.stringify(m),{expires:7300})}catch{}},sa=function(){var m=wi();return m.mux_viewer_id=m.mux_viewer_id||fe(),m.msn=m.msn||Math.random(),Ri(m),{mux_viewer_id:m.mux_viewer_id,mux_sample_number:m.msn}};function dr(m,h){var g=h.beaconCollectionDomain,_=h.beaconDomain;if(g)return"https://"+g;var L=_||"litix.io";return(m=m||"inferred").match(/^[a-z0-9]+$/)?"https://"+m+"."+L:"https://img.litix.io/a.gif"}var Di=function(){var m;switch(pn()){case"cellular":m="cellular";break;case"ethernet":m="wired";break;case"wifi":m="wifi";break;case void 0:break;default:m="other"}return m},pn=function(){var m=W().navigator,h=m&&(m.connection||m.mozConnection||m.webkitConnection);return h&&h.type};Di.getConnectionFromAPI=pn;var yn=Di,En=Ur({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"}),Tn=Ur({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 Ur(m){var h={};for(var g in m)m.hasOwnProperty(g)&&(h[m[g]]=g);return h}function Br(m){var h={},g={};return Object.keys(m).forEach(function(_){var L=!1;if(m.hasOwnProperty(_)&&m[_]!==void 0){var I=_.split("_"),R=I[0],x=En[R];x||(Le.info("Data key word `"+I[0]+"` not expected in "+_),x=R+"_"),I.splice(1).forEach(function(B){B==="url"&&(L=!0),Tn[B]?x+=Tn[B]:Number(B)&&Math.floor(Number(B))===Number(B)?x+=B:(Le.info("Data key word `"+B+"` not expected in "+_),x+="_"+B+"_")}),L?g[x]=m[_]:h[x]=m[_]}}),Object.assign(h,g)}var bn={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},_n=["hb","requestcompleted","requestfailed","requestcanceled"],Rt="https://img.litix.io",Gt=function(m){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=m||Rt,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},bn,h)};Gt.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)},Gt.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())},Gt.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)},Gt.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],Br({mux_view_message:"event queue truncated"}));var g=this._createPayload(h);An(this._beaconUrl,g,!0,function(){})},Gt.prototype._sendBeaconQueue=function(){var m=this;if(!this._postInFlight){var h=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var g=this._createPayload(h),_=Ke.now();An(this._beaconUrl,g,!1,function(L,I){I?(m._eventQueue=h.concat(m._eventQueue),m._failureCount+=1,Le.info("Error sending beacon: "+I)):m._failureCount=0,m._roundTripTime=Ke.now()-_,m._postInFlight=!1})}},Gt.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},Gt.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()))},Gt.prototype._createPayload=function(m){var h,g,_,L=this,I={transmission_timestamp:Math.round(Ke.now())};this._roundTripTime&&(I.rtt_ms=Math.round(this._roundTripTime));var R=function(){h=JSON.stringify({metadata:I,events:g||m}),_=h.length/1024},x=function(){return _<=L._options.maxPayloadKBSize};return R(),x()||(Le.info("Payload size is too big ("+_+" kb). Removing unnecessary events."),g=m.filter(function(B){return _n.indexOf(B.e)===-1}),R()),x()||(Le.info("Payload size still too big ("+_+" kb). Cropping fields.."),g.forEach(function(B){for(var F in B){var Y=B[F];typeof Y=="string"&&Y.length>51200&&(B[F]=Y.substring(0,51200))}}),R()),h};var Sn=function(m){return m.length<=57344},An=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:Sn(h)}).then(function(I){return _(null,I.ok?null:"Error")}).catch(function(I){return _(null,I)});else{if(W().XMLHttpRequest){var L=new(W()).XMLHttpRequest;return L.onreadystatechange=function(){if(L.readyState===4)return _(null,L.status!==200?"error":void 0)},L.open("POST",m),L.setRequestHeader("Content-Type","text/plain"),void L.send(h)}_()}},ai=Gt;function oa(m,h){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var I,R,x=[],B=!0,F=!1;try{for(L=L.call(g);!(B=(I=L.next()).done)&&(x.push(I.value),!_||x.length!==_);B=!0);}catch(Y){F=!0,R=Y}finally{try{B||L.return==null||L.return()}finally{if(F)throw R}}return x}}(m,h)||function(g,_){if(g){if(typeof g=="string")return Ii(g,_);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?Ii(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 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 si(m,h){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(m);h&&(_=_.filter(function(L){return Object.getOwnPropertyDescriptor(m,L).enumerable})),g.push.apply(g,_)}return g}function cr(m){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?si(Object(g),!0).forEach(function(_){oi(m,_,g[_])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):si(Object(g)).forEach(function(_){Object.defineProperty(m,_,Object.getOwnPropertyDescriptor(g,_))})}return m}function kr(m){return kr=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},kr(m)}function la(m,h){if(!(m instanceof h))throw new TypeError("Cannot call a class as a function")}function Ci(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 oi(m,h,g){return h in m?Object.defineProperty(m,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[h]=g,m}var Gr=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id"],Ln=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse"],kn=["viewstart","error","ended","viewend"],ua=function(){function m(L,I){var R,x,B,F,Y,Ae,se,ce,le,ve,Pe,ut,mt,Tt,It,Re=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};la(this,m),oi(this,"previousBeaconData",null),oi(this,"lastEventTime",0),oi(this,"rateLimited",!1),this.mux=L,this.envKey=I,this.options=Re,this.eventQueue=new ai(dr(this.envKey,this.options)),this.sampleRate=(R=this.options.sampleRate)!==null&&R!==void 0?R:1,this.disableCookies=(x=this.options.disableCookies)!==null&&x!==void 0&&x,this.respectDoNotTrack=(B=this.options.respectDoNotTrack)!==null&&B!==void 0&&B,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:(F=this.options.platform)===null||F===void 0?void 0:F.name,viewer_application_version:(Y=this.options.platform)===null||Y===void 0?void 0:Y.version,viewer_application_engine:(Ae=this.options.platform)===null||Ae===void 0?void 0:Ae.layout,viewer_device_name:(se=this.options.platform)===null||se===void 0?void 0:se.product,viewer_device_category:"",viewer_device_manufacturer:(ce=this.options.platform)===null||ce===void 0?void 0:ce.manufacturer,viewer_os_family:(le=this.options.platform)===null||le===void 0||(ve=le.os)===null||ve===void 0?void 0:ve.family,viewer_os_architecture:(Pe=this.options.platform)===null||Pe===void 0||(ut=Pe.os)===null||ut===void 0?void 0:ut.architecture,viewer_os_version:(mt=this.options.platform)===null||mt===void 0||(Tt=mt.os)===null||Tt===void 0?void 0:Tt.version,viewer_connection_type:yn(),page_url:W()===null||W()===void 0||(It=W().location)===null||It===void 0?void 0:It.href},this.viewerData=this.disableCookies?{}:sa()}var h,g,_;return h=m,(g=[{key:"send",value:function(L,I){var R;if(L&&I!=null&&I.view_id){if(this.respectDoNotTrack&&Lt())return Le.info("Not sending `"+L+"` because Do Not Track is enabled");if(!I||kr(I)!=="object")return Le.error("A data object was expected in send() but was not provided");var x,B,F=this.disableCookies?{}:(x=wi(),B=Ke.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<B)&&(x.sid=fe(),x.sst=B),x.sex=B+15e5,Ri(x),{session_id:x.sid,session_start:x.sst,session_expires:x.sex}),Y=cr(cr(cr(cr(cr({},this.pageLevelData),I),F),this.viewerData),{},{event:L,env_key:this.envKey});Y.user_id&&(Y.viewer_user_id=Y.user_id,delete Y.user_id);var Ae=((R=Y.mux_sample_number)!==null&&R!==void 0?R:0)>=this.sampleRate,se=Br(this._deduplicateBeaconData(L,Y));if(this.lastEventTime=this.mux.utils.now(),Ae)return Le.info("Not sending event due to sample rate restriction",L,Y,se);if(this.envKey||Le.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",L,Y,se),!this.rateLimited){if(Le.info("Sending event",L,Y,se),this.rateLimited=!this.eventQueue.queueEvent(L,se),this.mux.WINDOW_UNLOADING&&L==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&L==="hb"?this.eventQueue.flushEvents(!0):kn.indexOf(L)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return Y.event="eventrateexceeded",se=Br(Y),this.eventQueue.queueEvent(Y.event,se),Le.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(L,I){var R=this,x={},B=I.view_id;if(B==="-1"||L==="viewstart"||L==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)x=cr({},I),B&&(this.previousBeaconData=x),B&&L==="viewend"&&(this.previousBeaconData=null);else{var F=L.indexOf("request")===0;Object.entries(I).forEach(function(Y){var Ae=oa(Y,2),se=Ae[0],ce=Ae[1];R.previousBeaconData&&(ce!==R.previousBeaconData[se]||Gr.indexOf(se)>-1||R.objectHasChanged(F,se,ce,R.previousBeaconData[se])||R.eventRequiresKey(L,se))&&(x[se]=ce,R.previousBeaconData[se]=ce)})}return x}},{key:"objectHasChanged",value:function(L,I,R,x){return!(!L||I.indexOf("request_")!==0||I!=="request_response_headers"&&kr(R)==="object"&&kr(x)==="object"&&Object.keys(R||{}).length===Object.keys(x||{}).length)}},{key:"eventRequiresKey",value:function(L,I){return L==="renditionchange"&&I.indexOf("video_source_")===0||!(I.indexOf("ad_id")!==0||!Ln.includes(L))}}])&&Ci(h.prototype,g),_&&Ci(h,_),Object.defineProperty(h,"prototype",{writable:!1}),m}();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 wn(m,h,g){return h&&Pi(m.prototype,h),g&&Pi(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Rn=wn(function m(h){(function(F,Y){if(!(F instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,m);var g=0,_=0,L=0,I=0,R=0,x=0,B=0;h.on("requestcompleted",function(F,Y){var Ae,se,ce=Y.request_start,le=Y.request_response_start,ve=Y.request_response_end,Pe=Y.request_bytes_loaded;if(I++,le?(Ae=le-(ce!=null?ce:0),se=(ve!=null?ve:0)-le):se=(ve!=null?ve:0)-(ce!=null?ce:0),se>0&&Pe&&Pe>0){var ut=Pe/se*8e3;R++,_+=Pe,L+=se,h.data.view_min_request_throughput=Math.min(h.data.view_min_request_throughput||1/0,ut),h.data.view_average_request_throughput=_/L*8e3,h.data.view_request_count=I,Ae>0&&(g+=Ae,h.data.view_max_request_latency=Math.max(h.data.view_max_request_latency||0,Ae),h.data.view_average_request_latency=g/R)}}),h.on("requestfailed",function(F,Y){I++,x++,h.data.view_request_count=I,h.data.view_request_failed_count=x}),h.on("requestcanceled",function(F,Y){I++,B++,h.data.view_request_count=I,h.data.view_request_canceled_count=B})});function xi(m,h){for(var g=0;g<h.length;g++){var _=h[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(m,_.key,_)}}function wr(m,h,g){return h&&xi(m.prototype,h),g&&xi(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var hr=wr(function m(h){var g=this;(function(_,L){if(!(_ instanceof L))throw new TypeError("Cannot call a class as a function")})(this,m),h.on("before*",function(_,L){var I=L.viewer_time,R=Ke.now(),x=g._lastEventTime;if(g._lastEventTime=R,x&&R-x>36e5){var B=Object.keys(h.data).reduce(function(F,Y){return Y.indexOf("video_")===0?Object.assign(F,function(Ae,se,ce){return se in Ae?Object.defineProperty(Ae,se,{value:ce,enumerable:!0,configurable:!0,writable:!0}):Ae[se]=ce,Ae}({},Y,h.data[Y])):F},{});h.mux.log.info("Received event after at least an hour inactivity, creating a new view"),h.emit("viewinit",Object.assign({viewer_time:I},B)),h.playbackHeartbeat._playheadShouldBeProgressing&&_.type!=="play"&&_.type!=="adbreakstart"&&(h.emit("play",{viewer_time:I}),_.type!=="playing"&&h.emit("playing",{viewer_time:I}))}})});function Ot(m){return Ot=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},Ot(m)}function $t(m,h){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var I,R,x=[],B=!0,F=!1;try{for(L=L.call(g);!(B=(I=L.next()).done)&&(x.push(I.value),!_||x.length!==_);B=!0);}catch(Y){F=!0,R=Y}finally{try{B||L.return==null||L.return()}finally{if(F)throw R}}return x}}(m,h)||function(g,_){if(g){if(typeof g=="string")return qe(g,_);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?qe(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 qe(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 Ht(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 Yt(m,h){return Yt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,_){return g.__proto__=_,g},Yt(m,h)}function Dn(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,_=Hr(m);if(h){var L=Hr(this).constructor;g=Reflect.construct(_,arguments,L)}else g=_.apply(this,arguments);return Oi(this,g)}}function Oi(m,h){if(h&&(Ot(h)==="object"||typeof h=="function"))return h;if(h!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return lt(m)}function lt(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function Hr(m){return Hr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},Hr(m)}var In=["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"],Rr=function(m){(function(R,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function");R.prototype=Object.create(x&&x.prototype,{constructor:{value:R,writable:!0,configurable:!0}}),Object.defineProperty(R,"prototype",{writable:!1}),x&&Yt(R,x)})(I,m);var h,g,_,L=Dn(I);function I(R,x,B){var F;(function(le,ve){if(!(le instanceof ve))throw new TypeError("Cannot call a class as a function")})(this,I),(F=L.call(this)).DOM_CONTENT_LOADED_EVENT_END=$.domContentLoadedEventEnd(),F.NAVIGATION_START=$.navigationStart(),F.mux=R,F.id=x,(B=Object.assign({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(le){return le}},B)).data=B.data||{},B.data.property_key&&(B.data.env_key=B.data.property_key,delete B.data.property_key),Le.setLevel(B.debug?"debug":"warn"),F.getPlayheadTime=B.getPlayheadTime,F.getStateData=B.getStateData||function(){return{}},F.getAdData=B.getAdData||function(){},F.minimumRebufferDuration=B.minimumRebufferDuration,F.sustainedRebufferThreshold=B.sustainedRebufferThreshold,F.playbackHeartbeatTime=B.playbackHeartbeatTime,F.disableRebufferTracking=B.disableRebufferTracking,F.disableRebufferTracking&&F.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."),F.disablePlayheadRebufferTracking=B.disablePlayheadRebufferTracking,F.errorTranslator=B.errorTranslator,F.playbackEventDispatcher=new ua(R,B.data.env_key,B),F.data={player_instance_id:fe(),mux_sample_rate:B.sampleRate,beacon_domain:B.beaconCollectionDomain?B.beaconCollectionDomain:B.beaconDomain},F.data.view_sequence_number=1,F.data.player_sequence_number=1,F.oldEmit=F.emit,F.emit=function(le,ve){ve=Object.assign({viewer_time:this.mux.utils.now()},ve),this.oldEmit(le,ve)};var Y=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(lt(F));F.on("viewinit",function(le,ve){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,ve),this._initializeViewData(),this.one("play",Y),this.one("adbreakstart",Y)});var Ae=function(le){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",le)}.bind(lt(F));if(F.on("videochange",function(le,ve){Ae(ve)}),F.on("programchange",function(le,ve){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."),Ae(Object.assign(ve,{view_program_changed:!0})),Y(),this.emit("play"),this.emit("playing")}),F.on("fragmentchange",function(le,ve){this.currentFragmentPDT=ve.currentFragmentPDT,this.currentFragmentStart=ve.currentFragmentStart}),F.on("destroy",F.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var se=function(){var le=F.data.view_start!==void 0;F.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",le&&F.mux.WINDOW_HIDDEN&&(F.data.player_is_paused||F.emit("hb"))};window.addEventListener("visibilitychange",se,!1);var ce=function(le){le.persisted||F.destroy()};window.addEventListener("pagehide",ce,!1),F.on("destroy",function(){window.removeEventListener("visibilitychange",se),window.removeEventListener("pagehide",ce)})}return F.on("playerready",function(le,ve){Object.assign(this.data,ve)}),In.forEach(function(le){F.on(le,function(ve,Pe){le.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,Pe),this._sanitizeData()}),F.on("after"+le,function(){(le!=="error"||this.errorTracker.viewErrored)&&this.send(le)})}),F.on("viewend",function(le,ve){Object.assign(F.data,ve)}),F.one("playerready",function(le){var ve=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ve-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}),F.longResumeTracker=new hr(lt(F)),F.errorTracker=new Fe(lt(F)),new we(lt(F)),F.seekingTracker=new ia(lt(F)),F.playheadTime=new Mr(lt(F)),F.playbackHeartbeat=new je(lt(F)),new ta(lt(F)),F.watchTimeTracker=new Et(lt(F)),new xt(lt(F)),F.adTracker=new Vt(lt(F)),new Lr(lt(F)),new jt(lt(F)),new ur(lt(F)),new vn(lt(F)),new Rn(lt(F)),B.hlsjs&&F.addHLSJS(B),B.dashjs&&F.addDashJS(B),F.emit("viewinit",B.data),F}return h=I,g=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(R){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(Ae){x[Ae]=void 0}),x.video_source_url=x.video_source_url||x.player_source_url,x.video_source_url){var B=$t(at(x.video_source_url),2),F=B[0],Y=B[1];x.video_source_domain=Y,x.video_source_hostname=F}delete x.ad_request_id,this.playbackEventDispatcher.send(R,x),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),R==="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 R=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(x){var B=parseInt(R.data[x],10);R.data[x]=isNaN(B)?void 0:B}),["player_source_url","video_source_url"].forEach(function(x){if(R.data[x]){var B=R.data[x].toLowerCase();B.indexOf("data:")!==0&&B.indexOf("blob:")!==0||(R.data[x]="MSE style URL")}})}},{key:"_resetVideoData",value:function(R,x){var B=this;Object.keys(this.data).forEach(function(F){F.indexOf("video_")===0&&delete B.data[F]})}},{key:"_resetViewData",value:function(){var R=this;Object.keys(this.data).forEach(function(x){x.indexOf("view_")===0&&delete R.data[x]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(R,x){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var R=this,x=this.data.view_id=fe(),B=function(){x===R.data.view_id&&T(R.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",B):B()}},{key:"_restartHeartBeat",value:function(){var R=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){R.data.player_is_paused||R.emit("hb")},1e4))}},{key:"addHLSJS",value:function(R){R.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=R.hlsjs,function(x,B,F){var Y=arguments.length>4?arguments[4]:void 0,Ae=x.log,se=x.utils.secondsToMs,ce=function(Ge){var ee,re=parseInt(Y.version);return re===1&&Ge.programDateTime!==null&&(ee=Ge.programDateTime),re===0&&Ge.pdt!==null&&(ee=Ge.pdt),ee};if($.exists()){var le=function(Ge,ee){return x.emit(B,Ge,ee)},ve=function(Ge,ee){var re=ee.levels,ie=ee.audioTracks,ke=ee.url,xe=ee.stats,Qe=ee.networkDetails,Dt=ee.sessionData,dt={},bt={};re.forEach(function(he,gr){dt[gr]={width:he.width,height:he.height,bitrate:he.bitrate,attrs:he.attrs}}),ie.forEach(function(he,gr){bt[gr]={name:he.name,language:he.lang,bitrate:he.bitrate}});var ct=Tr(xe),ht=ct.bytesLoaded,Wt=ct.requestStart,Xr=ct.responseStart,ft=ct.responseEnd;le("requestcompleted",Ye(Ye({},Je(Dt)),{},{request_event_type:Ge,request_bytes_loaded:ht,request_start:Wt,request_response_start:Xr,request_response_end:ft,request_type:"manifest",request_hostname:vt(ke),request_response_headers:wt(Qe),request_rendition_lists:{media:dt,audio:bt,video:{}}}))};F.on(Y.Events.MANIFEST_LOADED,ve);var Pe=function(Ge,ee){var re=ee.details,ie=ee.level,ke=ee.networkDetails,xe=ee.stats,Qe=Tr(xe),Dt=Qe.bytesLoaded,dt=Qe.requestStart,bt=Qe.responseStart,ct=Qe.responseEnd,ht=re.fragments[re.fragments.length-1],Wt=ce(ht)+se(ht.duration);le("requestcompleted",{request_event_type:Ge,request_bytes_loaded:Dt,request_start:dt,request_response_start:bt,request_response_end:ct,request_current_level:ie,request_type:"manifest",request_hostname:vt(re.url),request_response_headers:wt(ke),video_holdback:re.holdBack&&se(re.holdBack),video_part_holdback:re.partHoldBack&&se(re.partHoldBack),video_part_target_duration:re.partTarget&&se(re.partTarget),video_target_duration:re.targetduration&&se(re.targetduration),video_source_is_live:re.live,player_manifest_newest_program_time:isNaN(Wt)?void 0:Wt})};F.on(Y.Events.LEVEL_LOADED,Pe);var ut=function(Ge,ee){var re=ee.details,ie=ee.networkDetails,ke=ee.stats,xe=Tr(ke),Qe=xe.bytesLoaded,Dt=xe.requestStart,dt=xe.responseStart,bt=xe.responseEnd;le("requestcompleted",{request_event_type:Ge,request_bytes_loaded:Qe,request_start:Dt,request_response_start:dt,request_response_end:bt,request_type:"manifest",request_hostname:vt(re.url),request_response_headers:wt(ie)})};F.on(Y.Events.AUDIO_TRACK_LOADED,ut);var mt=function(Ge,ee){var re=ee.stats,ie=ee.networkDetails,ke=ee.frag;re=re||ke.stats;var xe=Tr(re),Qe=xe.bytesLoaded,Dt=xe.requestStart,dt=xe.responseStart,bt=xe.responseEnd,ct=ie?wt(ie):void 0,ht={request_event_type:Ge,request_bytes_loaded:Qe,request_start:Dt,request_response_start:dt,request_response_end:bt,request_hostname:ie?vt(ie.responseURL):void 0,request_id:ct?He(ct):void 0,request_response_headers:ct,request_media_duration:ke.duration,request_url:ie==null?void 0:ie.responseURL};ke.type==="main"?(ht.request_type="media",ht.request_current_level=ke.level,ht.request_video_width=(F.levels[ke.level]||{}).width,ht.request_video_height=(F.levels[ke.level]||{}).height,ht.request_labeled_bitrate=(F.levels[ke.level]||{}).bitrate):ht.request_type=ke.type,le("requestcompleted",ht)};F.on(Y.Events.FRAG_LOADED,mt);var Tt=function(Ge,ee){var re=ee.frag,ie=re.start,ke={currentFragmentPDT:ce(re),currentFragmentStart:se(ie)};le("fragmentchange",ke)};F.on(Y.Events.FRAG_CHANGED,Tt);var It=function(Ge,ee){var re=ee.type,ie=ee.details,ke=ee.response,xe=ee.fatal,Qe=ee.frag,Dt=ee.networkDetails,dt=(Qe==null?void 0:Qe.url)||ee.url||"",bt=Dt?wt(Dt):void 0;if(ie!==Y.ErrorDetails.MANIFEST_LOAD_ERROR&&ie!==Y.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.FRAG_LOAD_ERROR&&ie!==Y.ErrorDetails.FRAG_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.LEVEL_LOAD_ERROR&&ie!==Y.ErrorDetails.LEVEL_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&ie!==Y.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.SUBTITLE_LOAD_ERROR&&ie!==Y.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&ie!==Y.ErrorDetails.KEY_LOAD_ERROR&&ie!==Y.ErrorDetails.KEY_LOAD_TIMEOUT||le("requestfailed",{request_error:ie,request_url:dt,request_hostname:vt(dt),request_id:bt?He(bt):void 0,request_type:ie===Y.ErrorDetails.FRAG_LOAD_ERROR||ie===Y.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":ie===Y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||ie===Y.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":ie===Y.ErrorDetails.SUBTITLE_LOAD_ERROR||ie===Y.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":ie===Y.ErrorDetails.KEY_LOAD_ERROR||ie===Y.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:ke==null?void 0:ke.code,request_error_text:ke==null?void 0:ke.text}),xe){var ct,ht="".concat(dt?"url: ".concat(dt,`
|
|
5
|
+
`):"")+"".concat(ke&&(ke.code||ke.text)?"response: ".concat(ke.code,", ").concat(ke.text,`
|
|
6
|
+
`):"")+"".concat(ee.reason?"failure reason: ".concat(ee.reason,`
|
|
7
|
+
`):"")+"".concat(ee.level?"level: ".concat(ee.level,`
|
|
8
|
+
`):"")+"".concat(ee.parent?"parent stream controller: ".concat(ee.parent,`
|
|
9
|
+
`):"")+"".concat(ee.buffer?"buffer length: ".concat(ee.buffer,`
|
|
10
|
+
`):"")+"".concat(ee.error?"error: ".concat(ee.error,`
|
|
11
|
+
`):"")+"".concat(ee.event?"event: ".concat(ee.event,`
|
|
12
|
+
`):"")+"".concat(ee.err?"error message: ".concat((ct=ee.err)===null||ct===void 0?void 0:ct.message,`
|
|
13
|
+
`):"");le("error",{player_error_code:re,player_error_message:ie,player_error_context:ht})}};F.on(Y.Events.ERROR,It);var Re=function(Ge,ee){var re=ee.frag,ie=re&&re._url||"";le("requestcanceled",{request_event_type:Ge,request_url:ie,request_type:"media",request_hostname:vt(ie)})};F.on(Y.Events.FRAG_LOAD_EMERGENCY_ABORTED,Re);var $e=function(Ge,ee){var re=ee.level,ie=F.levels[re];if(ie&&ie.attrs&&ie.attrs.BANDWIDTH){var ke,xe=ie.attrs.BANDWIDTH,Qe=parseFloat(ie.attrs["FRAME-RATE"]);isNaN(Qe)||(ke=Qe),xe?le("renditionchange",{video_source_fps:ke,video_source_bitrate:xe,video_source_width:ie.width,video_source_height:ie.height,video_source_rendition_name:ie.name,video_source_codec:ie==null?void 0:ie.videoCodec}):Ae.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};F.on(Y.Events.LEVEL_SWITCHED,$e),F._stopMuxMonitor=function(){F.off(Y.Events.MANIFEST_LOADED,ve),F.off(Y.Events.LEVEL_LOADED,Pe),F.off(Y.Events.AUDIO_TRACK_LOADED,ut),F.off(Y.Events.FRAG_LOADED,mt),F.off(Y.Events.FRAG_CHANGED,Tt),F.off(Y.Events.ERROR,It),F.off(Y.Events.FRAG_LOAD_EMERGENCY_ABORTED,Re),F.off(Y.Events.LEVEL_SWITCHED,$e),F.off(Y.Events.DESTROYING,F._stopMuxMonitor),delete F._stopMuxMonitor},F.on(Y.Events.DESTROYING,F._stopMuxMonitor)}else Ae.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,R.hlsjs,{},R.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var R;this.hlsjs&&((R=this.hlsjs)&&typeof R._stopMuxMonitor=="function"&&R._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(R){R.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=R.dashjs,function(x,B,F){var Y=x.log;if(F&&F.on){var Ae=function(Re,$e){return x.emit(B,Re,$e)},se=function(Re){var $e=Re.type,Ge=(Re.data||{}).url;Ae("requestcompleted",{request_event_type:$e,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:vt(Ge),request_url:Ge})};F.on("manifestLoaded",se);var ce={},le=function(Re){var $e=Re.type,Ge=Re.fragmentModel,ee=(Re.chunk||{}).mediaInfo||{},re=ee.type,ie=ee.bitrateList,ke={};(ie=ie||[]).forEach(function(ft,he){ke[he]={},ke[he].width=ft.width,ke[he].height=ft.height,ke[he].bitrate=ft.bandwidth,ke[he].attrs={}}),re==="video"?ce.video=ke:re==="audio"?ce.audio=ke:ce.media=ke;var xe=st(Ge,F),Qe=xe.requestStart,Dt=xe.requestResponseStart,dt=xe.requestResponseEnd,bt=xe.requestResponseHeaders,ct=xe.requestMediaDuration,ht=xe.requestHostname,Wt=xe.requestUrl,Xr=xe.requestId;Ae("requestcompleted",{request_event_type:$e,request_start:Qe,request_response_start:Dt,request_response_end:dt,request_bytes_loaded:-1,request_type:re+"_init",request_response_headers:bt,request_hostname:ht,request_id:Xr,request_url:Wt,request_media_duration:ct,request_rendition_lists:ce})};F.on("initFragmentLoaded",le);var ve=function(Re){var $e=Re.type,Ge=Re.fragmentModel,ee=Re.chunk||{},re=ee.mediaInfo,ie=ee.start,ke=(re||{}).type,xe=st(Ge,F),Qe=xe.requestStart,Dt=xe.requestResponseStart,dt=xe.requestResponseEnd,bt=xe.requestBytesLoaded,ct=xe.requestResponseHeaders,ht=xe.requestMediaDuration,Wt=xe.requestHostname,Xr=xe.requestUrl,ft=xe.requestId,he=tt(ke,F),gr=he.currentLevel,Dr=he.renditionWidth,Ir=he.renditionHeight,Qr=he.renditionBitrate;Ae("requestcompleted",{request_event_type:$e,request_start:Qe,request_response_start:Dt,request_response_end:dt,request_bytes_loaded:bt,request_type:ke,request_response_headers:ct,request_hostname:Wt,request_id:ft,request_url:Xr,request_media_start_time:ie,request_media_duration:ht,request_current_level:gr,request_labeled_bitrate:Qr,request_video_width:Dr,request_video_height:Ir})};F.on("mediaFragmentLoaded",ve);var Pe={video:void 0,audio:void 0,totalBitrate:void 0},ut=function(){if(Pe.video&&typeof Pe.video.bitrate=="number"){if(Pe.video.width&&Pe.video.height){var Re=Pe.video.bitrate;return Pe.audio&&typeof Pe.audio.bitrate=="number"&&(Re+=Pe.audio.bitrate),Re!==Pe.totalBitrate?(Pe.totalBitrate=Re,{video_source_bitrate:Re,video_source_height:Pe.video.height,video_source_width:Pe.video.width,video_source_codec:rt(Pe.video.codec)}):void 0}Y.warn("have bitrate info for video but missing width/height")}},mt=function(Re,$e,Ge){if(typeof Re.newQuality=="number"){var ee=Re.mediaType;if(ee==="audio"||ee==="video"){var re=F.getBitrateInfoListFor(ee).find(function(ke){return ke.qualityIndex===Re.newQuality});if(re&&typeof re.bitrate=="number"){Pe[ee]=Ct(Ct({},re),{},{codec:F.getCurrentTrackFor(ee).codec});var ie=ut();ie&&Ae("renditionchange",ie)}else Y.warn("missing bitrate info for ".concat(ee))}}else Y.warn("missing evt.newQuality in qualityChangeRendered event",Re)};F.on("qualityChangeRendered",mt);var Tt=function(Re){var $e=Re.request,Ge=Re.mediaType;Ae("requestcanceled",{request_event_type:($e=$e||{}).type+"_"+$e.action,request_url:$e.url,request_type:Ge,request_hostname:vt($e.url)})};F.on("fragmentLoadingAbandoned",Tt);var It=function(Re){var $e,Ge,ee=Re.error,re=(ee==null||($e=ee.data)===null||$e===void 0?void 0:$e.request)||{},ie=(ee==null||(Ge=ee.data)===null||Ge===void 0?void 0:Ge.response)||{};(ee==null?void 0:ee.code)===27&&Ae("requestfailed",{request_error:re.type+"_"+re.action,request_url:re.url,request_hostname:vt(re.url),request_type:re.mediaType,request_error_code:ie.status,request_error_text:ie.statusText});var ke="".concat(re!=null&&re.url?"url: ".concat(re.url,`
|
|
14
|
+
`):"")+"".concat(ie!=null&&ie.status||ie!=null&&ie.statusText?"response: ".concat(ie==null?void 0:ie.status,", ").concat(ie==null?void 0:ie.statusText,`
|
|
15
|
+
`):"");Ae("error",{player_error_code:ee==null?void 0:ee.code,player_error_message:ee==null?void 0:ee.message,player_error_context:ke})};F.on("error",It),F._stopMuxMonitor=function(){F.off("manifestLoaded",se),F.off("initFragmentLoaded",le),F.off("mediaFragmentLoaded",ve),F.off("qualityChangeRendered",mt),F.off("error",It),F.off("fragmentLoadingAbandoned",Tt),delete F._stopMuxMonitor}}else Y.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,R.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var R;this.dashjs&&((R=this.dashjs)&&typeof R._stopMuxMonitor=="function"&&R._stopMuxMonitor(),this.dashjs=void 0)}}],g&&Ht(h.prototype,g),_&&Ht(h,_),Object.defineProperty(h,"prototype",{writable:!1}),I}(X),Mi=Rr,Kr=q(153),qr=q.n(Kr);function fr(m){return fr=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},fr(m)}function li(m,h){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var I,R,x=[],B=!0,F=!1;try{for(L=L.call(g);!(B=(I=L.next()).done)&&(x.push(I.value),!_||x.length!==_);B=!0);}catch(Y){F=!0,R=Y}finally{try{B||L.return==null||L.return()}finally{if(F)throw R}}return x}}(m,h)||function(g,_){if(g){if(typeof g=="string")return jr(g,_);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?jr(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 jr(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 ir,da=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],ca={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};W()&&W().WeakMap&&(ir=new WeakMap);var Fi="#EXT-X-TARGETDURATION",Ni="#EXT-X-PART-INF",ha="#EXT-X-SERVER-CONTROL",fa="#EXTINF",Cn="#EXT-X-PROGRAM-DATE-TIME",Vr="#EXT-X-VERSION",Ui="#EXT-X-SESSION-DATA",Yr=function(m){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(m),this.manifest};Yr.prototype.process=function(m){var h;for(this.buffer+=m,h=this.buffer.indexOf(`
|
|
17
17
|
`);h>-1;h=this.buffer.indexOf(`
|
|
18
|
-
`))this.processLine(this.buffer.substring(0,h)),this.buffer=this.buffer.substring(h+1)},
|
|
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+`
|
|
18
|
+
`))this.processLine(this.buffer.substring(0,h)),this.buffer=this.buffer.substring(h+1)},Yr.prototype.processLine=function(m){var h=m.indexOf(":"),g=On(m,h),_=g[0],L=g.length===2?Wr(g[1]):void 0;if(_[0]!=="#")this.currentUri.uri=_,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(_){case Fi:if(!isFinite(L)||L<0)return;this.manifest.targetDuration=L,this.setHoldBack();break;case Ni:Bi(this.manifest,g),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case ha:Bi(this.manifest,g),this.setHoldBack();break;case fa:L===0?this.currentUri.duration=.01:L>0&&(this.currentUri.duration=L);break;case Cn:var I=L,R=new Date(I);this.manifest.dateTimeString||(this.manifest.dateTimeString=I,this.manifest.dateTimeObject=R),this.currentUri.dateTimeString=I,this.currentUri.dateTimeObject=R;break;case Vr:Bi(this.manifest,g);break;case Ui:var x=Hi(g[1]),B=Je(x);Object.assign(this.manifest.sessionData,B)}},Yr.prototype.setHoldBack=function(){var m=this.manifest,h=m.serverControl,g=m.targetDuration,_=m.partTargetDuration;if(h){var L="holdBack",I="partHoldBack",R=g&&3*g,x=_&&2*_;g&&!h.hasOwnProperty(L)&&(h[L]=R),R&&h[L]<R&&(h[L]=R),_&&!h.hasOwnProperty(I)&&(h[I]=3*_),_&&h[I]<x&&(h[I]=x)}};var Bi=function(m,h){var g,_=Gi(h[0].replace("#EXT-X-",""));ui(h[1])?(g={},g=Object.assign(xn(h[1]),g)):g=Wr(h[1]),m[_]=g},Gi=function(m){return m.toLowerCase().replace(/-(\w)/g,function(h){return h[1].toUpperCase()})},Wr=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},Pn=function(m){var h={},g=m.split("=");return g.length>1&&(h[Gi(g[0])]=Wr(g[1])),h},xn=function(m){for(var h=m.split(","),g={},_=0;h.length>_;_++){var L=h[_],I=Pn(L);g=Object.assign(I,g)}return g},ui=function(m){return m.indexOf("=")>-1},On=function(m,h){return h===-1?[m]:[m.substring(0,h),m.substring(h+1)]},Hi=function(m){var h={};if(m){var g=m.search(",");return[m.slice(0,g),m.slice(g+1)].forEach(function(_,L){for(var I=_.replace(/['"]+/g,"").split("="),R=0;R<I.length;R++)I[R]==="DATA-ID"&&(h["DATA-ID"]=I[1-R]),I[R]==="VALUE"&&(h.VALUE=I[1-R])}),{data:h}}},Mn=Yr,di={safeCall:function(m,h,g,_){var L=_;if(m&&typeof m[h]=="function")try{L=m[h].apply(m,g)}catch(I){Le.info("safeCall error",I)}return L},safeIncrement:T,getComputedStyle:function(m,h){var g;if(m&&h&&W()&&typeof W().getComputedStyle=="function")return ir&&ir.has(m)&&(g=ir.get(m)),g||(g=W().getComputedStyle(m,null),ir&&ir.set(m,g)),g.getPropertyValue(h)},secondsToMs:function(m){return Math.floor(1e3*m)},assign:Object.assign,headersStringToObject:ye,cdnHeadersToRequestId:He,extractHostnameAndDomain:at,extractHostname:vt,manifestParser:Mn,generateShortID:ge,generateUUID:fe,now:Ke.now},Fn={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 zr(m,h){return function(g){if(Array.isArray(g))return g}(m)||function(g,_){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var I,R,x=[],B=!0,F=!1;try{for(L=L.call(g);!(B=(I=L.next()).done)&&(x.push(I.value),!_||x.length!==_);B=!0);}catch(Y){F=!0,R=Y}finally{try{B||L.return==null||L.return()}finally{if(F)throw R}}return x}}(m,h)||function(g,_){if(g){if(typeof g=="string")return ci(g,_);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?ci(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 ci(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 Mt={},vr=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.")},va={loaded:Ke.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(m,h){return function(g,_,L){var I=li(Te(_),3),R=I[0],x=I[1],B=I[2],F=g.log,Y=g.utils.getComputedStyle,Ae=g.utils.secondsToMs;if(!R)return F.error("No element was found with the `"+x+"` query selector.");if(B!=="video"&&B!=="audio")return F.error("The element of `"+x+"` was not a media element.");R.mux&&(R.mux.destroy(),delete R.mux,F.warn("Already monitoring this video element, replacing existing event listeners")),(L=Object.assign({automaticErrorTracking:!0},L)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:g.VERSION},L.data),L.getPlayheadTime=function(){return Ae(R.currentTime)},L.getStateData=function(){var ce,le,ve=this.hlsjs&&this.hlsjs.url,Pe=this.dashjs&&fr(this.dashjs.getSource==="function")&&this.dashjs.getSource(),ut={player_is_paused:R.paused,player_playhead_time:Ae(R.currentTime),player_width:parseInt(Y(R,"width")),player_height:parseInt(Y(R,"height")),player_autoplay_on:R.autoplay,player_preload_on:R.preload,player_language_code:R.lang,player_is_fullscreen:qr()&&!!(qr().fullscreenElement||qr().webkitFullscreenElement||qr().mozFullScreenElement||qr().msFullscreenElement),video_poster_url:R.poster,video_source_url:ve||Pe||R.currentSrc,video_source_duration:Ae(R.duration),video_source_height:R.videoHeight,video_source_width:R.videoWidth,view_dropped_frame_count:(ce=R)===null||ce===void 0||(le=ce.getVideoPlaybackQuality)===null||le===void 0?void 0:le.call(ce).droppedVideoFrames},mt=L.getPlayheadTime();if(R.getStartDate&&mt>0){var Tt=R.getStartDate();if(Tt&&typeof Tt.getTime=="function"&&Tt.getTime()){var It=Tt.getTime();if(ut.player_program_time=It+mt,R.seekable.length>0){var Re=It+R.seekable.end(R.seekable.length-1);ut.player_live_edge_program_time=Re}}}return ut},R.mux=R.mux||{},R.mux.deleted=!1,R.mux.emit=function(ce,le){g.emit(x,ce,le)};var se=function(){F.error("The monitor for this video element has already been destroyed.")};R.mux.destroy=function(){Object.keys(R.mux.listeners).forEach(function(ce){R.removeEventListener(ce,R.mux.listeners[ce],!1)}),delete R.mux.listeners,R.mux.destroy=se,R.mux.swapElement=se,R.mux.emit=se,R.mux.addHLSJS=se,R.mux.addDashJS=se,R.mux.removeHLSJS=se,R.mux.removeDashJS=se,R.mux.deleted=!0,g.emit(x,"destroy")},R.mux.swapElement=function(ce){var le=li(Te(ce),3),ve=le[0],Pe=le[1],ut=le[2];return ve?ut!=="video"&&ut!=="audio"?g.log.error("The element of `"+Pe+"` was not a media element."):(ve.muxId=R.muxId,delete R.muxId,ve.mux=ve.mux||{},ve.mux.listeners=Object.assign({},R.mux.listeners),delete R.mux.listeners,Object.keys(ve.mux.listeners).forEach(function(mt){R.removeEventListener(mt,ve.mux.listeners[mt],!1),ve.addEventListener(mt,ve.mux.listeners[mt],!1)}),ve.mux.swapElement=R.mux.swapElement,ve.mux.destroy=R.mux.destroy,delete R.mux,void(R=ve)):g.log.error("No element was found with the `"+Pe+"` query selector.")},R.mux.addHLSJS=function(ce){g.addHLSJS(x,ce)},R.mux.addDashJS=function(ce){g.addDashJS(x,ce)},R.mux.removeHLSJS=function(){g.removeHLSJS(x)},R.mux.removeDashJS=function(){g.removeDashJS(x)},g.init(x,L),g.emit(x,"playerready"),R.paused||(g.emit(x,"play"),R.readyState>2&&g.emit(x,"playing")),R.mux.listeners={},da.forEach(function(ce){(ce!=="error"||L.automaticErrorTracking)&&(R.mux.listeners[ce]=function(){var le={};if(ce==="error"){if(!R.error||R.error.code===1)return;le.player_error_code=R.error.code,le.player_error_message=ca[R.error.code]||R.error.message}g.emit(x,ce,le)},R.addEventListener(ce,R.mux.listeners[ce],!1))})}(vr,m,h)},destroyMonitor:function(m){var h=zr(Te(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=me(m);Mt[g]?Mt[g].addHLSJS(h):Le.error("A monitor for `"+g+"` has not been initialized.")},addDashJS:function(m,h){var g=me(m);Mt[g]?Mt[g].addDashJS(h):Le.error("A monitor for `"+g+"` has not been initialized.")},removeHLSJS:function(m){var h=me(m);Mt[h]?Mt[h].removeHLSJS():Le.error("A monitor for `"+h+"` has not been initialized.")},removeDashJS:function(m){var h=me(m);Mt[h]?Mt[h].removeDashJS():Le.error("A monitor for `"+h+"` has not been initialized.")},init:function(m,h){Lt()&&h&&h.respectDoNotTrack&&Le.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var g=me(m);Mt[g]=new Mi(vr,g,h)},emit:function(m,h,g){var _=me(m);Mt[_]?(Mt[_].emit(h,g),h==="destroy"&&delete Mt[_]):Le.error("A monitor for `"+_+"` has not been initialized.")},checkDoNotTrack:Lt,log:Le,utils:di,events:Fn,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(vr,va),W()!==void 0&&typeof W().addEventListener=="function"&&W().addEventListener("pagehide",function(m){m.persisted||(vr.WINDOW_UNLOADING=!0)},!1);var Ki=vr},655:function(G,Q,q){var ae,W;function fe(ge){return fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(me){return typeof me}:function(me){return me&&typeof Symbol=="function"&&me.constructor===Symbol&&me!==Symbol.prototype?"symbol":typeof me},fe(ge);}(function(ge){var me=!1;if((W=typeof(ae=ge)=="function"?ae.call(Q,q,Q,G):ae)===void 0||(G.exports=W),me=!0,fe(Q)==="object"&&(G.exports=ge(),me=!0),!me){var Te=window.Cookies,Ce=window.Cookies=ge();Ce.noConflict=function(){return window.Cookies=Te,Ce}}})(function(){var ge=function(){for(var me=0,Te={};me<arguments.length;me++){var Ce=arguments[me];for(var Ie in Ce)Te[Ie]=Ce[Ie]}return Te};return function me(Te){function Ce(Ie,et,Le){var Lt;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(Le=ge({path:"/"},Ce.defaults,Le)).expires=="number"){var Ke=new Date;Ke.setMilliseconds(Ke.getMilliseconds()+864e5*Le.expires),Le.expires=Ke}try{Lt=JSON.stringify(et),/^[\{\[]/.test(Lt)&&(et=Lt)}catch{}return et=Te.write?Te.write(et,Ie):encodeURIComponent(String(et)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),Ie=(Ie=(Ie=encodeURIComponent(String(Ie))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[Ie,"=",et,Le.expires?"; expires="+Le.expires.toUTCString():"",Le.path?"; path="+Le.path:"",Le.domain?"; domain="+Le.domain:"",Le.secure?"; secure":""].join("")}Ie||(Lt={});for(var vt=document.cookie?document.cookie.split("; "):[],at=/(%[0-9A-Z]{2})+/g,$=0;$<vt.length;$++){var T=vt[$].split("="),Z=T.slice(1).join("=");Z.charAt(0)==='"'&&(Z=Z.slice(1,-1));try{var H=T[0].replace(at,decodeURIComponent);if(Z=Te.read?Te.read(Z,H):Te(Z,H)||Z.replace(at,decodeURIComponent),this.json)try{Z=JSON.parse(Z)}catch{}if(Ie===H){Lt=Z;break}Ie||(Lt[H]=Z)}catch{}}return Lt}}return Ce.set=Ce,Ce.get=function(Ie){return Ce.call(Ce,Ie)},Ce.getJSON=function(){return Ce.apply({json:!0},[].slice.call(arguments))},Ce.defaults={},Ce.remove=function(Ie,et){Ce(Ie,"",ge(et,{expires:-1}))},Ce.withConverter=me,Ce}(function(){})})},153:function(G,Q,q){var ae,W=q.g!==void 0?q.g:typeof window!="undefined"?window:{},fe=q(558);typeof document!="undefined"?ae=document:(ae=W["__GLOBAL_DOCUMENT_CACHE@4"])||(ae=W["__GLOBAL_DOCUMENT_CACHE@4"]=fe),G.exports=ae},48:function(G,Q,q){var ae;ae=typeof window!="undefined"?window:q.g!==void 0?q.g:typeof self!="undefined"?self:{},G.exports=ae},640:function(G,Q,q){var ae,W;(function(fe,ge){"use strict";ae=function(){var me=function(){},Te="undefined",Ce=typeof window!==Te&&typeof window.navigator!==Te&&/Trident\/|MSIE /.test(window.navigator.userAgent),Ie=["trace","debug","info","warn","error"];function et(ye,He){var Je=ye[He];if(typeof Je.bind=="function")return Je.bind(ye);try{return Function.prototype.bind.call(Je,ye)}catch{return function(){return Function.prototype.apply.apply(Je,[ye,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 Lt(ye){return ye==="debug"&&(ye="log"),typeof console!==Te&&(ye==="trace"&&Ce?Le:console[ye]!==void 0?et(console,ye):console.log!==void 0?et(console,"log"):me)}function Ke(ye,He){for(var Je=0;Je<Ie.length;Je++){var kt=Ie[Je];this[kt]=Je<ye?me:this.methodFactory(kt,ye,He)}this.log=this.debug}function vt(ye,He,Je){return function(){typeof console!==Te&&(Ke.call(this,He,Je),this[ye].apply(this,arguments))}}function at(ye,He,Je){return Lt(ye)||vt.apply(this,arguments)}function $(ye,He,Je){var kt,Ye=this;He=He==null?"WARN":He;var P="loglevel";function Tr(Be){var st=(Ie[Be]||"silent").toUpperCase();if(typeof window!==Te&&P){try{return void(window.localStorage[P]=st)}catch{}try{window.document.cookie=encodeURIComponent(P)+"="+st+";"}catch{}}}function wt(){var Be;if(typeof window!==Te&&P){try{Be=window.localStorage[P]}catch{}if(typeof Be===Te)try{var st=window.document.cookie,tt=st.indexOf(encodeURIComponent(P)+"=");tt!==-1&&(Be=/^([^;]+)/.exec(st.slice(tt))[1])}catch{}return Ye.levels[Be]===void 0&&(Be=void 0),Be}}function Xe(){if(typeof window!==Te&&P){try{return void window.localStorage.removeItem(P)}catch{}try{window.document.cookie=encodeURIComponent(P)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof ye=="string"?P+=":"+ye:typeof ye=="symbol"&&(P=void 0),Ye.name=ye,Ye.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Ye.methodFactory=Je||at,Ye.getLevel=function(){return kt},Ye.setLevel=function(Be,st){if(typeof Be=="string"&&Ye.levels[Be.toUpperCase()]!==void 0&&(Be=Ye.levels[Be.toUpperCase()]),!(typeof Be=="number"&&Be>=0&&Be<=Ye.levels.SILENT))throw"log.setLevel() called with invalid level: "+Be;if(kt=Be,st!==!1&&Tr(Be),Ke.call(Ye,Be,ye),typeof console===Te&&Be<Ye.levels.SILENT)return"No console available for logging"},Ye.setDefaultLevel=function(Be){He=Be,wt()||Ye.setLevel(Be,!1)},Ye.resetLevel=function(){Ye.setLevel(He,!1),Xe()},Ye.enableAll=function(Be){Ye.setLevel(Ye.levels.TRACE,Be)},Ye.disableAll=function(Be){Ye.setLevel(Ye.levels.SILENT,Be)};var Ct=wt();Ct==null&&(Ct=He),Ye.setLevel(Ct,!1)}var T=new $,Z={};T.getLogger=function(ye){if(typeof ye!="symbol"&&typeof ye!="string"||ye==="")throw new TypeError("You must supply a name when creating a logger.");var He=Z[ye];return He||(He=Z[ye]=new $(ye,T.getLevel(),T.methodFactory)),He};var H=typeof window!==Te?window.log:void 0;return T.noConflict=function(){return typeof window!==Te&&window.log===T&&(window.log=H),T},T.getLoggers=function(){return Z},T.default=T,T},(W=typeof ae=="function"?ae.call(Q,q,Q,G):ae)===void 0||(G.exports=W)})()},375:function(G,Q){"use strict";var q=Object.prototype.hasOwnProperty;function ae(fe){try{return decodeURIComponent(fe.replace(/\+/g," "))}catch{return null}}function W(fe){try{return encodeURIComponent(fe)}catch{return null}}Q.stringify=function(fe,ge){ge=ge||"";var me,Te,Ce=[];for(Te in typeof ge!="string"&&(ge="?"),fe)if(q.call(fe,Te)){if((me=fe[Te])||me!=null&&!isNaN(me)||(me=""),Te=W(Te),me=W(me),Te===null||me===null)continue;Ce.push(Te+"="+me)}return Ce.length?ge+Ce.join("&"):""},Q.parse=function(fe){for(var ge,me=/([^=?#&]+)=?([^&]*)/g,Te={};ge=me.exec(fe);){var Ce=ae(ge[1]),Ie=ae(ge[2]);Ce===null||Ie===null||Ce in Te||(Te[Ce]=Ie)}return Te}},558:function(){}},M={};function N(G){var Q=M[G];if(Q!==void 0)return Q.exports;var q=M[G]={exports:{}};return S[G].call(q.exports,q,q.exports,N),q.exports}return N.n=function(G){var Q=G&&G.__esModule?function(){return G.default}:function(){return G};return N.d(Q,{a:Q}),Q},N.d=function(G,Q){for(var q in Q)N.o(Q,q)&&!N.o(G,q)&&Object.defineProperty(G,q,{enumerable:!0,get:Q[q]})},N.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),N.o=function(G,Q){return Object.prototype.hasOwnProperty.call(G,Q)},N(80)}()},typeof Xn=="object"&&typeof Xa=="object"?Xa.exports=k():typeof Xn=="object"?Xn.mux=k():w.mux=k()})()});var To=vo((Eo,Qa)=>{(function w(k){var S,M;S=this,M=function(){"use strict";function N(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 G(s){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?N(Object(e),!0).forEach(function(t){ae(s,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):N(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,Lt(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 ae(s,n,e){return(n=Lt(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 fe(s,n){s.prototype=Object.create(n.prototype),s.prototype.constructor=s,me(s,n)}function ge(s){return ge=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ge(s)}function me(s,n){return me=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},me(s,n)}function Te(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ce(s,n,e){return Ce=Te()?Reflect.construct.bind():function(t,r,i){var a=[null];a.push.apply(a,r);var o=new(Function.bind.apply(t,a));return i&&me(o,i.prototype),o},Ce.apply(null,arguments)}function Ie(s){var n=typeof Map=="function"?new Map:void 0;return Ie=function(e){if(e===null||(t=e,Function.toString.call(t).indexOf("[native code]")===-1))return e;var t;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(n!==void 0){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return Ce(e,arguments,ge(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),me(r,e)},Ie(s)}function et(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 et(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)?et(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 Lt(s){var n=function(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}(s,"string");return typeof n=="symbol"?n:String(n)}function Ke(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var vt={exports:{}};(function(s,n){var e,t,r,i,a;e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(o,l,d){if(d=d||{},o=o.trim(),!(l=l.trim())){if(!d.alwaysNormalize)return o;var u=a.parseURL(o);if(!u)throw new Error("Error trying to parse base URL.");return u.path=a.normalizePath(u.path),a.buildURLFromParts(u)}var c=a.parseURL(l);if(!c)throw new Error("Error trying to parse relative URL.");if(c.scheme)return d.alwaysNormalize?(c.path=a.normalizePath(c.path),a.buildURLFromParts(c)):l;var f=a.parseURL(o);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var v=t.exec(f.path);f.netLoc=v[1],f.path=v[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:c.netLoc,path:null,params:c.params,query:c.query,fragment:c.fragment};if(!c.netLoc&&(p.netLoc=f.netLoc,c.path[0]!=="/"))if(c.path){var 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})(vt);var at=vt.exports,$=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}({}),H=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}({}),ye=function(){},He={trace:ye,debug:ye,log:ye,warn:ye,info:ye,error:ye},Je=He;function kt(s){var n=self.console[s];return n?n.bind(self.console,"["+s+"] >"):ye}function Ye(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){Je[a]=e[a]?e[a].bind(e):kt(a)})})(s,"debug","log","info","warn","error");try{Je.log('Debug logs enabled for "'+n+'" in hls.js version 1.4.1')}catch{Je=He}}else Je=He}var P=Je,Tr=/^(\d+)x(\d+)$/,wt=/(.+?)=(".*?"|.*?)(?:,|$)/g,Xe=function(){function s(e){for(var t in typeof e=="string"&&(e=s.parseAttrList(e)),e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}var n=s.prototype;return n.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},n.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.decimalFloatingPoint=function(e){return parseFloat(this[e])},n.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},n.enumeratedString=function(e){return this[e]},n.bool=function(e){return this[e]==="YES"},n.decimalResolution=function(e){var t=Tr.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},s.parseAttrList=function(e){var t,r={};for(wt.lastIndex=0;(t=wt.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 Ct(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var Be=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 Xe({}),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"]);$(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($(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&&$(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),s}(),st=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}},tt="audio",rt="video",ii="audiovideo",Si=function(){function s(n){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[tt]=null,e[rt]=null,e[ii]=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=at.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(n){this._url=n}}]),s}(),ni=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 st,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}fe(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[tt]=null,t[rt]=null,t[ii]=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||!$(this.programDateTime))return null;var t=$(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}(Si),X=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 st,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 fe(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}(Si),oe=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&&$(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 je(s){return Uint8Array.from(atob(s),function(n){return n.charCodeAt(0)})}function it(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=je(l)):(n=gt(l).subarray(0,16),(e=new Uint8Array(16)).set(n,16-n.length),r=e)}}return r}function gt(s){return Uint8Array.from(unescape(encodeURIComponent(s)),function(n){return n.charCodeAt(0)})}var Fe={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Pt="org.w3.clearkey",Et="com.apple.streamingkeydelivery",nt="com.microsoft.playready",xt="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function br(s){switch(s){case Et:return Fe.FAIRPLAY;case nt:return Fe.PLAYREADY;case xt:return Fe.WIDEVINE;case Pt:return Fe.CLEARKEY}}var Mr="edef8ba979d64acea3c827dcd51d21ed";function _r(s){switch(s){case Fe.FAIRPLAY:return Et;case Fe.PLAYREADY:return nt;case Fe.WIDEVINE:return xt;case Fe.CLEARKEY:return Pt}}function Sr(s){var n=s.drmSystems,e=s.widevineLicenseUrl,t=n?[Fe.FAIRPLAY,Fe.WIDEVINE,Fe.PLAYREADY,Fe.CLEARKEY].filter(function(r){return!!n[r]}):[];return!t[Fe.WIDEVINE]&&e&&t.push(Fe.WIDEVINE),t}var Ar=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function jt(s,n,e){return Uint8Array.prototype.slice?s.slice(n,e):new Uint8Array(Array.prototype.slice.call(s,n,e))}var We,tr=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},Lr=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},rr=function(s,n){for(var e=n,t=0;tr(s,n);)t+=10,t+=ur(s,n+6),Lr(s,n+10)&&(t+=10),n+=t;if(t>0)return s.subarray(e,e+t)},ur=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]},Fr=function(s,n){return tr(s,n)&&ur(s,n+6)+10<=s.length-n},dn=function(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"},ta=function(s){var n=String.fromCharCode(s[0],s[1],s[2],s[3]),e=ur(s,4);return{type:n,size:e,data:s.subarray(10,10+e)}},Ai=function(s){for(var n=0,e=[];tr(s,n);){for(var t=ur(s,n+6),r=(n+=10)+t;n+8<r;){var i=ta(s.subarray(n)),a=ra(i);a&&e.push(a),n+=i.size+10}Lr(s,n)&&(n+=10)}return e},ra=function(s){return s.type==="PRIV"?ia(s):s.type[0]==="W"?hn(s):cn(s)},ia=function(s){if(!(s.size<2)){var n=Bt(s.data,!0),e=new Uint8Array(s.data.subarray(n.length+1));return{key:s.type,info:n,data:e.buffer}}},cn=function(s){if(!(s.size<2)){if(s.type==="TXXX"){var n=1,e=Bt(s.data.subarray(n),!0);n+=e.length+1;var t=Bt(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=Bt(s.data.subarray(1));return{key:s.type,data:r}}},hn=function(s){if(s.type==="WXXX"){if(s.size<2)return;var n=1,e=Bt(s.data.subarray(n),!0);n+=e.length+1;var t=Bt(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=Bt(s.data);return{key:s.type,data:r}},fn=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)}},Bt=function(s,n){n===void 0&&(n=!1);var e=na();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 na(){return We||self.TextDecoder===void 0||(We=new self.TextDecoder("utf-8")),We}var Vt=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},Nr=Math.pow(2,32)-1,aa=[].push,vn={video:1,audio:2,id3:3,text:4};function ot(s){return String.fromCharCode.apply(null,s)}function gn(s,n){var e=s[n]<<8|s[n+1];return e<0?65536+e:e}function we(s,n){var e=Li(s,n);return e<0?4294967296+e:e}function Li(s,n){return s[n]<<24|s[n+1]<<16|s[n+2]<<8|s[n+3]}function ki(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 Ne(s,n){var e=[];if(!n.length)return e;for(var t=s.byteLength,r=0;r<t;){var i=we(s,r),a=i>1?r+i:t;if(ot(s.subarray(r+4,r+8))===n[0])if(n.length===1)e.push(s.subarray(r+8,a));else{var o=Ne(s.subarray(r+8,a),n.slice(1));o.length&&aa.apply(e,o)}r=a}return e}function mn(s){var n=[],e=s[0],t=8,r=we(s,t);t+=4,t+=e===0?8:16,t+=2;var i=s.length+0,a=gn(s,t);t+=2;for(var o=0;o<a;o++){var l=t,d=we(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=we(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 wi(s){for(var n=[],e=Ne(s,["moov","trak"]),t=0;t<e.length;t++){var r=e[t],i=Ne(r,["tkhd"])[0];if(i){var a=i[0],o=a===0?12:20,l=we(i,o),d=Ne(r,["mdia","mdhd"])[0];if(d){var u=we(d,o=(a=d[0])===0?12:20),c=Ne(r,["mdia","hdlr"])[0];if(c){var f=ot(c.subarray(8,12)),v={soun:tt,vide:rt}[f];if(v){var p=Ne(r,["mdia","minf","stbl","stsd"])[0],E=void 0;p&&(E=ot(p.subarray(12,16))),n[l]={timescale:u,type:v},n[v]={timescale:u,id:l,codec:E}}}}}}return Ne(s,["moov","mvex","trex"]).forEach(function(A){var y=we(A,4),b=n[y];b&&(b.default={duration:we(A,12),flags:we(A,20)})}),n}function Ri(s){var n=Ne(s,["schm"])[0];if(n){var e=ot(n.subarray(4,8));if(e==="cbcs"||e==="cenc")return Ne(s,["schi","tenc"])[0]}return P.error("[eme] missing 'schm' box"),null}function sa(s){var n=we(s,0),e=8;1&n&&(e+=4),4&n&&(e+=4);for(var t=0,r=we(s,4),i=0;i<r;i++)256&n&&(t+=we(s,e),e+=4),512&n&&(e+=4),1024&n&&(e+=4),2048&n&&(e+=4);return t}function dr(s,n){var e=new Uint8Array(s.length+n.length);return e.set(s),e.set(n,s.length),e}function Di(s,n){var e=[],t=n.samples,r=n.timescale,i=n.id,a=!1;return Ne(t,["moof"]).map(function(o){var l=o.byteOffset-8;Ne(o,["traf"]).map(function(d){var u=Ne(d,["tfdt"]).map(function(c){var f=c[0],v=we(c,4);return f===1&&(v*=Math.pow(2,32),v+=we(c,8)),v/r})[0];return u!==void 0&&(s=u),Ne(d,["tfhd"]).map(function(c){var f=we(c,4),v=16777215&we(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=we(c,b),b+=4),E&&(A=we(c,b),b+=4),y&&(b+=4),n.type==="video"&&(a=function(C){if(!C)return!1;var D=C.indexOf("."),O=D<0?C:C.substring(0,D);return O==="hvc1"||O==="hev1"||O==="dvh1"||O==="dvhe"}(n.codec)),Ne(d,["trun"]).map(function(C){var D=C[0],O=16777215&we(C,0),U=(1&O)!=0,K=0,z=(4&O)!=0,j=(256&O)!=0,V=0,te=(512&O)!=0,J=0,de=(1024&O)!=0,_e=(2048&O)!=0,ue=0,pe=we(C,4),Se=8;U&&(K=we(C,Se),Se+=4),z&&(Se+=4);for(var be=K+l,De=0;De<pe;De++){if(j?(V=we(C,Se),Se+=4):V=p,te?(J=we(C,Se),Se+=4):J=A,de&&(Se+=4),_e&&(ue=D===0?we(C,Se):Li(C,Se),Se+=4),n.type===rt)for(var Me=0;Me<J;){var Ue=we(t,be);pn(a,t[be+=4])&&yn(t.subarray(be,be+Ue),a?2:1,s+ue/r,e),be+=Ue,Me+=Ue+4}s+=V/r}}))})})}),e}function pn(s,n){if(s){var e=n>>1&63;return e===39||e===40}return(31&n)==6}function yn(s,n,e,t){var r=En(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=gn(r,i);if(i+=2,c===49){var f=we(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=[],D=0;D<16;D++){var O=r[i++].toString(16);C.push(O.length==1?"0"+O:O),D!==3&&D!==5&&D!==7&&D!==9||C.push("-")}for(var U=o-16,K=new Uint8Array(U),z=0;z<U;z++)K[z]=r[i++];t.push({payloadType:a,pts:e,uuid:C.join(""),userData:Bt(K),userDataBytes:K})}}else if(o<u)i+=o;else if(o>u)break}}function En(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 Tn(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 Ur={},Br=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(){Ur={}};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 Et:case xt:case nt:case Pt: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=it(this.uri);if(r)switch(this.keyFormat){case xt:this.pssh=r,r.length>=22&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case nt:var i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Tn(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=je(u).subarray(0,16);(function(A){var y=function(b,C,D){var O=b[C];b[C]=b[D],b[D]=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=Ur[this.uri];if(!p){var E=Object.keys(Ur).length%Number.MAX_SAFE_INTEGER;p=new Uint8Array(16),new DataView(p.buffer,12,4).setUint32(0,E),Ur[this.uri]=p}this.keyId=p}return this},s}(),bn=/\{\$([a-zA-Z0-9-_]+)\}/g;function _n(s){return bn.test(s)}function Rt(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]=Gt(s,i))}}function Gt(s,n){if(s.variableList!==null||s.hasVariableRefs){var e=s.variableList;return n.replace(bn,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 Sn(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 An(s,n,e){var t=n.IMPORT;if(e&&t in e){var r=s.variableList;r||(s.variableList=r={}),r[t]=e[t]}else s.playlistParsingError||(s.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+t+'"'))}function ai(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var oa={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}},Ii=ai();function si(s,n){var e;return(e=Ii==null?void 0:Ii.isTypeSupported((n||"video")+'/mp4;codecs="'+s+'"'))!=null&&e}var cr=/#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,kr=/#EXT-X-MEDIA:(.*)/g,la=/^#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"),oi=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),Gr=function(){function s(){}return s.findGroup=function(n,e){for(var t=0;t<n.length;t++){var r=n[t];if(r.id===e)return r}},s.convertAVC1ToAVCOTI=function(n){var e=n.split(".");if(e.length>2){var t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4)}return n},s.resolve=function(n,e){return at.buildAbsoluteURL(e,n,{alwaysNormalize:!0})},s.isMediaPlaylist=function(n){return la.test(n)},s.parseMasterPlaylist=function(n,e){var t,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:_n(n)},i=[];for(cr.lastIndex=0;(t=cr.exec(n))!=null;)if(t[1]){var a,o=new Xe(t[1]);Rt(r,o,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=Gt(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),ua((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 Xe(f);Rt(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=Ln(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 Xe(f);Rt(r,A,["NAME","VALUE","QUERYPARAM"]),Sn(r,A,e);break;case"CONTENT-STEERING":var y=new Xe(f);Rt(r,y,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:s.resolve(y["SERVER-URI"],e),pathwayId:y["PATHWAY-ID"]||"."};break;case"START":r.startTimeOffset=kn(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(kr.lastIndex=0;(r=kr.exec(n))!==null;){var d=new Xe(r[1]),u=d.TYPE;if(u){var c=o[u],f=i[u]||[];i[u]=f,Rt(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];Pi(v,p,"audioCodec"),Pi(v,p,"textCodec")}f.push(v)}}return i},s.parseLevelPlaylist=function(n,e,t,r,i,a){var o,l,d,u=new oe(e),c=u.fragments,f=null,v=0,p=0,E=0,A=0,y=null,b=new ni(r,e),C=-1,D=!1;for(Ci.lastIndex=0,u.m3u8=n,u.hasVariableRefs=_n(n);(o=Ci.exec(n))!==null;){D&&(D=!1,(b=new ni(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 U=(" "+o[2]).slice(1);b.title=U||null,b.tagList.push(U?["INF",O,U]:["INF",O])}else if(o[3]){if($(b.duration)){b.start=E,d&&xi(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=Gt(u,K),wn(b,y),y=b,E+=b.duration,v++,p=0,D=!0}}else if(o[4]){var z=(" "+o[4]).slice(1);y?b.setByteRange(z,y):b.setByteRange(z)}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(oi))){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),te=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 Xe(V);Rt(u,J,["RECENTLY-REMOVED-DATERANGES"]);var de=J.decimalInteger("SKIPPED-SEGMENTS");if($(de)){u.skippedSegments=de;for(var _e=de;_e--;)c.unshift(null);v+=de}var ue=J.enumeratedString("RECENTLY-REMOVED-DATERANGES");ue&&(u.recentlyRemovedDateranges=ue.split(" "));break;case"TARGETDURATION":u.targetduration=Math.max(parseInt(V),1);break;case"VERSION":u.version=parseInt(V);break;case"EXTM3U":break;case"ENDLIST":u.live=!1;break;case"#":(V||te)&&b.tagList.push(te?[V,te]:[V]);break;case"DISCONTINUITY":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 pe=new Xe(V);Rt(u,pe,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Rt(u,pe,pe.clientAttrs);var Se=new Be(pe,u.dateRanges[pe.ID]);Se.isValid||u.skippedSegments?u.dateRanges[Se.id]=Se:P.warn('Ignoring invalid DATERANGE tag: "'+V+'"'),b.tagList.push(["EXT-X-DATERANGE",V]);break;case"DEFINE":var be=new Xe(V);Rt(u,be,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in be?An(u,be,a):Sn(u,be,e);break;case"DISCONTINUITY-SEQUENCE":A=parseInt(V);break;case"KEY":var De=Ln(V,e,u);if(De.isSupported()){if(De.method==="NONE"){d=void 0;break}d||(d={}),d[De.keyFormat]&&(d=W({},d)),d[De.keyFormat]=De}else P.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+V+'"');break;case"START":u.startTimeOffset=kn(V);break;case"MAP":var Me=new Xe(V);if(Rt(u,Me,["BYTERANGE","URI"]),b.duration){var Ue=new ni(r,e);Rn(Ue,Me,t,d),f=Ue,b.initSegment=f,f.rawProgramDateTime&&!b.rawProgramDateTime&&(b.rawProgramDateTime=f.rawProgramDateTime)}else Rn(b,Me,t,d),f=b,D=!0;break;case"SERVER-CONTROL":var Ve=new Xe(V);u.canBlockReload=Ve.bool("CAN-BLOCK-RELOAD"),u.canSkipUntil=Ve.optionalFloat("CAN-SKIP-UNTIL",0),u.canSkipDateRanges=u.canSkipUntil>0&&Ve.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=Ve.optionalFloat("PART-HOLD-BACK",0),u.holdBack=Ve.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Ft=new Xe(V);u.partTarget=Ft.decimalFloatingPoint("PART-TARGET");break;case"PART":var pt=u.partList;pt||(pt=u.partList=[]);var Zt=p>0?pt[pt.length-1]:void 0,Qt=p++,Jt=new Xe(V);Rt(u,Jt,["BYTERANGE","URI"]);var yt=new X(Jt,b,e,Qt,Zt);pt.push(yt),b.duration+=yt.duration;break;case"PRELOAD-HINT":var St=new Xe(V);Rt(u,St,["URI"]),u.preloadHint=St;break;case"RENDITION-REPORT":var ar=new Xe(V);Rt(u,ar,["URI"]),u.renditionReports=u.renditionReports||[],u.renditionReports.push(ar);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&&(wn(b,y),b.cc=A,u.fragmentHint=b,d&&xi(b,d,u));var Pr=c.length,qt=c[0],Yi=c[Pr-1];if((E+=u.skippedSegments*u.targetduration)>0&&Pr&&Yi){u.averagetargetduration=E/Pr;var Wi=Yi.sn;u.endSN=Wi!=="initSegment"?Wi:0,u.live||(Yi.endList=!0),qt&&(u.startCC=qt.cc)}else u.endSN=0,u.startCC=0;return u.fragmentHint&&(E+=u.fragmentHint.duration),u.totalduration=E,u.endCC=A,C>0&&function(Wn,pi){for(var ei=Wn[pi],zi=pi;zi--;){var Er=Wn[zi];if(!Er)return;Er.programDateTime=ei.programDateTime-1e3*Er.duration,ei=Er}}(c,C),u},s}();function Ln(s,n,e){var t,r,i=new Xe(s);Rt(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?Gr.resolve(o,n):"",f=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Br(a,c,u,f,l)}function kn(s){var n=new Xe(s).decimalFloatingPoint("TIME-OFFSET");return $(n)?n:null}function ua(s,n){["video","audio","text"].forEach(function(e){var t=s.filter(function(i){return function(a,o){var l=oa[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 Pi(s,n,e){var t=n[e];t&&(s[e]=t)}function wn(s,n){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):n!=null&&n.programDateTime&&(s.programDateTime=n.endProgramDateTime),$(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function Rn(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 xi(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 wr="manifest",hr="level",Ot="audioTrack",$t="subtitleTrack",qe="main",Ht="audio",Yt="subtitle";function Dn(s){switch(s.type){case Ot:return Ht;case $t:return Yt;default:return qe}}function Oi(s,n){var e=s.url;return e!==void 0&&e.indexOf("data:")!==0||(e=n.url),e}var lt=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:wr,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:hr,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:Ot,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:$t,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===wr?o.manifestLoadPolicy.default:W({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),l=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part&&(e.type===hr&&e.level!==null?i=this.hls.levels[e.level].details:e.type===Ot&&e.id!==null?i=this.hls.audioTracks[e.id].details:e.type===$t&&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 D=a.getInternalLoader(b);a.resetInternalLoader(b.type);var O=A.data;O.indexOf("#EXTM3U")===0?(y.parsing.start=performance.now(),Gr.isMediaPlaylist(O)?a.handleTrackOrLevelPlaylist(A,y,b,C||null,D):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=Oi(e,r),d=Gr.parseMasterPlaylist(o,l);if(d.playlistParsingError)this.handleManifestParsingError(e,r,d.playlistParsingError,i,t);else{var u=d.contentSteering,c=d.levels,f=d.sessionData,v=d.sessionKeys,p=d.startTimeOffset,E=d.variableList;this.variableList=E;var A=Gr.parseMasterPlaylistMedia(o,l,d),y=A.AUDIO,b=y===void 0?[]:y,C=A.SUBTITLES,D=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 Xe({}),bitrate:0,url:""}))),a.trigger(T.MANIFEST_LOADED,{levels:c,audioTracks:b,subtitles:C,captions:D,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=Oi(e,r),f=$(l)?l:0,v=$(d)?d:f,p=Dn(r),E=Gr.parseLevelPlaylist(e.data,c,v,p,f,this.variableList);if(u===wr){var A={attrs:new Xe({}),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:H.MANIFEST_PARSING_ERROR,fatal:t.type===wr,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===hr?o+=": "+e.level+" id: "+e.id:e.type!==Ot&&e.type!==$t||(o+=" id: "+e.id+' group-id: "'+e.groupId+'"');var l=new Error(o);P.warn("[playlist-loader]: "+o);var d=H.UNKNOWN,u=!1,c=this.getInternalLoader(e);switch(e.type){case wr:d=r?H.MANIFEST_LOAD_TIMEOUT:H.MANIFEST_LOAD_ERROR,u=!0;break;case hr:d=r?H.LEVEL_LOAD_TIMEOUT:H.LEVEL_LOAD_ERROR,u=!1;break;case Ot:d=r?H.AUDIO_TRACK_LOAD_TIMEOUT:H.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case $t:d=r?H.SUBTITLE_TRACK_LOAD_TIMEOUT:H.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=G({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=Oi(t,i),E=Dn(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:H.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 wr:case hr:l.trigger(T.LEVEL_LOADED,{details:e,level:A||0,id:c||0,stats:r,networkDetails:a,deliveryDirectives:v});break;case Ot:l.trigger(T.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v});break;case $t: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:H.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 Hr(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 In(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 Mi(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 D=Math.floor((C+b)/2);if(A<E[D].startTime)C=D-1;else{if(!(A>E[D].startTime&&b<y))return D;b=D+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 Kr="org.id3",qr="com.apple.quicktime.HLS",fr="https://aomedia.org/emsg/ID3";function li(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var jr=function(){var s=li();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function ir(s,n){return s.getTime()/1e3-n}var da=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 Hr(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=li(),d=0;d<o.length;d++){var u=o[d].type;if((u!==fr||i)&&a){var c=Ai(o[d].data);if(c){var f=o[d].pts,v=f+o[d].duration;v>jr&&(v=jr),v-f<=0&&(v=f+.25);for(var p=0;p<c.length;p++){var E=c[p];if(!dn(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===jr&&(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)&&Mi(o,r,i,a==="audio"?function(f){return f.type===Kr&&c}:a==="video"?function(f){return f.type===fr&&u}:function(f){return f.type===Kr&&c||f.type===fr&&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&&$(v==null?void 0:v.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var p=v.programDateTime/1e3-v.start,E=li(),A=function(){var b=d[y],C=l[b],D=a[b],O=(D==null?void 0:D.cues)||{},U=(D==null?void 0:D.durationKnown)||!1,K=ir(C.startDate,p),z=jr,j=C.endDate;if(j)z=ir(j,p),U=!0;else if(C.endOnNext&&!U){var V=d.reduce(function(be,De){var Me=l[De];return Me.class===C.class&&Me.id!==De&&Me.startDate>C.startDate&&be.push(Me),be},[]).sort(function(be,De){return be.startDate.getTime()-De.startDate.getTime()})[0];V&&(z=ir(V.startDate,p),U=!0)}for(var te,J,de=Object.keys(C.attr),_e=0;_e<de.length;_e++){var ue=de[_e];if((J=ue)!=="ID"&&J!=="CLASS"&&J!=="START-DATE"&&J!=="DURATION"&&J!=="END-DATE"&&J!=="END-ON-NEXT"){var pe=O[ue];if(pe)U&&!D.durationKnown&&(pe.endTime=z);else{var Se=C.attr[ue];pe=new E(K,z,""),Ct(ue)&&(te=Se,Se=Uint8Array.from(te.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),pe.value={key:ue,data:Se},pe.type=qr,pe.id=b,r.id3Track.addCue(pe),O[ue]=pe}}}a[b]={cues:O,dateRange:C,durationKnown:U}},y=0;y<d.length;y++)A()}}},s}(),ca=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===H.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}(),Fi=["NONE","TYPE-0","TYPE-1",null],Ni="",ha="YES",fa="v2",Cn=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}(),Vr=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 Ui(s,n){var e=n.startPTS;if($(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 Yr(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($(l)){var u=Math.abs(l-e);$(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--)Ui(E[f],E[f-1]);for(f=p;f<E.length-1;f++)Ui(E[f],E[f+1]);return s.fragmentHint&&Ui(E[E.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,c}function Bi(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 D=b.skippedSegments,O=Math.max(y.startSN,b.startSN)-b.startSN,U=(y.fragmentHint?1:0)+(D?b.endSN:Math.min(y.endSN,b.endSN))-b.startSN,K=b.startSN-y.startSN,z=b.fragmentHint?b.fragments.concat(b.fragmentHint):b.fragments,j=y.fragmentHint?y.fragments.concat(y.fragmentHint):y.fragments,V=O;V<=U;V++){var te=j[K+V],J=z[V];D&&!J&&V<D&&(J=b.fragments[V]=te),te&&J&&C(te,J)}}(s,n,function(y,b){y.relurl&&(c=y.cc-b.cc),$(y.startPTS)&&$(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 Be(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 D=0,O=0,U=y.length;O<=U;O++){var K=y[O],z=b[O+D];K&&z&&K.index===z.index&&K.fragment.sn===z.fragment.sn?C(K,z):D--}}(s.partList,n.partList,function(y,b){b.elementaryStreams=y.elementaryStreams,b.stats=y.stats}),a?Yr(n,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):Gi(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 Gi(s,n){var e=n.startSN+n.skippedSegments-s.startSN,t=s.fragments;e<0||e>=t.length||Wr(n,t[e].start)}function Wr(s,n){if(n){for(var e=s.fragments,t=s.skippedSegments;t<e.length;t++)e[t].start+=n;s.fragmentHint&&(s.fragmentHint.start+=n)}}function Pn(s,n,e){var t;return s!=null&&s.details?xn((t=s.details)==null?void 0:t.partList,n,e):null}function xn(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 ui(s){switch(s.details){case H.FRAG_LOAD_TIMEOUT:case H.KEY_LOAD_TIMEOUT:case H.LEVEL_LOAD_TIMEOUT:case H.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function On(s,n){var e=ui(n);return s.default[(e?"timeout":"error")+"Retry"]}function Hi(s,n){var e=s.backoff==="linear"?1:Math.pow(2,n);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function Mn(s){return G(G({},s),{errorRetry:null,timeoutRetry:null})}function di(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 Fn=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 zr(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&&ci(e,t,r)===0)return r;var i=Fn(n,ci.bind(null,e,t));return!i||i===s&&r?r:i}function ci(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 Mt(s,n,e){var t=1e3*Math.min(n,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>s}var vr,va=3e5,Ki=0,m=2,h=5,g=0,_=1,L=2,I=function(){function s(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=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 H.FRAG_LOAD_ERROR:case H.FRAG_LOAD_TIMEOUT:case H.KEY_LOAD_ERROR:case H.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case H.FRAG_GAP:case H.FRAG_PARSING_ERROR:case H.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=m);case H.LEVEL_EMPTY_ERROR:case H.LEVEL_PARSING_ERROR:var o,l,d=t.parent===qe?t.level:i.loadLevel;return void(t.details===H.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 H.LEVEL_LOAD_ERROR:case H.LEVEL_LOAD_TIMEOUT:return void(typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case H.AUDIO_TRACK_LOAD_ERROR:case H.AUDIO_TRACK_LOAD_TIMEOUT:case H.SUBTITLE_LOAD_ERROR:case H.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var u=i.levels[i.loadLevel];if(u&&(a.type===Ot&&a.groupId===u.audioGroupId||a.type===$t&&a.groupId===u.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=m,void(t.errorAction.flags=_)}return;case H.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var c=i.levels[i.loadLevel],f=c==null?void 0:c.attrs["HDCP-LEVEL"];return void(f&&(t.errorAction={action:m,flags:L,hdcpLevel:f}));case H.BUFFER_ADD_CODEC_ERROR:case H.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:i.loadLevel));case H.INTERNAL_EXCEPTION:case H.BUFFER_APPENDING_ERROR:case H.BUFFER_APPEND_ERROR:case H.BUFFER_FULL_ERROR:case H.LEVEL_SWITCH_ERROR:case H.BUFFER_STALLED_ERROR:case H.BUFFER_SEEK_OVER_HOLE:case H.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:Ki,flags:g})}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=On(this.hls.config.playlistLoadPolicy,e),o=this.playlistError++,l=(r=e.response)==null?void 0:r.code;return di(a,o,ui(e),l)?{action:h,flags:g,retryConfig:a,retryCount:o}:(i=e.context)!=null&&i.deliveryDirectives?{action:Ki,flags:g,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=On(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!==H.FRAG_GAP&&i.fragmentError++;var f=(c=e.response)==null?void 0:c.code;if(di(d,u,ui(e),f))return{action:h,flags:g,retryConfig:d,retryCount:u}}var v=this.getLevelSwitchAction(e,r);return d&&(v.retryConfig=d,v.retryCount=u),v},n.getLevelSwitchAction=function(e,t){var r=this.hls;t==null&&(t=r.loadLevel);var i=this.hls.levels[t];if(i&&(i.loadError++,r.autoLevelEnabled)){for(var a,o,l=-1,d=r.levels,u=(a=e.frag)==null?void 0:a.type,c=(o=e.context)!=null?o:{},f=c.type,v=c.groupId,p=d.length;p--;){var E=(p+r.loadLevel)%d.length;if(E!==r.loadLevel&&d[E].loadError===0){var A=d[E];if(e.details===H.FRAG_GAP&&e.frag){var y=d[E].details;if(y){var b=zr(e.frag,y.fragments,e.frag.start);if(b!=null&&b.gap)continue}}else if(f===Ot&&v===A.audioGroupId||f===$t&&v===A.textGroupId||u===Ht&&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:m,flags:g,nextAutoLevel:l}}return{action:m,flags:_}},n.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case Ki:break;case m:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===H.FRAG_GAP||(t.fatal=!0)}t.fatal&&this.hls.stopLoad()},n.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var i=r.flags,a=r.hdcpLevel,o=r.nextAutoLevel;switch(i){case g:this.switchLevel(e,o);break;case _:r.resolved||(r.resolved=this.redundantFailover(e));break;case L:a&&(t.maxHdcpLevel=Fi[Fi.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>va)return!0;var b=E.details;if(A.details===H.FRAG_GAP&&b&&A.frag){var C=A.frag.start,D=zr(null,b.fragments,C);if(D&&!D.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}(),R=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 Cn(u,c>=0?c:void 0,Ni)}}},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&&Bi(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,D=Math.min(C-a.partTarget,1.5*a.targetduration);if(D>0){if(r&&D>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+D+" with playlist age: "+a.age),D=0;else{var O=Math.floor(D/a.targetduration);c+=O,f!==void 0&&(f+=Math.round(D%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+b.toFixed(2)+"s goal: "+D+" skip sn "+O+" to part "+f)}a.tuneInGoal=D}if(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 U=this.hls.mainForwardBufferInfo,K=U?U.end-U.len:0,z=function(V,te){te===void 0&&(te=1/0);var J=1e3*V.targetduration;if(V.updated){var de=V.fragments;if(de.length&&4*J>te){var _e=1e3*de[de.length-1].duration;_e<J&&(J=_e)}}else J/=2;return Math.round(J)}(a,1e3*(a.edge-K));a.updated&&l>this.requestScheduled+z&&(this.requestScheduled=o.loading.start),c!==void 0&&a.canBlockReload?this.requestScheduled=o.loading.first+z-(1e3*a.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+z<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=z);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?fa:ha:Ni}(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=Ni),new Cn(r,i,a)},n.checkRetry=function(e){var t=this,r=e.details,i=ui(e),a=e.errorAction,o=a||{},l=o.action,d=o.retryCount,u=d===void 0?0:d,c=o.retryConfig,f=!!a&&!!c&&(l===h||!a.resolved&&l===m);if(f){var v;if(this.requestScheduled=-1,i&&(v=e.context)!=null&&v.deliveryDirectives)this.warn("Retrying playlist loading "+(u+1)+"/"+c.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var p=Hi(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}(),x=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}fe(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&&(vr||(vr=/chrome|firefox/i.test(navigator.userAgent)),vr&&(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 Vr(l),o[y]=i,a.push(i)),B(i,"audio",c),B(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,D=b.videoCodec,O=b.width,U=b.height,K=b.unknownCodecs;return l||(l=!(!O||!U)),d||(d=!!D),u||(u=!!C),!(K!=null&&K.length)&&(!C||si(C,"audio"))&&(!D||si(D,"video"))});if((l||d)&&u&&(c=c.filter(function(b){var C=b.videoCodec,D=b.width,O=b.height;return!!C||!(!D||!O)})),c.length!==0){r.audioTracks&&F(a=r.audioTracks.filter(function(b){return!b.audioCodec||si(b.audioCodec,"audio")})),r.subtitles&&F(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:H.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===hr&&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:H.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}(R);function B(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 F(s){var n={};s.forEach(function(e){var t=e.groupId||"";e.id=n[t]=n[t]||0,n[t]++})}var Y="NOT_LOADED",Ae="APPENDING",se="PARTIAL",ce="OK",le=function(){function s(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var n=s.prototype;return n._registerListeners=function(){var e=this.hls;e.on(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.activePartLists=this.endListFragments=this.timeRanges=null},n.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var i=r.length;i--;){var a=r[i];if(!a)break;var o=a.end;if(a.start<=e&&o!==null&&e<=o)return a}return this.getBufferedFrag(e,t)},n.getBufferedFrag=function(e,t){for(var r=this.fragments,i=Object.keys(r),a=i.length;a--;){var o=r[i[a]];if((o==null?void 0:o.body.type)===t&&o.buffered){var l=o.body;if(l.start<=e&&e<=l.end)return l}}return null},n.detectEvictedFragments=function(e,t,r,i){var a=this;this.timeRanges&&(this.timeRanges[e]=t);var o=(i==null?void 0:i.fragment.sn)||0;Object.keys(this.fragments).forEach(function(l){var d=a.fragments[l];if(d&&!(o>=d.body.sn))if(d.buffered||d.loaded){var u=d.range[e];u&&u.time.some(function(c){var f=!a.isTimeBuffered(c.startPTS,c.endPTS,t);return f&&a.removeFragment(d.body),f})}else d.body.type===r&&a.removeFragment(d.body)})},n.detectPartialFragments=function(e){var t=this,r=this.timeRanges,i=e.frag,a=e.part;if(r&&i.sn!=="initSegment"){var o=Pe(i),l=this.fragments[o];if(l){var d=!i.relurl;Object.keys(r).forEach(function(u){var c=i.elementaryStreams[u];if(c){var f=r[u],v=d||c.partial===!0;l.range[u]=t.getBufferedTimes(i,a,v,f)}}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,l.body.endList&&(this.endListFragments[l.body.type]=l),ve(l)||this.removeParts(i.sn-1,i.type)):this.removeFragment(l.body)}}},n.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(function(i){return i.fragment.sn>=e}))},n.fragBuffered=function(e,t){var r=Pe(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},n.getBufferedTimes=function(e,t,r,i){for(var a={time:[],partial:r},o=e.start,l=e.end,d=e.minEndPTS||l,u=e.maxStartPTS||o,c=0;c<i.length;c++){var f=i.start(c)-this.bufferPadding,v=i.end(c)+this.bufferPadding;if(u>=f&&d<=v){a.time.push({startPTS:Math.max(o,i.start(c)),endPTS:Math.min(l,i.end(c))});break}if(o<v&&l>f)a.partial=!0,a.time.push({startPTS:Math.max(o,i.start(c)),endPTS:Math.min(l,i.end(c))});else if(l<=f)break}return a},n.getPartialFragment=function(e){var t,r,i,a=null,o=0,l=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(u){var c=d[u];c&&ve(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||ve(t))},n.getState=function(e){var t=Pe(e),r=this.fragments[t];return r?r.buffered?ve(r)?se:ce:Ae:Y},n.isTimeBuffered=function(e,t,r){for(var i,a,o=0;o<r.length;o++){if(i=r.start(o)-this.bufferPadding,a=r.end(o)+this.bufferPadding,e>=i&&t<=a)return!0;if(t<=i)return!1}return!1},n.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if(r.sn!=="initSegment"&&!r.bitrateTest){var a=i?null:t,o=Pe(r);this.fragments[o]={body:r,appendedPTS:null,loaded:a,buffered:!1,range:Object.create(null)}}},n.onBufferAppended=function(e,t){var r=this,i=t.frag,a=t.part,o=t.timeRanges;if(i.sn!=="initSegment"){var l=i.type;if(a){var d=this.activePartLists[l];d||(this.activePartLists[l]=d=[]),d.push(a)}this.timeRanges=o,Object.keys(o).forEach(function(u){var c=o[u];r.detectEvictedFragments(u,c,l,a)})}},n.onFragBuffered=function(e,t){this.detectPartialFragments(t)},n.hasFragment=function(e){var t=Pe(e);return!!this.fragments[t]},n.hasParts=function(e){var t;return!((t=this.activePartLists[e])==null||!t.length)},n.removeFragmentsInRange=function(e,t,r,i,a){var o=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach(function(l){var d=o.fragments[l];if(d){var u=d.body;u.type!==r||i&&!u.gap||u.start<t&&u.end>e&&(d.buffered||a)&&o.removeFragment(u)}})},n.removeFragment=function(e){var t=Pe(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=r.filter(function(a){return a.fragment.sn!==i})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},n.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},s}();function ve(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 Pe(s){return s.type+"_"+s.level+"_"+s.urlId+"_"+s.sn}var ut=Math.pow(2,17),mt=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 Re({type:Z.NETWORK_ERROR,details:H.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(It(e));else{var c=r.loader=e.loader=o?new o(a):new l(a),f=Tt(e),v=Mn(a.fragLoadPolicy.default),p={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:ut};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 Re({type:Z.NETWORK_ERROR,details:H.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:G({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 Re({type:Z.NETWORK_ERROR,details:H.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 Re({type:Z.NETWORK_ERROR,details:H.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(It(e,t));else{var c=i.loader=e.loader=o?new o(a):new l(a),f=Tt(e,t),v=Mn(a.fragLoadPolicy.default),p={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ut};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 Re({type:Z.NETWORK_ERROR,details:H.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:G({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 Re({type:Z.NETWORK_ERROR,details:H.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 Re({type:Z.NETWORK_ERROR,details:H.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 Tt(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($(r)&&$(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 It(s,n){var e=new Error("GAP "+(s.gap?"tag":"attribute")+" found"),t={type:Z.MEDIA_ERROR,details:H.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return n&&(t.part=n),(n||s).stats.aborted=!0,new Re(t)}var Re=function(s){function n(e){var t;return(t=s.call(this,e.error.message)||this).data=void 0,t.data=e,t}return fe(n,s),n}(Ie(Error)),$e=function(){function s(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var n=s.prototype;return n.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){if(e&&e!==r.context.frag.type)return;r.abort()}}},n.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},n.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},n.createKeyLoadError=function(e,t,r,i,a){return t===void 0&&(t=H.KEY_LOAD_ERROR),new Re({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,H.KEY_LOAD_ERROR,o))}var l=a.uri;if(!l)return Promise.reject(this.createKeyLoadError(e,H.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,H.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,H.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,H.KEY_LOAD_ERROR,new Error("HTTP Error "+v.code+" loading key "+v.text),E,G({url:d.url,data:void 0},v)))},onTimeout:function(v,p,E){r.resetLoader(p),l(r.createKeyLoadError(t,H.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),E))},onAbort:function(v,p,E){r.resetLoader(p),l(r.createKeyLoadError(t,H.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}(),Ge=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}(),ee={length:0,start:function(){return 0},end:function(){return 0}},re=function(){function s(){}return s.isBuffered=function(n,e){try{if(n){for(var t=s.getBuffered(n),r=0;r<t.length;r++)if(e>=t.start(r)&&e<=t.end(r))return!0}}catch{}return!1},s.bufferInfo=function(n,e,t){try{if(n){var r,i=s.getBuffered(n),a=[];for(r=0;r<i.length;r++)a.push({start:i.start(r),end:i.end(r)});return this.bufferedInfo(a,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},s.bufferedInfo=function(n,e,t){e=Math.max(0,e),n.sort(function(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),ee}},s}(),ie=function(s,n,e,t,r,i){t===void 0&&(t=0),r===void 0&&(r=-1),i===void 0&&(i=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=s,this.sn=n,this.id=e,this.size=t,this.part=r,this.partial=i};function ke(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 xe(s,n){if(s){var e=s.start+n;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function Qe(s,n){for(var e=n.fragments,t=0,r=e.length;t<r;t++)xe(e[t],s);n.fragmentHint&&xe(n.fragmentHint,s),n.alignedSliding=!0}function Dt(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=ke(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&&$(a.start)&&(P.log("Adjusting PTS using last level due to CC increase within current level "+r.url),Qe(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&&$(o)&&(P.log("Adjusting PTS using programDateTime delta "+(a-i)+"ms, sliding:"+o.toFixed(3)+" "+t.url+" "),Qe(o,t))}}(e,n.details),e.alignedSliding||!n.details||e.skippedSegments||Gi(n.details,e))}function dt(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=ke(e,r.cc)||e[Math.round(e.length/2)-1],a=r.programDateTime,o=i.programDateTime;a!==null&&o!==null&&Qe((o-a)/1e3-(i.start-r.start),s)}}}var bt=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}(),ct=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}(),ht=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],D=p[C],O=p[D],U=257*p[b]^16843008*b;i[E]=U<<24|U>>>8,a[E]=U<<16|U>>>16,o[E]=U<<8|U>>>24,l[E]=U,U=16843009*O^65537*D^257*C^16843008*E,u[b]=U<<24|U>>>8,c[b]=U<<16|U>>>16,f[b]=U<<8|U>>>24,v[b]=U,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],D=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]]^D[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,D=this.invKeySchedule,O=this.invSBox,U=this.invSubMix,K=U[0],z=U[1],j=U[2],V=U[3],te=this.uint8ArrayToUint32Array_(r),J=te[0],de=te[1],_e=te[2],ue=te[3],pe=new Int32Array(e),Se=new Int32Array(pe.length),be=this.networkToHostOrderSwap;t<pe.length;){for(v=be(pe[t]),p=be(pe[t+1]),E=be(pe[t+2]),A=be(pe[t+3]),d=v^D[0],u=A^D[1],c=E^D[2],f=p^D[3],y=4,b=1;b<C;b++)i=K[d>>>24]^z[u>>16&255]^j[c>>8&255]^V[255&f]^D[y],a=K[u>>>24]^z[c>>16&255]^j[f>>8&255]^V[255&d]^D[y+1],o=K[c>>>24]^z[f>>16&255]^j[d>>8&255]^V[255&u]^D[y+2],l=K[f>>>24]^z[d>>16&255]^j[u>>8&255]^V[255&c]^D[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]^D[y],a=O[u>>>24]<<24^O[c>>16&255]<<16^O[f>>8&255]<<8^O[255&d]^D[y+1],o=O[c>>>24]<<24^O[f>>16&255]<<16^O[d>>8&255]<<8^O[255&u]^D[y+2],l=O[f>>>24]<<24^O[d>>16&255]<<16^O[u>>8&255]<<8^O[255&c]^D[y+3],Se[t]=be(i^J),Se[t+1]=be(l^de),Se[t+2]=be(o^_e),Se[t+3]=be(a^ue),J=v,de=p,_e=E,ue=A,t+=4}return Se.buffer},s}(),Wt=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))?jt(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=dr(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 ht),d.expandKey(t);var u=a;return this.currentResult=d.decrypt(l.buffer,0,r),this.currentIV=jt(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 ct(a,t)),this.fastAesKey.expandKey().then(function(o){return a?(i.logOnce("WebCrypto AES decrypt"),new bt(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=jt(e,0,r),this.remainderData=jt(e,r)),t},n.logOnce=function(e){this.logEnabled&&(P.log("[decrypter]: "+e),this.logEnabled=!1)},s}(),Xr=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},ft="STOPPED",he="IDLE",gr="KEY_LOADING",Dr="FRAG_LOADING",Ir="FRAG_LOADING_WAITING_RETRY",Qr="WAITING_TRACK",mr="PARSING",Nn="PARSED",qi="ENDED",hi="ERROR",ji="WAITING_INIT_PTS",fi="WAITING_LEVEL",ga=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=ft,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 mt(t.config),l.keyLoader=i,l.fragmentTracker=r,l.config=t.config,l.decrypter=new Wt(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}fe(n,s);var e=n.prototype;return e.doTick=function(){this.onTickEnd()},e.onTickEnd=function(){},e.startLoad=function(t){},e.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ft},e._streamEnded=function(t,r){if(r.live||t.nextStart||!t.end||!this.media)return!1;var i=r.partList;if(i!=null&&i.length){var a=i[i.length-1];return re.isBuffered(this.media,a.start+a.duration/2)}var o=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)},e.getLevelDetails=function(){var t;if(this.levels&&this.levelLastLoaded!==null)return(t=this.levels[this.levelLastLoaded])==null?void 0:t.details},e.onMediaAttached=function(t,r){var i=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);var a=this.config;this.levels&&a.autoStartLoad&&this.state===ft&&this.startLoad(a.startPosition)},e.onMediaDetaching=function(){var t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},e.onMediaSeeking=function(){var t=this.config,r=this.fragCurrent,i=this.media,a=this.mediaBuffer,o=this.state,l=i?i.currentTime:0,d=re.bufferInfo(a||i,l,t.maxBufferHole);if(this.log("media seeking to "+($(l)?l.toFixed(3):l)+", state: "+o),this.state===qi)this.resetLoadingState();else if(r){var u=t.maxFragLookUpTolerance,c=r.start-u,f=r.start+r.duration+u;if(!d.len||f<d.start||c>d.end){var v=l>f;(l<c||v)&&(v&&r.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(l,1/0,this.playlistType,!0),this.lastCurrentTime=l),this.loadedmetadata||d.len||(this.nextLoadPosition=this.startPosition=l),this.tickImmediate()},e.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},e.onManifestLoaded=function(t,r){this.startTimeOffset=r.startTimeOffset,this.initPTS=[]},e.onHandlerDestroying=function(){this.stopLoad(),s.prototype.onHandlerDestroying.call(this)},e.onHandlerDestroyed=function(){this.state=ft,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,s.prototype.onHandlerDestroyed.call(this)},e.loadFragment=function(t,r,i){this._loadFragForPlayback(t,r,i)},e._loadFragForPlayback=function(t,r,i){var a=this;this._doFragLoad(t,r,i,function(o){if(a.fragContextChanged(t))return a.warn("Fragment "+t.sn+(o.part?" p: "+o.part.index:"")+" of level "+t.level+" was dropped during download."),void a.fragmentTracker.removeFragment(t);t.stats.chunkCount++,a._handleFragmentLoadProgress(o)}).then(function(o){if(o){var l=a.state;a.fragContextChanged(t)?(l===Dr||!a.fragCurrent&&l===mr)&&(a.fragmentTracker.removeFragment(t),a.state=he):("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!==ft&&a.state!==hi&&(a.warn(o),a.resetFragmentLoading(t))})},e.clearTrackerIfNeeded=function(t){var r,i=this.fragmentTracker;if(i.getState(t)===Ae){var a=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,a),l=Math.max(t.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(l)&&i.removeFragment(t)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===se&&i.removeFragment(t))},e.flushMainBuffer=function(t,r,i){if(i===void 0&&(i=null),t-r){var a={startOffset:t,endOffset:r,type:i};this.hls.trigger(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:H.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=he,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!==ft&&i.state!==hi&&(i.warn(a),i.resetFragmentLoading(t))})},e.fragContextChanged=function(t){var r=this.fragCurrent;return!t||!r||t.level!==r.level||t.sn!==r.sn||t.urlId!==r.urlId},e.fragBufferedComplete=function(t,r){var i,a,o,l,d=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+(this.playlistType===qe?"level":"track")+" "+t.level+" (frag:["+((i=t.startPTS)!=null?i:NaN).toFixed(3)+"-"+((a=t.endPTS)!=null?a:NaN).toFixed(3)+"] > buffer:"+(d?Xr(re.getBuffered(d)):"(detached)")+")"),this.state=he,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 ie(i.level,i.sn,i.stats.chunkCount+1,0,a?a.index:-1,!l);r.flush(d)}},e._handleFragmentLoadProgress=function(t){},e._doFragLoad=function(t,r,i,a){var o,l=this;i===void 0&&(i=null);var d=r==null?void 0:r.details;if(!this.levels||!d)throw new Error("frag load aborted, missing level"+(d?"":" detail")+"s");var u=null;if(!t.encrypted||(o=t.decryptdata)!=null&&o.key?!t.encrypted&&d.encryptedFragments.length&&this.keyLoader.loadClear(t,d.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+d.startSN+"-"+d.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=gr,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===gr&&(l.state=he),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&&t.sn!=="initSegment"){var c=d.partList;if(c&&a){i>t.end&&d.fragmentHint&&(t=d.fragmentHint);var f=this.getNextPart(c,t,i);if(f>-1){var v,p=c[f];return this.log("Loading part sn: "+t.sn+" p: "+p.index+" cc: "+t.cc+" of playlist ["+d.startSN+"-"+d.endSN+"] parts [0-"+f+"-"+(c.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=p.start+p.duration,this.state=Dr,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))),$(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Dr;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=Pn(i,t.sn,p.index+1)||xn(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===H.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:H.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},e._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(r&&this.state===mr){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===ft||this.state===hi||(this.state=he)},e.getCurrentContext=function(t){var r=this.levels,i=this.fragCurrent,a=t.level,o=t.sn,l=t.part;if(r==null||!r[a])return this.warn("Levels object was unset while buffering fragment "+o+" of level "+a+". The current chunk will not be buffered."),null;var d=r[a],u=l>-1?Pn(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===mr){var l=t.data1,d=t.data2,u=l;if(l&&d&&(u=dr(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(re.isBuffered(r,r.currentTime)){var i=r.currentTime,a=re.bufferInfo(r,i,0),o=t.duration,l=Math.min(2*this.config.maxFragLookUpTolerance,.25*o),d=Math.max(Math.min(t.start-l,a.end-l),i+l);t.start-d>l&&this.flushMainBuffer(d,t.start)}else this.flushMainBuffer(0,t.start)},e.getFwdBufferInfo=function(t,r){var i=this.getLoadPosition();return $(i)?this.getFwdBufferInfoAtPos(t,i,r):null},e.getFwdBufferInfoAtPos=function(t,r,i){var a=this.config.maxBufferHole,o=re.bufferInfo(t,r,a);if(o.len===0&&o.nextStart!==void 0){var l=this.fragmentTracker.getBufferedFrag(r,i);if(l&&o.nextStart<l.end)return re.bufferInfo(t,r,Math.max(o.nextStart,a))}return o},e.getMaxBufferLength=function(t){var r,i=this.config;return r=t?Math.max(8*i.maxBufferSize/t,i.maxBufferLength):i.maxBufferLength,Math.min(r,i.maxMaxBufferLength)},e.reduceMaxBufferLength=function(t){var r=this.config,i=t||r.maxBufferLength;return r.maxMaxBufferLength>=i&&(r.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+r.maxMaxBufferLength+"s"),!0)},e.getAppendedFrag=function(t,r){var i=this.fragmentTracker.getAppendedFrag(t,qe);return i&&"fragment"in i?i.fragment:i},e.getNextFragment=function(t,r){var i=r.fragments,a=i.length;if(!a)return null;var o,l=this.config,d=i[0].start;if(r.live){var u=l.initialLiveManifestSize;if(a<u)return this.warn("Not enough fragments to start playback (have: "+a+", need: "+u+")"),null;r.PTSKnown||this.startFragRequested||this.startPosition!==-1||(o=this.getInitialLiveFragment(r,i),this.startPosition=o?this.hls.liveSyncPosition||o.start:t)}else t<=d&&(o=i[0]);if(!o){var c=l.lowLatencyMode?r.partEnd:r.fragmentEnd;o=this.getFragmentAtPosition(t,c,r)}return this.mapToInitFragWhenRequired(o)},e.isLoopLoading=function(t,r){var i=this.fragmentTracker.getState(t);return(i===ce||i===se&&!!t.gap)&&this.nextLoadPosition>r},e.getNextFragmentLoopLoading=function(t,r,i,a,o){var l=t.gap,d=this.getNextFragment(this.nextLoadPosition,r);if(d===null)return d;if(t=d,l&&t&&!t.gap&&i.nextStart){var u=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,a);if(u!==null&&i.len+u.len>=o)return this.log('buffer full after gaps in "'+a+'" playlist starting at sn: '+t.sn),null}return t},e.mapToInitFragWhenRequired=function(t){return t==null||!t.initSegment||t!=null&&t.initSegment.data||this.bitrateTest?t:t.initSegment},e.getNextPart=function(t,r,i){for(var a=-1,o=!1,l=!0,d=0,u=t.length;d<u;d++){var c=t[d];if(l=l&&!c.independent,a>-1&&i<c.start)break;var f=c.loaded;f?a=-1:(o||c.independent||l)&&c.fragment===r&&(a=d),o=f}return a},e.loadedEndOfParts=function(t,r){var i=t[t.length-1];return i&&r>i.start&&i.loaded},e.getInitialLiveFragment=function(t,r){var i=this.fragPrevious,a=null;if(i){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),a=function(u,c,f){if(c===null||!Array.isArray(u)||!u.length||!$(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(Mt(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 Fn(u,function(f){return f.cc<c?1:f.cc>c?-1:0})}(r,i.cc),a&&this.log("Live playlist, switching playlist, load frag with same CC: "+a.sn))}}else{var d=this.hls.liveSyncPosition;d!==null&&(a=this.getFragmentAtPosition(d,this.bitrateTest?t.fragmentEnd:t.edge,t))}return a},e.getFragmentAtPosition=function(t,r,i){var a,o=this.config,l=this.fragPrevious,d=i.fragments,u=i.endSN,c=i.fragmentHint,f=o.maxFragLookUpTolerance,v=i.partList,p=!!(o.lowLatencyMode&&v!=null&&v.length&&c);if(p&&c&&!this.bitrateTest&&(d=d.concat(c),u=c.sn),a=t<r?zr(l,d,t,t>r-f?0:f):d[d.length-1]){var E=a.sn-i.startSN,A=this.fragmentTracker.getState(a);if((A===ce||A===se&&a.gap)&&(l=a),l&&a.sn===l.sn&&(!p||v[0].fragment.sn>a.sn)&&l&&a.level===l.level){var y=d[E+1];a=a.sn<u&&this.fragmentTracker.getState(y)!==ce?y:null}}return a},e.synchronizeToLiveEdge=function(t){var r=this.config,i=this.media;if(i){var a=this.hls.liveSyncPosition,o=i.currentTime,l=t.fragments[0].start,d=t.edge,u=o>=l-r.maxFragLookUpTolerance&&o<=d;if(a!==null&&i.duration>a&&(o<a||!u)){var c=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;(!u&&i.readyState<4||o<d-c)&&(this.loadedmetadata||(this.nextLoadPosition=a),i.readyState&&(this.warn("Playback: "+o.toFixed(3)+" is located too far from the end of live sliding playlist: "+d+", reset currentTime to : "+a.toFixed(3)),i.currentTime=a))}}},e.alignPlaylists=function(t,r){var i=this.levels,a=this.levelLastLoaded,o=this.fragPrevious,l=a!==null?i[a]:null,d=t.fragments.length;if(!d)return this.warn("No fragments in live playlist"),0;var u=t.fragments[0].start,c=!r,f=t.alignedSliding&&$(u);if(c||!f&&!u){Dt(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&&$(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===Ir)||(this.state=he)},e.onFragmentOrKeyLoadError=function(t,r){if(r.chunkMeta&&!r.frag){var i=this.getCurrentContext(r.chunkMeta);i&&(r.frag=i.frag)}var a=r.frag;if(a&&a.type===t&&this.levels)if(this.fragContextChanged(a)){var o;this.warn("Frag load error must match current frag to retry "+a.url+" > "+((o=this.fragCurrent)==null?void 0:o.url))}else{var l=r.details===H.FRAG_GAP;l&&this.fragmentTracker.fragBuffered(a,!0);var d=r.errorAction,u=d||{},c=u.action,f=u.retryCount,v=f===void 0?0:f,p=u.retryConfig;if(d&&c===h&&p){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var E=Hi(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=Ir}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=hi;this.tickImmediate()}},e.reduceLengthAndFlushBuffer=function(t){if(this.state===mr||this.state===Nn){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===Ht&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ft&&(this.state=he)},e.afterBufferFlushed=function(t,r,i){if(t){var a=re.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,a,i),this.state===qi&&this.resetLoadingState()}},e.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=he},e.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var r=this.levels?this.levels[t].details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},e.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(t.level),this.resetLoadingState()},e.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},e.updateLevelTiming=function(t,r,i,a){var o,l=this,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:Yr(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:H.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=Nn,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}(Ge);function ps(){return self.SourceBuffer||self.WebKitSourceBuffer}function nr(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 ys=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=dr(this.cachedData,e),this.cachedData=null);var r,i=rr(e,0),a=i?i.length:0,o=this._audioTrack,l=this._id3Track,d=i?function(v){for(var p=Ai(v),E=0;E<p.length;E++){var A=p[E];if(dn(A))return fn(A)}}(i):void 0,u=e.length;for((this.basePTS===null||this.frameIndex===0&&$(d))&&(this.basePTS=ll(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:Kr,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 Fr(e,a)?(i=rr(e,a),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Kr,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===u&&r!==u){var f=jt(e,r);this.cachedData?this.cachedData=dr(this.cachedData,f):this.cachedData=f}}return{audioTrack:o,videoTrack:nr(),id3Track:l,textTrack:nr()}},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:nr(),id3Track:this._id3Track,textTrack:nr()}},n.destroy=function(){},s}(),ll=function(s,n,e){return $(s)?90*s:9e4*n+(e?9e4*e.baseTime/e.timescale:0)};function Es(s,n){return s[n]===255&&(246&s[n+1])==240}function Ts(s,n){return 1&s[n+1]?7:9}function ma(s,n){return(3&s[n+3])<<11|s[n+4]<<3|(224&s[n+5])>>>5}function Un(s,n){return n+1<s.length&&Es(s,n)}function ul(s,n){if(Un(s,n)){var e=Ts(s,n);if(n+e>=s.length)return!1;var t=ma(s,n);if(t<=e)return!1;var r=n+t;return r===s.length||Un(s,r)}return!1}function bs(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:H.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 _s(s){return 9216e4/s}function Ss(s,n,e,t,r){var i,a=t+r*_s(s.samplerate),o=function(p,E){var A=Ts(p,E);if(E+A<=p.length){var y=ma(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 dl=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}fe(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=(rr(t,0)||[]).length,i=t.length;r<i;r++)if(ul(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)&&Es(i,a)&&ma(i,a)<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){bs(t,this.observer,r,i,t.manifestCodec);var a=Ss(t,r,i,this.basePTS,this.frameIndex);if(a&&a.missing===0)return a},n}(ys),cl=/\/emsg[-/]ID3/i,hl=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=nr("video",1),o=this.audioTrack=nr("audio",1),l=this.txtTrack=nr("text",1);if(this.id3Track=nr("id3",1),this.timeOffset=0,e!=null&&e.byteLength){var d=wi(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=vn.text,a.sampleDuration=0,a.duration=o.duration=i}},n.resetContiguity=function(){this.remainderData=null},s.probe=function(e){return Ne(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=dr(this.remainderData,e));var o=function(d){var u={valid:null,remainder:null},c=Ne(d,["moof"]);if(!c)return u;if(c.length<2)return u.remainder=d,u;var f=c[c.length-1];return u.valid=jt(d,0,f.byteOffset-8),u.remainder=jt(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=Di(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=Di(e,t),{videoTrack:t,audioTrack:nr(),id3Track:i,textTrack:nr()}},n.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=Ne(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,D=0;if(f===0){for(;ot(c.subarray(D,D+1))!=="\0";)v+=ot(c.subarray(D,D+1)),D+=1;for(v+=ot(c.subarray(D,D+1)),D+=1;ot(c.subarray(D,D+1))!=="\0";)p+=ot(c.subarray(D,D+1)),D+=1;p+=ot(c.subarray(D,D+1)),D+=1,E=we(c,12),A=we(c,16),b=we(c,20),C=we(c,24),D=28}else if(f===1){E=we(c,D+=4);var O=we(c,D+=4),U=we(c,D+=4);for(D+=4,y=Math.pow(2,32)*O+U,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=we(c,D),C=we(c,D+=4),D+=4;ot(c.subarray(D,D+1))!=="\0";)v+=ot(c.subarray(D,D+1)),D+=1;for(v+=ot(c.subarray(D,D+1)),D+=1;ot(c.subarray(D,D+1))!=="\0";)p+=ot(c.subarray(D,D+1)),D+=1;p+=ot(c.subarray(D,D+1)),D+=1}return{schemeIdUri:v,value:p,timeScale:E,presentationTime:y,presentationTimeDelta:A,eventDuration:b,id:C,payload:c.subarray(D,c.byteLength)}}(a);if(cl.test(o.schemeIdUri)){var l=$(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:fr,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}(),Bn=null,fl=[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],vl=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],gl=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ml=[0,1,1,4];function As(s,n,e,t,r){if(!(e+24>n.length)){var i=Ls(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 Ls(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*fl[14*(e===3?3-t:t===3?3:4)+r-1],d=vl[3*(e===3?0:e===2?1:2)+i],u=o===3?1:2,c=gl[e][t],f=ml[t],v=8*c*f,p=Math.floor(c*l/d+a)*f;if(Bn===null){var E=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Bn=E?parseInt(E[1]):0}return!!Bn&&Bn<=87&&t===2&&l>=224e3&&o===0&&(s[n+3]=128|s[n+3]),{sampleRate:d,channelCount:u,frameLength:p,samplesPerFrame:v}}}function pa(s,n){return s[n]===255&&(224&s[n+1])==224&&(6&s[n+1])!=0}function ks(s,n){return n+1<s.length&&pa(s,n)}function pl(s,n){if(n+1<s.length&&pa(s,n)){var e=Ls(s,n),t=4;e!=null&&e.frameLength&&(t=e.frameLength);var r=n+t;return r===s.length||ks(s,r)}return!1}var ws=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 D=c(),O=c(),U=u(1);U===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*(D+1)-2*i-2*a),height:(2-U)*(O+1)*16-(U?2:4)*(o+l),pixelRatio:K}},n.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},s}(),yl=function(){function s(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Wt(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=En(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}(),Kt=188,El=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-Kt)+1,i=0;i<r;){for(var a=!1,o=i;o<t&&e[o]===71;o+=Kt)if(a||ya(e,o)!==0||(a=!0),a&&o+Kt>r)return i;i++}return-1},s.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:vn[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,D=e.length;if(this.remainderData&&(D=(e=dr(this.remainderData,e)).length,this.remainderData=null),D<Kt&&!i)return this.remainderData=e,{audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};var O=Math.max(0,s.syncOffset(e));(D-=(D-O)%Kt)<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,D,e.buffer.byteLength-D));for(var U=0,K=O;K<D;K+=Kt)if(e[K]===71){var z=!!(64&e[K+1]),j=ya(e,K),V=void 0;if((48&e[K+3])>>4>1){if((V=K+5+e[K+4])===K+Kt)continue}else V=K+4;switch(j){case c:z&&(f&&(a=vi(f))&&this.parseAVCPES(o,u,a,!1),f={data:[],size:0}),f&&(f.data.push(e.subarray(V,K+Kt)),f.size+=K+Kt-V);break;case v:if(z){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+Kt)),E.size+=K+Kt-V);break;case p:z&&(A&&(a=vi(A))&&this.parseID3PES(d,a),A={data:[],size:0}),A&&(A.data.push(e.subarray(V,K+Kt)),A.size+=K+Kt-V);break;case 0:z&&(V+=e[V]+1),C=this._pmtId=Tl(e,V);break;case C:z&&(V+=e[V]+1);var te=bl(e,V,this.typeSupported,r);(c=te.avc)>0&&(o.pid=c),(v=te.audio)>0&&(l.pid=v,l.segmentCodec=te.segmentCodec),(p=te.id3)>0&&(d.pid=p),y===null||b||(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 U++;if(U>0){var J=new Error("Found "+U+" TS packet/s that do not start with 0x47");this.observer.emit(T.ERROR,T.ERROR,{type:Z.MEDIA_ERROR,details:H.FRAG_PARSING_ERROR,fatal:!1,error:J,reason:J.message})}o.pesData=f,l.pesData=E,d.pesData=A;var de={audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};return i&&this.extractRemainingSamples(de),de},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 yl(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&&(Ea(d,e),d=this.avcSample=Gn(!1,r.pts,r.dts,"")),l.forEach(function(c){switch(c.type){case 1:a=!0,d||(d=o.avcSample=Gn(!0,r.pts,r.dts,"")),d.frame=!0;var f=c.data;if(u&&f.length>4){var v=new ws(f).readSliceType();v!==2&&v!==4&&v!==7&&v!==9||(d.key=!0)}break;case 5:a=!0,d||(d=o.avcSample=Gn(!0,r.pts,r.dts,"")),d.key=!0,d.frame=!0;break;case 6:a=!0,yn(c.data,1,r.pts,t.samples);break;case 7:if(a=!0,u=!0,!e.sps){var p=c.data,E=new ws(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&&Ea(d,e),d=o.avcSample=Gn(!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&&(Ea(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&&!Un(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:H.FRAG_PARSING_ERROR,fatal:!1,levelRetry:E,error:A,reason:p}),!E)return}if(bs(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=_s(e.samplerate);a=l.sample.pts+y}for(var b,C=0;r<i;){if(r+=(b=Ss(e,d,r,a,C)).length,b.missing){this.aacOverFlow=b;break}for(C++;r<i-1&&!Un(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(ks(r,o)){var d=As(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?fr:Kr,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else P.warn("[tsdemuxer]: ID3 PES unknown PTS")},s}();function Gn(s,n,e,t){return{key:s,frame:!1,pts:n,dts:e,units:[],debug:t,length:0}}function ya(s,n){return((31&s[n+1])<<8)+s[n+2]}function Tl(s,n){return(31&s[n+10])<<8|s[n+11]}function bl(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=ya(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 Ea(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 _l=function(s){function n(){return s.apply(this,arguments)||this}fe(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=(rr(t,0)||[]).length,i=t.length;r<i;r++)if(pl(t,r))return P.log("MPEG Audio sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return pa(i,a)&&4<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){if(this.basePTS!==null)return As(t,r,i,this.basePTS,this.frameIndex)},n}(ys),Rs=function(){function s(){}return s.getSilentFrame=function(n,e){if(n==="mp4a.40.2"){if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},s}(),Cr=Math.pow(2,32)-1,_t=function(){function s(){}return s.init=function(){var n;for(n in s.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},s.types)s.types.hasOwnProperty(n)&&(s.types[n]=[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]);var e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),t=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);s.HDLR_TYPES={video:e,audio:t};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);s.STTS=s.STSC=s.STCO=i,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);s.FTYP=s.box(s.types.ftyp,a,l,a,o),s.DINF=s.box(s.types.dinf,s.box(s.types.dref,r))},s.box=function(n){for(var e=8,t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var a=r.length,o=a;a--;)e+=r[a].byteLength;var l=new Uint8Array(e);for(l[0]=e>>24&255,l[1]=e>>16&255,l[2]=e>>8&255,l[3]=255&e,l.set(n,4),a=0,e=8;a<o;a++)l.set(r[a],e),e+=r[a].byteLength;return l},s.hdlr=function(n){return s.box(s.types.hdlr,s.HDLR_TYPES[n])},s.mdat=function(n){return s.box(s.types.mdat,n)},s.mdhd=function(n,e){e*=n;var t=Math.floor(e/(Cr+1)),r=Math.floor(e%(Cr+1));return s.box(s.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,85,196,0,0]))},s.mdia=function(n){return s.box(s.types.mdia,s.mdhd(n.timescale,n.duration),s.hdlr(n.type),s.minf(n))},s.mfhd=function(n){return s.box(s.types.mfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n]))},s.minf=function(n){return n.type==="audio"?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(n)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(n))},s.moof=function(n,e,t){return s.box(s.types.moof,s.mfhd(n),s.traf(t,e))},s.moov=function(n){for(var e=n.length,t=[];e--;)t[e]=s.trak(n[e]);return s.box.apply(null,[s.types.moov,s.mvhd(n[0].timescale,n[0].duration)].concat(t).concat(s.mvex(n)))},s.mvex=function(n){for(var e=n.length,t=[];e--;)t[e]=s.trex(n[e]);return s.box.apply(null,[s.types.mvex].concat(t))},s.mvhd=function(n,e){e*=n;var t=Math.floor(e/(Cr+1)),r=Math.floor(e%(Cr+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return s.box(s.types.mvhd,i)},s.sdtp=function(n){var e,t,r=n.samples||[],i=new Uint8Array(4+r.length);for(e=0;e<r.length;e++)t=r[e].flags,i[e+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return s.box(s.types.sdtp,i)},s.stbl=function(n){return s.box(s.types.stbl,s.stsd(n),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))},s.avc1=function(n){var e,t,r,i=[],a=[];for(e=0;e<n.sps.length;e++)r=(t=n.sps[e]).byteLength,i.push(r>>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(e=0;e<n.pps.length;e++)r=(t=n.pps[e]).byteLength,a.push(r>>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(t));var o=s.box(s.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|n.sps.length].concat(i).concat([n.pps.length]).concat(a))),l=n.width,d=n.height,u=n.pixelRatio[0],c=n.pixelRatio[1];return s.box(s.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,d>>8&255,255&d,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,c>>24,c>>16&255,c>>8&255,255&c])))},s.esds=function(n){var e=n.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(n.config).concat([6,1,2]))},s.mp4a=function(n){var e=n.samplerate;return s.box(s.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),s.box(s.types.esds,s.esds(n)))},s.mp3=function(n){var e=n.samplerate;return s.box(s.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))},s.stsd=function(n){return n.type==="audio"?n.segmentCodec==="mp3"&&n.codec==="mp3"?s.box(s.types.stsd,s.STSD,s.mp3(n)):s.box(s.types.stsd,s.STSD,s.mp4a(n)):s.box(s.types.stsd,s.STSD,s.avc1(n))},s.tkhd=function(n){var e=n.id,t=n.duration*n.timescale,r=n.width,i=n.height,a=Math.floor(t/(Cr+1)),o=Math.floor(t%(Cr+1));return s.box(s.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,255&r,0,0,i>>8&255,255&i,0,0]))},s.traf=function(n,e){var t=s.sdtp(n),r=n.id,i=Math.floor(e/(Cr+1)),a=Math.floor(e%(Cr+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a])),s.trun(n,t.length+16+20+8+16+8+8),t)},s.trak=function(n){return n.duration=n.duration||4294967295,s.box(s.types.trak,s.tkhd(n),s.mdia(n))},s.trex=function(n){var e=n.id;return s.box(s.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},s.trun=function(n,e){var t,r,i,a,o,l,d=n.samples||[],u=d.length,c=12+16*u,f=new Uint8Array(c);for(e+=8+c,f.set([n.type==="video"?1:0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),t=0;t<u;t++)i=(r=d[t]).duration,a=r.size,o=r.flags,l=r.cts,f.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*t);return s.box(s.types.trun,f)},s.initSegment=function(n){s.types||s.init();var e=s.moov(n),t=new Uint8Array(s.FTYP.byteLength+e.byteLength);return t.set(s.FTYP),t.set(e,s.FTYP.byteLength),t},s}();function Ta(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 Vi(s,n){return n===void 0&&(n=!1),Ta(s,1e3,1/9e4,n)}_t.types=void 0,_t.HDLR_TYPES=void 0,_t.STTS=void 0,_t.STSC=void 0,_t.STCO=void 0,_t.STSZ=void 0,_t.VMHD=void 0,_t.SMHD=void 0,_t.STSD=void 0,_t.FTYP=void 0,_t.DINF=void 0;var Hn=null,ba=null,_a=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,Hn===null){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Hn=a?parseInt(a[1]):0}if(ba===null){var o=navigator.userAgent.match(/Safari\/(\d+)/i);ba=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,zt(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,D=t.samples.length,O=e.samples.length>0,U=l&&D>0||D>1;if((!b||O)&&(!C||U)||this.ISGenerated||l){this.ISGenerated||(f=this.generateIS(e,t,a,o));var K,z=this.isVideoContiguous,j=-1;if(U&&(j=function(_e){for(var ue=0;ue<_e.length;ue++)if(_e[ue].key)return ue;return-1}(t.samples),!z&&this.config.forceKeyFrameOnDiscontinuity))if(E=!0,j>0){P.warn("[mp4-remuxer]: Dropped "+j+" out of "+D+" 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 "+D+" video samples"),E=!1);if(this.ISGenerated){if(O&&U){var te=this.getVideoStartPts(t.samples),J=(zt(e.samples[0].pts,te)-te)/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||U||d===Ht?y:void 0),U){var de=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,z,de)}}else U&&(u=this.remuxVideo(t,y,z,0));u&&(u.firstKeyFrame=j,u.independent=j!==-1,u.firstKeyFramePTS=K)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(p=Ds(r,a,this._initPTS,this._initDTS)),i.samples.length&&(v=Is(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):_t.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:_t.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,zt(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-zt(d[0].dts,d[0].pts)));for(var C=f.baseTime*l/f.timescale,D=0;D<c;D++){var O=d[D];O.pts=zt(O.pts-C,v),O.dts=zt(O.dts-C,v),O.dts<d[D>0?D-1:D].dts&&(b=!0)}b&&d.sort(function(zn,fo){var Tu=zn.dts-fo.dts,bu=zn.pts-fo.pts;return Tu||bu}),a=d[0].dts;var U=(o=d[d.length-1].dts)-a,K=U?Math.round(U/(c-1)):E||e.inputTimeScale/30;if(r){var z=a-v,j=z>K,V=z<-1;if((j||V)&&(j?P.warn("AVC: "+Vi(z,!0)+" ms ("+z+"dts) hole between fragments detected, filling it"):P.warn("AVC: "+Vi(-z,!0)+" ms ("+z+"dts) overlapping between fragments detected"),!V||v>d[0].pts)){a=v;var te=d[0].pts-z;d[0].dts=a,d[0].pts=te,P.log("Video: First PTS/DTS adjusted: "+Vi(te,!0)+"/"+Vi(a,!0)+", delta: "+Vi(z,!0)+" ms")}}a=Math.max(0,a);for(var J=0,de=0,_e=0;_e<c;_e++){for(var ue=d[_e],pe=ue.units,Se=pe.length,be=0,De=0;De<Se;De++)be+=pe[De].data.length;de+=be,J+=Se,ue.length=be,ue.dts=Math.max(ue.dts,a),A=Math.min(ue.pts,A),y=Math.max(ue.pts,y)}o=d[c-1].dts;var Me,Ue=de+4*J+8;try{Me=new Uint8Array(Ue)}catch(zn){return void this.observer.emit(T.ERROR,T.ERROR,{type:Z.MUX_ERROR,details:H.REMUX_ALLOC_ERROR,fatal:!1,error:zn,bytes:Ue,reason:"fail allocating video mdat "+Ue})}var Ve=new DataView(Me.buffer);Ve.setUint32(0,Ue),Me.set(_t.types.mdat,4);for(var Ft=!1,pt=Number.POSITIVE_INFINITY,Zt=Number.POSITIVE_INFINITY,Qt=Number.NEGATIVE_INFINITY,Jt=Number.NEGATIVE_INFINITY,yt=0;yt<c;yt++){for(var St=d[yt],ar=St.units,Pr=0,qt=0,Yi=ar.length;qt<Yi;qt++){var Wi=ar[qt],Wn=Wi.data,pi=Wi.data.byteLength;Ve.setUint32(p,pi),p+=4,Me.set(Wn,p),p+=pi,Pr+=4+pi}var ei=void 0;if(yt<c-1)E=d[yt+1].dts-St.dts,ei=d[yt+1].pts-St.pts;else{var zi=this.config,Er=yt>0?St.dts-d[yt-1].dts:K;if(ei=yt>0?St.pts-d[yt-1].pts:K,zi.stretchShortVideoTrack&&this.nextAudioPts!==null){var gu=Math.floor(zi.maxBufferHole*l),Ka=(i?A+i*l:this.nextAudioPts)-St.pts;Ka>gu?((E=Ka-Er)<0?E=Er:Ft=!0,P.log("[mp4-remuxer]: It is approximately "+Ka/90+" ms to the next segment; using duration "+E/90+" ms for the last video frame.")):E=Er}else E=Er}var mu=Math.round(St.pts-St.dts);pt=Math.min(pt,E),Qt=Math.max(Qt,E),Zt=Math.min(Zt,ei),Jt=Math.max(Jt,ei),u.push(new Cs(St.key,E,Pr,mu))}if(u.length){if(Hn){if(Hn<70){var uo=u[0].flags;uo.dependsOn=2,uo.isNonSync=0}}else if(ba&&Jt-Zt<Qt-pt&&K/Qt<.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 qa=a,er=0,co=u.length;er<co;er++){var ho=qa+u[er].duration,pu=qa+u[er].cts;if(er<co-1){var yu=ho+u[er+1].cts;u[er].duration=yu-pu}else u[er].duration=er?u[er-1].duration:K;u[er].cts=0,qa=ho}}}E=Ft||!E?K:E,this.nextAvcDts=v=o+E,this.videoSampleDuration=E,this.isVideoContiguous=!0;var Eu={data1:_t.moof(e.sequenceNumber++,a,W({},e,{samples:u})),data2:Me,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,Eu},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(zt(E[0].pts-C,b)-y)<20*u),E.forEach(function(qt){qt.pts=zt(qt.pts-C,b)}),!r||y<0){if(E=E.filter(function(qt){return qt.pts>=0}),!E.length)return;y=a===0?0:i&&!p?Math.max(0,b):E[0].pts}if(e.segmentCodec==="aac")for(var D=this.config.maxAudioFramesDrift,O=0,U=y;O<E.length;O++){var K=E[O],z=K.pts,j=z-U,V=Math.abs(1e3*j/o);if(j<=-D*u&&p)O===0&&(P.warn("Audio frame @ "+(z/o).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*j/o)+" ms."),this.nextAudioPts=y=U=z);else if(j>=D*u&&V<1e4&&p){var te=Math.round(j/u);(U=z-te*u)<0&&(te--,U+=u),O===0&&(this.nextAudioPts=y=U),P.warn("[mp4-remuxer]: Injecting "+te+" audio frame @ "+(U/o).toFixed(3)+"s due to "+Math.round(1e3*j/o)+" ms gap.");for(var J=0;J<te;J++){var de=Math.max(U,0),_e=Rs.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);_e||(P.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),_e=K.unit.subarray()),E.splice(O,0,{unit:_e,pts:de}),U+=u,O++}}K.pts=U,U+=u}for(var ue,pe=null,Se=null,be=0,De=E.length;De--;)be+=E[De].unit.byteLength;for(var Me=0,Ue=E.length;Me<Ue;Me++){var Ve=E[Me],Ft=Ve.unit,pt=Ve.pts;if(Se!==null)v[Me-1].duration=Math.round((pt-Se)/l);else{if(r&&e.segmentCodec==="aac"&&(pt=y),pe=pt,!(be>0))return;be+=A;try{ue=new Uint8Array(be)}catch(qt){return void this.observer.emit(T.ERROR,T.ERROR,{type:Z.MUX_ERROR,details:H.REMUX_ALLOC_ERROR,fatal:!1,error:qt,bytes:be,reason:"fail allocating audio mdat "+be})}f||(new DataView(ue.buffer).setUint32(0,be),ue.set(_t.types.mdat,4))}ue.set(Ft,A);var Zt=Ft.byteLength;A+=Zt,v.push(new Cs(!0,d,Zt,0)),Se=pt}var Qt=v.length;if(Qt){var Jt=v[v.length-1];this.nextAudioPts=y=Se+l*Jt.duration;var yt=f?new Uint8Array(0):_t.moof(e.sequenceNumber++,pe/l,W({},e,{samples:v}));e.samples=[];var St=pe/o,ar=y/o,Pr={data1:yt,data2:ue,startPTS:St,endPTS:ar,startDTS:St,endDTS:ar,type:"audio",hasAudio:!0,hasVideo:!1,nb:Qt};return this.isAudioContiguous=!0,Pr}},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=Rs.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 zt(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 Ds(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=zt(o.pts-9e4*e.baseTime/e.timescale,n*i)/i,o.dts=zt(o.dts-9e4*t.baseTime/t.timescale,n*i)/i}var l=s.samples;return s.samples=[],{samples:l}}}function Is(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=zt(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 pr,Cs=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 Sl(s)},Sl=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},Al=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&&Ne(a,["moov","trak"]).forEach(function(d){var u=Ne(d,["mdia","minf","stbl","stsd"])[0].subarray(8),c=Ne(u,["enca"]),f=c.length>0;f||(c=Ne(u,["encv"])),c.forEach(function(v){Ne(f?v.subarray(28):v.subarray(78),["sinf"]).forEach(function(p){var E=Ri(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: "+Vt(A)+" -> "+Vt(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=wi(e);t||(t=Ps(i.audio,tt)),r||(r=Ps(i.video,rt));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};$(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 Ne(V,["moof","traf"]).reduce(function(te,J){var de=Ne(J,["tfdt"])[0],_e=de[0],ue=Ne(J,["tfhd"]).reduce(function(pe,Se){var be=we(Se,4),De=j[be];if(De){var Me=we(de,4);if(_e===1){if(Me===Nr)return P.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),pe;Me*=Nr+1,Me+=we(de,8)}var Ue=Me/(De.timescale||9e4);if(isFinite(Ue)&&(pe===null||Ue<pe))return Ue}return pe},null);return ue!==null&&isFinite(ue)&&(te===null||ue<te)?ue:te},null)}(E,v),y=A===null?a:A;(function(j,V,te){if(j===null)return!0;var J=V-j.baseTime/j.timescale;return J<0&&Math.abs(J-te)>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 te=0,J=0,de=0,_e=Ne(j,["moof","traf"]),ue=0;ue<_e.length;ue++){var pe=_e[ue],Se=Ne(pe,["tfhd"])[0],be=V[we(Se,4)];if(be){var De=be.default,Me=we(Se,0)|(De==null?void 0:De.flags),Ue=De==null?void 0:De.duration;8&Me&&(Ue=we(Se,2&Me?12:8));for(var Ve=be.timescale||9e4,Ft=Ne(pe,["trun"]),pt=0;pt<Ft.length;pt++)!(te=sa(Ft[pt]))&&Ue&&(te=Ue*we(Ft[pt],4)),be.type===rt?J+=te/Ve:be.type===tt&&(de+=te/Ve)}}if(J===0&&de===0){for(var Zt=0,Qt=Ne(j,["sidx"]),Jt=0;Jt<Qt.length;Jt++){var yt=mn(Qt[Jt]);yt!=null&&yt.references&&(Zt+=yt.references.reduce(function(St,ar){return St+ar.info.duration||0},0))}return Zt}return J||de}(v,E),C=e?y-u.baseTime/u.timescale:c,D=C+b;(function(j,V,te){Ne(V,["moof","traf"]).forEach(function(J){Ne(J,["tfhd"]).forEach(function(de){var _e=we(de,4),ue=j[_e];if(ue){var pe=ue.timescale||9e4;Ne(J,["tfdt"]).forEach(function(Se){var be=Se[0],De=we(Se,4);if(be===0)De-=te*pe,ki(Se,4,De=Math.max(De,0));else{De*=Math.pow(2,32),De+=we(Se,8),De-=te*pe,De=Math.max(De,0);var Me=Math.floor(De/(Nr+1)),Ue=Math.floor(De%(Nr+1));ki(Se,4,Me),ki(Se,8,Ue)}})}})})})(E,v,u.baseTime/u.timescale),b>0?this.lastEndTime=D:(P.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var O=!!E.audio,U=!!E.video,K="";O&&(K+="audio"),U&&(K+="video");var z={data1:v,startPTS:C,startDTS:C,endPTS:D,endDTS:D,type:K,hasAudio:O,hasVideo:U,nb:1,dropped:0};return f.audio=z.type==="audio"?z:void 0,f.video=z.type!=="audio"?z:void 0,f.initSegment=p,f.id3=Ds(r,a,u,u),i.samples.length&&(f.text=Is(i,a,u)),f},s}();function Ps(s,n){var e=s==null?void 0:s.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||n===rt?"avc1.42e01e":"mp4a.40.5"}try{pr=self.performance.now.bind(self.performance)}catch{P.debug("Unable to use Performance API on this environment"),pr=typeof self!="undefined"&&self.Date.now}var Sa=[{demux:hl,remux:Al},{demux:El,remux:_a},{demux:dl,remux:_a},{demux:_l,remux:_a}],Aa=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=pr();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,D=u.defaultInitPts,O=u.duration,U=u.initSegmentData,K=function(_e,ue){var pe=null;return _e.byteLength>0&&ue!=null&&ue.key!=null&&ue.iv!==null&&ue.method!=null&&(pe=ue),pe}(l,t);if(K&&K.method==="AES-128"){var z=this.getDecrypter();if(!z.isSync())return this.decryptionPromise=z.webCryptoDecrypt(l,K.key.buffer,K.iv.buffer).then(function(_e){var ue=a.push(_e,null,r);return a.decryptionPromise=null,ue}),this.decryptionPromise;var j=z.softwareDecrypt(l,K.key.buffer,K.iv.buffer);if(r.part>-1&&(j=z.flush()),!j)return o.executeEnd=pr(),La(r);l=new Uint8Array(j)}var V=this.needsProbing(v,p);if(V){var te=this.configureTransmuxer(l);if(te)return P.warn("[transmuxer] "+te.message),this.observer.emit(T.ERROR,T.ERROR,{type:Z.MEDIA_ERROR,details:H.FRAG_PARSING_ERROR,fatal:!1,error:te,reason:te.message}),o.executeEnd=pr(),La(r)}(v||p||y||V)&&this.resetInitSegment(U,b,C,O,t),(v||y||V)&&this.resetInitialTimestamp(D),f||this.resetContiguity();var J=this.transmux(l,K,A,E,r),de=this.currentTransmuxState;return de.contiguous=!0,de.discontinuity=!1,de.trackSwitch=!1,o.executeEnd=pr(),J},n.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=pr();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=pr(),[La(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=pr()},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=Sa.length;l<d;l++)if(Sa[l].demux.probe(e)){t=Sa[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 Wt(this.config)),e},s}(),La=function(s){return{remuxResult:{},chunkMeta:s}};function Jr(s){return"then"in s&&s.then instanceof Function}var Ll=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},kl=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},xs={exports:{}};(function(s){var n=Object.prototype.hasOwnProperty,e="~";function t(){}function r(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function i(l,d,u,c,f){if(typeof u!="function")throw new TypeError("The listener must be a function");var v=new r(u,c||l,f),p=e?e+d:d;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],v]:l._events[p].push(v):(l._events[p]=v,l._eventsCount++),l}function a(l,d){--l._eventsCount==0?l._events=new t:delete l._events[d]}function o(){this._events=new t,this._eventsCount=0}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1)),o.prototype.eventNames=function(){var l,d,u=[];if(this._eventsCount===0)return u;for(d in l=this._events)n.call(l,d)&&u.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(l)):u},o.prototype.listeners=function(l){var d=e?e+l:l,u=this._events[d];if(!u)return[];if(u.fn)return[u.fn];for(var c=0,f=u.length,v=new Array(f);c<f;c++)v[c]=u[c].fn;return v},o.prototype.listenerCount=function(l){var d=e?e+l:l,u=this._events[d];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,d,u,c,f,v){var p=e?e+l:l;if(!this._events[p])return!1;var 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,D=y.length;for(A=0;A<D;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})(xs);var Kn=Ke(xs.exports);function ka(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&&Os(t,i),a&&Os(t,a),s.postMessage({event:"transmuxComplete",data:n},t),!0}function Os(s,n){n.data1&&s.push(n.data1.buffer),n.data2&&s.push(n.data2.buffer)}function Ms(s,n,e){n.reduce(function(t,r){return ka(s,r)||t},!1)||s.postMessage({event:"transmuxComplete",data:n[0]}),s.postMessage({event:"flush",data:e})}k!==void 0&&k&&function(s){var n=new Kn,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 Aa(n,i.typeSupported,a,i.vendor,i.id),Ye(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){ka(s,u)}).catch(function(u){e(T.ERROR,{type:Z.MEDIA_ERROR,details:H.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker push error"})})):(s.transmuxer.async=!1,ka(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){Ms(s,u,l)}).catch(function(u){e(T.ERROR,{type:Z.MEDIA_ERROR,details:H.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker flush error"})})):Ms(s,d,l)}})}(self);var wa=ai()||{isTypeSupported:function(){return!1}},Fs=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 Kn,this.observer.on(T.FRAG_DECRYPTED,l),this.observer.on(T.ERROR,l);var d,u,c,f,v={mp4:wa.isTypeSupported("video/mp4"),mpeg:wa.isTypeSupported("audio/mpeg"),mp3:wa.isTypeSupported('audio/mp4; codecs="mp3"')},p=navigator.vendor;if(!this.useWorker||typeof Worker=="undefined"||(o.workerPath,0))this.transmuxer=new Aa(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;("+w.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:H.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 Aa(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),D=!(b&&u.level===b.level),O=b?u.sn-b.sn:-1,U=this.part?u.part-this.part.index:-1,K=O===0&&u.id>1&&u.id===(b==null?void 0:b.stats.chunkCount),z=!D&&(O===1||O===0&&(U===1||K&&U<=0)),j=self.performance.now();(D||O||a.stats.parsing.start===0)&&(a.stats.parsing.start=j),!o||!U&&z||(o.stats.parsing.start=j);var V=!(b&&((f=a.initSegment)==null?void 0:f.url)===((v=b.initSegment)==null?void 0:v.url)),te=new kl(C,z,d,D,A,V);if(!z||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
21
|
discontinuity: `+C+`
|
|
22
|
-
trackSwitch: `+
|
|
23
|
-
contiguous: `+
|
|
22
|
+
trackSwitch: `+D+`
|
|
23
|
+
contiguous: `+z+`
|
|
24
24
|
accurateTimeOffset: `+d+`
|
|
25
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;
|
|
26
|
+
initSegmentChange: `+V);var J=new Ll(r,i,t,l,c);this.configureTransmuxer(J)}if(this.frag=a,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:u,state:te},e instanceof ArrayBuffer?[e]:[]);else if(E){var de=E.push(e,y,u,te);Jr(de)?(E.async=!0,de.then(function(_e){p.handleTransmuxComplete(_e)}).catch(function(_e){p.transmuxerError(_e,u,"transmuxer-interface push error")})):(E.async=!1,this.handleTransmuxComplete(de))}},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:H.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}(),wl=function(){function s(e,t,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i}var n=s.prototype;return n.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},n.poll=function(e,t){var r=this.config,i=this.media,a=this.stalled;if(i!==null){var o=i.currentTime,l=i.seeking,d=this.seeking&&!l,u=!this.seeking&&l;if(this.seeking=l,o===e){if(u||d)this.stalled=null;else if(!(i.paused&&!l||i.ended||i.playbackRate===0)&&re.getBuffered(i).length){var c=re.bufferInfo(i,o,0),f=c.len>0,v=c.nextStart||0;if(f||v){if(l){var p=c.len>2,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,D=this.fragmentTracker.getPartialFragment(o);if(y>0&&(y<=C||D))return void this._trySkipBufferHole(D)}var O=self.performance.now();if(a!==null){var U=O-a;if(l||!(U>=250)||(this._reportStall(c),this.media)){var K=re.bufferInfo(i,o,r.maxBufferHole);this._tryFixBufferStall(K,U)}}else this.stalled=O}}}else if(this.moved=!0,a!==null){if(this.stallReported){var z=self.performance.now()-a;P.warn("playback not stuck anymore @"+o+", after "+Math.round(z)+"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:H.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}},n._trySkipBufferHole=function(e){var t=this.config,r=this.hls,i=this.media;if(i===null)return 0;var a=i.currentTime,o=re.bufferInfo(i,a,0),l=a<o.start?o.start:o.nextStart;if(l){var d=o.len<=t.maxBufferHole,u=o.len>0&&o.len<1&&i.readyState<3,c=l-a;if(c>0&&(d||u)){if(c>t.maxBufferHole){var f=this.fragmentTracker,v=!1;if(a===0){var p=f.getAppendedFrag(0,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 D=new Error("fragment loaded with buffer holes, seeking from "+a+" to "+C);r.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:H.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:D,reason:D.message,frag:e})}return C}}return 0},n._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(r!==null){var a=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var o=a+(i+1)*e.nudgeOffset,l=new Error("Nudging 'currentTime' from "+a+" to "+o);P.warn(l.message),r.currentTime=o,t.trigger(T.ERROR,{type:Z.MEDIA_ERROR,details:H.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:H.BUFFER_STALLED_ERROR,error:d,fatal:!0})}}},s}(),Rl=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}fe(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=he,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=ft},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=he;break}break;case Ir:var o,l=self.performance.now(),d=this.retryDate;(!d||l>=d||(o=this.media)!=null&&o.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=he)}this.state===he&&this.doTickIdle(),this.onTickEnd()},e.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},e.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,i=this.levels,a=this.media,o=t.config,l=t.nextLoadLevel;if(r!==null&&(a||!this.startFragRequested&&o.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&i!=null&&i[l]){var 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=qi)}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)!==ce){var b,C=((b=this.backtrackFragment)!=null?b:y).sn-v.startSN,D=v.fragments[C-1];D&&y.cc===D.cc&&(y=D,this.fragmentTracker.removeFragment(D))}else this.backtrackFragment&&u.len&&(this.backtrackFragment=null);if(y&&this.isLoopLoading(y,A)){if(!y.gap){var O=this.audioOnly&&!this.altAudio?tt:rt,U=(O===rt?this.videoBuffer:this.mediaBuffer)||this.media;U&&this.afterBufferFlushed(U,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===Y||a===se?t.sn==="initSegment"?this._loadInitSegment(t,r):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,i)):this.clearTrackerIfNeeded(t)},e.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,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);a&&a.start>1&&this.flushMainBuffer(0,a.start-1);var o=this.getLevelDetails();if(o!=null&&o.live){var l=this.getMainFwdBufferInfo();if(!l||l.len<2*o.targetduration)return}if(!r.paused&&t){var d=t[this.hls.nextLoadLevel],u=this.fragLastKbps;i=u&&this.fragCurrent?this.fragCurrent.duration*d.maxBitrate/(1e3*u)+1:0}else i=0;var c=this.getBufferedFrag(r.currentTime+i);if(c){var f=this.followingBufferedFrag(c);if(f){this.abortCurrentFrag();var v=f.maxStartPTS?f.maxStartPTS:f.start,p=f.duration,E=Math.max(c.end,v+Math.min(Math.max(p-this.config.maxFragLookUpTolerance,.5*p),.75*p));this.flushMainBuffer(E,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 gr:case Dr:case Ir:case mr:case Nn:this.state=he}this.nextLoadPosition=this.getLoadPosition()},e.flushMainBuffer=function(t,r){s.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},e.onMediaAttached=function(t,r){s.prototype.onMediaAttached.call(this,t,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new wl(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;$(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.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1},e.onManifestParsed=function(t,r){var i,a,o,l=!1,d=!1;r.levels.forEach(function(u){(i=u.audioCodec)&&(i.indexOf("mp4a.40.2")!==-1&&(l=!0),i.indexOf("mp4a.40.5")!==-1&&(d=!0))}),this.audioCodecSwitch=l&&d&&typeof((o=ps())==null||(a=o.prototype)==null?void 0:a.changeType)!="function",this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},e.onLevelLoading=function(t,r){var i=this.levels;if(i&&this.state===he){var a=i[r.level];(!a.details||a.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(a.details))&&(this.state=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+"]"+(l.lastPartSn?"[part-"+l.lastPartSn+"-"+l.lastPartIndex+"]":"")+", cc ["+l.startCC+", "+l.endCC+"] duration:"+d);var u=a[o],c=this.fragCurrent;!c||this.state!==Dr&&this.state!==Ir||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=he}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,f),this.tick()}else this.warn("Levels were reset while loading level "+o)},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.levels;if(l){var 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 Fs(this.hls,qe,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),A=a?a.index:-1,y=A!==-1,b=new ie(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===Nn&&(this.state=he));var o=a?a.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,a)}},e.onError=function(t,r){var i;if(r.fatal)this.state=hi;else switch(r.details){case H.FRAG_GAP:case H.FRAG_PARSING_ERROR:case H.FRAG_DECRYPT_ERROR:case H.FRAG_LOAD_ERROR:case H.FRAG_LOAD_TIMEOUT:case H.KEY_LOAD_ERROR:case H.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(qe,r);break;case H.LEVEL_LOAD_ERROR:case H.LEVEL_LOAD_TIMEOUT:case H.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==fi||((i=r.context)==null?void 0:i.type)!==hr||(this.state=he);break;case H.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case H.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.checkBuffer=function(){var t=this.media,r=this.gapController;if(t&&r&&t.readyState){if(this.loadedmetadata||!re.getBuffered(t).length){var i=this.state!==he?this.fragCurrent:null;r.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}},e.onFragLoadEmergencyAborted=function(){this.state=he,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},e.onBufferFlushed=function(t,r){var i=r.type;if(i!==tt||this.audioOnly&&!this.altAudio){var a=(i===rt?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=re.getBuffered(t),o=(a.length?a.start(0):0)-i;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+o+" to match buffer start"),i+=o,this.startPosition=i),this.log("seek to target start position "+i+" from current time "+r),t.currentTime=i}}},e._getAudioCodec=function(t){var r=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r=r.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),r},e._loadBitrateTestFrag=function(t,r){var i=this;t.bitrateTest=!0,this._doFragLoad(t,r).then(function(a){var o=i.hls;if(a&&!i.fragContextChanged(t)){r.fragmentError=0,i.state=he,i.startFragRequested=!1,i.bitrateTest=!1;var l=t.stats;l.parsing.start=l.parsing.end=l.buffering.start=l.buffering.end=self.performance.now(),o.trigger(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=mr,A){if(A!=null&&A.tracks){var C=u.initSegment||u;this._bufferInitSegment(f,A.tracks,C,l),a.trigger(T.FRAG_PARSING_INIT_SEGMENT,{frag:C,id:i,tracks:A.tracks})}var D=A.initPTS,O=A.timescale;$(D)&&(this.initPTS[u.cc]={baseTime:D,timescale:O},a.trigger(T.INIT_PTS_FOUND,{frag:u,id:i,initPTS:D,timescale:O}))}if(v&&o.independent!==!1){if(y){var U=v.startPTS,K=v.endPTS,z=v.startDTS,j=v.endDTS;if(c)c.elementaryStreams[v.type]={startPTS:U,endPTS:K,startDTS:z,endDTS:j};else if(v.firstKeyFrame&&v.independent&&l.id===1&&(this.couldBacktrack=!0),v.dropped&&v.independent){var V=this.getMainFwdBufferInfo();if((V?V.end:this.getLoadPosition())+this.config.maxBufferHole<(v.firstKeyFramePTS?v.firstKeyFramePTS:U)-this.config.maxBufferHole)return void this.backtrack(u);u.setElementaryStreamInfo(v.type,u.start,K,u.start,j,!0)}u.setElementaryStreamInfo(v.type,U,K,z,j),this.backtrackFragment&&(this.backtrackFragment=u),this.bufferFragmentData(v,u,c,l)}}else if(o.independent===!1)return void this.backtrack(u);if(b){var te=b.startPTS,J=b.endPTS,de=b.startDTS,_e=b.endDTS;c&&(c.elementaryStreams[tt]={startPTS:te,endPTS:J,startDTS:de,endDTS:_e}),u.setElementaryStreamInfo(tt,te,J,de,_e),this.bufferFragmentData(b,u,c,l)}if(y&&E!=null&&(r=E.samples)!=null&&r.length){var ue={id:i,frag:u,details:y,samples:E.samples};a.trigger(T.FRAG_PARSING_METADATA,ue)}if(y&&p){var pe={id:i,frag:u,details:y,samples:p.samples};a.trigger(T.FRAG_PARSING_USERDATA,pe)}}}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i,a){var o=this;if(this.state===mr){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=he},e.checkFragmentChanged=function(){var t=this.media,r=null;if(t&&t.readyState>1&&t.seeking===!1){var i=t.currentTime;if(re.isBuffered(t,i)?r=this.getAppendedFrag(i):re.isBuffered(t,i+.1)&&(r=this.getAppendedFrag(i+.1)),r){this.backtrackFragment=null;var a=this.fragPlaying,o=r.level;a&&r.sn===a.sn&&a.level===o&&r.urlId===a.urlId||(this.fragPlaying=r,this.hls.trigger(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&&$(r)&&$(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}(ga),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}(),Dl=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}(),Il=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 Dl(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;$(a)&&$(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,D=b[e.level],O=l.total||Math.max(l.loaded,Math.round(d*D.maxBitrate/8)),U=u-E;U<1&&A&&(U=Math.min(u,8*l.loaded/y));var K=A?1e3*l.loaded/U:0,z=K?(O-l.loaded)/K:8*O/y+f/1e3;if(!(z<=p)){var j,V=K?8*K:y,te=Number.POSITIVE_INFINITY;for(j=e.level-1;j>C;j--){var J=b[j].maxBitrate;if((te=this.getTimeToLoadFrag(f/1e3,V,d*J,!b[j].details))<p)break}te>=z||te>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
27
|
Time to underbuffer: `+p.toFixed(3)+` s
|
|
28
|
-
Estimated load time for current fragment: `+
|
|
29
|
-
Estimated load time for down switch fragment: `+
|
|
28
|
+
Estimated load time for current fragment: `+z.toFixed(3)+` s
|
|
29
|
+
Estimated load time for down switch fragment: `+te.toFixed(3)+` s
|
|
30
30
|
TTFB estimate: `+E+`
|
|
31
|
-
Current BW estimate: `+(
|
|
31
|
+
Current BW estimate: `+($(y)?(y/1024).toFixed(3):"Unknown")+` Kb/s
|
|
32
32
|
New BW estimate: `+(this.bwEstimator.getEstimate()/1024).toFixed(3)+` Kb/s
|
|
33
|
-
Aborting and switching to level `+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
|
|
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,D=r;D>=t;D--){var O=f[D];if(!O||E&&O.codecSet!==E)O&&(b=Math.min(D,b),C=Math.max(D,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 U=O.details,K=(u?U==null?void 0:U.partTarget:U==null?void 0:U.averagetargetduration)||A,z=void 0;z=D<=c?a*e:o*e;var j=f[D].maxBitrate,V=this.getTimeToLoadFrag(y,z,j*K,U===void 0);if(P.trace("[abr] level:"+D+" adjustedbw-bitrate:"+Math.round(z-j)+" avgDuration:"+K.toFixed(1)+" maxFetchDuration:"+i.toFixed(1)+" fetchDuration:"+V.toFixed(1)),z>j&&(V===0||!$(V)||p&&!this.bitrateTestDelay||V<i))return D}}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}(),Ns=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}(),Cl=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[audio-stream-controller]",Ht)||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}fe(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===ji&&this.tick()}},e.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=ft);var r=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),r>0&&t===-1?(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r,this.state=he):(this.loadedmetadata=!1,this.state=Qr),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.doTick=function(){switch(this.state){case he:this.doTickIdle();break;case Qr: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=ji}break;case Ir: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=he);break;case ji: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=Dr;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=re.bufferInfo(this.mediaBuffer,A,this.config.maxBufferHole);ci(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=he}this.onTickEnd()},e.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=he)},e.resetLoadingState=function(){this.clearWaitingFragment(),s.prototype.resetLoadingState.call(this)},e.onTickEnd=function(){var t=this.media;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)},e.doTickIdle=function(){var t=this.hls,r=this.levels,i=this.media,a=this.trackId,o=t.config;if(r!=null&&r[a]&&(i||!this.startFragRequested&&o.startFragPrefetch)){var l=r[a],d=l.details;if(!d||d.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(d))this.state=Qr;else{var u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,tt,Ht));var c=this.getFwdBufferInfo(u,Ht);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=qi);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 D=this.getNextFragment(b,d),O=!1;if(D&&this.isLoopLoading(D,b)&&(O=!!D.gap,D=this.getNextFragmentLoopLoading(D,d,c,qe,A)),D){var U=p&&D.start>p.end+d.targetduration;if(U||(p==null||!p.len)&&c.len){var K=this.getAppendedFrag(D.start,qe);if(K===null||(O||(O=!!K.gap||!!U&&p.len===0),U&&!O||O&&c.nextStart&&c.nextStart<K.end))return}this.loadFragment(D,l,b)}else this.bufferFlushed=!0}}}}},e.getMaxBufferLength=function(t){var r=s.prototype.getMaxBufferLength.call(this);return t?Math.min(Math.max(r,t),this.config.maxMaxBufferLength):r},e.onMediaDetaching=function(){this.videoBuffer=null,s.prototype.onMediaDetaching.call(this)},e.onAudioTracksUpdated=function(t,r){var i=r.audioTracks;this.resetTransmuxer(),this.levels=i.map(function(a){return new Vr(a)})},e.onAudioTrackSwitching=function(t,r){var i=!!r.url;this.trackId=r.id;var a=this.fragCurrent;a&&(a.abortRequests(),this.removeUnbufferedFrags(a.start)),this.resetLoadingState(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.switchingTrack=r,this.state=he):(this.switchingTrack=null,this.bufferedTrack=r,this.state=ft),this.tick()},e.onManifestLoading=function(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1},e.onLevelLoaded=function(t,r){this.mainDetails=r.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(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+"]"+(o.lastPartSn?"[part-"+o.lastPartSn+"-"+o.lastPartIndex+"]":"")+",duration:"+o.totalduration);var d=a[l],u=0;if(o.live||(i=d.details)!=null&&i.live){var c=this.mainDetails;if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed||!c)return;!d.details&&o.hasProgramDateTime&&c.hasProgramDateTime?(dt(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!==Qr||this.waitForCdnTuneIn(o)||(this.state=he),this.tick()}else this.warn("Audio tracks were reset while loading level "+l)}else this.cachedTrackLoadedData=r},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.config,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 Fs(this.hls,Ht,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 ie(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 Ns,complete:!1}).cache.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=ji}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===Ht)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,G({},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=hi;else switch(r.details){case H.FRAG_GAP:case H.FRAG_PARSING_ERROR:case H.FRAG_DECRYPT_ERROR:case H.FRAG_LOAD_ERROR:case H.FRAG_LOAD_TIMEOUT:case H.KEY_LOAD_ERROR:case H.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Ht,r);break;case H.AUDIO_TRACK_LOAD_ERROR:case H.AUDIO_TRACK_LOAD_TIMEOUT:case H.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==Qr||((i=r.context)==null?void 0:i.type)!==Ot||(this.state=he);break;case H.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 H.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.onBufferFlushed=function(t,r){r.type===tt&&(this.bufferFlushed=!0,this.state===qi&&(this.state=he))},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=mr,this.switchingTrack&&v&&this.completeAudioSwitch(this.switchingTrack),A!=null&&A.tracks){var y=u.initSegment||u;this._bufferInitSegment(A.tracks,y,l),a.trigger(T.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:i,tracks:A.tracks})}if(v){var b=v.startPTS,C=v.endPTS,D=v.startDTS,O=v.endDTS;c&&(c.elementaryStreams[tt]={startPTS:b,endPTS:C,startDTS:D,endDTS:O}),u.setElementaryStreamInfo(tt,b,C,D,O),this.bufferFragmentData(v,u,c,l)}if(E!=null&&(r=E.samples)!=null&&r.length){var U=W({id:i,frag:u,details:f},E);a.trigger(T.FRAG_PARSING_METADATA,U)}if(p){var K=W({id:i,frag:u,details:f},p);a.trigger(T.FRAG_PARSING_USERDATA,K)}}else this.fragmentTracker.removeFragment(u)}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i){if(this.state===mr){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===Y||o===se?t.sn==="initSegment"?this._loadInitSegment(t,r):(a=r.details)!=null&&a.live&&!this.initPTS[t.cc]?(this.log("Waiting for video PTS in continuity counter "+t.cc+" of live stream before loading audio fragment "+t.sn+" of level "+this.trackId),this.state=ji):(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,G({},t))},n}(ga),Pl=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}fe(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===Ot&&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,G({},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:H.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}},e.findTrackId=function(t){for(var r=this.tracksInGroup,i=0;i<r.length;i++){var a=r[i];if((!this.selectDefaultTrack||a.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===a.attrs["STABLE-RENDITION-ID"]||t.name===a.name&&t.lang===a.lang))return a.id}return-1},e.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,a=r.groupId,o=r.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("loading audio-track playlist "+i+' "'+r.name+'" lang:'+r.lang+" group:"+a),this.clearTimer(),this.hls.trigger(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}(R);function Us(s,n){if(s.length!==n.length)return!1;for(var e=0;e<s.length;e++)if(!xl(s[e].attrs,n[e].attrs))return!1;return!0}function xl(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 Ol=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}fe(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=he,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},e.onMediaDetaching=function(){this.tracksBuffered=[],s.prototype.onMediaDetaching.call(this)},e.onLevelLoaded=function(t,r){this.mainDetails=r.details},e.onSubtitleFragProcessed=function(t,r){var i=r.frag,a=r.success;if(this.fragPrevious=i,this.state=he,a){var o=this.tracksBuffered[this.currentTrackId];if(o){for(var l,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!==ft&&(this.state=he))},e.onSubtitleTracksUpdated=function(t,r){var i=this,a=r.subtitleTracks;Us(this.levels,a)?this.levels=a.map(function(o){return new Vr(o)}):(this.tracksBuffered=[],this.levels=a.map(function(o){var l=new Vr(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&&Wr(a,c=v.start):a.hasProgramDateTime&&f.hasProgramDateTime?(dt(a,f),c=a.fragments[0].start):v&&Wr(a,c=v.start)}u.details=a,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(u.details,c),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===he&&(zr(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:H.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=he})}},e.doTick=function(){if(this.media){if(this.state===he){var t=this.currentTrackId,r=this.levels,i=r[t];if(!r.length||!i||!i.details)return;var a=i.details,o=a.targetduration,l=this.config,d=this.getLoadPosition(),u=re.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],d-o,l.maxBufferHole),c=u.end,f=u.len,v=this.getFwdBufferInfo(this.media,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=zr(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)===Y&&this.loadFragment(y,i,c)}}else this.state=he},e.getMaxBufferLength=function(t){var r=s.prototype.getMaxBufferLength.call(this);return t?Math.max(r,t):r},e.loadFragment=function(t,r,i){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t,r):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,i))},q(n,[{key:"mediaBufferTimeRanges",get:function(){return new Ml(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(ga),Ml=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)}}},Fl=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}fe(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),Ra(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===$t&&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=Ra(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=Ra(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}(R);function Ra(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 Nl=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}(),Bs=ai(),Gs=/([ha]vc.)(?:\.[^.,]+)+/,Ul=function(){function s(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var r=t.media,i=t.mediaSource;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_LOADING,this.onManifestLoading,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_LOADING,this.onManifestLoading,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 Nl(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},n.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},n.onManifestParsed=function(e,t){var r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,P.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},n.onMediaAttaching=function(e,t){var r=this.media=t.media;if(r&&Bs){var i=this.mediaSource=new Bs;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(Gs,"$1"),E=(c||u).replace(Gs,"$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,D={execute:function(){if(v.executeStart=self.performance.now(),b){var O=r.sourceBuffer[d];if(O){var U=C-O.timestampOffset;Math.abs(U)>=.1&&(P.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+C+" (delta: "+U+") 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 U=r.sourceBuffer,K={};for(var z in U)K[z]=re.getBuffered(U[z]);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 U={type:Z.MEDIA_ERROR,parent:u.type,details:H.BUFFER_APPEND_ERROR,frag:u,part:c,chunkMeta:f,error:O,err:O,fatal:!1};O.code===DOMException.QUOTA_EXCEEDED_ERR?U.details=H.BUFFER_FULL_ERROR:(r.appendError++,U.details=H.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(P.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),U.fatal=!0)),i.trigger(T.ERROR,U)}};a.append(D,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[ii]?o.push("audiovideo"):(l[tt]&&o.push("audio"),l[rt]&&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($(o)&&!(o<0)){var l=r.currentTime,d=t.levelTargetDuration,u=Math.max(o,d),c=Math.floor(l/d)*d-u;a.forEach(function(f){var v=i[f];if(v){var p=re.getBuffered(v);if(p.length>0&&c>p.start(0)){if(e.trigger(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=$(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||!$(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:H.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:H.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:H.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=$(i.duration)?i.duration:1/0,u=$(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}(),Hs={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},Ks=function(s){var n=s;return Hs.hasOwnProperty(s)&&(n=Hs[s]),String.fromCharCode(n)},$r=15,yr=100,Bl={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Gl={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Hl={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Kl={25:2,26:4,29:6,30:8,31:10,27:13,28:15},ql=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],jl=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}(),Zr=function(s){for(var n=[],e=0;e<s.length;e++)n.push(s[e].toString(16));return n},qs=function(){function s(e,t,r,i,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=a||!1}var n=s.prototype;return n.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},n.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}},n.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},n.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},n.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},n.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},s}(),Vl=function(){function s(e,t,r,i,a,o){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new qs(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}(),Yl=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<yr;t++)this.chars.push(new Vl);this.logger=e,this.pos=0,this.currPenState=new qs}var n=s.prototype;return n.equals=function(e){for(var t=!0,r=0;r<yr;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<yr;t++)this.chars[t].copy(e.chars[t])},n.isEmpty=function(){for(var e=!0,t=0;t<yr;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>yr&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=yr)},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=Ks(e);this.pos>=yr?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<yr;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<yr;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}(),Da=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<$r;t++)this.rows.push(new Yl(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<$r;e++)this.rows[e].clear();this.currRow=14},n.equals=function(e){for(var t=!0,r=0;r<$r;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<$r;t++)this.rows[t].copy(e.rows[t])},n.isEmpty=function(){for(var e=!0,t=0;t<$r;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<$r;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<$r;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}(),js=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 Da(r),this.nonDisplayedMemory=new Da(r),this.lastOutputScreen=new Da(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}(),Vs=function(){function s(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new jl;this.channels=[null,new js(e,t,i),new js(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,"["+Zr([t[l],t[l+1]])+"] -> ("+Zr([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 "+Zr([i,a])+" orig: "+Zr([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(Ys(e,t,r))return mi(null,null,r),this.logger.log(3,"Repeated command ("+Zr([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 ("+Zr([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(Ys(e,t,i))return mi(null,null,i),!0;var a=e<=23?1:2;r=t>=64&&t<=95?a===1?Bl[e]:Hl[e]:a===1?Gl[e]:Kl[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 '"+Ks(i)+"' in channel "+r),a=[i]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var l=Zr(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=ql[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 Ys(s,n,e){return e.a===s&&e.b===n}var qn=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}(),Ia=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",D="start",O=50,U="middle",K=50,z="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(te){return e(s,te)}(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 D},set:function(j){var V=t(j);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");D=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 U},set:function(j){var V=t(j);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");U=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 z},set:function(j){var V=t(j);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");z=V,this.hasBeenReset=!0}})),d.displayState=void 0}return i.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},i}(),Wl=function(){function s(){}return s.prototype.decode=function(n,e){if(!n)return"";if(typeof n!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(n))},s}();function Ws(s){function n(t,r,i,a){return 3600*(0|t)+60*(0|r)+(0|i)+parseFloat(a||0)}var e=s.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?n(e[2],e[3],0,e[4]):n(e[1],e[2],e[3],e[4]):null}var zl=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 zs(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 Ca=new Ia(0,0,""),jn=Ca.align==="middle"?"middle":"center";function Xl(s,n,e){var t=s;function r(){var a=Ws(s);if(a===null)throw new Error("Malformed timestamp: "+t);return s=s.replace(/^[^\sa-zA-Z-]+/,""),a}function i(){s=s.replace(/^\s+/,"")}if(i(),n.startTime=r(),i(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+t);s=s.slice(3),i(),n.endTime=r(),i(),function(a,o){var l=new zl;zs(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",jn,"end"]);break;case"position":v=f.split(","),l.percent(c,v[0]),v.length===2&&l.alt("positionAlign",v[1],["start",jn,"end","line-left","line-right","auto"]);break;case"size":l.percent(c,f);break;case"align":l.alt(c,f,["start",jn,"end","left","right"])}},/:/,/\s/),o.region=l.get("region",null),o.vertical=l.get("vertical","");var d=l.get("line","auto");d==="auto"&&Ca.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",jn);var u=l.get("position","auto");u==="auto"&&Ca.position===50&&(u=o.align==="start"||o.align==="left"?0:o.align==="end"||o.align==="right"?100:50),o.position=u}(s,n)}function Xs(s){return s.replace(/<br(?: \/)?>/gi,`
|
|
35
|
+
`)}var Ql=function(){function s(){this.state="INITIAL",this.buffer="",this.decoder=new Wl,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=Xs(d);u<d.length&&d[u]!=="\r"&&d[u]!==`
|
|
36
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)?
|
|
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)?zs(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 Ia(0,0,""),t.state="CUE",i.indexOf("-->")===-1){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Xl(i,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var l=i.indexOf("-->")!==-1;if(!i||l&&(o=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
|
|
38
38
|
`),t.cue.text+=i;continue;case"BADCUE":i||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},n.flush=function(){var e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
|
|
39
39
|
|
|
40
|
-
`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this},s}(),
|
|
40
|
+
`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this},s}(),Jl=/\r\n|\n\r|\n|\r/g,Pa=function(s,n,e){return e===void 0&&(e=0),s.slice(e,e+n.length)===n},xa=function(s){for(var n=5381,e=s.length;e;)n=33*n^s.charCodeAt(--e);return(n>>>0).toString()};function Oa(s,n,e){return xa(s.toString())+xa(n.toString())+xa(e)}function $l(s,n,e,t,r,i,a){var o,l,d,u=new Ql,c=Bt(new Uint8Array(s)).trim().replace(Jl,`
|
|
41
41
|
`).split(`
|
|
42
|
-
`),f=[],v=(o=n.baseTime,(l=n.timescale)===void 0&&(l=1),
|
|
43
|
-
`)}),u.flush()}var
|
|
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((
|
|
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.1"}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=`
|
|
42
|
+
`),f=[],v=(o=n.baseTime,(l=n.timescale)===void 0&&(l=1),Ta(o,9e4,1/l)),p="00:00.000",E=0,A=0,y=!0;u.oncue=function(b){var C=e[t],D=e.ccOffset,O=(E-v)/9e4;C!=null&&C.new&&(A!==void 0?D=e.ccOffset=C.start:function(j,V,te){var J=j[V],de=j[J.prevCC];if(!de||!de.new&&J.new)return j.ccOffset=j.presentationOffset=J.start,void(J.new=!1);for(;(_e=de)!=null&&_e.new;){var _e;j.ccOffset+=J.start-de.start,J.new=!1,de=j[(J=de).prevCC]}j.presentationOffset=te}(e,t,O)),O&&(D=O-e.presentationOffset);var U=b.endTime-b.startTime,K=zt(9e4*(b.startTime+D-A),9e4*r)/9e4;b.startTime=Math.max(K,0),b.endTime=Math.max(K+U,0);var z=b.text.trim();b.text=decodeURIComponent(encodeURIComponent(z)),b.id||(b.id=Oa(b.startTime,b.endTime,z)),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(Pa(b,"X-TIMESTAMP-MAP=")){y=!1,b.slice(16).split(",").forEach(function(C){Pa(C,"LOCAL:")?p=C.slice(6):Pa(C,"MPEGTS:")&&(E=parseInt(C.slice(7)))});try{A=function(C){var D=parseInt(C.slice(-3)),O=parseInt(C.slice(-6,-4)),U=parseInt(C.slice(-9,-7)),K=C.length>9?parseInt(C.substring(0,C.indexOf(":"))):0;if(!($(D)&&$(O)&&$(U)&&$(K)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+C);return D+=1e3*O,(D+=6e4*U)+36e5*K}(p)/1e3}catch(C){d=C}return}b===""&&(y=!1)}u.parse(b+`
|
|
43
|
+
`)}),u.flush()}var Ma="stpp.ttml.im1t",Qs=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Js=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Zl={left:"start",center:"center",right:"end",start:"start",end:"end"};function $s(s,n,e,t){var r=Ne(new Uint8Array(s),["mdat"]);if(r.length!==0){var i,a,o,l,d=r.map(function(c){return Bt(c)}),u=(i=n.baseTime,a=1,(o=n.timescale)===void 0&&(o=1),l===void 0&&(l=!1),Ta(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,U){return O[U]=p.getAttribute("ttp:"+U)||E[U],O},{}),y=p.getAttribute("xml:space")!=="preserve",b=Zs(Fa(p,"styling","style")),C=Zs(Fa(p,"layout","region")),D=Fa(p,"body","[begin]");return[].map.call(D,function(O){var U=eo(O,y);if(!U||!O.hasAttribute("begin"))return null;var K=Ua(O.getAttribute("begin"),A),z=Ua(O.getAttribute("dur"),A),j=Ua(O.getAttribute("end"),A);if(K===null)throw to(O);if(j===null){if(z===null)throw to(O);j=K+z}var V=new Ia(K-v,j-v,U);V.id=Oa(V.startTime,V.endTime,V.text);var te=function(_e,ue,pe){var Se="http://www.w3.org/ns/ttml#styling",be=null,De=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],Me=_e!=null&&_e.hasAttribute("style")?_e.getAttribute("style"):null;return Me&&pe.hasOwnProperty(Me)&&(be=pe[Me]),De.reduce(function(Ue,Ve){var Ft=Na(ue,Se,Ve)||Na(_e,Se,Ve)||Na(be,Se,Ve);return Ft&&(Ue[Ve]=Ft),Ue},{})}(C[O.getAttribute("region")],b[O.getAttribute("style")],b),J=te.textAlign;if(J){var de=Zl[J];de&&(V.lineAlign=de),V.align=J}return W(V,te),V}).filter(function(O){return O!==null})}(c,u))})}catch(c){t(c)}}else t(new Error("Could not parse IMSC1 mdat"))}function Fa(s,n,e){var t=s.getElementsByTagName(n)[0];return t?[].slice.call(t.querySelectorAll(e)):[]}function Zs(s){return s.reduce(function(n,e){var t=e.getAttribute("xml:id");return t&&(n[t]=e),n},{})}function eo(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?eo(t,n):n?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function Na(s,n,e){return s&&s.hasAttributeNS(n,e)?s.getAttributeNS(n,e):null}function to(s){return new Error("Could not parse ttml timestamp "+s)}function Ua(s,n){if(!s)return null;var e=Ws(s);return e===null&&(Qs.test(s)?e=function(t,r){var i=Qs.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):Js.test(s)&&(e=function(t,r){var i=Js.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 eu=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 qn(this,"textTrack1"),r=new qn(this,"textTrack2"),i=new qn(this,"textTrack3"),a=new qn(this,"textTrack4");this.cea608Parser1=new Vs(1,t,r),this.cea608Parser2=new Vs(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]),Hr(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===Ma});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){if(Us(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(tu(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===Ma?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;$s(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;$l((i=e.initSegment)!=null&&i.data?dr(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||$s(t,this.initPTS[e.cc],function(){i.textCodec=Ma,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 In(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 Mi(d[c],r,i)})}if(this.config.renderTextTracksNatively&&r===0&&a!==void 0){var u=this.textTracks;Object.keys(u).forEach(function(c){return Mi(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 tu(s,n){return!!s&&s.label===n.name&&!(s.textTrack1||s.textTrack2)}var ru=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}(),iu=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}(),Vn="[eme]",ro=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,Vn),this.log=P.log.bind(P,Vn),this.warn=P.warn.bind(P,Vn),this.error=P.error.bind(P,Vn),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_LOADING,this.onManifestLoading,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_LOADING,this.onManifestLoading,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===Fe.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 Xt?v:new Xt({type:Z.KEY_SYSTEM_ERROR,details:H.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 Fe.FAIRPLAY:p=["cenc","sinf"];break;case Fe.WIDEVINE:case Fe.PLAYREADY:p=["cenc"];break;case Fe.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: '+Vt(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 Vt(e.keyId)},n.updateKeySession=function(e,t){var r,i=e.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+Vt(((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(br).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 Xt?this.hls.trigger(T.ERROR,e.data):this.hls.trigger(T.ERROR,{type:Z.KEY_SYSTEM_ERROR,details:H.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=br(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 Xt({type:Z.KEY_SYSTEM_ERROR,details:H.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[Fe.FAIRPLAY]){var l=ot(new Uint8Array(i));try{var d=je(JSON.parse(l).sinf),u=Ri(new Uint8Array(d));if(!u)return;a=u.subarray(8,24),o=Fe.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 D={version:0,systemId:"",kids:null,data:null},O=new DataView(C),U=O.getUint32(0);if(C.byteLength!==U&&U>44||O.getUint32(4)!==1886614376||(D.version=O.getUint32(8)>>>24,D.version>1))return null;D.systemId=Vt(new Uint8Array(C,12,16));var K=O.getUint32(28);if(D.version===0){if(U-32<K)return null;D.data=new Uint8Array(C,32,K)}else if(D.version===1){D.kids=[];for(var z=0;z<K;z++)D.kids.push(new Uint8Array(C,32+16*z,16))}return D}(i);if(c===null)return;c.version===0&&c.systemId===Mr&&c.data&&(a=c.data.subarray(8,24)),o=function(C){if(C===Mr)return Fe.WIDEVINE}(c.systemId)}if(o&&a){for(var f=Vt(a),v=this.keyIdToKeySessionPromise,p=this.mediaKeySessions,E=v[f],A=function(){var C=p[y],D=C.decryptdata;if(D.pssh||!D.keyId)return"continue";var O=Vt(D.keyId);return f===O||D.uri.replace(/-/g,"").indexOf(f)!==-1?(E=v[O],delete v[O],D.pssh=new Uint8Array(i),D.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 D,O=C.keySystem,U=C.mediaKeys;t.throwIfDestroyed();var K=new Br("ISO-23001-7",f,(D=_r(O))!=null?D:"");return K.pssh=new Uint8Array(i),K.keyId=a,t.attemptSetMediaKeys(O,U).then(function(){t.throwIfDestroyed();var z=t.createMediaKeySessionContext({decryptdata:K,keySystem:O,mediaKeys:U});return t.generateRequestWithPreferredKeySession(z,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 Kn;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===Fe.FAIRPLAY&&(l.updateKeySession(e,gt("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 Xt({type:Z.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):y==="internal-error"?A(new Xt({type:Z.KEY_SYSTEM_ERROR,details:H.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 Xt({type:Z.KEY_SYSTEM_ERROR,details:H.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: '+Vt("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))+" session keyId: "+Vt(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 Xt({type:Z.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:p,response:G({url:l.url,data:void 0},f)},'"'+e+'" certificate request failed ('+i+"). Status: "+f.code+" ("+f.text+")"))},onTimeout:function(f,v,p){o(new Xt({type:Z.KEY_SYSTEM_ERROR,details:H.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 Xt({type:Z.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:l,fatal:!0},l.message))})})},n.renewLicense=function(e,t){var r=this;return this.requestLicense(e,new Uint8Array(t)).then(function(i){return r.updateKeySession(e,new Uint8Array(i)).catch(function(a){throw new Xt({type:Z.KEY_SYSTEM_ERROR,details:H.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 Xt({type:Z.KEY_SYSTEM_ERROR,details:H.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={},Br.clearKeyUriToKeyIdMap();var i=r.length;s.CDMCleanupPromise=Promise.all(r.map(function(a){return e.removeSession(a)}).concat(t==null?void 0:t.setMediaKeys(null).catch(function(a){e.log("Could not clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))}))).then(function(){i&&(e.log("finished closing key sessions and clearing media keys"),r.length=0)}).catch(function(a){e.log("Could not close sessions and clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))})},n.onManifestLoading=function(){this.keyFormatPromise=null},n.onManifestLoaded=function(e,t){var r=t.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var i=r.reduce(function(a,o){return a.indexOf(o.keyFormat)===-1&&a.push(o.keyFormat),a},[]);this.log("Selecting key-system from session-keys "+i.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(i)}},n.removeSession=function(e){var t=this,r=e.mediaKeysSession,i=e.licenseXhr;if(r){this.log("Remove licenses and keys and close session "+r.sessionId),r.onmessage=null,r.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);return a>-1&&this.mediaKeySessions.splice(a,1),r.remove().catch(function(o){t.log("Could not remove session: "+o)}).then(function(){return r.close()}).catch(function(o){t.log("Could not close session: "+o)})}},s}();ro.CDMCleanupPromise=void 0;var Xt=function(s){function n(e,t){var r;return(r=s.call(this,t)||this).data=void 0,e.error||(e.error=new Error(t)),r.data=e,e.err=e.error,r}return fe(n,s),n}(Ie(Error)),nu="m",Yn="a",Ba="v",Ga="av",io="i",au="tt",su=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:nu,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!==Ba&&d!==Yn&&d!=Ga||(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===io||t.ot===Ba||t.ot===Ga;if(this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){var i=s.toHeaders(t);if(!Object.keys(i).length)return;e.headers||(e.headers={}),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"?au:e.sn==="initSegment"?io:t==="audio"?Yn:t==="main"?this.hls.audioTracks.length?Ba:Ga:void 0},n.getTopBandwidth=function(e){var t,r=0,i=this.hls;if(e===Yn)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===Yn?this.audioBuffer:this.videoBuffer;return r&&t?1e3*re.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN},n.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function i(o){this.loader=void 0,this.loader=new r(o)}var a=i.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(o,l,d){t(o),this.loader.load(o,l,d)},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}(),ou=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)===m&&r.flags===_){var i=this.pathwayPriority,a=this.pathwayId;this.penalizedPathways[a]||(this.penalizedPathways[a]=performance.now()),!i&&this.levels&&(i=this.levels.reduce(function(o,l){return o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o},[])),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==a)}},n.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t):e},n.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(t){return e===t.pathwayId})},n.updatePathwayPriority=function(e){var t;this.pathwayPriority=e;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(function(c){i-r[c]>3e5&&delete r[c]});for(var a=0;a<e.length;a++){var o=e[a];if(!r[o]){if(o===this.pathwayId)return;var l=this.hls.nextLoadLevel,d=this.hls.levels[l];if((t=this.getLevelsForPathway(o)).length>0){this.log('Setting Pathway to "'+o+'"'),this.pathwayId=o,this.hls.trigger(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=ao(f.uri,f.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",u);var p=new Xe(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 Vr(v);return B(y,"audio",E),B(y,"text",A),y});r.push.apply(r,c),no(t.audioTracks,i,u,l),no(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"],D=y["PATHWAY-PRIORITY"];if(b)try{r.uri=new self.URL(b,t).href}catch{return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+b)}r.scheduleRefresh(r.uri||E.url),C&&r.clonePathways(C),D&&r.updatePathwayPriority(D)}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 no(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 Xe(o.attrs),o.url=o.attrs.URI=ao(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 ao(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 lu=/^age:\s*[\d.]+\s*$/im,so=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 st,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&&$(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;di(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(di(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=Hi(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&&lu.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}(),uu=/(\d+)-(\d+)\/(\d+)/,oo=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||du,this.controller=new self.AbortController,this.stats=new st}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&&$(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 cu(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 D=function(U){var K=uu.exec(U);if(K)return parseInt(K[2])-parseInt(K[1])+1}(C);if($(D))return D}var O=b.get("Content-Length");if(O)return parseInt(O)}(p.headers)||a.total,l&&$(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&&!$(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 Ns,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 du(s,n){return new self.Request(s.url,n)}var cu=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 fe(n,s),n}(Ie(Error)),hu=/\s/,fu=G(G({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:so,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Il,bufferController:Ul,capLevelController:ru,errorController:I,fpsController:iu,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++)hu.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=Xs(l.trim()),E=Oa(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 In(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:Ol,subtitleTrackController:Fl,timelineController:eu,audioStreamController:Cl,audioTrackController:Pl,emeController:ro,cmcdController:su,contentSteeringController:ou});function Ha(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Ha):Object.keys(s).reduce(function(n,e){return n[e]=Ha(s[e]),n},{}):s}function vu(s){var n=s.loader;n!==oo&&n!==so?(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=oo,s.progressive=!0,s.enableSoftwareAES=!0,P.log("[config]: Progressive streaming enabled, using FetchLoader"))}var lo=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 Kn,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,Ye(e.debug||!1,"Hls instance");var t=this.config=function(te,J){if((J.liveSyncDurationCount||J.liveMaxLatencyDurationCount)&&(J.liveSyncDuration||J.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(J.liveMaxLatencyDurationCount!==void 0&&(J.liveSyncDurationCount===void 0||J.liveMaxLatencyDurationCount<=J.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(J.liveMaxLatencyDuration!==void 0&&(J.liveSyncDuration===void 0||J.liveMaxLatencyDuration<=J.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var de=Ha(te),_e=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(ue){var pe=(ue==="level"?"playlist":ue)+"LoadPolicy",Se=J[pe]===void 0,be=[];_e.forEach(function(De){var Me=ue+"Loading"+De,Ue=J[Me];if(Ue!==void 0&&Se){be.push(Me);var Ve=de[pe].default;switch(J[pe]={default:Ve},De){case"TimeOut":Ve.maxLoadTimeMs=Ue,Ve.maxTimeToFirstByteMs=Ue;break;case"MaxRetry":Ve.errorRetry.maxNumRetry=Ue,Ve.timeoutRetry.maxNumRetry=Ue;break;case"RetryDelay":Ve.errorRetry.retryDelayMs=Ue,Ve.timeoutRetry.retryDelayMs=Ue;break;case"MaxRetryTimeout":Ve.errorRetry.maxRetryDelayMs=Ue,Ve.timeoutRetry.maxRetryDelayMs=Ue}}}),be.length&&P.warn('hls.js config: "'+be.join('", "')+'" setting(s) are deprecated, use "'+pe+'": '+JSON.stringify(J[pe]))}),G(G({},de),J)}(s.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&vu(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 lt(this),E=new da(this),A=t.contentSteeringController,y=A?new A(this):null,b=this.levelController=new x(this,y),C=new le(this),D=new $e(this.config),O=this.streamController=new Rl(this,C,D);f.setStreamController(O),v.setStreamController(O);var U=[p,b,O];y&&U.splice(1,0,y),this.networkControllers=U;var K=[u,c,f,v,E,C];this.audioTrackController=this.createController(t.audioTrackController,U);var z=t.audioStreamController;z&&U.push(new z(this,C,D)),this.subtitleTrackController=this.createController(t.subtitleTrackController,U);var j=t.subtitleStreamController;j&&U.push(new j(this,C,D)),this.createController(t.timelineController,K),D.emeController=this.emeController=this.createController(t.emeController,K),this.cmcdController=this.createController(t.cmcdController,K),this.latencyController=this.createController(ca,K),this.coreComponents=K,U.push(d);var V=d.onErrorOut;typeof V=="function"&&this.on(T.ERROR,V,d)}s.isSupported=function(){return function(){var e=ai();if(!e)return!1;var t=ps(),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:H.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=at.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){Fi.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.1"}},{key:"Events",get:function(){return T}},{key:"ErrorTypes",get:function(){return Z}},{key:"ErrorDetails",get:function(){return H}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:fu},set:function(e){s.defaultConfig=e}}]),s}();return lo.defaultConfig=void 0,lo},typeof Eo=="object"&&typeof Qa!="undefined"?Qa.exports=M():typeof define=="function"&&define.amd?define(M):(S=typeof globalThis!="undefined"?globalThis:S||self).Hls=M()})(!1)});var yi=class{addEventListener(){}removeEventListener(){}dispatchEvent(k){return!0}};if(typeof DocumentFragment=="undefined"){class w extends yi{}globalThis.DocumentFragment=w}var Qi=class extends yi{},Ya=class extends yi{},Du={get(w){},define(w,k,S){},upgrade(w){},whenDefined(w){return Promise.resolve(Qi)}},Ji,Wa=class{constructor(k,S={}){Oe(this,Ji,void 0);ze(this,Ji,S==null?void 0:S.detail)}get detail(){return ne(this,Ji)}initCustomEvent(){}};Ji=new WeakMap;function Iu(w,k){return new Qi}var mo={document:{createElement:Iu},DocumentFragment,customElements:Du,CustomEvent:Wa,EventTarget:yi,HTMLElement:Qi,HTMLVideoElement:Ya},po=typeof window=="undefined"||typeof globalThis.customElements=="undefined",sr=po?mo:globalThis,za=po?mo.document:globalThis.document;var Qn=go(yo(),1),wo=go(To(),1),Cu=wo.default,Ut=Cu,$i=class extends Error{constructor(w,k=$i.MEDIA_ERR_CUSTOM,S,M){var N;super(w),this.name="MediaError",this.code=k,this.context=M,this.fatal=S!=null?S:k>=$i.MEDIA_ERR_NETWORK&&k<=$i.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(N=$i.defaultMessages[this.code])!=null?N:"")}},Nt=$i;Nt.MEDIA_ERR_ABORTED=1,Nt.MEDIA_ERR_NETWORK=2,Nt.MEDIA_ERR_DECODE=3,Nt.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Nt.MEDIA_ERR_ENCRYPTED=5,Nt.MEDIA_ERR_CUSTOM=100,Nt.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 Pu=w=>w==null,Ro=(w,k)=>Pu(k)?!1:w in k,$a={ANY:"any",MUTED:"muted"},ti={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},ri={MSE:"mse",NATIVE:"native"},Za={HEADER:"header",QUERY:"query",NONE:"none"},rs=Object.values(Za),Ei={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},es={HLS:Ei.M3U8},hd=Object.keys(es),fd=[...Object.values(Ei),"hls","HLS"],xr=(w,k,S,M,N=w)=>{N.addEventListener(k,S,M),w.addEventListener("teardown",()=>{N.removeEventListener(k,S)},{once:!0})};function xu(w,k,S){k&&S>k&&(S=k);for(let M=0;M<w.length;M++)if(w.start(M)<=S&&w.end(M)>=S)return!0;return!1}var Ou=w=>{let k=w.indexOf("?");if(k<0)return[w];let S=w.slice(0,k),M=w.slice(k);return[S,M]},Do=w=>{let k=w.type;if(k){let M=k.toUpperCase();return Ro(M,es)?es[M]:k}let{src:S}=w;return S?Mu(S):""},Io=w=>w==="VOD"?ti.ON_DEMAND:ti.LIVE,Co=w=>w==="EVENT"?Number.POSITIVE_INFINITY:w==="VOD"?Number.NaN:0,Mu=w=>{let k="";try{k=new URL(w).pathname}catch{console.error("invalid url")}let S=k.lastIndexOf(".");if(S<0)return"";let M=k.slice(S+1).toUpperCase();return Ro(M,Ei)?Ei[M]:""},Fu=Object.values($a),bo=w=>typeof w=="boolean"||typeof w=="string"&&Fu.includes(w),Nu=({autoplay:w},k,S)=>{let M=!1,N=!1,G=bo(w)?w:!!w,Q=()=>{M||xr(k,"playing",()=>{M=!0},{once:!0})};if(Q(),xr(k,"loadstart",()=>{M=!1,Q(),Ja(k,G)},{once:!0}),xr(k,"loadstart",()=>{S||(N=!Number.isFinite(k.duration)),Ja(k,G)},{once:!0}),S&&S.once(Ut.Events.LEVEL_LOADED,(q,ae)=>{var W;N=(W=ae.details.live)!=null?W:!1}),!G){let q=()=>{!N||(S!=null&&S.liveSyncPosition?k.currentTime=S.liveSyncPosition:Number.isFinite(k.seekable.end(0))&&(k.currentTime=k.seekable.end(0)))};S&&xr(k,"play",()=>{k.preload==="metadata"?S.once(Ut.Events.LEVEL_UPDATED,q):q()},{once:!0})}return q=>{M||(G=bo(q)?q:!!q,Ja(k,G))}},Ja=(w,k)=>{if(!k)return;let S=w.muted,M=()=>w.muted=S;switch(k){case $a.ANY:w.play().catch(()=>{w.muted=!0,w.play().catch(M)});break;case $a.MUTED:w.muted=!0,w.play().catch(M);break;default:w.play().catch(()=>{});break}},Uu=({preload:w,src:k},S,M)=>{let N=ge=>{ge!=null&&["","none","metadata","auto"].includes(ge)?S.setAttribute("preload",ge):S.removeAttribute("preload")};if(!M)return N(w),N;let G=!1,Q=!1,q=M.config.maxBufferLength,ae=M.config.maxBufferSize,W=ge=>{N(ge);let me=ge!=null?ge:S.preload;Q||me==="none"||(me==="metadata"?(M.config.maxBufferLength=1,M.config.maxBufferSize=1):(M.config.maxBufferLength=q,M.config.maxBufferSize=ae),fe())},fe=()=>{!G&&k&&(G=!0,M.loadSource(k))};return xr(S,"play",()=>{Q=!0,M.config.maxBufferLength=q,M.config.maxBufferSize=ae,fe()},{once:!0}),W(w),W};function Bu(w,k){k.on(Ut.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(N,{tracks:G})=>{G.forEach(Q=>{var q;let ae=(q=Q.subtitleTrack)!=null?q:Q.closedCaptions,W=k.subtitleTracks.findIndex(({lang:fe,name:ge,type:me})=>fe==(ae==null?void 0:ae.lang)&&ge===Q.label&&me.toLowerCase()===Q.kind);Po(w,Q.kind,Q.label,ae==null?void 0:ae.lang,`${Q.kind}${W}`)})});let S=()=>{var N;if(!k.subtitleTracks.length)return;let G=Array.from(w.textTracks).find(q=>q.id&&q.mode==="showing"&&["subtitles","captions"].includes(q.kind)),Q=`${(N=k.subtitleTracks[k.subtitleTrack])==null?void 0:N.type.toLowerCase()}${k.subtitleTrack}`;if(G&&(k.subtitleTrack<0||(G==null?void 0:G.id)!==Q)){let q=k.subtitleTracks.findIndex(({lang:ae,name:W,type:fe})=>ae==G.language&&W===G.label&&fe.toLowerCase()===G.kind);k.subtitleTrack=q}G&&(G==null?void 0:G.id)===Q&&G.cues&&Array.from(G.cues).forEach(q=>{G.addCue(q)})};w.textTracks.addEventListener("change",S),k.on(Ut.Events.CUES_PARSED,(N,{track:G,cues:Q})=>{let q=w.textTracks.getTrackById(G);if(!q)return;let ae=q.mode==="disabled";ae&&(q.mode="hidden"),Q.forEach(W=>{var fe;(fe=q.cues)!=null&&fe.getCueById(W.id)||q.addCue(W)}),ae&&(q.mode="disabled")}),k.once(Ut.Events.DESTROYING,()=>{w.textTracks.removeEventListener("change",S),w.querySelectorAll("track[data-removeondestroy]").forEach(N=>{N.remove()})});let M=()=>{Array.from(w.textTracks).forEach(N=>{var G,Q;if(!["subtitles","caption"].includes(N.kind)&&N.label==="thumbnails"){if(!((G=N.cues)!=null&&G.length)){let q=w.querySelector('track[label="thumbnails"]'),ae=(Q=q==null?void 0:q.getAttribute("src"))!=null?Q:"";q==null||q.removeAttribute("src"),setTimeout(()=>{q==null||q.setAttribute("src",ae)},0)}N.mode!=="hidden"&&(N.mode="hidden")}})};k.once(Ut.Events.MANIFEST_LOADED,M),k.once(Ut.Events.MEDIA_ATTACHED,M)}function Po(w,k,S,M,N){let G=document.createElement("track");return G.kind=k,G.label=S,M&&(G.srclang=M),N&&(G.id=N),G.track.mode=["subtitles","captions"].includes(k)?"disabled":"hidden",G.setAttribute("data-removeondestroy",""),w.append(G),G.track}var Zi="cuepoints",is=Object.freeze({label:Zi}),ns=(w,{label:k=Zi}=is)=>{var S;return(S=Array.from(w.querySelectorAll("track")).find(M=>M.track.label===k&&M.track.kind==="metadata"))==null?void 0:S.track};async function as(w,k,S=is){let M=ns(w,S);if(!M){let{label:N=Zi}=S;M=Po(w,"metadata",N),M.mode="hidden",await new Promise(G=>setTimeout(()=>G(void 0),0))}return M.mode!=="hidden"&&(M.mode="hidden"),[...k].sort(({time:N},{time:G})=>G-N).forEach(({time:N,value:G})=>{var Q,q;let ae=Array.prototype.findIndex.call(M==null?void 0:M.cues,Te=>Te.startTime>=N),W=(Q=M==null?void 0:M.cues)==null?void 0:Q[ae],fe=W?W.startTime:Number.isFinite(w.duration)?w.duration:Number.MAX_SAFE_INTEGER,ge=(q=M==null?void 0:M.cues)==null?void 0:q[ae-1];ge&&(ge.endTime=N);let me=new VTTCue(N,fe,JSON.stringify(G!=null?G:null));M.addCue(me)}),M}var xo=w=>({time:w.startTime,value:JSON.parse(w.text)});function Oo(w,k={label:Zi}){let S=ns(w,k);return S!=null&&S.cues?Array.from(S.cues,M=>xo(M)):[]}function ss(w,k={label:Zi}){var S,M;let N=ns(w,k);if(!((S=N==null?void 0:N.activeCues)!=null&&S.length))return;let{currentTime:G}=w,Q=Array.prototype.find.call((M=N.activeCues)!=null?M:[],({startTime:q,endTime:ae})=>q<=G&&ae>G);return xo(Q)}async function Gu(w,k=is){return new Promise(S=>{xr(w,"loadstart",async()=>{let M=await as(w,[],k);xr(w,"cuechange",()=>{let N=ss(w);if(N){let G=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:N});w.dispatchEvent(G)}},{},M),S(M)})})}function Mo(w,k){if(k){let S=k.playingDate;if(S!=null)return new Date(S.getTime()-w.currentTime*1e3)}return typeof w.getStartDate=="function"?w.getStartDate():new Date(NaN)}function Fo(w,k){if(k&&k.playingDate)return k.playingDate;if(typeof w.getStartDate=="function"){let S=w.getStartDate();return new Date(S.getTime()+w.currentTime*1e3)}return new Date(NaN)}var Hu=async w=>fetch(w).then(k=>k.text()).then(k=>{let S=k.split(`
|
|
46
|
+
`).find((M,N,G)=>N&&G[N-1].startsWith("#EXT-X-STREAM-INF"));return fetch(S).then(M=>M.text()).then(M=>M.split(`
|
|
47
|
+
`))}),Ku=w=>{var k,S;let M=(S=((k=w.find(q=>q.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?k:"").split(":")[1])==null?void 0:S.trim(),N=Io(M),G=Co(M),Q;if(N===ti.LIVE){let q=w.find(ae=>ae.startsWith("#EXT-X-PART-INF"));q?Q=+q.split(":")[1].split("=")[1]*2:Q=+w.find(ae=>ae.startsWith("#EXT-X-TARGETDURATION")).split(":")[1]*3}return{streamType:N,targetLiveWindow:G,liveEdgeStartOffset:Q}},_o=async(w,k)=>{var S,M,N;let G=await Hu(w),{streamType:Q,targetLiveWindow:q,liveEdgeStartOffset:ae}=Ku(G);((S=At.get(k))!=null?S:{}).liveEdgeStartOffset=ae,((M=At.get(k))!=null?M:{}).targetLiveWindow=q,k.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((N=At.get(k))!=null?N:{}).streamType=Q,k.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},qu=w=>{var k;let S=w.type,M=Io(S),N=Co(S),G,Q=!!((k=w.partList)!=null&&k.length);return M===ti.LIVE&&(G=Q?w.partTarget*2:w.targetduration*3),{streamType:M,targetLiveWindow:N,liveEdgeStartOffset:G,lowLatency:Q}},ju=(w,k,S)=>{var M,N,G,Q,q,ae,W,fe;let{streamType:ge,targetLiveWindow:me,liveEdgeStartOffset:Te,lowLatency:Ce}=qu(w);if(ge===ti.LIVE){Ce?(S.config.backBufferLength=(M=S.userConfig.backBufferLength)!=null?M:4,S.config.maxFragLookUpTolerance=(N=S.userConfig.maxFragLookUpTolerance)!=null?N:.001,S.config.abrBandWidthUpFactor=(G=S.userConfig.abrBandWidthUpFactor)!=null?G:S.config.abrBandWidthFactor):S.config.backBufferLength=(Q=S.userConfig.backBufferLength)!=null?Q:8;let Ie=Object.freeze({get length(){return k.seekable.length},start(et){return k.seekable.start(et)},end(et){var Le;return et>this.length?k.seekable.end(et):(Le=S.liveSyncPosition)!=null?Le:k.seekable.end(et)}});((q=At.get(k))!=null?q:{}).seekable=Ie}((ae=At.get(k))!=null?ae:{}).liveEdgeStartOffset=Te,((W=At.get(k))!=null?W:{}).targetLiveWindow=me,k.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((fe=At.get(k))!=null?fe:{}).streamType=ge,k.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},So,Ao,Vu=(Ao=(So=globalThis==null?void 0:globalThis.navigator)==null?void 0:So.userAgent)!=null?Ao:"",Yu=Vu.toLowerCase().indexOf("android")!==-1,At=new WeakMap,No="mux.com",Lo,ko,Uo=(ko=(Lo=Ut).isSupported)==null?void 0:ko.call(Lo),Wu=Yu,Bo=()=>Qn.default.utils.now(),zu=Qn.default.utils.generateUUID,Go=(w,{domain:k=No,maxResolution:S=""}={})=>{if(!w)return;let[M,N=""]=Ou(w),G=new URL(`https://stream.${k}/${M}.m3u8${N}`);return S&&G.searchParams.set("max_resolution",S),G.toString()},Xu=w=>{if(!w)return;let[k]=w.split("?");return k||void 0},Qu=w=>{if(!w||!w.startsWith("https://stream."))return;let[k]=new URL(w).pathname.slice(1).split(".m3u8");return k||void 0},Ju=w=>{var k,S,M;return(k=w==null?void 0:w.metadata)!=null&&k.video_id?w.metadata.video_id:Wo(w)&&(M=(S=Xu(w.playbackId))!=null?S:Qu(w.src))!=null?M:w.src},Ho=w=>{var k;return(k=At.get(w))==null?void 0:k.error},Ko=w=>{var k,S;return(S=(k=At.get(w))==null?void 0:k.streamType)!=null?S:ti.UNKNOWN},qo=w=>{var k,S;return(S=(k=At.get(w))==null?void 0:k.targetLiveWindow)!=null?S:Number.NaN},os=w=>{var k,S;return(S=(k=At.get(w))==null?void 0:k.seekable)!=null?S:w.seekable},jo=w=>{var k;let S=(k=At.get(w))==null?void 0:k.liveEdgeStartOffset;if(typeof S!="number")return Number.NaN;let M=os(w);return M.length?M.end(M.length-1)-S:Number.NaN},Vo=(w,k,S)=>{ls(k,S);let{metadata:M={}}=w,{view_session_id:N=zu()}=M,G=Ju(w);M.view_session_id=N,M.video_id=G,w.metadata=M,At.set(k,{});let Q=$u(w,k);ed(w,k,Q),td(w,k,Q),Gu(k);let q=Nu(w,k,Q),ae=Uu(w,k,Q);return{engine:Q,setAutoplay:q,setPreload:ae}},ls=(w,k)=>{let S=k==null?void 0:k.engine;S&&(S.detachMedia(),S.destroy()),(w==null?void 0:w.mux)&&!w.mux.deleted&&(w.mux.destroy(),delete w.mux),w&&(w.removeAttribute("src"),w.load(),w.removeEventListener("error",Xo),w.removeEventListener("error",ts),w.removeEventListener("durationchange",zo),At.delete(w),w.dispatchEvent(new Event("teardown")))};function Yo(w,k){var S;let M=Do(w);if(M!==Ei.M3U8)return!0;let N=!M||((S=k.canPlayType(M))!=null?S:!0),{preferPlayback:G}=w,Q=G===ri.MSE,q=G===ri.NATIVE;return N&&(q||!(Uo&&(Q||Wu)))}var $u=(w,k)=>{let{debug:S,streamType:M,startTime:N=-1,metadata:G,preferCmcd:Q}=w,q=Do(w)===Ei.M3U8,ae=Yo(w,k);if(q&&!ae&&Uo){let W={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},fe=Zu(M),ge=Q!==Za.NONE?{useHeaders:Q===Za.HEADER,sessionId:G==null?void 0:G.view_session_id,contentId:G==null?void 0:G.video_id}:void 0;return new Ut({debug:S,startPosition:N,cmcd:ge,...W,...fe})}},Zu=w=>w===ti.LIVE?{backBufferLength:8}:{},Wo=({playbackId:w,src:k,customDomain:S})=>{if(w)return!0;if(typeof k!="string")return!1;let M=window==null?void 0:window.location.href,N=new URL(k,M).hostname.toLocaleLowerCase();return N.includes(No)||!!S&&N.includes(S.toLocaleLowerCase())},ed=(w,k,S)=>{var M;let{envKey:N}=w,G=Wo(w);if(N||G){let{playerInitTime:Q,playerSoftwareName:q,playerSoftwareVersion:ae,beaconCollectionDomain:W,debug:fe,disableCookies:ge}=w,me={...w.metadata,video_title:((M=w==null?void 0:w.metadata)==null?void 0:M.video_title)||void 0},Te=Ce=>typeof Ce.player_error_code=="string"?!1:typeof w.errorTranslator=="function"?w.errorTranslator(Ce):Ce;Qn.default.monitor(k,{debug:fe,beaconCollectionDomain:W,hlsjs:S,Hls:S?Ut:void 0,automaticErrorTracking:!1,errorTranslator:Te,disableCookies:ge,data:{...N?{env_key:N}:{},player_software_name:q,player_software:q,player_software_version:ae,player_init_time:Q,...me}})}},td=(w,k,S)=>{var M;let N=Yo(w,k),{src:G}=w;k&&N?(typeof G=="string"?(k.preload==="none"?xr(k,"loadstart",()=>_o(G,k)):_o(G,k),k.setAttribute("src",G),w.startTime&&(((M=At.get(k))!=null?M:{}).startTime=w.startTime,k.addEventListener("durationchange",zo,{once:!0}))):k.removeAttribute("src"),k.addEventListener("error",Xo),k.addEventListener("error",ts),k.addEventListener("emptied",()=>{k.querySelectorAll("track[data-removeondestroy]").forEach(Q=>{Q.remove()})},{once:!0})):S&&G?(S.once(Ut.Events.LEVEL_LOADED,(Q,q)=>{ju(q.details,k,S)}),S.on(Ut.Events.ERROR,(Q,q)=>{let ae={[Ut.ErrorTypes.NETWORK_ERROR]:Nt.MEDIA_ERR_NETWORK,[Ut.ErrorTypes.MEDIA_ERROR]:Nt.MEDIA_ERR_DECODE},W=new Nt("",ae[q.type]);W.fatal=q.fatal,W.data=q,k.dispatchEvent(new CustomEvent("error",{detail:W}))}),k.addEventListener("error",ts),Bu(k,S),S.attachMedia(k)):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 zo(w){var k;let S=w.target,M=(k=At.get(S))==null?void 0:k.startTime;if(!!M&&xu(S.seekable,S.duration,M)){let N=S.preload==="auto";N&&(S.preload="none"),S.currentTime=M,N&&(S.preload="auto")}}async function Xo(w){if(!w.isTrusted)return;w.stopImmediatePropagation();let k=w.target;if(!(k!=null&&k.error))return;let{message:S,code:M}=k.error,N=new Nt(S,M);if(k.src&&(M!==Nt.MEDIA_ERR_DECODE||M!==void 0))try{let{status:G}=await fetch(k.src);N.data={response:{code:G}}}catch{}k.dispatchEvent(new CustomEvent("error",{detail:N}))}function ts(w){var k,S;if(!(w instanceof CustomEvent)||!(w.detail instanceof Nt))return;let M=w.target,N=w.detail;!N||!N.fatal||(((k=At.get(M))!=null?k:{}).error=N,(S=M.mux)==null||S.emit("error",{player_error_code:N.code,player_error_message:N.message,player_error_context:N.context}))}var rd=()=>{try{return"0.15.2"}catch{}return"UNKNOWN"},id=rd(),Qo=()=>id;var Jo=w=>{var k,S,M,N,G,$o,q,Jn,W,or,ge,$n,Te,Zn,Ie,Zo,Le,el,Ke,us,at,$,T,Z,H,ye,He,en,kt,tl,P,ds,wt,rl,Ct,cs,st,il,rt,hs;return k=class extends w{constructor(){super();Oe(this,He);Oe(this,kt);Oe(this,P);Oe(this,wt);Oe(this,Ct);Oe(this,st);Oe(this,rt);Xi(this,"castEnabled",!1);Oe(this,at,{paused:!1});Oe(this,$,void 0);Oe(this,T,{});Oe(this,Z,void 0);Oe(this,H,void 0);Oe(this,ye,void 0);k.instances.add(this),Ze(this,Ct,cs).call(this)}static get castElement(){return ne(k,S)}static get castEnabled(){return ne(k,M)}static get castState(){var X;return(X=ne(k,W,or))==null?void 0:X.getCastState()}static async exitCast(){try{await ne(k,W,or).endCurrentSession(!0)}catch(oe){console.error(oe);return}}get castPlayer(){if(k.castElement===this)return ne(this,$)}attributeChangedCallback(X){if(!!this.castPlayer)switch(X){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(X={}){var oe;Ze(oe=k,Ke,us).call(oe,X),ze(k,S,this),Object.entries(ne(this,T)).forEach(([je,it])=>{ne(this,$).controller.addEventListener(je,it)});try{await ne(k,W,or).requestSession()}catch{ze(k,S,void 0);return}ne(this,at).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(je){console.error(je)}}async load(){var Fe,Pt;if(!this.castPlayer)return super.load();let X=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),oe=[...this.querySelectorAll("track")].filter(({kind:Et,src:nt})=>nt&&(Et==="subtitles"||Et==="captions")),je=[],it=0;oe.length&&(X.tracks=oe.map(Et=>{let nt=++it;je.length===0&&Et.track.mode==="showing"&&je.push(nt);let xt=new chrome.cast.media.Track(nt,chrome.cast.media.TrackType.TEXT);return xt.trackContentId=Et.src,xt.trackContentType="text/vtt",xt.subtype=Et.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,xt.name=Et.label,xt.language=Et.srclang,xt})),this.castStreamType==="live"?X.streamType=chrome.cast.media.StreamType.LIVE:X.streamType=chrome.cast.media.StreamType.BUFFERED,X.metadata=new chrome.cast.media.GenericMediaMetadata,X.metadata.title=this.title,X.metadata.images=[{url:this.poster}];let gt=new chrome.cast.media.LoadRequest(X);gt.currentTime=(Fe=super.currentTime)!=null?Fe:0,gt.autoplay=!ne(this,at).paused,gt.activeTrackIds=je,await((Pt=ne(k,ge,$n))==null?void 0:Pt.loadMedia(gt)),this.dispatchEvent(new Event("volumechange"))}play(){var X;if(this.castPlayer){this.castPlayer.isPaused&&((X=this.castPlayer.controller)==null||X.playOrPause());return}return super.play()}pause(){var X;if(this.castPlayer){this.castPlayer.isPaused||(X=this.castPlayer.controller)==null||X.playOrPause();return}super.pause()}get castSrc(){var X,oe,je;return(je=(oe=this.getAttribute("cast-src"))!=null?oe:(X=this.querySelector("source"))==null?void 0:X.src)!=null?je:this.currentSrc}set castSrc(X){this.castSrc!=X&&this.setAttribute("cast-src",`${X}`)}get castContentType(){var X;return(X=this.getAttribute("cast-content-type"))!=null?X:void 0}set castContentType(X){this.setAttribute("cast-content-type",`${X}`)}get castStreamType(){var X,oe;return(oe=(X=this.getAttribute("cast-stream-type"))!=null?X:this.streamType)!=null?oe:void 0}set castStreamType(X){this.setAttribute("cast-stream-type",`${X}`)}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 X;return this.castPlayer?(X=this.castPlayer)==null?void 0:X.isMuted:super.muted}set muted(X){var oe;if(this.castPlayer){(X&&!this.castPlayer.isMuted||!X&&this.castPlayer.isMuted)&&((oe=this.castPlayer.controller)==null||oe.muteOrUnmute());return}super.muted=X}get volume(){var X,oe;return this.castPlayer?(oe=(X=this.castPlayer)==null?void 0:X.volumeLevel)!=null?oe:1:super.volume}set volume(X){var oe;if(this.castPlayer){this.castPlayer.volumeLevel=X,(oe=this.castPlayer.controller)==null||oe.setVolumeLevel();return}super.volume=X}get duration(){var X,oe;return this.castPlayer&&ne(this,He,en)?(oe=(X=this.castPlayer)==null?void 0:X.duration)!=null?oe:NaN:super.duration}get currentTime(){var X,oe;return this.castPlayer&&ne(this,He,en)?(oe=(X=this.castPlayer)==null?void 0:X.currentTime)!=null?oe:0:super.currentTime}set currentTime(X){var oe;if(this.castPlayer){this.castPlayer.currentTime=X,(oe=this.castPlayer.controller)==null||oe.seek();return}super.currentTime=X}get onentercast(){return ne(this,Z)}set onentercast(X){ne(this,Z)&&(this.removeEventListener("entercast",ne(this,Z)),ze(this,Z,null)),typeof X=="function"&&(ze(this,Z,X),this.addEventListener("entercast",X))}get onleavecast(){return ne(this,H)}set onleavecast(X){ne(this,H)&&(this.removeEventListener("leavecast",ne(this,H)),ze(this,H,null)),typeof X=="function"&&(ze(this,H,X),this.addEventListener("leavecast",X))}get oncastchange(){return ne(this,ye)}set oncastchange(X){ne(this,ye)&&(this.removeEventListener("castchange",ne(this,ye)),ze(this,ye,null)),typeof X=="function"&&(ze(this,ye,X),this.addEventListener("castchange",X))}},S=new WeakMap,M=new WeakMap,N=new WeakMap,G=new WeakSet,$o=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},q=new WeakSet,Jn=function(){return typeof cast!="undefined"&&cast.framework},W=new WeakSet,or=function(){if(ne(k,q,Jn))return cast.framework.CastContext.getInstance()},ge=new WeakSet,$n=function(){var X;return(X=ne(k,W,or))==null?void 0:X.getCurrentSession()},Te=new WeakSet,Zn=function(){var X;return(X=ne(k,ge,$n))==null?void 0:X.getSessionObj().media[0]},Ie=new WeakSet,Zo=function(X){return new Promise((oe,je)=>{ne(k,Te,Zn).editTracksInfo(X,oe,je)})},Le=new WeakSet,el=function(X){return new Promise((oe,je)=>{ne(k,Te,Zn).getStatus(X,oe,je)})},Ke=new WeakSet,us=function(X){return ne(k,W,or).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...X})},at=new WeakMap,$=new WeakMap,T=new WeakMap,Z=new WeakMap,H=new WeakMap,ye=new WeakMap,He=new WeakSet,en=function(){var X;return(X=this.castPlayer)==null?void 0:X.isMediaLoaded},kt=new WeakSet,tl=function(){ne(k,S)===this&&(Object.entries(ne(this,T)).forEach(([X,oe])=>{ne(this,$).controller.removeEventListener(X,oe)}),ze(k,S,void 0),this.muted=ne(this,$).isMuted,this.currentTime=ne(this,$).savedPlayerState.currentTime,ne(this,$).savedPlayerState.isPaused===!1&&this.play())},P=new WeakSet,ds=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:ne(k,W,or).getCastState()}))},wt=new WeakSet,rl=async function(){var oe,je;let{SESSION_RESUMED:X}=cast.framework.SessionState;if(ne(k,W,or).getSessionState()===X&&this.castSrc===((oe=ne(k,Te,Zn))==null?void 0:oe.media.contentId)){ze(k,S,this),Object.entries(ne(this,T)).forEach(([it,gt])=>{ne(this,$).controller.addEventListener(it,gt)});try{await Ze(je=k,Le,el).call(je,new chrome.cast.media.GetStatusRequest)}catch(it){console.error(it)}ne(this,T)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),ne(this,T)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},Ct=new WeakSet,cs=function(){var X;!ne(k,q,Jn)||this.castEnabled||(this.castEnabled=!0,Ze(X=k,Ke,us).call(X),this.textTracks.addEventListener("change",Ze(this,rt,hs).bind(this)),Ze(this,P,ds).call(this),ze(this,$,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(ne(this,$)),ze(this,T,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:oe})=>{oe===!1&&Ze(this,kt,tl).call(this),this.dispatchEvent(new Event(oe?"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]:()=>{!ne(this,He,en)||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 oe,je;((oe=this.castPlayer)==null?void 0:oe.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"}[(je=this.castPlayer)==null?void 0:je.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!ne(this,He,en)||(await Promise.resolve(),Ze(this,st,il).call(this))}}))},st=new WeakSet,il=function(){Ze(this,rt,hs).call(this)},rt=new WeakSet,hs=async function(){var br,Mr,_r,Sr,Ar,jt;if(!this.castPlayer)return;let oe=((Mr=(br=ne(this,$).mediaInfo)==null?void 0:br.tracks)!=null?Mr:[]).filter(({type:We})=>We===chrome.cast.media.TrackType.TEXT),je=[...this.textTracks].filter(({kind:We})=>We==="subtitles"||We==="captions"),it=oe.map(({language:We,name:tr,trackId:Lr})=>{var ur;let{mode:rr}=(ur=je.find(Fr=>Fr.language===We&&Fr.label===tr))!=null?ur:{};return rr?{mode:rr,trackId:Lr}:!1}).filter(Boolean),Fe=it.filter(({mode:We})=>We!=="showing").map(({trackId:We})=>We),Pt=it.find(({mode:We})=>We==="showing"),Et=(Ar=(Sr=(_r=ne(k,ge,$n))==null?void 0:_r.getSessionObj().media[0])==null?void 0:Sr.activeTrackIds)!=null?Ar:[],nt=Et;if(Et.length&&(nt=nt.filter(We=>!Fe.includes(We))),Pt!=null&&Pt.trackId&&(nt=[...nt,Pt.trackId]),nt=[...new Set(nt)],!((We,tr)=>We.length===tr.length&&We.every(Lr=>tr.includes(Lr)))(Et,nt))try{let We=new chrome.cast.media.EditTracksInfoRequest(nt);await Ze(jt=k,Ie,Zo).call(jt,We)}catch(We){console.error(We)}},Oe(k,G),Oe(k,q),Oe(k,W),Oe(k,ge),Oe(k,Te),Oe(k,Ie),Oe(k,Le),Oe(k,Ke),Xi(k,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Xi(k,"instances",new Set),Oe(k,S,void 0),Oe(k,M,!1),Xi(k,"initCast",()=>{var X;ne(k,G,$o)?ne(k,q,Jn)?ne(X=k,N).call(X,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var oe;return ne(oe=k,N).call(oe,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var oe;return ne(oe=k,N).call(oe,chrome.cast.isAvailable)})}}),Oe(k,N,X=>{if(X){ze(k,M,!0);let{CAST_STATE_CHANGED:oe}=cast.framework.CastContextEventType;ne(k,W,or).addEventListener(oe,it=>{k.instances.forEach(gt=>{var Fe;return Ze(Fe=gt,P,ds).call(Fe,it)})});let{SESSION_STATE_CHANGED:je}=cast.framework.CastContextEventType;ne(k,W,or).addEventListener(je,it=>{k.instances.forEach(gt=>{var Fe;return Ze(Fe=gt,wt,rl).call(Fe,it)})}),k.instances.forEach(it=>{var gt;return Ze(gt=it,Ct,cs).call(gt)})}}),k},fs=globalThis.HTMLVideoElement?Jo(HTMLVideoElement):Jo(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",fs,{extends:"video"}),globalThis.CastableVideoElement=fs);fs.initCast();var nl=["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"],al=za.createElement("template");al.innerHTML=`
|
|
48
48
|
<style>
|
|
49
49
|
:host {
|
|
50
50
|
display: inline-block;
|
|
@@ -69,7 +69,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
69
69
|
</style>
|
|
70
70
|
<video is="castable-video" part="video" crossorigin></video>
|
|
71
71
|
<slot></slot>
|
|
72
|
-
`;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;})();
|
|
72
|
+
`;var tn,Ti,ea,rn,vs,Or=class extends sr.HTMLElement{constructor(){super();Oe(this,Ti);Oe(this,rn);Oe(this,tn,void 0);this.attachShadow({mode:"open"}),this.isConnected&&Ze(this,Ti,ea).call(this)}static get observedAttributes(){let S=[],M=G=>G.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(G=>{let Q=!1;try{typeof this.prototype[G]=="function"&&(Q=!0)}catch{}!Q&&G!==G.toUpperCase()&&S.push(G.toLowerCase(),M(G))});let N=Object.getPrototypeOf(this).observedAttributes;return N&&(S=S.concat(N)),S}attributeChangedCallback(S,M,N){Ze(this,Ti,ea).call(this),Ze(this,rn,vs).call(this,S,M,N)}connectedCallback(){Ze(this,Ti,ea).call(this)}};tn=new WeakMap,Ti=new WeakSet,ea=function(){if(ne(this,tn))return;ze(this,tn,!0),this.shadowRoot.append(al.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),nl.forEach(M=>{this.nativeEl.addEventListener(M,N=>{this.dispatchEvent(new CustomEvent(N.type,{detail:N.detail}))})});let S=this.shadowRoot.querySelector("slot");S.addEventListener("slotchange",()=>{S.assignedElements().forEach(M=>{!["track","source"].includes(M.localName)||this.nativeEl.append(M)})}),Array.prototype.forEach.call(this.attributes,M=>{Ze(this,rn,vs).call(this,M.name,null,M.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},rn=new WeakSet,vs=function(S,M,N){let G=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),Q=ad(G,S),q=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;Q&&!q?typeof this[Q]=="boolean"?N===null?this[Q]=!1:this[Q]=!0:this[Q]=N:N===null?this.nativeEl.removeAttribute(S):["id","class"].indexOf(S)===-1&&this.nativeEl.setAttribute(S,N)};var sl=[],ol=za.createElement("video",{is:"castable-video"}),nd=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let w=Object.getPrototypeOf(ol);w&&w!==sr.HTMLElement.prototype;w=Object.getPrototypeOf(w))Object.getOwnPropertyNames(w).forEach(k=>{nd.indexOf(k)===-1&&sl.push(k)});sl.forEach(w=>{if(w in Or.prototype)return;if(typeof ol[w]=="function")Or.prototype[w]=function(){return this.nativeEl[w].apply(this.nativeEl,arguments)};else{let S={get(){return this.nativeEl[w]}};w!==w.toUpperCase()&&(S.set=function(M){this.nativeEl[w]=M}),Object.defineProperty(Or.prototype,w,S)}});function ad(w,k){let S=null;return w.forEach(M=>{M.toLowerCase()==k.toLowerCase()&&(S=M)}),S}sr.customElements.get("custom-video")||(sr.customElements.define("custom-video",Or),sr.CustomVideoElement=Or);var gs=Or;var Ee={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"},sd=Object.values(Ee),od=Qo(),ld="mux-video",lr,bi,an,_i,sn,on,ln,un,ms,nn=class extends gs{constructor(){super();Oe(this,un);Oe(this,lr,void 0);Oe(this,bi,void 0);Oe(this,an,void 0);Oe(this,_i,{});Oe(this,sn,void 0);Oe(this,on,void 0);Oe(this,ln,void 0);ze(this,an,Bo())}static get observedAttributes(){var S;return[...sd,...(S=gs.observedAttributes)!=null?S:[]]}get preferCmcd(){var S;return(S=this.getAttribute(Ee.PREFER_CMCD))!=null?S:void 0}set preferCmcd(S){S!==this.preferCmcd&&(S?rs.includes(S)?this.setAttribute(Ee.PREFER_CMCD,S):console.warn(`Invalid value for preferCmcd. Must be one of ${rs.join()}`):this.removeAttribute(Ee.PREFER_CMCD))}get playerInitTime(){return ne(this,an)}get playerSoftwareName(){var S;return(S=ne(this,on))!=null?S:ld}set playerSoftwareName(S){ze(this,on,S)}get playerSoftwareVersion(){var S;return(S=ne(this,sn))!=null?S:od}set playerSoftwareVersion(S){ze(this,sn,S)}get _hls(){var S;return(S=ne(this,lr))==null?void 0:S.engine}get mux(){return this.nativeEl.mux}get error(){var S;return(S=Ho(this.nativeEl))!=null?S:null}get errorTranslator(){return ne(this,ln)}set errorTranslator(S){ze(this,ln,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(Ee.TYPE))!=null?S:void 0}set type(S){S!==this.type&&(S?this.setAttribute(Ee.TYPE,S):this.removeAttribute(Ee.TYPE))}get autoplay(){let S=this.getAttribute("autoplay");return S===null?!1:S===""?!0:S}set autoplay(S){let M=this.autoplay;S!==M&&(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(Ee.DEBUG)!=null}set debug(S){S!==this.debug&&(S?this.setAttribute(Ee.DEBUG,""):this.removeAttribute(Ee.DEBUG))}get disableCookies(){return this.hasAttribute(Ee.DISABLE_COOKIES)}set disableCookies(S){S!==this.disableCookies&&(S?this.setAttribute(Ee.DISABLE_COOKIES,""):this.removeAttribute(Ee.DISABLE_COOKIES))}get startTime(){let S=this.getAttribute(Ee.START_TIME);if(S==null)return;let M=+S;return Number.isNaN(M)?void 0:M}set startTime(S){S!==this.startTime&&(S==null?this.removeAttribute(Ee.START_TIME):this.setAttribute(Ee.START_TIME,`${S}`))}get playbackId(){var S;return(S=this.getAttribute(Ee.PLAYBACK_ID))!=null?S:void 0}set playbackId(S){S!==this.playbackId&&(S?this.setAttribute(Ee.PLAYBACK_ID,S):this.removeAttribute(Ee.PLAYBACK_ID))}get maxResolution(){var S;return(S=this.getAttribute(Ee.MAX_RESOLUTION))!=null?S:void 0}set maxResolution(S){S!==this.maxResolution&&(S?this.setAttribute(Ee.MAX_RESOLUTION,S):this.removeAttribute(Ee.MAX_RESOLUTION))}get customDomain(){var S;return(S=this.getAttribute(Ee.CUSTOM_DOMAIN))!=null?S:void 0}set customDomain(S){S!==this.customDomain&&(S?this.setAttribute(Ee.CUSTOM_DOMAIN,S):this.removeAttribute(Ee.CUSTOM_DOMAIN))}get envKey(){var S;return(S=this.getAttribute(Ee.ENV_KEY))!=null?S:void 0}set envKey(S){S!==this.envKey&&(S?this.setAttribute(Ee.ENV_KEY,S):this.removeAttribute(Ee.ENV_KEY))}get beaconCollectionDomain(){var S;return(S=this.getAttribute(Ee.BEACON_COLLECTION_DOMAIN))!=null?S:void 0}set beaconCollectionDomain(S){S!==this.beaconCollectionDomain&&(S?this.setAttribute(Ee.BEACON_COLLECTION_DOMAIN,S):this.removeAttribute(Ee.BEACON_COLLECTION_DOMAIN))}get streamType(){var S;return(S=this.getAttribute(Ee.STREAM_TYPE))!=null?S:Ko(this.nativeEl)}set streamType(S){S!==this.streamType&&(S?this.setAttribute(Ee.STREAM_TYPE,S):this.removeAttribute(Ee.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(Ee.TARGET_LIVE_WINDOW)?+this.getAttribute(Ee.TARGET_LIVE_WINDOW):qo(this.nativeEl)}set targetLiveWindow(S){S!=this.targetLiveWindow&&(S==null?this.removeAttribute(Ee.TARGET_LIVE_WINDOW):this.setAttribute(Ee.TARGET_LIVE_WINDOW,`${+S}`))}get liveEdgeStart(){var S,M;if(this.hasAttribute(Ee.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:N}=this,G=(S=this.nativeEl.seekable.end(0))!=null?S:0,Q=(M=this.nativeEl.seekable.start(0))!=null?M:0;return Math.max(Q,G-N)}return jo(this.nativeEl)}get liveEdgeOffset(){if(!!this.hasAttribute(Ee.LIVE_EDGE_OFFSET))return+this.getAttribute(Ee.LIVE_EDGE_OFFSET)}set liveEdgeOffset(S){S!=this.targetLiveWindow&&(S==null?this.removeAttribute(Ee.LIVE_EDGE_OFFSET):this.setAttribute(Ee.LIVE_EDGE_OFFSET,`${+S}`))}get seekable(){return os(this.nativeEl)}async addCuePoints(S){return as(this.nativeEl,S)}get activeCuePoint(){return ss(this.nativeEl)}get cuePoints(){return Oo(this.nativeEl)}getStartDate(){return Mo(this.nativeEl,this._hls)}get currentPdt(){return Fo(this.nativeEl,this._hls)}get preferPlayback(){let S=this.getAttribute(Ee.PREFER_PLAYBACK);if(S===ri.MSE||S===ri.NATIVE)return S}set preferPlayback(S){S!==this.preferPlayback&&(S===ri.MSE||S===ri.NATIVE?this.setAttribute(Ee.PREFER_PLAYBACK,S):this.removeAttribute(Ee.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(M=>M.startsWith("metadata-")&&![Ee.METADATA_URL].includes(M)).reduce((M,N)=>{let G=this.getAttribute(N);return G!=null&&(M[N.replace(/^metadata-/,"").replace(/-/g,"_")]=G),M},{}),...ne(this,_i)}}set metadata(S){ze(this,_i,S!=null?S:{}),this.mux&&this.mux.emit("hb",ne(this,_i))}load(){ze(this,lr,Vo(this,this.nativeEl,ne(this,lr)))}unload(){ls(this.nativeEl,ne(this,lr)),ze(this,lr,void 0)}attributeChangedCallback(S,M,N){var G,Q;switch(super.attributeChangedCallback(S,M,N),S){case Ee.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=N!=null?N:void 0;break;case Ee.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=N!=null?N:void 0;break;case"src":{let q=!!M,ae=!!N;!q&&ae?Ze(this,un,ms).call(this):q&&!ae?this.unload():q&&ae&&(this.unload(),Ze(this,un,ms).call(this));break}case"autoplay":if(N===M)break;(G=ne(this,lr))==null||G.setAutoplay(this.autoplay);break;case"preload":if(N===M)break;(Q=ne(this,lr))==null||Q.setPreload(N);break;case Ee.PLAYBACK_ID:this.src=Go(N!=null?N:void 0,{maxResolution:this.maxResolution,domain:this.customDomain});break;case Ee.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 Ee.METADATA_URL:N&&fetch(N).then(q=>q.json()).then(q=>this.metadata=q).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${N}!`));break;case Ee.STREAM_TYPE:(N==null||N!==M)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case Ee.TARGET_LIVE_WINDOW:(N==null||N!==M)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}disconnectedCallback(){this.unload()}};lr=new WeakMap,bi=new WeakMap,an=new WeakMap,_i=new WeakMap,sn=new WeakMap,on=new WeakMap,ln=new WeakMap,un=new WeakSet,ms=async function(){ne(this,bi)||(await ze(this,bi,Promise.resolve()),ze(this,bi,null),this.load())};sr.customElements.get("mux-video")||(sr.customElements.define("mux-video",nn),sr.MuxVideoElement=nn);var Cd=nn;})();
|
|
73
73
|
/*!
|
|
74
74
|
* JavaScript Cookie v2.1.3
|
|
75
75
|
* https://github.com/js-cookie/js-cookie
|