@mux/playback-core 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +3 -1
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.mjs +3 -1
- package/dist/index.mjs.map +4 -4
- package/dist/playback-core.js +46 -31
- package/dist/playback-core.js.map +4 -4
- package/dist/playback-core.mjs +46 -31
- package/dist/playback-core.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/errors.d.ts +2 -1
- package/dist/types/index.d.ts +25 -5
- package/dist/types/media-chrome.d.ts +6 -0
- package/dist/types/mux-embed.d.ts +594 -0
- package/dist/types/pdt.d.ts +7 -0
- package/dist/types/types.d.ts +14 -10
- package/dist/types/util.d.ts +3 -1
- package/dist/types-ts3.4/errors.d.ts +2 -1
- package/dist/types-ts3.4/index.d.ts +25 -5
- package/dist/types-ts3.4/media-chrome.d.ts +7 -0
- package/dist/types-ts3.4/mux-embed.d.ts +566 -0
- package/dist/types-ts3.4/pdt.d.ts +7 -0
- package/dist/types-ts3.4/types.d.ts +14 -10
- package/dist/types-ts3.4/util.d.ts +3 -1
- package/package.json +6 -6
package/dist/playback-core.js
CHANGED
|
@@ -1,35 +1,50 @@
|
|
|
1
|
-
"use strict";(()=>{var Ga=Object.create;var $n=Object.defineProperty;var ja=Object.getOwnPropertyDescriptor;var Ka=Object.getOwnPropertyNames;var qa=Object.getPrototypeOf,Va=Object.prototype.hasOwnProperty;var Zn=(X,te)=>()=>(te||X((te={exports:{}}).exports,te),te.exports);var Ya=(X,te,Se,De)=>{if(te&&typeof te=="object"||typeof te=="function")for(let fe of Ka(te))!Va.call(X,fe)&&fe!==Se&&$n(X,fe,{get:()=>te[fe],enumerable:!(De=ja(te,fe))||De.enumerable});return X};var ea=(X,te,Se)=>(Se=X!=null?Ga(qa(X)):{},Ya(te||!X||!X.__esModule?$n(Se,"default",{value:X,enumerable:!0}):Se,X));var ta=Zn((Wi,wn)=>{(function(){var X,te;X=this,te=function(){return function(){var Se={80:function(re,N,B){re.exports=B(728).default},728:function(re,N,B){"use strict";B.d(N,{default:function(){return hn}});var $=B(48),R=B.n($),p=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(g){var h=16*Math.random()|0;return(g==="x"?h:3&h|8).toString(16)})},w=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},k=function(g){return g&&g.nodeName!==void 0?(g.muxId||(g.muxId=g.id||w()),g.muxId):g},ve=function(g){var h;g&&g.nodeName!==void 0?g=k(h=g):h=document.querySelector(g);var f=h&&h.nodeName?h.nodeName.toLowerCase():"";return[h,g,f]},Z=B(640),le=B.n(Z),Te=le().methodFactory;le().methodFactory=function(g,h,f){var y=Te(g,h,f);return function(){for(var b=["[mux]"],C=0;C<arguments.length;C++)b.push(arguments[C]);y.apply(void 0,b)}},le().setLevel(le().getLevel());var H=le();function ce(){return(R().doNotTrack||R().navigator&&R().navigator.doNotTrack)==="1"}var z={now:function(){var g=R().performance,h=g&&g.timing,f=h&&h.navigationStart,y=typeof f=="number"&&typeof g.now=="function"?f+g.now():Date.now();return Math.round(y)}},ne=B(678),U=B.n(ne),be=function(g){return ke(g)[0]},ke=function(g){if(typeof g!="string"||g==="")return["localhost"];var h,f=(g.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return f&&(h=(f.match(/[^\.]+\.[^\.]+$/)||[])[0]),[f,h]},He={exists:function(){var g=R().performance;return(g&&g.timing)!==void 0},domContentLoadedEventEnd:function(){var g=R().performance,h=g&&g.timing;return h&&h.domContentLoadedEventEnd},navigationStart:function(){var g=R().performance,h=g&&g.timing;return h&&h.navigationStart}};function K(g,h,f){f=f===void 0?1:f,g[h]=g[h]||0,g[h]+=f}var E=["x-cdn","content-type","x-request-id"];function M(g){var h={};return(g=g||"").trim().split(/[\r\n]+/).forEach(function(f){if(f){var y=f.split(": "),b=y.shift();b&&(E.indexOf(b.toLowerCase())>=0||b.toLowerCase().indexOf("x-litix-")===0)&&(h[b]=y.join(": "))}}),h}var L=function(g){var h={};for(var f in g){var y=g[f];y["DATA-ID"].search("io.litix.data.")!==-1&&(h[y["DATA-ID"].replace("io.litix.data.","")]=y.VALUE)}return h};function oe(g,h){var f=Object.keys(g);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(g);h&&(y=y.filter(function(b){return Object.getOwnPropertyDescriptor(g,b).enumerable})),f.push.apply(f,y)}return f}function ye(g){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?oe(Object(f),!0).forEach(function(y){W(g,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(f)):oe(Object(f)).forEach(function(y){Object.defineProperty(g,y,Object.getOwnPropertyDescriptor(f,y))})}return g}function W(g,h,f){return h in g?Object.defineProperty(g,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):g[h]=f,g}var V=function(g){if(!g)return{};var h=He.navigationStart(),f=g.loading,y=f?f.start:g.trequest,b=f?f.first:g.tfirst,C=f?f.end:g.tload;return{bytesLoaded:g.total,requestStart:Math.round(h+y),responseStart:Math.round(h+b),responseEnd:Math.round(h+C)}},we=function(g){if(g&&typeof g.getAllResponseHeaders=="function")return M(g.getAllResponseHeaders())};function Re(g,h){var f=Object.keys(g);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(g);h&&(y=y.filter(function(b){return Object.getOwnPropertyDescriptor(g,b).enumerable})),f.push.apply(f,y)}return f}function Ce(g){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?Re(Object(f),!0).forEach(function(y){ge(g,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(f)):Re(Object(f)).forEach(function(y){Object.defineProperty(g,y,Object.getOwnPropertyDescriptor(f,y))})}return g}function ge(g,h,f){return h in g?Object.defineProperty(g,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):g[h]=f,g}var qe=function(g,h){if(!g||typeof g.getRequests!="function")return{};var f=g.getRequests({state:"executed"});if(f.length===0)return{};var y,b=f[f.length-1],C=be(b.url),A=b.url,G=b.bytesLoaded,se=new Date(b.requestStartDate).getTime(),Q=new Date(b.firstByteDate).getTime(),Pe=new Date(b.requestEndDate).getTime(),at=isNaN(b.duration)?0:b.duration,Je=typeof h.getMetricsFor=="function"?h.getMetricsFor(b.mediaType).HttpList:h.getDashMetrics().getHttpRequests(b.mediaType);return Je.length>0&&(y=M(Je[Je.length-1]._responseHeaders||"")),{requestStart:se,requestResponseStart:Q,requestResponseEnd:Pe,requestBytesLoaded:G,requestResponseHeaders:y,requestMediaDuration:at,requestHostname:C,requestUrl:A}},tt=function(g,h){var f=h.getQualityFor(g),y=h.getCurrentTrackFor(g).bitrateList;return y?{currentLevel:f,renditionWidth:y[f].width||null,renditionHeight:y[f].height||null,renditionBitrate:y[f].bandwidth}:{}},ee=function(g){var h;return(h=g.match(/.*codecs\*?="(.*)"/))===null||h===void 0?void 0:h[1]};function ue(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var ie=0,Oe=function(){function g(){(function(b,C){if(!(b instanceof C))throw new TypeError("Cannot call a class as a function")})(this,g)}var h,f,y;return h=g,f=[{key:"on",value:function(b,C,A){return C._eventEmitterGuid=C._eventEmitterGuid||++ie,this._listeners=this._listeners||{},this._listeners[b]=this._listeners[b]||[],A&&(C=C.bind(A)),this._listeners[b].push(C),C}},{key:"off",value:function(b,C){var A=this._listeners&&this._listeners[b];A&&A.forEach(function(G,se){G._eventEmitterGuid===C._eventEmitterGuid&&A.splice(se,1)})}},{key:"one",value:function(b,C,A){var G=this;C._eventEmitterGuid=C._eventEmitterGuid||++ie;var se=function Q(){G.off(b,Q),C.apply(A||this,arguments)};se._eventEmitterGuid=C._eventEmitterGuid,this.on(b,se)}},{key:"emit",value:function(b,C){var A=this;if(this._listeners){C=C||{};var G=this._listeners["before*"]||[],se=this._listeners[b]||[],Q=this._listeners["after"+b]||[],Pe=function(at,Je){(at=at.slice()).forEach(function(it){it.call(A,{type:b},Je)})};Pe(G,C),Pe(se,C),Pe(Q,C)}}}],f&&ue(h.prototype,f),y&&ue(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}(),xe=Oe;function Ne(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Be=function(){function g(b){var C=this;(function(A,G){if(!(A instanceof G))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,b.on("playing",function(){C._playheadShouldBeProgressing=!0}),b.on("play",this._startPlaybackHeartbeatInterval.bind(this)),b.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),b.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),b.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),b.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),b.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),b.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),b.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),b.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),b.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("seeked",function(){b.data.player_is_paused?C._stopPlaybackHeartbeatInterval():C._startPlaybackHeartbeatInterval()}),b.on("timeupdate",function(){C._playbackHeartbeatInterval!==null&&b.emit("playbackheartbeat")}),b.on("devicesleep",function(A,G){C._playbackHeartbeatInterval!==null&&(R().clearInterval(C._playbackHeartbeatInterval),b.emit("playbackheartbeatend",{viewer_time:G.viewer_time}),C._playbackHeartbeatInterval=null)})}var h,f,y;return h=g,(f=[{key:"_startPlaybackHeartbeatInterval",value:function(){var b=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=R().setInterval(function(){b.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(R().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Ne(h.prototype,f),y&&Ne(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function je(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function pe(g,h,f){return h&&je(g.prototype,h),f&&je(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var Ie=pe(function g(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,g),h.on("viewinit",function(){f.viewErrored=!1}),h.on("error",function(y,b){try{var C=h.errorTranslator({player_error_code:b.player_error_code,player_error_message:b.player_error_message,player_error_context:b.player_error_context});C?(h.data.player_error_code=C.player_error_code||b.player_error_code,h.data.player_error_message=C.player_error_message||b.player_error_message,h.data.player_error_context=C.player_error_context||b.player_error_context,f.viewErrored=!0):(delete h.data.player_error_code,delete h.data.player_error_message,delete h.data.player_error_context)}catch(A){h.mux.log.warn("Exception in error translator callback.",A),f.viewErrored=!0}})});function Ye(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var rt=function(){function g(b){(function(C,A){if(!(C instanceof A))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,this._watchTimeTrackerLastCheckedTime=null,b.on("playbackheartbeat",this._updateWatchTime.bind(this)),b.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var h,f,y;return h=g,(f=[{key:"_updateWatchTime",value:function(b,C){var A=C.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=A),K(this.pm.data,"view_watch_time",A-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=A}},{key:"_clearWatchTimeState",value:function(b,C){this._updateWatchTime(b,C),this._watchTimeTrackerLastCheckedTime=null}}])&&Ye(h.prototype,f),y&&Ye(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function yt(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var ht=function(){function g(b){(function(C,A){if(!(C instanceof A))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,this._playbackTimeTrackerLastPlayheadPosition=-1,b.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),b.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),b.on("seeking",this._clearPlaybackTimeState.bind(this))}var h,f,y;return h=g,(f=[{key:"_updatePlaybackTime",value:function(){var b=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&b>this._playbackTimeTrackerLastPlayheadPosition){var C=b-this._playbackTimeTrackerLastPlayheadPosition;C<=1e3&&K(this.pm.data,"view_content_playback_time",C)}this._playbackTimeTrackerLastPlayheadPosition=b}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&yt(h.prototype,f),y&&yt(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function It(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Dt=function(){function g(b){(function(A,G){if(!(A instanceof G))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b;var C=this._updatePlayheadTime.bind(this);b.on("playbackheartbeat",C),b.on("playbackheartbeatend",C),b.on("timeupdate",C),b.on("destroy",function(){b.off("timeupdate",C)})}var h,f,y;return h=g,(f=[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=this.pm.data.view_max_playhead_position===void 0?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(b,C){var A=this,G=function(){A.pm.currentFragmentPDT&&A.pm.currentFragmentStart&&(A.pm.data.player_program_time=A.pm.currentFragmentPDT+A.pm.data.player_playhead_time-A.pm.currentFragmentStart)};if(C&&C.player_playhead_time)this.pm.data.player_playhead_time=C.player_playhead_time,G(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var se=this.pm.getPlayheadTime();se!==void 0&&(this.pm.data.player_playhead_time=se,G(),this._updateMaxPlayheadPosition())}}}])&&It(h.prototype,f),y&&It(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function St(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function kt(g,h,f){return h&&St(g.prototype,h),f&&St(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var gt=kt(function g(h){if(function(C,A){if(!(C instanceof A))throw new TypeError("Cannot call a class as a function")}(this,g),!h.disableRebufferTracking){var f,y=function(C,A){b(A),f=void 0},b=function(C){if(f){var A=C.viewer_time-f;K(h.data,"view_rebuffer_duration",A),f=C.viewer_time}h.data.view_watch_time>=0&&h.data.view_rebuffer_count>0&&(h.data.view_rebuffer_frequency=h.data.view_rebuffer_count/h.data.view_watch_time,h.data.view_rebuffer_percentage=h.data.view_rebuffer_duration/h.data.view_watch_time)};h.on("playbackheartbeat",function(C,A){return b(A)}),h.on("rebufferstart",function(C,A){f||(K(h.data,"view_rebuffer_count",1),f=A.viewer_time,h.one("rebufferend",y))}),h.on("viewinit",function(){f=void 0,h.off("rebufferend",y)})}});function ut(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Rt=function(){function g(b){var C=this;(function(A,G){if(!(A instanceof G))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,b.disableRebufferTracking||b.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,b.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),b.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),b.on("seeking",function(){C._cleanupRebufferTracker(null,{viewer_time:z.now()})}))}var h,f,y;return h=g,f=[{key:"_checkIfRebuffering",value:function(b,C){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(b,C);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var A=C.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&A>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=C.viewer_time}else this._cleanupRebufferTracker(b,C,!0);else this._prepareRebufferTrackerState(C.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(b){this._lastCheckedTime=b,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=b}},{key:"_cleanupRebufferTracker",value:function(b,C){var A=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:C.viewer_time});else{if(this._lastCheckedTime===null)return;var G=this.pm.data.player_playhead_time-this._lastPlayheadTime,se=C.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&G>0&&se-G>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+se-G}))}A?this._prepareRebufferTrackerState(C.viewer_time):this._clearRebufferTrackerState()}}],f&&ut(h.prototype,f),y&&ut(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}(),Pt=Rt;function jt(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var zt=function(){function g(b){var C=this;(function(A,G){if(!(A instanceof G))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,b.on("viewinit",function(){var A=b.data,G=A.view_id;if(!A.view_program_changed){var se=function(Q,Pe){var at=Pe.viewer_time;Q.type==="playing"&&b.data.view_time_to_first_frame===void 0?C.calculateTimeToFirstFrame(at||z.now(),G):Q.type!=="adplaying"||b.data.view_time_to_first_frame!==void 0&&!C._inPrerollPosition()||C.calculateTimeToFirstFrame(at||z.now(),G)};b.one("playing",se),b.one("adplaying",se),b.one("viewend",function(){b.off("playing",se),b.off("adplaying",se)})}})}var h,f,y;return h=g,(f=[{key:"_inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(b,C){C===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:b}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&jt(h.prototype,f),y&&jt(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function Nt(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function dr(g,h,f){return h&&Nt(g.prototype,h),f&&Nt(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var J=dr(function g(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,g),h.on("viewinit",function(){f._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(y){h.on(y,function(){if(f._lastPlayheadPosition>=0&&h.data.player_playhead_time>=0&&f._lastPlayerWidth>=0&&f._lastSourceWidth>0&&f._lastPlayerHeight>=0&&f._lastSourceHeight>0){var b=h.data.player_playhead_time-f._lastPlayheadPosition;if(b<0)return void(f._lastPlayheadPosition=-1);var C=Math.min(f._lastPlayerWidth/f._lastSourceWidth,f._lastPlayerHeight/f._lastSourceHeight),A=Math.max(0,C-1),G=Math.max(0,1-C);h.data.view_max_upscale_percentage=Math.max(h.data.view_max_upscale_percentage||0,A),h.data.view_max_downscale_percentage=Math.max(h.data.view_max_downscale_percentage||0,G),K(h.data,"view_total_content_playback_time",b),K(h.data,"view_total_upscaling",A*b),K(h.data,"view_total_downscaling",G*b)}f._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(y){h.on(y,function(){f._lastPlayheadPosition=h.data.player_playhead_time,f._lastPlayerWidth=h.data.player_width,f._lastPlayerHeight=h.data.player_height,f._lastSourceWidth=h.data.video_source_width,f._lastSourceHeight=h.data.video_source_height})})});function O(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function T(g,h,f){return h&&O(g.prototype,h),f&&O(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var P=T(function g(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,g),this.isSeeking=!1,h.on("seeking",function(y,b){U()(h.data,b),f._lastSeekingTime=z.now(),f.isSeeking===!1&&(f.isSeeking=!0,h.send("seeking"))}),h.on("seeked",function(){f.isSeeking=!1;var y=f._lastSeekingTime||z.now(),b=z.now()-y;K(h.data,"view_seek_count",1),K(h.data,"view_seek_duration",b);var C=h.data.view_max_seek_time||0;h.data.view_max_seek_time=Math.max(C,b)}),h.on("viewend",function(){f.isSeeking=!1})});function D(g,h){return function(f){if(Array.isArray(f))return f}(g)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var C,A,G=[],se=!0,Q=!1;try{for(b=b.call(f);!(se=(C=b.next()).done)&&(G.push(C.value),!y||G.length!==y);se=!0);}catch(Pe){Q=!0,A=Pe}finally{try{se||b.return==null||b.return()}finally{if(Q)throw A}}return G}}(g,h)||function(f,y){if(f){if(typeof f=="string")return F(f,y);var b=Object.prototype.toString.call(f).slice(8,-1);return b==="Object"&&f.constructor&&(b=f.constructor.name),b==="Map"||b==="Set"?Array.from(f):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?F(f,y):void 0}}(g,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 F(g,h){(h==null||h>g.length)&&(h=g.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=g[f];return y}function q(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Y=function(g,h){g.push(h),g.sort(function(f,y){return f.viewer_time-y.viewer_time})},he=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Le=function(){function g(b){var C=this;(function(G,se){if(!(G instanceof se))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,b.on("viewinit",function(){C.isAdBreak=!1,C._currentAdRequestNumber=0,C._currentAdResponseNumber=0,C._adRequests=[],C._adResponses=[],C._adHasPlayed=!1,C._wouldBeNewAdPlay=!0,C._prerollPlayTime=void 0}),he.forEach(function(G){return b.on(G,C._updateAdData.bind(C))});var A=function(){C.isAdBreak=!1};b.on("adbreakstart",function(){C.isAdBreak=!0}),b.on("play",A),b.on("playing",A),b.on("viewend",A),b.on("adrequest",function(G,se){se=U()({ad_request_id:"generatedAdRequestId"+C._currentAdRequestNumber++},se),Y(C._adRequests,se),K(b.data,"view_ad_request_count"),C.inPrerollPosition()&&(b.data.view_preroll_requested=!0,C._adHasPlayed||K(b.data,"view_preroll_request_count"))}),b.on("adresponse",function(G,se){se=U()({ad_request_id:"generatedAdRequestId"+C._currentAdResponseNumber++},se),Y(C._adResponses,se);var Q=C.findAdRequest(se.ad_request_id);Q&&K(b.data,"view_ad_request_time",Math.max(0,se.viewer_time-Q.viewer_time))}),b.on("adplay",function(G,se){C._adHasPlayed=!0,C._wouldBeNewAdPlay&&(C._wouldBeNewAdPlay=!1,K(b.data,"view_ad_played_count")),C.inPrerollPosition()&&!b.data.view_preroll_played&&(b.data.view_preroll_played=!0,C._adRequests.length>0&&(b.data.view_preroll_request_time=Math.max(0,se.viewer_time-C._adRequests[0].viewer_time)),b.data.view_start&&(b.data.view_startup_preroll_request_time=Math.max(0,se.viewer_time-b.data.view_start)),C._prerollPlayTime=se.viewer_time)}),b.on("adplaying",function(G,se){C.inPrerollPosition()&&b.data.view_preroll_load_time===void 0&&C._prerollPlayTime!==void 0&&(b.data.view_preroll_load_time=se.viewer_time-C._prerollPlayTime,b.data.view_startup_preroll_load_time=se.viewer_time-C._prerollPlayTime)}),b.on("adended",function(){C._wouldBeNewAdPlay=!0}),b.on("aderror",function(){C._wouldBeNewAdPlay=!0})}var h,f,y;return h=g,(f=[{key:"inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(b){for(var C=0;C<this._adRequests.length;C++)if(this._adRequests[C].ad_request_id===b)return this._adRequests[C]}},{key:"_updateAdData",value:function(b,C){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&C.ad_tag_url){var A=D(ke(C.ad_tag_url),2),G=A[0],se=A[1];this.pm.data.view_preroll_ad_tag_domain=se,this.pm.data.view_preroll_ad_tag_hostname=G}if(!this.pm.data.view_preroll_ad_asset_hostname&&C.ad_asset_url){var Q=D(ke(C.ad_asset_url),2),Pe=Q[0],at=Q[1];this.pm.data.view_preroll_ad_asset_domain=at,this.pm.data.view_preroll_ad_asset_hostname=Pe}}}}])&&q(h.prototype,f),y&&q(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function Ae(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function Me(g,h,f){return h&&Ae(g.prototype,h),f&&Ae(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var Ve=Me(function g(h){var f,y;(function(G,se){if(!(G instanceof se))throw new TypeError("Cannot call a class as a function")})(this,g);var b=function(){h.disableRebufferTracking||f&&(K(h.data,"view_waiting_rebuffer_duration",z.now()-f),f=!1,R().clearInterval(y))},C=!1,A=function(){C=!1,b()};h.on("waiting",function(){C&&(h.disableRebufferTracking||(K(h.data,"view_waiting_rebuffer_count",1),f=z.now(),y=R().setInterval(function(){if(f){var G=z.now();K(h.data,"view_waiting_rebuffer_duration",G-f),f=G}},250)))}),h.on("playing",function(){b(),C=!0}),h.on("pause",A),h.on("seeking",A)});function Ue(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function Qe(g,h,f){return h&&Ue(g.prototype,h),f&&Ue(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var ot=Qe(function g(h){var f=this;(function(C,A){if(!(C instanceof A))throw new TypeError("Cannot call a class as a function")})(this,g);var y=function(){f.lastWallClockTime=z.now(),h.on("before*",b)},b=function(C){var A=z.now(),G=f.lastWallClockTime;f.lastWallClockTime=A,A-G>3e4&&(h.emit("devicesleep",{viewer_time:G}),U()(h.data,{viewer_time:G}),h.send("devicesleep"),h.emit("devicewake",{viewer_time:A}),U()(h.data,{viewer_time:A}),h.send("devicewake"))};h.one("playbackheartbeat",y),h.on("playbackheartbeatend",function(){h.off("before*",b),h.one("playbackheartbeat",y)})}),bt=B(375),We=B(655),Lt=B.n(We),Qt="muxData",Ot=function(){var g;try{g=bt.parse(Lt().get(Qt)||"")}catch{g={}}return g},xt=function(g){try{Lt().set(Qt,bt.stringify(g),{expires:7300})}catch{}},Ut=function(){var g=Ot();return g.mux_viewer_id=g.mux_viewer_id||p(),g.msn=g.msn||Math.random(),xt(g),{mux_viewer_id:g.mux_viewer_id,mux_sample_number:g.msn}};function Ze(g,h){var f=h.beaconCollectionDomain,y=h.beaconDomain;if(f)return"https://"+f;var b=y||"litix.io";return(g=g||"inferred").match(/^[a-z0-9]+$/)?"https://"+g+"."+b:"https://img.litix.io/a.gif"}var rr=function(){var g;switch(Er()){case"cellular":g="cellular";break;case"ethernet":g="wired";break;case"wifi":g="wifi";break;case void 0:break;default:g="other"}return g},Er=function(){var g=R().navigator,h=g&&(g.connection||g.mozConnection||g.webkitConnection);return h&&h.type};rr.getConnectionFromAPI=Er;var Ft=rr,Vt=wr({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"}),hr=wr({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function wr(g){var h={};for(var f in g)g.hasOwnProperty(f)&&(h[g[f]]=f);return h}function cr(g){var h={},f={};return Object.keys(g).forEach(function(y){var b=!1;if(g.hasOwnProperty(y)&&g[y]!==void 0){var C=y.split("_"),A=C[0],G=Vt[A];G||(H.info("Data key word `"+C[0]+"` not expected in "+y),G=A+"_"),C.splice(1).forEach(function(se){se==="url"&&(b=!0),hr[se]?G+=hr[se]:Number(se)&&Math.floor(Number(se))===Number(se)?G+=se:(H.info("Data key word `"+se+"` not expected in "+y),G+="_"+se+"_")}),b?f[G]=g[y]:h[G]=g[y]}}),U()(h,f)}var Mt={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},vi=["hb","requestcompleted","requestfailed","requestcanceled"],Ci="https://img.litix.io",Tr=function(g){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=g||Ci,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=U()({},Mt,h)};Tr.prototype.queueEvent=function(g,h){var f=U()({},h);return(this._eventQueue.length<=this._options.maxQueueLength||g==="eventrateexceeded")&&(this._eventQueue.push(f),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},Tr.prototype.flushEvents=function(){var g=arguments.length>0&&arguments[0]!==void 0&&arguments[0];g&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},Tr.prototype.destroy=function(){var g=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,g?this._clearBeaconQueue():this.flushEvents(),R().clearTimeout(this._sendTimeout)},Tr.prototype._clearBeaconQueue=function(){var g=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,h=this._eventQueue.slice(g);g>0&&U()(h[h.length-1],cr({mux_view_message:"event queue truncated"}));var f=this._createPayload(h);Zr(this._beaconUrl,f,!0,function(){})},Tr.prototype._sendBeaconQueue=function(){var g=this;if(!this._postInFlight){var h=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var f=this._createPayload(h),y=z.now();Zr(this._beaconUrl,f,!1,function(b,C){C?(g._eventQueue=h.concat(g._eventQueue),g._failureCount+=1,H.info("Error sending beacon: "+C)):g._failureCount=0,g._roundTripTime=z.now()-y,g._postInFlight=!1})}},Tr.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var g=Math.pow(2,this._failureCount-1);return(1+(g*=Math.random()))*this._options.baseTimeBetweenBeacons},Tr.prototype._startBeaconSending=function(){var g=this;R().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=R().setTimeout(function(){g._eventQueue.length&&g._sendBeaconQueue(),g._startBeaconSending()},this._getNextBeaconTime()))},Tr.prototype._createPayload=function(g){var h,f,y,b=this,C={transmission_timestamp:Math.round(z.now())};this._roundTripTime&&(C.rtt_ms=Math.round(this._roundTripTime));var A=function(){h=JSON.stringify({metadata:C,events:f||g}),y=h.length/1024},G=function(){return y<=b._options.maxPayloadKBSize};return A(),G()||(H.info("Payload size is too big ("+y+" kb). Removing unnecessary events."),f=g.filter(function(se){return vi.indexOf(se.e)===-1}),A()),G()||(H.info("Payload size still too big ("+y+" kb). Cropping fields.."),f.forEach(function(se){for(var Q in se){var Pe=se[Q];typeof Pe=="string"&&Pe.length>51200&&(se[Q]=Pe.substring(0,51200))}}),A()),h};var Zr=function(g,h,f,y){if(f&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(g,h))y();else if(R().fetch)R().fetch(g,{method:"POST",body:h,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(C){return y(null,C.ok?null:"Error")}).catch(function(C){return y(null,C)});else{if(R().XMLHttpRequest){var b=new(R()).XMLHttpRequest;return b.onreadystatechange=function(){if(b.readyState===4)return y(null,b.status!==200?"error":void 0)},b.open("POST",g),b.setRequestHeader("Content-Type","text/plain"),void b.send(h)}y()}},xi=Tr;function Oi(g,h){return function(f){if(Array.isArray(f))return f}(g)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var C,A,G=[],se=!0,Q=!1;try{for(b=b.call(f);!(se=(C=b.next()).done)&&(G.push(C.value),!y||G.length!==y);se=!0);}catch(Pe){Q=!0,A=Pe}finally{try{se||b.return==null||b.return()}finally{if(Q)throw A}}return G}}(g,h)||function(f,y){if(f){if(typeof f=="string")return ei(f,y);var b=Object.prototype.toString.call(f).slice(8,-1);return b==="Object"&&f.constructor&&(b=f.constructor.name),b==="Map"||b==="Set"?Array.from(f):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?ei(f,y):void 0}}(g,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(g,h){(h==null||h>g.length)&&(h=g.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=g[f];return y}function ni(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function ai(g,h){return ai=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,y){return f.__proto__=y,f},ai(g,h)}function pi(g){var h=function(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var f,y=si(g);if(h){var b=si(this).constructor;f=Reflect.construct(y,arguments,b)}else f=y.apply(this,arguments);return Ni(this,f)}}function Ni(g,h){if(h&&(Pr(h)==="object"||typeof h=="function"))return h;if(h!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Yt(g)}function Yt(g){if(g===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g}function si(g){return si=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},si(g)}var en=["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"],Ui=function(g){(function(A,G){if(typeof G!="function"&&G!==null)throw new TypeError("Super expression must either be null or a function");A.prototype=Object.create(G&&G.prototype,{constructor:{value:A,writable:!0,configurable:!0}}),Object.defineProperty(A,"prototype",{writable:!1}),G&&ai(A,G)})(C,g);var h,f,y,b=pi(C);function C(A,G,se){var Q;(function(Xe,nt){if(!(Xe instanceof nt))throw new TypeError("Cannot call a class as a function")})(this,C),(Q=b.call(this)).DOM_CONTENT_LOADED_EVENT_END=He.domContentLoadedEventEnd(),Q.NAVIGATION_START=He.navigationStart(),Q.mux=A,Q.id=G,(se=U()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(Xe){return Xe}},se)).data=se.data||{},se.data.property_key&&(se.data.env_key=se.data.property_key,delete se.data.property_key),H.setLevel(se.debug?"debug":"warn"),Q.getPlayheadTime=se.getPlayheadTime,Q.getStateData=se.getStateData||function(){return{}},Q.getAdData=se.getAdData||function(){},Q.minimumRebufferDuration=se.minimumRebufferDuration,Q.sustainedRebufferThreshold=se.sustainedRebufferThreshold,Q.playbackHeartbeatTime=se.playbackHeartbeatTime,Q.disableRebufferTracking=se.disableRebufferTracking,Q.disableRebufferTracking&&Q.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."),Q.disablePlayheadRebufferTracking=se.disablePlayheadRebufferTracking,Q.errorTranslator=se.errorTranslator,Q.playbackEventDispatcher=new Nr(A,se.data.env_key,se),Q.data={player_instance_id:p(),mux_sample_rate:se.sampleRate,beacon_domain:se.beaconCollectionDomain?se.beaconCollectionDomain:se.beaconDomain},Q.data.view_sequence_number=1,Q.data.player_sequence_number=1,Q.oldEmit=Q.emit,Q.emit=function(Xe,nt){nt=U()({viewer_time:this.mux.utils.now()},nt),this.oldEmit(Xe,nt)};var Pe=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Yt(Q));Q.on("viewinit",function(Xe,nt){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),U()(this.data,nt),this._initializeViewData(),this.one("play",Pe),this.one("adbreakstart",Pe)});var at=function(Xe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",Xe)}.bind(Yt(Q));if(Q.on("videochange",function(Xe,nt){at(nt)}),Q.on("programchange",function(Xe,nt){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."),at(U()(nt,{view_program_changed:!0})),Pe(),this.emit("play"),this.emit("playing")}),Q.on("fragmentchange",function(Xe,nt){this.currentFragmentPDT=nt.currentFragmentPDT,this.currentFragmentStart=nt.currentFragmentStart}),Q.on("destroy",Q.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var Je=function(){var Xe=Q.data.view_start!==void 0;Q.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",Xe&&Q.mux.WINDOW_HIDDEN&&(Q.data.player_is_paused||Q.emit("hb"))};window.addEventListener("visibilitychange",Je,!1);var it=function(Xe){Xe.persisted||Q.destroy()};window.addEventListener("pagehide",it,!1),Q.on("destroy",function(){window.removeEventListener("visibilitychange",Je),window.removeEventListener("pagehide",it)})}return Q.on("playerready",function(Xe,nt){U()(this.data,nt)}),en.forEach(function(Xe){Q.on(Xe,function(nt,wt){Xe.indexOf("ad")!==0&&this._updateStateData(),U()(this.data,wt),this._sanitizeData()}),Q.on("after"+Xe,function(){(Xe!=="error"||this.errorTracker.viewErrored)&&this.send(Xe)})}),Q.on("viewend",function(Xe,nt){U()(Q.data,nt)}),Q.one("playerready",function(Xe){var nt=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=nt-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}),Q.longResumeTracker=new Sr(Yt(Q)),Q.errorTracker=new Ie(Yt(Q)),new ot(Yt(Q)),Q.seekingTracker=new P(Yt(Q)),Q.playheadTime=new Dt(Yt(Q)),Q.playbackHeartbeat=new Be(Yt(Q)),new J(Yt(Q)),Q.watchTimeTracker=new rt(Yt(Q)),new ht(Yt(Q)),Q.adTracker=new Le(Yt(Q)),new Pt(Yt(Q)),new gt(Yt(Q)),new zt(Yt(Q)),new Ve(Yt(Q)),new br(Yt(Q)),se.hlsjs&&Q.addHLSJS(se),se.dashjs&&Q.addDashJS(se),Q.emit("viewinit",se.data),Q}return h=C,f=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(A){var G=U()({},this.data);if(G.video_source_is_live===void 0&&(G.player_source_duration===1/0||G.video_source_duration===1/0?G.video_source_is_live=!0:(G.player_source_duration>0||G.video_source_duration>0)&&(G.video_source_is_live=!1)),G.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(at){G[at]=void 0}),G.video_source_url=G.video_source_url||G.player_source_url,G.video_source_url){var se=Br(ke(G.video_source_url),2),Q=se[0],Pe=se[1];G.video_source_domain=Pe,G.video_source_hostname=Q}delete G.ad_request_id,this.playbackEventDispatcher.send(A,G),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){U()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var A=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(G){var se=parseInt(A.data[G],10);A.data[G]=isNaN(se)?void 0:se}),["player_source_url","video_source_url"].forEach(function(G){if(A.data[G]){var se=A.data[G].toLowerCase();se.indexOf("data:")!==0&&se.indexOf("blob:")!==0||(A.data[G]="MSE style URL")}})}},{key:"_resetVideoData",value:function(A,G){var se=this;Object.keys(this.data).forEach(function(Q){Q.indexOf("video_")===0&&delete se.data[Q]})}},{key:"_resetViewData",value:function(){var A=this;Object.keys(this.data).forEach(function(G){G.indexOf("view_")===0&&delete A.data[G]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(A,G){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var A=this,G=this.data.view_id=p(),se=function(){G===A.data.view_id&&K(A.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",se):se()}},{key:"_restartHeartBeat",value:function(){var A=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){A.data.player_is_paused||A.emit("hb")},1e4))}},{key:"addHLSJS",value:function(A){A.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=A.hlsjs,function(G,se,Q){var Pe=arguments.length>4?arguments[4]:void 0,at=G.log,Je=G.utils.secondsToMs,it=function(_t){var et,dt=parseInt(Pe.version);return dt===1&&_t.programDateTime!==null&&(et=_t.programDateTime),dt===0&&_t.pdt!==null&&(et=_t.pdt),et};if(He.exists()){var Xe=function(_t,et){return G.emit(se,_t,et)},nt=function(_t,et){var dt=et.levels,$e=et.audioTracks,lt=et.url,Ht=et.stats,Kt=et.networkDetails,nr=et.sessionData,tr={},vr={};dt.forEach(function(gr,jr){tr[jr]={width:gr.width,height:gr.height,bitrate:gr.bitrate,attrs:gr.attrs}}),$e.forEach(function(gr,jr){vr[jr]={name:gr.name,language:gr.lang,bitrate:gr.bitrate}});var ar=V(Ht),pr=ar.bytesLoaded,qt=ar.requestStart,sr=ar.responseStart,Jr=ar.responseEnd;Xe("requestcompleted",ye(ye({},L(nr)),{},{request_event_type:_t,request_bytes_loaded:pr,request_start:qt,request_response_start:sr,request_response_end:Jr,request_type:"manifest",request_hostname:be(lt),request_response_headers:we(Kt),request_rendition_lists:{media:tr,audio:vr,video:{}}}))};Q.on(Pe.Events.MANIFEST_LOADED,nt);var wt=function(_t,et){var dt=et.details,$e=et.level,lt=et.networkDetails,Ht=et.stats,Kt=V(Ht),nr=Kt.bytesLoaded,tr=Kt.requestStart,vr=Kt.responseStart,ar=Kt.responseEnd,pr=dt.fragments[dt.fragments.length-1],qt=it(pr)+Je(pr.duration);Xe("requestcompleted",{request_event_type:_t,request_bytes_loaded:nr,request_start:tr,request_response_start:vr,request_response_end:ar,request_current_level:$e,request_type:"manifest",request_hostname:be(dt.url),request_response_headers:we(lt),video_holdback:dt.holdBack&&Je(dt.holdBack),video_part_holdback:dt.partHoldBack&&Je(dt.partHoldBack),video_part_target_duration:dt.partTarget&&Je(dt.partTarget),video_target_duration:dt.targetduration&&Je(dt.targetduration),video_source_is_live:dt.live,player_manifest_newest_program_time:isNaN(qt)?void 0:qt})};Q.on(Pe.Events.LEVEL_LOADED,wt);var Bt=function(_t,et){var dt=et.details,$e=et.networkDetails,lt=et.stats,Ht=V(lt),Kt=Ht.bytesLoaded,nr=Ht.requestStart,tr=Ht.responseStart,vr=Ht.responseEnd;Xe("requestcompleted",{request_event_type:_t,request_bytes_loaded:Kt,request_start:nr,request_response_start:tr,request_response_end:vr,request_type:"manifest",request_hostname:be(dt.url),request_response_headers:we($e)})};Q.on(Pe.Events.AUDIO_TRACK_LOADED,Bt);var Jt=function(_t,et){var dt=et.stats,$e=et.networkDetails,lt=et.frag;dt=dt||lt.stats;var Ht=V(dt),Kt=Ht.bytesLoaded,nr=Ht.requestStart,tr=Ht.responseStart,vr=Ht.responseEnd,ar=we($e),pr=ar==null?void 0:ar["x-request-id"],qt={request_event_type:_t,request_bytes_loaded:Kt,request_start:nr,request_response_start:tr,request_response_end:vr,request_hostname:$e?be($e.responseURL):void 0,request_id:pr,request_response_headers:ar,request_media_duration:lt.duration,request_url:$e==null?void 0:$e.responseURL};lt.type==="main"?(qt.request_type="media",qt.request_current_level=lt.level,qt.request_video_width=(Q.levels[lt.level]||{}).width,qt.request_video_height=(Q.levels[lt.level]||{}).height,qt.request_labeled_bitrate=(Q.levels[lt.level]||{}).bitrate):qt.request_type=lt.type,Xe("requestcompleted",qt)};Q.on(Pe.Events.FRAG_LOADED,Jt);var ir=function(_t,et){var dt=et.frag,$e=dt.start,lt={currentFragmentPDT:it(dt),currentFragmentStart:Je($e)};Xe("fragmentchange",lt)};Q.on(Pe.Events.FRAG_CHANGED,ir);var mt=function(_t,et){var dt=et.type,$e=et.details,lt=et.response,Ht=et.fatal,Kt=et.context,nr=et.frag;if($e===Pe.ErrorDetails.MANIFEST_LOAD_ERROR||$e===Pe.ErrorDetails.MANIFEST_LOAD_TIMEOUT||$e===Pe.ErrorDetails.FRAG_LOAD_ERROR||$e===Pe.ErrorDetails.FRAG_LOAD_TIMEOUT||$e===Pe.ErrorDetails.LEVEL_LOAD_ERROR||$e===Pe.ErrorDetails.LEVEL_LOAD_TIMEOUT){var tr=nr&&nr.url||Kt&&Kt.url||"";Xe("requestfailed",{request_error:$e,request_url:tr,request_hostname:be(tr),request_type:$e===Pe.ErrorDetails.FRAG_LOAD_ERROR||$e===Pe.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:lt&<.code,request_error_text:lt&<.text})}Ht&&Xe("error",{player_error_code:dt,player_error_message:$e})};Q.on(Pe.Events.ERROR,mt);var Wt=function(_t,et){var dt=et.frag,$e=dt&&dt._url||"";Xe("requestcanceled",{request_event_type:_t,request_url:$e,request_type:"media",request_hostname:be($e)})};Q.on(Pe.Events.FRAG_LOAD_EMERGENCY_ABORTED,Wt);var er=function(_t,et){var dt=et.level,$e=Q.levels[dt];if($e&&$e.attrs&&$e.attrs.BANDWIDTH){var lt,Ht=$e.attrs.BANDWIDTH,Kt=parseFloat($e.attrs["FRAME-RATE"]);isNaN(Kt)||(lt=Kt),Ht?Xe("renditionchange",{video_source_fps:lt,video_source_bitrate:Ht,video_source_width:$e.width,video_source_height:$e.height,video_source_rendition_name:$e.name,video_source_codec:$e==null?void 0:$e.videoCodec}):at.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};Q.on(Pe.Events.LEVEL_SWITCHED,er),Q._stopMuxMonitor=function(){Q.off(Pe.Events.MANIFEST_LOADED,nt),Q.off(Pe.Events.LEVEL_LOADED,wt),Q.off(Pe.Events.AUDIO_TRACK_LOADED,Bt),Q.off(Pe.Events.FRAG_LOADED,Jt),Q.off(Pe.Events.FRAG_CHANGED,ir),Q.off(Pe.Events.ERROR,mt),Q.off(Pe.Events.FRAG_LOAD_EMERGENCY_ABORTED,Wt),Q.off(Pe.Events.LEVEL_SWITCHED,er),Q.off(Pe.Events.DESTROYING,Q._stopMuxMonitor),delete Q._stopMuxMonitor},Q.on(Pe.Events.DESTROYING,Q._stopMuxMonitor)}else at.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,A.hlsjs,{},A.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var A;this.hlsjs&&((A=this.hlsjs)&&typeof A._stopMuxMonitor=="function"&&A._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(A){A.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=A.dashjs,function(G,se,Q){var Pe=G.log;if(Q&&Q.on){var at=function(mt,Wt){return G.emit(se,mt,Wt)},Je=function(mt){var Wt=mt.type,er=(mt.data||{}).url;at("requestcompleted",{request_event_type:Wt,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:be(er),request_url:er})};Q.on("manifestLoaded",Je);var it={},Xe=function(mt){var Wt=mt.type,er=mt.fragmentModel,_t=(mt.chunk||{}).mediaInfo||{},et=_t.type,dt=_t.bitrateList,$e={};(dt=dt||[]).forEach(function(qt,sr){$e[sr]={},$e[sr].width=qt.width,$e[sr].height=qt.height,$e[sr].bitrate=qt.bandwidth,$e[sr].attrs={}}),et==="video"?it.video=$e:et==="audio"?it.audio=$e:it.media=$e;var lt=qe(er,Q),Ht=lt.requestStart,Kt=lt.requestResponseStart,nr=lt.requestResponseEnd,tr=lt.requestResponseHeaders,vr=lt.requestMediaDuration,ar=lt.requestHostname,pr=lt.requestUrl;at("requestcompleted",{request_event_type:Wt,request_start:Ht,request_response_start:Kt,request_response_end:nr,request_bytes_loaded:-1,request_type:et+"_init",request_response_headers:tr,request_hostname:ar,request_url:pr,request_media_duration:vr,request_rendition_lists:it})};Q.on("initFragmentLoaded",Xe);var nt=function(mt){var Wt=mt.type,er=mt.fragmentModel,_t=mt.chunk||{},et=_t.mediaInfo,dt=_t.start,$e=(et||{}).type,lt=qe(er,Q),Ht=lt.requestStart,Kt=lt.requestResponseStart,nr=lt.requestResponseEnd,tr=lt.requestBytesLoaded,vr=lt.requestResponseHeaders,ar=lt.requestMediaDuration,pr=lt.requestHostname,qt=lt.requestUrl,sr=tt($e,Q),Jr=sr.currentLevel,gr=sr.renditionWidth,jr=sr.renditionHeight,Ki=sr.renditionBitrate;at("requestcompleted",{request_event_type:Wt,request_start:Ht,request_response_start:Kt,request_response_end:nr,request_bytes_loaded:tr,request_type:$e,request_response_headers:vr,request_hostname:pr,request_url:qt,request_media_start_time:dt,request_media_duration:ar,request_current_level:Jr,request_labeled_bitrate:Ki,request_video_width:gr,request_video_height:jr})};Q.on("mediaFragmentLoaded",nt);var wt={video:void 0,audio:void 0,totalBitrate:void 0},Bt=function(){if(wt.video&&typeof wt.video.bitrate=="number"){if(wt.video.width&&wt.video.height){var mt=wt.video.bitrate;return wt.audio&&typeof wt.audio.bitrate=="number"&&(mt+=wt.audio.bitrate),mt!==wt.totalBitrate?(wt.totalBitrate=mt,{video_source_bitrate:mt,video_source_height:wt.video.height,video_source_width:wt.video.width,video_source_codec:ee(wt.video.codec)}):void 0}Pe.warn("have bitrate info for video but missing width/height")}},Jt=function(mt,Wt,er){if(typeof mt.newQuality=="number"){var _t=mt.mediaType;if(_t==="audio"||_t==="video"){var et=Q.getBitrateInfoListFor(_t).find(function($e){return $e.qualityIndex===mt.newQuality});if(et&&typeof et.bitrate=="number"){wt[_t]=Ce(Ce({},et),{},{codec:Q.getCurrentTrackFor(_t).codec});var dt=Bt();dt&&at("renditionchange",dt)}else Pe.warn("missing bitrate info for ".concat(_t))}}else Pe.warn("missing evt.newQuality in qualityChangeRendered event",mt)};Q.on("qualityChangeRendered",Jt);var ir=function(mt){var Wt=mt.error,er=mt.event,_t=(er=er||{}).request||{},et=R().event&&R().event.currentTarget||{};at("requestfailed",{request_error:Wt+"_"+er.id+"_"+_t.type,request_url:er.url,request_hostname:be(er.url),request_type:_t.mediaType,request_error_code:et.status,request_error_type:et.statusText})};Q.on("error",ir),Q._stopMuxMonitor=function(){Q.off("manifestLoaded",Je),Q.off("initFragmentLoaded",Xe),Q.off("mediaFragmentLoaded",nt),Q.off("qualityChangeRendered",Jt),Q.off("error",ir),delete Q._stopMuxMonitor}}else Pe.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,A.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var A;this.dashjs&&((A=this.dashjs)&&typeof A._stopMuxMonitor=="function"&&A._stopMuxMonitor(),this.dashjs=void 0)}}],f&&ni(h.prototype,f),y&&ni(h,y),Object.defineProperty(h,"prototype",{writable:!1}),C}(xe),Cr=Ui,gi=B(153),Xr=B.n(gi);function zr(g){return zr=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},zr(g)}function mi(g,h){return function(f){if(Array.isArray(f))return f}(g)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var C,A,G=[],se=!0,Q=!1;try{for(b=b.call(f);!(se=(C=b.next()).done)&&(G.push(C.value),!y||G.length!==y);se=!0);}catch(Pe){Q=!0,A=Pe}finally{try{se||b.return==null||b.return()}finally{if(Q)throw A}}return G}}(g,h)||function(f,y){if(f){if(typeof f=="string")return Bi(f,y);var b=Object.prototype.toString.call(f).slice(8,-1);return b==="Object"&&f.constructor&&(b=f.constructor.name),b==="Map"||b==="Set"?Array.from(f):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?Bi(f,y):void 0}}(g,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
-
|
|
1
|
+
"use strict";(()=>{var cl=Object.create;var bs=Object.defineProperty;var hl=Object.getOwnPropertyDescriptor;var fl=Object.getOwnPropertyNames;var vl=Object.getPrototypeOf,gl=Object.prototype.hasOwnProperty;var Ss=(D,I)=>()=>(I||D((I={exports:{}}).exports,I),I.exports);var pl=(D,I,F,H)=>{if(I&&typeof I=="object"||typeof I=="function")for(let j of fl(I))!gl.call(D,j)&&j!==F&&bs(D,j,{get:()=>I[j],enumerable:!(H=hl(I,j))||H.enumerable});return D};var Ls=(D,I,F)=>(F=D!=null?cl(vl(D)):{},pl(I||!D||!D.__esModule?bs(F,"default",{value:D,enumerable:!0}):F,D));var ks=Ss((yn,pa)=>{(function(){var D,I;D=this,I=function(){return function(){var F={80:function(G,Q,q){G.exports=q(728).default},728:function(G,Q,q){"use strict";q.d(Q,{default:function(){return Gr}});var te=q(48),z=q.n(te),ne=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(p){var h=16*Math.random()|0;return(p==="x"?h:3&h|8).toString(16)})},Te=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},ae=function(p){return p&&p.nodeName!==void 0?(p.muxId||(p.muxId=p.id||Te()),p.muxId):p},Ee=function(p){var h;p&&p.nodeName!==void 0?p=ae(h=p):h=document.querySelector(p);var g=h&&h.nodeName?h.nodeName.toLowerCase():"";return[h,p,g]},Ae=q(640),Ie=q.n(Ae),Ye=Ie().methodFactory;Ie().methodFactory=function(p,h,g){var b=Ye(p,h,g);return function(){for(var L=["[mux]"],w=0;w<arguments.length;w++)L.push(arguments[w]);b.apply(void 0,L)}},Ie().setLevel(Ie().getLevel());var ke=Ie();function ut(){return(z().doNotTrack||z().navigator&&z().navigator.doNotTrack)==="1"}var Fe={now:function(){var p=z().performance,h=p&&p.timing,g=h&&h.navigationStart,b=typeof g=="number"&&typeof p.now=="function"?g+p.now():Date.now();return Math.round(b)}},ee=function(p){return _(p)[0]},_=function(p){if(typeof p!="string"||p==="")return["localhost"];var h,g=(p.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return g&&(h=(g.match(/[^\.]+\.[^\.]+$/)||[])[0]),[g,h]},re={exists:function(){var p=z().performance;return(p&&p.timing)!==void 0},domContentLoadedEventEnd:function(){var p=z().performance,h=p&&p.timing;return h&&h.domContentLoadedEventEnd},navigationStart:function(){var p=z().performance,h=p&&p.timing;return h&&h.navigationStart}};function M(p,h,g){g=g===void 0?1:g,p[h]=p[h]||0,p[h]+=g}var Ke=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],St=["x-cdn","content-type"].concat(Ke);function we(p){var h={};return(p=p||"").trim().split(/[\r\n]+/).forEach(function(g){if(g){var b=g.split(": "),L=b.shift();L&&(St.indexOf(L.toLowerCase())>=0||L.toLowerCase().indexOf("x-litix-")===0)&&(h[L]=b.join(": "))}}),h}function We(p){if(p){var h=Ke.find(function(g){return p[g]!==void 0});return h?p[h]:void 0}}var $e=function(p){var h={};for(var g in p){var b=p[g];b["DATA-ID"].search("io.litix.data.")!==-1&&(h[b["DATA-ID"].replace("io.litix.data.","")]=b.VALUE)}return h};function P(p,h){var g=Object.keys(p);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(p);h&&(b=b.filter(function(L){return Object.getOwnPropertyDescriptor(p,L).enumerable})),g.push.apply(g,b)}return g}function He(p){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?P(Object(g),!0).forEach(function(b){dt(p,b,g[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(g)):P(Object(g)).forEach(function(b){Object.defineProperty(p,b,Object.getOwnPropertyDescriptor(g,b))})}return p}function dt(p,h,g){return h in p?Object.defineProperty(p,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):p[h]=g,p}var Be=function(p){if(!p)return{};var h=re.navigationStart(),g=p.loading,b=g?g.start:p.trequest,L=g?g.first:p.tfirst,w=g?g.end:p.tload;return{bytesLoaded:p.total,requestStart:Math.round(h+b),responseStart:Math.round(h+L),responseEnd:Math.round(h+w)}},Ht=function(p){if(p&&typeof p.getAllResponseHeaders=="function")return we(p.getAllResponseHeaders())};function ur(p,h){var g=Object.keys(p);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(p);h&&(b=b.filter(function(L){return Object.getOwnPropertyDescriptor(p,L).enumerable})),g.push.apply(g,b)}return g}function Mt(p){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?ur(Object(g),!0).forEach(function(b){Se(p,b,g[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(g)):ur(Object(g)).forEach(function(b){Object.defineProperty(p,b,Object.getOwnPropertyDescriptor(g,b))})}return p}function Se(p,h,g){return h in p?Object.defineProperty(p,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):p[h]=g,p}var ze=function(p,h){if(!p||typeof p.getRequests!="function")return{};var g=p.getRequests({state:"executed"});if(g.length===0)return{};var b,L=g[g.length-1],w=ee(L.url),k=L.url,x=L.bytesLoaded,U=new Date(L.requestStartDate).getTime(),O=new Date(L.firstByteDate).getTime(),W=new Date(L.requestEndDate).getTime(),pe=isNaN(L.duration)?0:L.duration,ie=typeof h.getMetricsFor=="function"?h.getMetricsFor(L.mediaType).HttpList:h.getDashMetrics().getHttpRequests(L.mediaType);return ie.length>0&&(b=we(ie[ie.length-1]._responseHeaders||"")),{requestStart:U,requestResponseStart:O,requestResponseEnd:W,requestBytesLoaded:x,requestResponseHeaders:b,requestMediaDuration:pe,requestHostname:w,requestUrl:k,requestId:b?We(b):void 0}},Gt=function(p,h){var g=h.getQualityFor(p),b=h.getCurrentTrackFor(p).bitrateList;return b?{currentLevel:g,renditionWidth:b[g].width||null,renditionHeight:b[g].height||null,renditionBitrate:b[g].bandwidth}:{}},_r=function(p){var h;return(h=p.match(/.*codecs\*?="(.*)"/))===null||h===void 0?void 0:h[1]};function br(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Ai=0,Ln=function(){function p(){(function(L,w){if(!(L instanceof w))throw new TypeError("Cannot call a class as a function")})(this,p)}var h,g,b;return h=p,g=[{key:"on",value:function(L,w,k){return w._eventEmitterGuid=w._eventEmitterGuid||++Ai,this._listeners=this._listeners||{},this._listeners[L]=this._listeners[L]||[],k&&(w=w.bind(k)),this._listeners[L].push(w),w}},{key:"off",value:function(L,w){var k=this._listeners&&this._listeners[L];k&&k.forEach(function(x,U){x._eventEmitterGuid===w._eventEmitterGuid&&k.splice(U,1)})}},{key:"one",value:function(L,w,k){var x=this;w._eventEmitterGuid=w._eventEmitterGuid||++Ai;var U=function O(){x.off(L,O),w.apply(k||this,arguments)};U._eventEmitterGuid=w._eventEmitterGuid,this.on(L,U)}},{key:"emit",value:function(L,w){var k=this;if(this._listeners){w=w||{};var x=this._listeners["before*"]||[],U=this._listeners[L]||[],O=this._listeners["after"+L]||[],W=function(pe,ie){(pe=pe.slice()).forEach(function(he){he.call(k,{type:L},ie)})};W(x,w),W(U,w),W(O,w)}}}],g&&br(h.prototype,g),b&&br(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}(),Xr=Ln;function Ri(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Di=function(){function p(L){var w=this;(function(k,x){if(!(k instanceof x))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,L.on("playing",function(){w._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?w._stopPlaybackHeartbeatInterval():w._startPlaybackHeartbeatInterval()}),L.on("timeupdate",function(){w._playbackHeartbeatInterval!==null&&L.emit("playbackheartbeat")}),L.on("devicesleep",function(k,x){w._playbackHeartbeatInterval!==null&&(z().clearInterval(w._playbackHeartbeatInterval),L.emit("playbackheartbeatend",{viewer_time:x.viewer_time}),w._playbackHeartbeatInterval=null)})}var h,g,b;return h=p,(g=[{key:"_startPlaybackHeartbeatInterval",value:function(){var L=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=z().setInterval(function(){L.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(z().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Ri(h.prototype,g),b&&Ri(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function qe(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Qr(p,h,g){return h&&qe(p.prototype,h),g&&qe(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Jr=Qr(function p(h){var g=this;(function(b,L){if(!(b instanceof L))throw new TypeError("Cannot call a class as a function")})(this,p),h.on("viewinit",function(){g.viewErrored=!1}),h.on("error",function(b,L){try{var w=h.errorTranslator({player_error_code:L.player_error_code,player_error_message:L.player_error_message,player_error_context:L.player_error_context});w?(h.data.player_error_code=w.player_error_code||L.player_error_code,h.data.player_error_message=w.player_error_message||L.player_error_message,h.data.player_error_context=w.player_error_context||L.player_error_context,g.viewErrored=!0):(delete h.data.player_error_code,delete h.data.player_error_message,delete h.data.player_error_context)}catch(k){h.mux.log.warn("Exception in error translator callback.",k),g.viewErrored=!0}})});function dr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Sr=function(){function p(L){(function(w,k){if(!(w instanceof k))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,this._watchTimeTrackerLastCheckedTime=null,L.on("playbackheartbeat",this._updateWatchTime.bind(this)),L.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var h,g,b;return h=p,(g=[{key:"_updateWatchTime",value:function(L,w){var k=w.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=k),M(this.pm.data,"view_watch_time",k-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=k}},{key:"_clearWatchTimeState",value:function(L,w){this._updateWatchTime(L,w),this._watchTimeTrackerLastCheckedTime=null}}])&&dr(h.prototype,g),b&&dr(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function $r(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Ii=function(){function p(L){(function(w,k){if(!(w instanceof k))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,this._playbackTimeTrackerLastPlayheadPosition=-1,L.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),L.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),L.on("seeking",this._clearPlaybackTimeState.bind(this))}var h,g,b;return h=p,(g=[{key:"_updatePlaybackTime",value:function(){var L=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&L>this._playbackTimeTrackerLastPlayheadPosition){var w=L-this._playbackTimeTrackerLastPlayheadPosition;w<=1e3&&M(this.pm.data,"view_content_playback_time",w)}this._playbackTimeTrackerLastPlayheadPosition=L}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&$r(h.prototype,g),b&&$r(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Zr(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var ei=function(){function p(L){(function(k,x){if(!(k instanceof x))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L;var w=this._updatePlayheadTime.bind(this);L.on("playbackheartbeat",w),L.on("playbackheartbeatend",w),L.on("timeupdate",w),L.on("destroy",function(){L.off("timeupdate",w)})}var h,g,b;return h=p,(g=[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=this.pm.data.view_max_playhead_position===void 0?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(L,w){var k=this,x=function(){k.pm.currentFragmentPDT&&k.pm.currentFragmentStart&&(k.pm.data.player_program_time=k.pm.currentFragmentPDT+k.pm.data.player_playhead_time-k.pm.currentFragmentStart)};if(w&&w.player_playhead_time)this.pm.data.player_playhead_time=w.player_playhead_time,x(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var U=this.pm.getPlayheadTime();U!==void 0&&(this.pm.data.player_playhead_time=U,x(),this._updateMaxPlayheadPosition())}}}])&&Zr(h.prototype,g),b&&Zr(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function ti(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function zt(p,h,g){return h&&ti(p.prototype,h),g&&ti(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Lr=3e5,ri=zt(function p(h){if(function(w,k){if(!(w instanceof k))throw new TypeError("Cannot call a class as a function")}(this,p),!h.disableRebufferTracking){var g,b=function(w,k){L(k),g=void 0},L=function(w){if(g){var k=w.viewer_time-g;M(h.data,"view_rebuffer_duration",k),g=w.viewer_time,h.data.view_rebuffer_duration>Lr&&(h.emit("viewend"),h.send("viewend"),h.mux.log.warn("Ending view after rebuffering for longer than ".concat(Lr,"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(w,k){return L(k)}),h.on("rebufferstart",function(w,k){g||(M(h.data,"view_rebuffer_count",1),g=k.viewer_time,h.one("rebufferend",b))}),h.on("viewinit",function(){g=void 0,h.off("rebufferend",b)})}});function ii(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var kr=function(){function p(L){var w=this;(function(k,x){if(!(k instanceof x))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,L.disableRebufferTracking||L.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,L.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),L.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),L.on("seeking",function(){w._cleanupRebufferTracker(null,{viewer_time:Fe.now()})}))}var h,g,b;return h=p,g=[{key:"_checkIfRebuffering",value:function(L,w){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(L,w);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var k=w.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&k>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=w.viewer_time}else this._cleanupRebufferTracker(L,w,!0);else this._prepareRebufferTrackerState(w.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,w){var k=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:w.viewer_time});else{if(this._lastCheckedTime===null)return;var x=this.pm.data.player_playhead_time-this._lastPlayheadTime,U=w.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&x>0&&U-x>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+U-x}))}k?this._prepareRebufferTrackerState(w.viewer_time):this._clearRebufferTrackerState()}}],g&&ii(h.prototype,g),b&&ii(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}(),wr=kr;function xi(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Ci=function(){function p(L){var w=this;(function(k,x){if(!(k instanceof x))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,L.on("viewinit",function(){var k=L.data,x=k.view_id;if(!k.view_program_changed){var U=function(O,W){var pe=W.viewer_time;O.type==="playing"&&L.data.view_time_to_first_frame===void 0?w.calculateTimeToFirstFrame(pe||Fe.now(),x):O.type!=="adplaying"||L.data.view_time_to_first_frame!==void 0&&!w._inPrerollPosition()||w.calculateTimeToFirstFrame(pe||Fe.now(),x)};L.one("playing",U),L.one("adplaying",U),L.one("viewend",function(){L.off("playing",U),L.off("adplaying",U)})}})}var h,g,b;return h=p,(g=[{key:"_inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(L,w){w===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))}}])&&xi(h.prototype,g),b&&xi(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Pi(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Oi(p,h,g){return h&&Pi(p.prototype,h),g&&Pi(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var kn=Oi(function p(h){var g=this;(function(b,L){if(!(b instanceof L))throw new TypeError("Cannot call a class as a function")})(this,p),h.on("viewinit",function(){g._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(b){h.on(b,function(){if(g._lastPlayheadPosition>=0&&h.data.player_playhead_time>=0&&g._lastPlayerWidth>=0&&g._lastSourceWidth>0&&g._lastPlayerHeight>=0&&g._lastSourceHeight>0){var L=h.data.player_playhead_time-g._lastPlayheadPosition;if(L<0)return void(g._lastPlayheadPosition=-1);var w=Math.min(g._lastPlayerWidth/g._lastSourceWidth,g._lastPlayerHeight/g._lastSourceHeight),k=Math.max(0,w-1),x=Math.max(0,1-w);h.data.view_max_upscale_percentage=Math.max(h.data.view_max_upscale_percentage||0,k),h.data.view_max_downscale_percentage=Math.max(h.data.view_max_downscale_percentage||0,x),M(h.data,"view_total_content_playback_time",L),M(h.data,"view_total_upscaling",k*L),M(h.data,"view_total_downscaling",x*L)}g._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(b){h.on(b,function(){g._lastPlayheadPosition=h.data.player_playhead_time,g._lastPlayerWidth=h.data.player_width,g._lastPlayerHeight=h.data.player_height,g._lastSourceWidth=h.data.video_source_width,g._lastSourceHeight=h.data.video_source_height})})});function Mi(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function wn(p,h,g){return h&&Mi(p.prototype,h),g&&Mi(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var An=wn(function p(h){var g=this;(function(b,L){if(!(b instanceof L))throw new TypeError("Cannot call a class as a function")})(this,p),this.isSeeking=!1,h.on("seeking",function(b,L){Object.assign(h.data,L),g._lastSeekingTime=Fe.now(),g.isSeeking===!1&&(g.isSeeking=!0,h.send("seeking"))}),h.on("seeked",function(){g.isSeeking=!1;var b=g._lastSeekingTime||Fe.now(),L=Fe.now()-b;M(h.data,"view_seek_count",1),M(h.data,"view_seek_duration",L);var w=h.data.view_max_seek_time||0;h.data.view_max_seek_time=Math.max(w,L)}),h.on("viewend",function(){g.isSeeking=!1})});function Fi(p,h){return function(g){if(Array.isArray(g))return g}(p)||function(g,b){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var w,k,x=[],U=!0,O=!1;try{for(L=L.call(g);!(U=(w=L.next()).done)&&(x.push(w.value),!b||x.length!==b);U=!0);}catch(W){O=!0,k=W}finally{try{U||L.return==null||L.return()}finally{if(O)throw k}}return x}}(p,h)||function(g,b){if(g){if(typeof g=="string")return Tt(g,b);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?Tt(g,b):void 0}}(p,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Tt(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}function Ni(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}var Et=function(p,h){p.push(h),p.sort(function(g,b){return g.viewer_time-b.viewer_time})},Ar=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Rn=function(){function p(L){var w=this;(function(x,U){if(!(x instanceof U))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=L,L.on("viewinit",function(){w.isAdBreak=!1,w._currentAdRequestNumber=0,w._currentAdResponseNumber=0,w._adRequests=[],w._adResponses=[],w._adHasPlayed=!1,w._wouldBeNewAdPlay=!0,w._prerollPlayTime=void 0}),Ar.forEach(function(x){return L.on(x,w._updateAdData.bind(w))});var k=function(){w.isAdBreak=!1};L.on("adbreakstart",function(){w.isAdBreak=!0}),L.on("play",k),L.on("playing",k),L.on("viewend",k),L.on("adrequest",function(x,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+w._currentAdRequestNumber++},U),Et(w._adRequests,U),M(L.data,"view_ad_request_count"),w.inPrerollPosition()&&(L.data.view_preroll_requested=!0,w._adHasPlayed||M(L.data,"view_preroll_request_count"))}),L.on("adresponse",function(x,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+w._currentAdResponseNumber++},U),Et(w._adResponses,U);var O=w.findAdRequest(U.ad_request_id);O&&M(L.data,"view_ad_request_time",Math.max(0,U.viewer_time-O.viewer_time))}),L.on("adplay",function(x,U){w._adHasPlayed=!0,w._wouldBeNewAdPlay&&(w._wouldBeNewAdPlay=!1,M(L.data,"view_ad_played_count")),w.inPrerollPosition()&&!L.data.view_preroll_played&&(L.data.view_preroll_played=!0,w._adRequests.length>0&&(L.data.view_preroll_request_time=Math.max(0,U.viewer_time-w._adRequests[0].viewer_time)),L.data.view_start&&(L.data.view_startup_preroll_request_time=Math.max(0,U.viewer_time-L.data.view_start)),w._prerollPlayTime=U.viewer_time)}),L.on("adplaying",function(x,U){w.inPrerollPosition()&&L.data.view_preroll_load_time===void 0&&w._prerollPlayTime!==void 0&&(L.data.view_preroll_load_time=U.viewer_time-w._prerollPlayTime,L.data.view_startup_preroll_load_time=U.viewer_time-w._prerollPlayTime)}),L.on("adended",function(){w._wouldBeNewAdPlay=!0}),L.on("aderror",function(){w._wouldBeNewAdPlay=!0})}var h,g,b;return h=p,(g=[{key:"inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(L){for(var w=0;w<this._adRequests.length;w++)if(this._adRequests[w].ad_request_id===L)return this._adRequests[w]}},{key:"_updateAdData",value:function(L,w){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&w.ad_tag_url){var k=Fi(_(w.ad_tag_url),2),x=k[0],U=k[1];this.pm.data.view_preroll_ad_tag_domain=U,this.pm.data.view_preroll_ad_tag_hostname=x}if(!this.pm.data.view_preroll_ad_asset_hostname&&w.ad_asset_url){var O=Fi(_(w.ad_asset_url),2),W=O[0],pe=O[1];this.pm.data.view_preroll_ad_asset_domain=pe,this.pm.data.view_preroll_ad_asset_hostname=W}}this.pm.data.ad_asset_url=w==null?void 0:w.ad_asset_url,this.pm.data.ad_tag_url=w==null?void 0:w.ad_tag_url,this.pm.data.ad_creative_id=w==null?void 0:w.ad_creative_id,this.pm.data.ad_id=w==null?void 0:w.ad_id,this.pm.data.ad_universal_id=w==null?void 0:w.ad_universal_id}}])&&Ni(h.prototype,g),b&&Ni(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function ni(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function et(p,h,g){return h&&ni(p.prototype,h),g&&ni(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Ui=et(function p(h){var g,b;(function(x,U){if(!(x instanceof U))throw new TypeError("Cannot call a class as a function")})(this,p);var L=function(){h.disableRebufferTracking||g&&(M(h.data,"view_waiting_rebuffer_duration",Fe.now()-g),g=!1,z().clearInterval(b))},w=!1,k=function(){w=!1,L()};h.on("waiting",function(){w&&(h.disableRebufferTracking||(M(h.data,"view_waiting_rebuffer_count",1),g=Fe.now(),b=z().setInterval(function(){if(g){var x=Fe.now();M(h.data,"view_waiting_rebuffer_duration",x-g),g=x}},250)))}),h.on("playing",function(){L(),w=!0}),h.on("pause",k),h.on("seeking",k)});function _e(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Bi(p,h,g){return h&&_e(p.prototype,h),g&&_e(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var ai=Bi(function p(h){var g=this;(function(w,k){if(!(w instanceof k))throw new TypeError("Cannot call a class as a function")})(this,p);var b=function(){g.lastWallClockTime=Fe.now(),h.on("before*",L)},L=function(w){var k=Fe.now(),x=g.lastWallClockTime;g.lastWallClockTime=k,k-x>3e4&&(h.emit("devicesleep",{viewer_time:x}),Object.assign(h.data,{viewer_time:x}),h.send("devicesleep"),h.emit("devicewake",{viewer_time:k}),Object.assign(h.data,{viewer_time:k}),h.send("devicewake"))};h.one("playbackheartbeat",b),h.on("playbackheartbeatend",function(){h.off("before*",L),h.one("playbackheartbeat",b)})}),xe=q(375),Dn=q(655),si=q.n(Dn),oi="muxData",Hi=function(){var p;try{p=xe.parse(si().get(oi)||"")}catch{p={}}return p},Kt=function(p){try{si().set(oi,xe.stringify(p),{expires:7300})}catch{}},Gi=function(){var p=Hi();return p.mux_viewer_id=p.mux_viewer_id||ne(),p.msn=p.msn||Math.random(),Kt(p),{mux_viewer_id:p.mux_viewer_id,mux_sample_number:p.msn}};function In(p,h){var g=h.beaconCollectionDomain,b=h.beaconDomain;if(g)return"https://"+g;var L=b||"litix.io";return(p=p||"inferred").match(/^[a-z0-9]+$/)?"https://"+p+"."+L:"https://img.litix.io/a.gif"}var li=function(){var p;switch(ui()){case"cellular":p="cellular";break;case"ethernet":p="wired";break;case"wifi":p="wifi";break;case void 0:break;default:p="other"}return p},ui=function(){var p=z().navigator,h=p&&(p.connection||p.mozConnection||p.webkitConnection);return h&&h.type};li.getConnectionFromAPI=ui;var xn=li,Rr=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"}),Dr=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(p){var h={};for(var g in p)p.hasOwnProperty(g)&&(h[p[g]]=g);return h}function Ir(p){var h={},g={};return Object.keys(p).forEach(function(b){var L=!1;if(p.hasOwnProperty(b)&&p[b]!==void 0){var w=b.split("_"),k=w[0],x=Rr[k];x||(ke.info("Data key word `"+w[0]+"` not expected in "+b),x=k+"_"),w.splice(1).forEach(function(U){U==="url"&&(L=!0),Dr[U]?x+=Dr[U]:Number(U)&&Math.floor(Number(U))===Number(U)?x+=U:(ke.info("Data key word `"+U+"` not expected in "+b),x+="_"+U+"_")}),L?g[x]=p[b]:h[x]=p[b]}}),Object.assign(h,g)}var ct={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},ci=["hb","requestcompleted","requestfailed","requestcanceled"],Ki="https://img.litix.io",Ft=function(p){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=p||Ki,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},ct,h)};Ft.prototype.queueEvent=function(p,h){var g=Object.assign({},h);return(this._eventQueue.length<=this._options.maxQueueLength||p==="eventrateexceeded")&&(this._eventQueue.push(g),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},Ft.prototype.flushEvents=function(){var p=arguments.length>0&&arguments[0]!==void 0&&arguments[0];p&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},Ft.prototype.destroy=function(){var p=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,p?this._clearBeaconQueue():this.flushEvents(),z().clearTimeout(this._sendTimeout)},Ft.prototype._clearBeaconQueue=function(){var p=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,h=this._eventQueue.slice(p);p>0&&Object.assign(h[h.length-1],Ir({mux_view_message:"event queue truncated"}));var g=this._createPayload(h);xr(this._beaconUrl,g,!0,function(){})},Ft.prototype._sendBeaconQueue=function(){var p=this;if(!this._postInFlight){var h=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var g=this._createPayload(h),b=Fe.now();xr(this._beaconUrl,g,!1,function(L,w){w?(p._eventQueue=h.concat(p._eventQueue),p._failureCount+=1,ke.info("Error sending beacon: "+w)):p._failureCount=0,p._roundTripTime=Fe.now()-b,p._postInFlight=!1})}},Ft.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var p=Math.pow(2,this._failureCount-1);return(1+(p*=Math.random()))*this._options.baseTimeBetweenBeacons},Ft.prototype._startBeaconSending=function(){var p=this;z().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=z().setTimeout(function(){p._eventQueue.length&&p._sendBeaconQueue(),p._startBeaconSending()},this._getNextBeaconTime()))},Ft.prototype._createPayload=function(p){var h,g,b,L=this,w={transmission_timestamp:Math.round(Fe.now())};this._roundTripTime&&(w.rtt_ms=Math.round(this._roundTripTime));var k=function(){h=JSON.stringify({metadata:w,events:g||p}),b=h.length/1024},x=function(){return b<=L._options.maxPayloadKBSize};return k(),x()||(ke.info("Payload size is too big ("+b+" kb). Removing unnecessary events."),g=p.filter(function(U){return ci.indexOf(U.e)===-1}),k()),x()||(ke.info("Payload size still too big ("+b+" kb). Cropping fields.."),g.forEach(function(U){for(var O in U){var W=U[O];typeof W=="string"&&W.length>51200&&(U[O]=W.substring(0,51200))}}),k()),h};var Cn=function(p){return p.length<=57344},xr=function(p,h,g,b){if(g&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(p,h))b();else if(z().fetch)z().fetch(p,{method:"POST",body:h,headers:{"Content-Type":"text/plain"},keepalive:Cn(h)}).then(function(w){return b(null,w.ok?null:"Error")}).catch(function(w){return b(null,w)});else{if(z().XMLHttpRequest){var L=new(z()).XMLHttpRequest;return L.onreadystatechange=function(){if(L.readyState===4)return b(null,L.status!==200?"error":void 0)},L.open("POST",p),L.setRequestHeader("Content-Type","text/plain"),void L.send(h)}b()}},qi=Ft;function Vi(p,h){return function(g){if(Array.isArray(g))return g}(p)||function(g,b){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var w,k,x=[],U=!0,O=!1;try{for(L=L.call(g);!(U=(w=L.next()).done)&&(x.push(w.value),!b||x.length!==b);U=!0);}catch(W){O=!0,k=W}finally{try{U||L.return==null||L.return()}finally{if(O)throw k}}return x}}(p,h)||function(g,b){if(g){if(typeof g=="string")return ji(g,b);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?ji(g,b):void 0}}(p,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function ji(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}function hi(p,h){var g=Object.keys(p);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(p);h&&(b=b.filter(function(L){return Object.getOwnPropertyDescriptor(p,L).enumerable})),g.push.apply(g,b)}return g}function rr(p){for(var h=1;h<arguments.length;h++){var g=arguments[h]!=null?arguments[h]:{};h%2?hi(Object(g),!0).forEach(function(b){Cr(p,b,g[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(g)):hi(Object(g)).forEach(function(b){Object.defineProperty(p,b,Object.getOwnPropertyDescriptor(g,b))})}return p}function Nt(p){return Nt=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},Nt(p)}function Wi(p,h){if(!(p instanceof h))throw new TypeError("Cannot call a class as a function")}function fi(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Cr(p,h,g){return h in p?Object.defineProperty(p,h,{value:g,enumerable:!0,configurable:!0,writable:!0}):p[h]=g,p}var Yi=["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"],zi=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse"],Xi=["viewstart","error","ended","viewend"],Qi=function(){function p(L,w){var k,x,U,O,W,pe,ie,he,se,fe,Ce,Ge,tt,ht,pt,ue=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Wi(this,p),Cr(this,"previousBeaconData",null),Cr(this,"lastEventTime",0),Cr(this,"rateLimited",!1),this.mux=L,this.envKey=w,this.options=ue,this.eventQueue=new qi(In(this.envKey,this.options)),this.sampleRate=(k=this.options.sampleRate)!==null&&k!==void 0?k:1,this.disableCookies=(x=this.options.disableCookies)!==null&&x!==void 0&&x,this.respectDoNotTrack=(U=this.options.respectDoNotTrack)!==null&&U!==void 0&&U,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(O=this.options.platform)===null||O===void 0?void 0:O.name,viewer_application_version:(W=this.options.platform)===null||W===void 0?void 0:W.version,viewer_application_engine:(pe=this.options.platform)===null||pe===void 0?void 0:pe.layout,viewer_device_name:(ie=this.options.platform)===null||ie===void 0?void 0:ie.product,viewer_device_category:"",viewer_device_manufacturer:(he=this.options.platform)===null||he===void 0?void 0:he.manufacturer,viewer_os_family:(se=this.options.platform)===null||se===void 0||(fe=se.os)===null||fe===void 0?void 0:fe.family,viewer_os_architecture:(Ce=this.options.platform)===null||Ce===void 0||(Ge=Ce.os)===null||Ge===void 0?void 0:Ge.architecture,viewer_os_version:(tt=this.options.platform)===null||tt===void 0||(ht=tt.os)===null||ht===void 0?void 0:ht.version,viewer_connection_type:xn(),page_url:z()===null||z()===void 0||(pt=z().location)===null||pt===void 0?void 0:pt.href},this.viewerData=this.disableCookies?{}:Gi()}var h,g,b;return h=p,(g=[{key:"send",value:function(L,w){var k;if(L&&w!=null&&w.view_id){if(this.respectDoNotTrack&&ut())return ke.info("Not sending `"+L+"` because Do Not Track is enabled");if(!w||Nt(w)!=="object")return ke.error("A data object was expected in send() but was not provided");var x,U,O=this.disableCookies?{}:(x=Hi(),U=Fe.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<U)&&(x.sid=ne(),x.sst=U),x.sex=U+15e5,Kt(x),{session_id:x.sid,session_start:x.sst,session_expires:x.sex}),W=rr(rr(rr(rr(rr({},this.pageLevelData),w),O),this.viewerData),{},{event:L,env_key:this.envKey});W.user_id&&(W.viewer_user_id=W.user_id,delete W.user_id);var pe=((k=W.mux_sample_number)!==null&&k!==void 0?k:0)>=this.sampleRate,ie=Ir(this._deduplicateBeaconData(L,W));if(this.lastEventTime=this.mux.utils.now(),pe)return ke.info("Not sending event due to sample rate restriction",L,W,ie);if(this.envKey||ke.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",L,W,ie),!this.rateLimited){if(ke.info("Sending event",L,W,ie),this.rateLimited=!this.eventQueue.queueEvent(L,ie),this.mux.WINDOW_UNLOADING&&L==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&L==="hb"?this.eventQueue.flushEvents(!0):Xi.indexOf(L)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return W.event="eventrateexceeded",ie=Ir(W),this.eventQueue.queueEvent(W.event,ie),ke.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(L,w){var k=this,x={},U=w.view_id;if(U==="-1"||L==="viewstart"||L==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)x=rr({},w),U&&(this.previousBeaconData=x),U&&L==="viewend"&&(this.previousBeaconData=null);else{var O=L.indexOf("request")===0;Object.entries(w).forEach(function(W){var pe=Vi(W,2),ie=pe[0],he=pe[1];k.previousBeaconData&&(he!==k.previousBeaconData[ie]||Yi.indexOf(ie)>-1||k.objectHasChanged(O,ie,he,k.previousBeaconData[ie])||k.eventRequiresKey(L,ie))&&(x[ie]=he,k.previousBeaconData[ie]=he)})}return x}},{key:"objectHasChanged",value:function(L,w,k,x){return!(!L||w.indexOf("request_")!==0||w!=="request_response_headers"&&Nt(k)==="object"&&Nt(x)==="object"&&Object.keys(k||{}).length===Object.keys(x||{}).length)}},{key:"eventRequiresKey",value:function(L,w){return L==="renditionchange"&&w.indexOf("video_source_")===0||!(w.indexOf("ad_id")!==0||!zi.includes(L))}}])&&fi(h.prototype,g),b&&fi(h,b),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Xt(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Qt(p,h,g){return h&&Xt(p.prototype,h),g&&Xt(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var Lt=Qt(function p(h){(function(O,W){if(!(O instanceof W))throw new TypeError("Cannot call a class as a function")})(this,p);var g=0,b=0,L=0,w=0,k=0,x=0,U=0;h.on("requestcompleted",function(O,W){var pe,ie,he=W.request_start,se=W.request_response_start,fe=W.request_response_end,Ce=W.request_bytes_loaded;if(w++,se?(pe=se-(he!=null?he:0),ie=(fe!=null?fe:0)-se):ie=(fe!=null?fe:0)-(he!=null?he:0),ie>0&&Ce&&Ce>0){var Ge=Ce/ie*8e3;k++,b+=Ce,L+=ie,h.data.view_min_request_throughput=Math.min(h.data.view_min_request_throughput||1/0,Ge),h.data.view_average_request_throughput=b/L*8e3,h.data.view_request_count=w,pe>0&&(g+=pe,h.data.view_max_request_latency=Math.max(h.data.view_max_request_latency||0,pe),h.data.view_average_request_latency=g/k)}}),h.on("requestfailed",function(O,W){w++,x++,h.data.view_request_count=w,h.data.view_request_failed_count=x}),h.on("requestcanceled",function(O,W){w++,U++,h.data.view_request_count=w,h.data.view_request_canceled_count=U})});function kt(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Me(p,h,g){return h&&kt(p.prototype,h),g&&kt(p,g),Object.defineProperty(p,"prototype",{writable:!1}),p}var wt=Me(function p(h){var g=this;(function(b,L){if(!(b instanceof L))throw new TypeError("Cannot call a class as a function")})(this,p),h.on("before*",function(b,L){var w=L.viewer_time,k=Fe.now(),x=g._lastEventTime;if(g._lastEventTime=k,x&&k-x>36e5){var U=Object.keys(h.data).reduce(function(O,W){return W.indexOf("video_")===0?Object.assign(O,function(pe,ie,he){return ie in pe?Object.defineProperty(pe,ie,{value:he,enumerable:!0,configurable:!0,writable:!0}):pe[ie]=he,pe}({},W,h.data[W])):O},{});h.mux.log.info("Received event after at least an hour inactivity, creating a new view"),h.emit("viewinit",Object.assign({viewer_time:w},U)),h.playbackHeartbeat._playheadShouldBeProgressing&&b.type!=="play"&&b.type!=="adbreakstart"&&(h.emit("play",{viewer_time:w}),b.type!=="playing"&&h.emit("playing",{viewer_time:w}))}})});function At(p){return At=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},At(p)}function Ji(p,h){return function(g){if(Array.isArray(g))return g}(p)||function(g,b){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var w,k,x=[],U=!0,O=!1;try{for(L=L.call(g);!(U=(w=L.next()).done)&&(x.push(w.value),!b||x.length!==b);U=!0);}catch(W){O=!0,k=W}finally{try{U||L.return==null||L.return()}finally{if(O)throw k}}return x}}(p,h)||function(g,b){if(g){if(typeof g=="string")return Pr(g,b);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?Pr(g,b):void 0}}(p,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Pr(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}function $i(p,h){for(var g=0;g<h.length;g++){var b=h[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(p,b.key,b)}}function Or(p,h){return Or=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,b){return g.__proto__=b,g},Or(p,h)}function Zi(p){var h=function(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var g,b=qt(p);if(h){var L=qt(this).constructor;g=Reflect.construct(b,arguments,L)}else g=b.apply(this,arguments);return ir(this,g)}}function ir(p,h){if(h&&(At(h)==="object"||typeof h=="function"))return h;if(h!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Xe(p)}function Xe(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function qt(p){return qt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},qt(p)}var Pn=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],cr=function(p){(function(k,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function");k.prototype=Object.create(x&&x.prototype,{constructor:{value:k,writable:!0,configurable:!0}}),Object.defineProperty(k,"prototype",{writable:!1}),x&&Or(k,x)})(w,p);var h,g,b,L=Zi(w);function w(k,x,U){var O;(function(se,fe){if(!(se instanceof fe))throw new TypeError("Cannot call a class as a function")})(this,w),(O=L.call(this)).DOM_CONTENT_LOADED_EVENT_END=re.domContentLoadedEventEnd(),O.NAVIGATION_START=re.navigationStart(),O.mux=k,O.id=x,(U=Object.assign({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(se){return se}},U)).data=U.data||{},U.data.property_key&&(U.data.env_key=U.data.property_key,delete U.data.property_key),ke.setLevel(U.debug?"debug":"warn"),O.getPlayheadTime=U.getPlayheadTime,O.getStateData=U.getStateData||function(){return{}},O.getAdData=U.getAdData||function(){},O.minimumRebufferDuration=U.minimumRebufferDuration,O.sustainedRebufferThreshold=U.sustainedRebufferThreshold,O.playbackHeartbeatTime=U.playbackHeartbeatTime,O.disableRebufferTracking=U.disableRebufferTracking,O.disableRebufferTracking&&O.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),O.disablePlayheadRebufferTracking=U.disablePlayheadRebufferTracking,O.errorTranslator=U.errorTranslator,O.playbackEventDispatcher=new Qi(k,U.data.env_key,U),O.data={player_instance_id:ne(),mux_sample_rate:U.sampleRate,beacon_domain:U.beaconCollectionDomain?U.beaconCollectionDomain:U.beaconDomain},O.data.view_sequence_number=1,O.data.player_sequence_number=1,O.oldEmit=O.emit,O.emit=function(se,fe){fe=Object.assign({viewer_time:this.mux.utils.now()},fe),this.oldEmit(se,fe)};var W=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Xe(O));O.on("viewinit",function(se,fe){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,fe),this._initializeViewData(),this.one("play",W),this.one("adbreakstart",W)});var pe=function(se){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",se)}.bind(Xe(O));if(O.on("videochange",function(se,fe){pe(fe)}),O.on("programchange",function(se,fe){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),pe(Object.assign(fe,{view_program_changed:!0})),W(),this.emit("play"),this.emit("playing")}),O.on("fragmentchange",function(se,fe){this.currentFragmentPDT=fe.currentFragmentPDT,this.currentFragmentStart=fe.currentFragmentStart}),O.on("destroy",O.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ie=function(){var se=O.data.view_start!==void 0;O.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",se&&O.mux.WINDOW_HIDDEN&&(O.data.player_is_paused||O.emit("hb"))};window.addEventListener("visibilitychange",ie,!1);var he=function(se){se.persisted||O.destroy()};window.addEventListener("pagehide",he,!1),O.on("destroy",function(){window.removeEventListener("visibilitychange",ie),window.removeEventListener("pagehide",he)})}return O.on("playerready",function(se,fe){Object.assign(this.data,fe)}),Pn.forEach(function(se){O.on(se,function(fe,Ce){se.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,Ce),this._sanitizeData()}),O.on("after"+se,function(){(se!=="error"||this.errorTracker.viewErrored)&&this.send(se)})}),O.on("viewend",function(se,fe){Object.assign(O.data,fe)}),O.one("playerready",function(se){var fe=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=fe-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),O.longResumeTracker=new wt(Xe(O)),O.errorTracker=new Jr(Xe(O)),new ai(Xe(O)),O.seekingTracker=new An(Xe(O)),O.playheadTime=new ei(Xe(O)),O.playbackHeartbeat=new Di(Xe(O)),new kn(Xe(O)),O.watchTimeTracker=new Sr(Xe(O)),new Ii(Xe(O)),O.adTracker=new Rn(Xe(O)),new wr(Xe(O)),new ri(Xe(O)),new Ci(Xe(O)),new Ui(Xe(O)),new Lt(Xe(O)),U.hlsjs&&O.addHLSJS(U),U.dashjs&&O.addDashJS(U),O.emit("viewinit",U.data),O}return h=w,g=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(k){if(this.data.view_id){var 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(pe){x[pe]=void 0}),x.video_source_url=x.video_source_url||x.player_source_url,x.video_source_url){var U=Ji(_(x.video_source_url),2),O=U[0],W=U[1];x.video_source_domain=W,x.video_source_hostname=O}delete x.ad_request_id,this.playbackEventDispatcher.send(k,x),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),k==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var k=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(x){var U=parseInt(k.data[x],10);k.data[x]=isNaN(U)?void 0:U}),["player_source_url","video_source_url"].forEach(function(x){if(k.data[x]){var U=k.data[x].toLowerCase();U.indexOf("data:")!==0&&U.indexOf("blob:")!==0||(k.data[x]="MSE style URL")}})}},{key:"_resetVideoData",value:function(k,x){var U=this;Object.keys(this.data).forEach(function(O){O.indexOf("video_")===0&&delete U.data[O]})}},{key:"_resetViewData",value:function(){var k=this;Object.keys(this.data).forEach(function(x){x.indexOf("view_")===0&&delete k.data[x]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(k,x){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var k=this,x=this.data.view_id=ne(),U=function(){x===k.data.view_id&&M(k.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",U):U()}},{key:"_restartHeartBeat",value:function(){var k=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){k.data.player_is_paused||k.emit("hb")},1e4))}},{key:"addHLSJS",value:function(k){k.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=k.hlsjs,function(x,U,O){var W=arguments.length>4?arguments[4]:void 0,pe=x.log,ie=x.utils.secondsToMs,he=function(Pe){var J,de=parseInt(W.version);return de===1&&Pe.programDateTime!==null&&(J=Pe.programDateTime),de===0&&Pe.pdt!==null&&(J=Pe.pdt),J};if(re.exists()){var se=function(Pe,J){return x.emit(U,Pe,J)},fe=function(Pe,J){var de=J.levels,Z=J.audioTracks,be=J.url,Re=J.stats,Qe=J.networkDetails,ft=J.sessionData,Je={},nt={};de.forEach(function(je,gt){Je[gt]={width:je.width,height:je.height,bitrate:je.bitrate,attrs:je.attrs}}),Z.forEach(function(je,gt){nt[gt]={name:je.name,language:je.lang,bitrate:je.bitrate}});var Ne=Be(Re),ce=Ne.bytesLoaded,Rt=Ne.requestStart,Dt=Ne.responseStart,mt=Ne.responseEnd;se("requestcompleted",He(He({},$e(ft)),{},{request_event_type:Pe,request_bytes_loaded:ce,request_start:Rt,request_response_start:Dt,request_response_end:mt,request_type:"manifest",request_hostname:ee(be),request_response_headers:Ht(Qe),request_rendition_lists:{media:Je,audio:nt,video:{}}}))};O.on(W.Events.MANIFEST_LOADED,fe);var Ce=function(Pe,J){var de=J.details,Z=J.level,be=J.networkDetails,Re=J.stats,Qe=Be(Re),ft=Qe.bytesLoaded,Je=Qe.requestStart,nt=Qe.responseStart,Ne=Qe.responseEnd,ce=de.fragments[de.fragments.length-1],Rt=he(ce)+ie(ce.duration);se("requestcompleted",{request_event_type:Pe,request_bytes_loaded:ft,request_start:Je,request_response_start:nt,request_response_end:Ne,request_current_level:Z,request_type:"manifest",request_hostname:ee(de.url),request_response_headers:Ht(be),video_holdback:de.holdBack&&ie(de.holdBack),video_part_holdback:de.partHoldBack&&ie(de.partHoldBack),video_part_target_duration:de.partTarget&&ie(de.partTarget),video_target_duration:de.targetduration&&ie(de.targetduration),video_source_is_live:de.live,player_manifest_newest_program_time:isNaN(Rt)?void 0:Rt})};O.on(W.Events.LEVEL_LOADED,Ce);var Ge=function(Pe,J){var de=J.details,Z=J.networkDetails,be=J.stats,Re=Be(be),Qe=Re.bytesLoaded,ft=Re.requestStart,Je=Re.responseStart,nt=Re.responseEnd;se("requestcompleted",{request_event_type:Pe,request_bytes_loaded:Qe,request_start:ft,request_response_start:Je,request_response_end:nt,request_type:"manifest",request_hostname:ee(de.url),request_response_headers:Ht(Z)})};O.on(W.Events.AUDIO_TRACK_LOADED,Ge);var tt=function(Pe,J){var de=J.stats,Z=J.networkDetails,be=J.frag;de=de||be.stats;var Re=Be(de),Qe=Re.bytesLoaded,ft=Re.requestStart,Je=Re.responseStart,nt=Re.responseEnd,Ne=Z?Ht(Z):void 0,ce={request_event_type:Pe,request_bytes_loaded:Qe,request_start:ft,request_response_start:Je,request_response_end:nt,request_hostname:Z?ee(Z.responseURL):void 0,request_id:Ne?We(Ne):void 0,request_response_headers:Ne,request_media_duration:be.duration,request_url:Z==null?void 0:Z.responseURL};be.type==="main"?(ce.request_type="media",ce.request_current_level=be.level,ce.request_video_width=(O.levels[be.level]||{}).width,ce.request_video_height=(O.levels[be.level]||{}).height,ce.request_labeled_bitrate=(O.levels[be.level]||{}).bitrate):ce.request_type=be.type,se("requestcompleted",ce)};O.on(W.Events.FRAG_LOADED,tt);var ht=function(Pe,J){var de=J.frag,Z=de.start,be={currentFragmentPDT:he(de),currentFragmentStart:ie(Z)};se("fragmentchange",be)};O.on(W.Events.FRAG_CHANGED,ht);var pt=function(Pe,J){var de=J.type,Z=J.details,be=J.response,Re=J.fatal,Qe=J.frag,ft=J.networkDetails,Je=(Qe==null?void 0:Qe.url)||J.url||"",nt=ft?Ht(ft):void 0;if(Z!==W.ErrorDetails.MANIFEST_LOAD_ERROR&&Z!==W.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&Z!==W.ErrorDetails.FRAG_LOAD_ERROR&&Z!==W.ErrorDetails.FRAG_LOAD_TIMEOUT&&Z!==W.ErrorDetails.LEVEL_LOAD_ERROR&&Z!==W.ErrorDetails.LEVEL_LOAD_TIMEOUT&&Z!==W.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&Z!==W.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&Z!==W.ErrorDetails.SUBTITLE_LOAD_ERROR&&Z!==W.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&Z!==W.ErrorDetails.KEY_LOAD_ERROR&&Z!==W.ErrorDetails.KEY_LOAD_TIMEOUT||se("requestfailed",{request_error:Z,request_url:Je,request_hostname:ee(Je),request_id:nt?We(nt):void 0,request_type:Z===W.ErrorDetails.FRAG_LOAD_ERROR||Z===W.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":Z===W.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||Z===W.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":Z===W.ErrorDetails.SUBTITLE_LOAD_ERROR||Z===W.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":Z===W.ErrorDetails.KEY_LOAD_ERROR||Z===W.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:be==null?void 0:be.code,request_error_text:be==null?void 0:be.text}),Re){var Ne,ce="".concat(Je?"url: ".concat(Je,`
|
|
5
|
+
`):"")+"".concat(be&&(be.code||be.text)?"response: ".concat(be.code,", ").concat(be.text,`
|
|
6
|
+
`):"")+"".concat(J.reason?"failure reason: ".concat(J.reason,`
|
|
7
|
+
`):"")+"".concat(J.level?"level: ".concat(J.level,`
|
|
8
|
+
`):"")+"".concat(J.parent?"parent stream controller: ".concat(J.parent,`
|
|
9
|
+
`):"")+"".concat(J.buffer?"buffer length: ".concat(J.buffer,`
|
|
10
|
+
`):"")+"".concat(J.error?"error: ".concat(J.error,`
|
|
11
|
+
`):"")+"".concat(J.event?"event: ".concat(J.event,`
|
|
12
|
+
`):"")+"".concat(J.err?"error message: ".concat((Ne=J.err)===null||Ne===void 0?void 0:Ne.message,`
|
|
13
|
+
`):"");se("error",{player_error_code:de,player_error_message:Z,player_error_context:ce})}};O.on(W.Events.ERROR,pt);var ue=function(Pe,J){var de=J.frag,Z=de&&de._url||"";se("requestcanceled",{request_event_type:Pe,request_url:Z,request_type:"media",request_hostname:ee(Z)})};O.on(W.Events.FRAG_LOAD_EMERGENCY_ABORTED,ue);var Ve=function(Pe,J){var de=J.level,Z=O.levels[de];if(Z&&Z.attrs&&Z.attrs.BANDWIDTH){var be,Re=Z.attrs.BANDWIDTH,Qe=parseFloat(Z.attrs["FRAME-RATE"]);isNaN(Qe)||(be=Qe),Re?se("renditionchange",{video_source_fps:be,video_source_bitrate:Re,video_source_width:Z.width,video_source_height:Z.height,video_source_rendition_name:Z.name,video_source_codec:Z==null?void 0:Z.videoCodec}):pe.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};O.on(W.Events.LEVEL_SWITCHED,Ve),O._stopMuxMonitor=function(){O.off(W.Events.MANIFEST_LOADED,fe),O.off(W.Events.LEVEL_LOADED,Ce),O.off(W.Events.AUDIO_TRACK_LOADED,Ge),O.off(W.Events.FRAG_LOADED,tt),O.off(W.Events.FRAG_CHANGED,ht),O.off(W.Events.ERROR,pt),O.off(W.Events.FRAG_LOAD_EMERGENCY_ABORTED,ue),O.off(W.Events.LEVEL_SWITCHED,Ve),O.off(W.Events.DESTROYING,O._stopMuxMonitor),delete O._stopMuxMonitor},O.on(W.Events.DESTROYING,O._stopMuxMonitor)}else pe.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,k.hlsjs,{},k.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var k;this.hlsjs&&((k=this.hlsjs)&&typeof k._stopMuxMonitor=="function"&&k._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(k){k.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=k.dashjs,function(x,U,O){var W=x.log;if(O&&O.on){var pe=function(ue,Ve){return x.emit(U,ue,Ve)},ie=function(ue){var Ve=ue.type,Pe=(ue.data||{}).url;pe("requestcompleted",{request_event_type:Ve,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:ee(Pe),request_url:Pe})};O.on("manifestLoaded",ie);var he={},se=function(ue){var Ve=ue.type,Pe=ue.fragmentModel,J=(ue.chunk||{}).mediaInfo||{},de=J.type,Z=J.bitrateList,be={};(Z=Z||[]).forEach(function(mt,je){be[je]={},be[je].width=mt.width,be[je].height=mt.height,be[je].bitrate=mt.bandwidth,be[je].attrs={}}),de==="video"?he.video=be:de==="audio"?he.audio=be:he.media=be;var Re=ze(Pe,O),Qe=Re.requestStart,ft=Re.requestResponseStart,Je=Re.requestResponseEnd,nt=Re.requestResponseHeaders,Ne=Re.requestMediaDuration,ce=Re.requestHostname,Rt=Re.requestUrl,Dt=Re.requestId;pe("requestcompleted",{request_event_type:Ve,request_start:Qe,request_response_start:ft,request_response_end:Je,request_bytes_loaded:-1,request_type:de+"_init",request_response_headers:nt,request_hostname:ce,request_id:Dt,request_url:Rt,request_media_duration:Ne,request_rendition_lists:he})};O.on("initFragmentLoaded",se);var fe=function(ue){var Ve=ue.type,Pe=ue.fragmentModel,J=ue.chunk||{},de=J.mediaInfo,Z=J.start,be=(de||{}).type,Re=ze(Pe,O),Qe=Re.requestStart,ft=Re.requestResponseStart,Je=Re.requestResponseEnd,nt=Re.requestBytesLoaded,Ne=Re.requestResponseHeaders,ce=Re.requestMediaDuration,Rt=Re.requestHostname,Dt=Re.requestUrl,mt=Re.requestId,je=Gt(be,O),gt=je.currentLevel,Kr=je.renditionWidth,pr=je.renditionHeight,ar=je.renditionBitrate;pe("requestcompleted",{request_event_type:Ve,request_start:Qe,request_response_start:ft,request_response_end:Je,request_bytes_loaded:nt,request_type:be,request_response_headers:Ne,request_hostname:Rt,request_id:mt,request_url:Dt,request_media_start_time:Z,request_media_duration:ce,request_current_level:gt,request_labeled_bitrate:ar,request_video_width:Kr,request_video_height:pr})};O.on("mediaFragmentLoaded",fe);var Ce={video:void 0,audio:void 0,totalBitrate:void 0},Ge=function(){if(Ce.video&&typeof Ce.video.bitrate=="number"){if(Ce.video.width&&Ce.video.height){var ue=Ce.video.bitrate;return Ce.audio&&typeof Ce.audio.bitrate=="number"&&(ue+=Ce.audio.bitrate),ue!==Ce.totalBitrate?(Ce.totalBitrate=ue,{video_source_bitrate:ue,video_source_height:Ce.video.height,video_source_width:Ce.video.width,video_source_codec:_r(Ce.video.codec)}):void 0}W.warn("have bitrate info for video but missing width/height")}},tt=function(ue,Ve,Pe){if(typeof ue.newQuality=="number"){var J=ue.mediaType;if(J==="audio"||J==="video"){var de=O.getBitrateInfoListFor(J).find(function(be){return be.qualityIndex===ue.newQuality});if(de&&typeof de.bitrate=="number"){Ce[J]=Mt(Mt({},de),{},{codec:O.getCurrentTrackFor(J).codec});var Z=Ge();Z&&pe("renditionchange",Z)}else W.warn("missing bitrate info for ".concat(J))}}else W.warn("missing evt.newQuality in qualityChangeRendered event",ue)};O.on("qualityChangeRendered",tt);var ht=function(ue){var Ve=ue.request,Pe=ue.mediaType;pe("requestcanceled",{request_event_type:(Ve=Ve||{}).type+"_"+Ve.action,request_url:Ve.url,request_type:Pe,request_hostname:ee(Ve.url)})};O.on("fragmentLoadingAbandoned",ht);var pt=function(ue){var Ve,Pe,J=ue.error,de=(J==null||(Ve=J.data)===null||Ve===void 0?void 0:Ve.request)||{},Z=(J==null||(Pe=J.data)===null||Pe===void 0?void 0:Pe.response)||{};(J==null?void 0:J.code)===27&&pe("requestfailed",{request_error:de.type+"_"+de.action,request_url:de.url,request_hostname:ee(de.url),request_type:de.mediaType,request_error_code:Z.status,request_error_text:Z.statusText});var be="".concat(de!=null&&de.url?"url: ".concat(de.url,`
|
|
14
|
+
`):"")+"".concat(Z!=null&&Z.status||Z!=null&&Z.statusText?"response: ".concat(Z==null?void 0:Z.status,", ").concat(Z==null?void 0:Z.statusText,`
|
|
15
|
+
`):"");pe("error",{player_error_code:J==null?void 0:J.code,player_error_message:J==null?void 0:J.message,player_error_context:be})};O.on("error",pt),O._stopMuxMonitor=function(){O.off("manifestLoaded",ie),O.off("initFragmentLoaded",se),O.off("mediaFragmentLoaded",fe),O.off("qualityChangeRendered",tt),O.off("error",pt),O.off("fragmentLoadingAbandoned",ht),delete O._stopMuxMonitor}}else W.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,k.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var k;this.dashjs&&((k=this.dashjs)&&typeof k._stopMuxMonitor=="function"&&k._stopMuxMonitor(),this.dashjs=void 0)}}],g&&$i(h.prototype,g),b&&$i(h,b),Object.defineProperty(h,"prototype",{writable:!1}),w}(Xr),vi=cr,Mr=q(153),Jt=q.n(Mr);function gi(p){return gi=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},gi(p)}function en(p,h){return function(g){if(Array.isArray(g))return g}(p)||function(g,b){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var w,k,x=[],U=!0,O=!1;try{for(L=L.call(g);!(U=(w=L.next()).done)&&(x.push(w.value),!b||x.length!==b);U=!0);}catch(W){O=!0,k=W}finally{try{U||L.return==null||L.return()}finally{if(O)throw k}}return x}}(p,h)||function(g,b){if(g){if(typeof g=="string")return Fr(g,b);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?Fr(g,b):void 0}}(p,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 Fr(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}var Vt,On=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Mn={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};z()&&z().WeakMap&&(Vt=new WeakMap);var tn="#EXT-X-TARGETDURATION",hr="#EXT-X-PART-INF",pi="#EXT-X-SERVER-CONTROL",rn="#EXTINF",Fn="#EXT-X-PROGRAM-DATE-TIME",nn="#EXT-X-VERSION",mi="#EXT-X-SESSION-DATA",fr=function(p){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(p),this.manifest};fr.prototype.process=function(p){var h;for(this.buffer+=p,h=this.buffer.indexOf(`
|
|
6
17
|
`);h>-1;h=this.buffer.indexOf(`
|
|
7
|
-
`))this.processLine(this.buffer.substring(0,h)),this.buffer=this.buffer.substring(h+1)},
|
|
8
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function pt(g,h){(h==null||h>g.length)&&(h=g.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=g[f];return y}var fr={},Gr=function g(h){var f=arguments;typeof h=="string"?g.hasOwnProperty(h)?R().setTimeout(function(){f=Array.prototype.splice.call(f,1),g[h].apply(null,f)},0):H.warn("`"+h+"` is an unknown task"):typeof h=="function"?R().setTimeout(function(){h(g)},0):H.warn("`"+h+"` is invalid.")},ji={loaded:z.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(g,h){return function(f,y,b){var C=mi(ve(y),3),A=C[0],G=C[1],se=C[2],Q=f.log,Pe=f.utils.getComputedStyle,at=f.utils.secondsToMs;if(!A)return Q.error("No element was found with the `"+G+"` query selector.");if(se!=="video"&&se!=="audio")return Q.error("The element of `"+G+"` was not a media element.");A.mux&&(A.mux.destroy(),delete A.mux,Q.warn("Already monitoring this video element, replacing existing event listeners")),(b=U()({automaticErrorTracking:!0},b)).data=U()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:f.VERSION},b.data),b.getPlayheadTime=function(){return at(A.currentTime)},b.getStateData=function(){var it,Xe,nt=this.hlsjs&&this.hlsjs.url,wt=this.dashjs&&zr(this.dashjs.getSource==="function")&&this.dashjs.getSource(),Bt={player_is_paused:A.paused,player_playhead_time:at(A.currentTime),player_width:parseInt(Pe(A,"width")),player_height:parseInt(Pe(A,"height")),player_autoplay_on:A.autoplay,player_preload_on:A.preload,player_language_code:A.lang,player_is_fullscreen:Xr()&&!!(Xr().fullscreenElement||Xr().webkitFullscreenElement||Xr().mozFullScreenElement||Xr().msFullscreenElement),video_poster_url:A.poster,video_source_url:nt||wt||A.currentSrc,video_source_duration:at(A.duration),video_source_height:A.videoHeight,video_source_width:A.videoWidth,view_dropped_frame_count:(it=A)===null||it===void 0||(Xe=it.getVideoPlaybackQuality)===null||Xe===void 0?void 0:Xe.call(it).droppedVideoFrames},Jt=b.getPlayheadTime();if(A.getStartDate&&Jt>0){var ir=A.getStartDate();if(ir&&typeof ir.getTime=="function"&&ir.getTime()){var mt=ir.getTime();if(Bt.player_program_time=mt+Jt,A.seekable.length>0){var Wt=mt+A.seekable.end(A.seekable.length-1);Bt.player_live_edge_program_time=Wt}}}return Bt},A.mux=A.mux||{},A.mux.deleted=!1,A.mux.emit=function(it,Xe){f.emit(G,it,Xe)};var Je=function(){Q.error("The monitor for this video element has already been destroyed.")};A.mux.destroy=function(){Object.keys(A.mux.listeners).forEach(function(it){A.removeEventListener(it,A.mux.listeners[it],!1)}),delete A.mux.listeners,A.mux.destroy=Je,A.mux.swapElement=Je,A.mux.emit=Je,A.mux.addHLSJS=Je,A.mux.addDashJS=Je,A.mux.removeHLSJS=Je,A.mux.removeDashJS=Je,A.mux.deleted=!0,f.emit(G,"destroy")},A.mux.swapElement=function(it){var Xe=mi(ve(it),3),nt=Xe[0],wt=Xe[1],Bt=Xe[2];return nt?Bt!=="video"&&Bt!=="audio"?f.log.error("The element of `"+wt+"` was not a media element."):(nt.muxId=A.muxId,delete A.muxId,nt.mux=nt.mux||{},nt.mux.listeners=U()({},A.mux.listeners),delete A.mux.listeners,Object.keys(nt.mux.listeners).forEach(function(Jt){A.removeEventListener(Jt,nt.mux.listeners[Jt],!1),nt.addEventListener(Jt,nt.mux.listeners[Jt],!1)}),nt.mux.swapElement=A.mux.swapElement,nt.mux.destroy=A.mux.destroy,delete A.mux,void(A=nt)):f.log.error("No element was found with the `"+wt+"` query selector.")},A.mux.addHLSJS=function(it){f.addHLSJS(G,it)},A.mux.addDashJS=function(it){f.addDashJS(G,it)},A.mux.removeHLSJS=function(){f.removeHLSJS(G)},A.mux.removeDashJS=function(){f.removeDashJS(G)},f.init(G,b),f.emit(G,"playerready"),A.paused||(f.emit(G,"play"),A.readyState>2&&f.emit(G,"playing")),A.mux.listeners={},yi.forEach(function(it){(it!=="error"||b.automaticErrorTracking)&&(A.mux.listeners[it]=function(){var Xe={};if(it==="error"){if(!A.error||A.error.code===1)return;Xe.player_error_code=A.error.code,Xe.player_error_message=tn[A.error.code]||A.error.message}f.emit(G,it,Xe)},A.addEventListener(it,A.mux.listeners[it],!1))})}(Gr,g,h)},destroyMonitor:function(g){var h=cn(ve(g),1)[0];h&&h.mux&&typeof h.mux.destroy=="function"?h.mux.destroy():H.error("A video element monitor for `"+g+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(g,h){var f=k(g);fr[f]?fr[f].addHLSJS(h):H.error("A monitor for `"+f+"` has not been initialized.")},addDashJS:function(g,h){var f=k(g);fr[f]?fr[f].addDashJS(h):H.error("A monitor for `"+f+"` has not been initialized.")},removeHLSJS:function(g){var h=k(g);fr[h]?fr[h].removeHLSJS():H.error("A monitor for `"+h+"` has not been initialized.")},removeDashJS:function(g){var h=k(g);fr[h]?fr[h].removeDashJS():H.error("A monitor for `"+h+"` has not been initialized.")},init:function(g,h){ce()&&h&&h.respectDoNotTrack&&H.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var f=k(g);fr[f]=new Cr(Gr,f,h)},emit:function(g,h,f){var y=k(g);fr[y]?(fr[y].emit(h,f),h==="destroy"&&delete fr[y]):H.error("A monitor for `"+y+"` has not been initialized.")},checkDoNotTrack:ce,log:H,utils:_i,events:Si,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Gr,ji),R()!==void 0&&typeof R().addEventListener=="function"&&R().addEventListener("pagehide",function(g){g.persisted||(Gr.WINDOW_UNLOADING=!0)},!1);var hn=Gr},655:function(re,N,B){var $,R;function p(w){return p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},p(w);}(function(w){var k=!1;if((R=typeof($=w)=="function"?$.call(N,B,N,re):$)===void 0||(re.exports=R),k=!0,p(N)==="object"&&(re.exports=w(),k=!0),!k){var ve=window.Cookies,Z=window.Cookies=w();Z.noConflict=function(){return window.Cookies=ve,Z}}})(function(){var w=function(){for(var k=0,ve={};k<arguments.length;k++){var Z=arguments[k];for(var le in Z)ve[le]=Z[le]}return ve};return function k(ve){function Z(le,Te,H){var ce;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(H=w({path:"/"},Z.defaults,H)).expires=="number"){var z=new Date;z.setMilliseconds(z.getMilliseconds()+864e5*H.expires),H.expires=z}try{ce=JSON.stringify(Te),/^[\{\[]/.test(ce)&&(Te=ce)}catch{}return Te=ve.write?ve.write(Te,le):encodeURIComponent(String(Te)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),le=(le=(le=encodeURIComponent(String(le))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[le,"=",Te,H.expires?"; expires="+H.expires.toUTCString():"",H.path?"; path="+H.path:"",H.domain?"; domain="+H.domain:"",H.secure?"; secure":""].join("")}le||(ce={});for(var ne=document.cookie?document.cookie.split("; "):[],U=/(%[0-9A-Z]{2})+/g,be=0;be<ne.length;be++){var ke=ne[be].split("="),He=ke.slice(1).join("=");He.charAt(0)==='"'&&(He=He.slice(1,-1));try{var K=ke[0].replace(U,decodeURIComponent);if(He=ve.read?ve.read(He,K):ve(He,K)||He.replace(U,decodeURIComponent),this.json)try{He=JSON.parse(He)}catch{}if(le===K){ce=He;break}le||(ce[K]=He)}catch{}}return ce}}return Z.set=Z,Z.get=function(le){return Z.call(Z,le)},Z.getJSON=function(){return Z.apply({json:!0},[].slice.call(arguments))},Z.defaults={},Z.remove=function(le,Te){Z(le,"",w(Te,{expires:-1}))},Z.withConverter=k,Z}(function(){})})},153:function(re,N,B){var $,R=B.g!==void 0?B.g:typeof window!="undefined"?window:{},p=B(558);typeof document!="undefined"?$=document:($=R["__GLOBAL_DOCUMENT_CACHE@4"])||($=R["__GLOBAL_DOCUMENT_CACHE@4"]=p),re.exports=$},48:function(re,N,B){var $;$=typeof window!="undefined"?window:B.g!==void 0?B.g:typeof self!="undefined"?self:{},re.exports=$},678:function(re){var N=9007199254740991,B="[object Arguments]",$="[object Function]",R="[object GeneratorFunction]",p=/^(?:0|[1-9]\d*)$/;function w(W,V,we){switch(we.length){case 0:return W.call(V);case 1:return W.call(V,we[0]);case 2:return W.call(V,we[0],we[1]);case 3:return W.call(V,we[0],we[1],we[2])}return W.apply(V,we)}var k,ve,Z=Object.prototype,le=Z.hasOwnProperty,Te=Z.toString,H=Z.propertyIsEnumerable,ce=(k=Object.keys,ve=Object,function(W){return k(ve(W))}),z=Math.max,ne=!H.call({valueOf:1},"valueOf");function U(W,V){var we=E(W)||function(qe){return function(tt){return function(ee){return!!ee&&typeof ee=="object"}(tt)&&M(tt)}(qe)&&le.call(qe,"callee")&&(!H.call(qe,"callee")||Te.call(qe)==B)}(W)?function(qe,tt){for(var ee=-1,ue=Array(qe);++ee<qe;)ue[ee]=tt(ee);return ue}(W.length,String):[],Re=we.length,Ce=!!Re;for(var ge in W)!V&&!le.call(W,ge)||Ce&&(ge=="length"||ke(ge,Re))||we.push(ge);return we}function be(W,V,we){var Re=W[V];le.call(W,V)&&K(Re,we)&&(we!==void 0||V in W)||(W[V]=we)}function ke(W,V){return!!(V=V==null?N:V)&&(typeof W=="number"||p.test(W))&&W>-1&&W%1==0&&W<V}function He(W){var V=W&&W.constructor;return W===(typeof V=="function"&&V.prototype||Z)}function K(W,V){return W===V||W!=W&&V!=V}var E=Array.isArray;function M(W){return W!=null&&function(V){return typeof V=="number"&&V>-1&&V%1==0&&V<=N}(W.length)&&!function(V){var we=L(V)?Te.call(V):"";return we==$||we==R}(W)}function L(W){var V=typeof W;return!!W&&(V=="object"||V=="function")}var oe,ye=(oe=function(W,V){if(ne||He(V)||M(V))(function(Re,Ce,ge,qe){ge||(ge={});for(var tt=-1,ee=Ce.length;++tt<ee;){var ue=Ce[tt],ie=qe?qe(ge[ue],Re[ue],ue,ge,Re):void 0;be(ge,ue,ie===void 0?Re[ue]:ie)}})(V,function(Re){return M(Re)?U(Re):function(Ce){if(!He(Ce))return ce(Ce);var ge=[];for(var qe in Object(Ce))le.call(Ce,qe)&&qe!="constructor"&&ge.push(qe);return ge}(Re)}(V),W);else for(var we in V)le.call(V,we)&&be(W,we,V[we])},function(W,V){return V=z(V===void 0?W.length-1:V,0),function(){for(var we=arguments,Re=-1,Ce=z(we.length-V,0),ge=Array(Ce);++Re<Ce;)ge[Re]=we[V+Re];Re=-1;for(var qe=Array(V+1);++Re<V;)qe[Re]=we[Re];return qe[V]=ge,w(W,this,qe)}}(function(W,V){var we=-1,Re=V.length,Ce=Re>1?V[Re-1]:void 0,ge=Re>2?V[2]:void 0;for(Ce=oe.length>3&&typeof Ce=="function"?(Re--,Ce):void 0,ge&&function(tt,ee,ue){if(!L(ue))return!1;var ie=typeof ee;return!!(ie=="number"?M(ue)&&ke(ee,ue.length):ie=="string"&&ee in ue)&&K(ue[ee],tt)}(V[0],V[1],ge)&&(Ce=Re<3?void 0:Ce,Re=1),W=Object(W);++we<Re;){var qe=V[we];qe&&oe(W,qe,we,Ce)}return W}));re.exports=ye},640:function(re,N,B){var $,R;(function(p,w){"use strict";$=function(){var k=function(){},ve="undefined",Z=typeof window!==ve&&typeof window.navigator!==ve&&/Trident\/|MSIE /.test(window.navigator.userAgent),le=["trace","debug","info","warn","error"];function Te(E,M){var L=E[M];if(typeof L.bind=="function")return L.bind(E);try{return Function.prototype.bind.call(L,E)}catch{return function(){return Function.prototype.apply.apply(L,[E,arguments])}}}function H(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function ce(E){return E==="debug"&&(E="log"),typeof console!==ve&&(E==="trace"&&Z?H:console[E]!==void 0?Te(console,E):console.log!==void 0?Te(console,"log"):k)}function z(E,M){for(var L=0;L<le.length;L++){var oe=le[L];this[oe]=L<E?k:this.methodFactory(oe,E,M)}this.log=this.debug}function ne(E,M,L){return function(){typeof console!==ve&&(z.call(this,M,L),this[E].apply(this,arguments))}}function U(E,M,L){return ce(E)||ne.apply(this,arguments)}function be(E,M,L){var oe,ye=this;M=M==null?"WARN":M;var W="loglevel";function V(ge){var qe=(le[ge]||"silent").toUpperCase();if(typeof window!==ve&&W){try{return void(window.localStorage[W]=qe)}catch{}try{window.document.cookie=encodeURIComponent(W)+"="+qe+";"}catch{}}}function we(){var ge;if(typeof window!==ve&&W){try{ge=window.localStorage[W]}catch{}if(typeof ge===ve)try{var qe=window.document.cookie,tt=qe.indexOf(encodeURIComponent(W)+"=");tt!==-1&&(ge=/^([^;]+)/.exec(qe.slice(tt))[1])}catch{}return ye.levels[ge]===void 0&&(ge=void 0),ge}}function Re(){if(typeof window!==ve&&W){try{return void window.localStorage.removeItem(W)}catch{}try{window.document.cookie=encodeURIComponent(W)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof E=="string"?W+=":"+E:typeof E=="symbol"&&(W=void 0),ye.name=E,ye.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},ye.methodFactory=L||U,ye.getLevel=function(){return oe},ye.setLevel=function(ge,qe){if(typeof ge=="string"&&ye.levels[ge.toUpperCase()]!==void 0&&(ge=ye.levels[ge.toUpperCase()]),!(typeof ge=="number"&&ge>=0&&ge<=ye.levels.SILENT))throw"log.setLevel() called with invalid level: "+ge;if(oe=ge,qe!==!1&&V(ge),z.call(ye,ge,E),typeof console===ve&&ge<ye.levels.SILENT)return"No console available for logging"},ye.setDefaultLevel=function(ge){M=ge,we()||ye.setLevel(ge,!1)},ye.resetLevel=function(){ye.setLevel(M,!1),Re()},ye.enableAll=function(ge){ye.setLevel(ye.levels.TRACE,ge)},ye.disableAll=function(ge){ye.setLevel(ye.levels.SILENT,ge)};var Ce=we();Ce==null&&(Ce=M),ye.setLevel(Ce,!1)}var ke=new be,He={};ke.getLogger=function(E){if(typeof E!="symbol"&&typeof E!="string"||E==="")throw new TypeError("You must supply a name when creating a logger.");var M=He[E];return M||(M=He[E]=new be(E,ke.getLevel(),ke.methodFactory)),M};var K=typeof window!==ve?window.log:void 0;return ke.noConflict=function(){return typeof window!==ve&&window.log===ke&&(window.log=K),ke},ke.getLoggers=function(){return He},ke.default=ke,ke},(R=typeof $=="function"?$.call(N,B,N,re):$)===void 0||(re.exports=R)})()},375:function(re,N){"use strict";var B=Object.prototype.hasOwnProperty;function $(p){try{return decodeURIComponent(p.replace(/\+/g," "))}catch{return null}}function R(p){try{return encodeURIComponent(p)}catch{return null}}N.stringify=function(p,w){w=w||"";var k,ve,Z=[];for(ve in typeof w!="string"&&(w="?"),p)if(B.call(p,ve)){if((k=p[ve])||k!=null&&!isNaN(k)||(k=""),ve=R(ve),k=R(k),ve===null||k===null)continue;Z.push(ve+"="+k)}return Z.length?w+Z.join("&"):""},N.parse=function(p){for(var w,k=/([^=?#&]+)=?([^&]*)/g,ve={};w=k.exec(p);){var Z=$(w[1]),le=$(w[2]);Z===null||le===null||Z in ve||(ve[Z]=le)}return ve}},558:function(){}},De={};function fe(re){var N=De[re];if(N!==void 0)return N.exports;var B=De[re]={exports:{}};return Se[re].call(B.exports,B,B.exports,fe),B.exports}return fe.n=function(re){var N=re&&re.__esModule?function(){return re.default}:function(){return re};return fe.d(N,{a:N}),N},fe.d=function(re,N){for(var B in N)fe.o(N,B)&&!fe.o(re,B)&&Object.defineProperty(re,B,{enumerable:!0,get:N[B]})},fe.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),fe.o=function(re,N){return Object.prototype.hasOwnProperty.call(re,N)},fe(80)}()},typeof Wi=="object"&&typeof wn=="object"?wn.exports=te():typeof Wi=="object"?Wi.mux=te():X.mux=te()})()});var ra=Zn((Ri,An)=>{typeof window!="undefined"&&function(X,te){typeof Ri=="object"&&typeof An=="object"?An.exports=te():typeof define=="function"&&define.amd?define([],te):typeof Ri=="object"?Ri.Hls=te():X.Hls=te()}(Ri,()=>(()=>{var X={21:(fe,re,N)=>{"use strict";N.r(re),N.d(re,{default:()=>ve});var B=function(){function Z(le,Te){this.subtle=void 0,this.aesIV=void 0,this.subtle=le,this.aesIV=Te}return Z.prototype.decrypt=function(le,Te){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},Te,le)},Z}(),$=function(){function Z(le,Te){this.subtle=void 0,this.key=void 0,this.subtle=le,this.key=Te}return Z.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},Z}(),R=N(145),p=function(){function Z(){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 le=Z.prototype;return le.uint8ArrayToUint32Array_=function(Te){for(var H=new DataView(Te),ce=new Uint32Array(4),z=0;z<4;z++)ce[z]=H.getUint32(4*z);return ce},le.initTable=function(){var Te=this.sBox,H=this.invSBox,ce=this.subMix,z=ce[0],ne=ce[1],U=ce[2],be=ce[3],ke=this.invSubMix,He=ke[0],K=ke[1],E=ke[2],M=ke[3],L=new Uint32Array(256),oe=0,ye=0,W=0;for(W=0;W<256;W++)L[W]=W<128?W<<1:W<<1^283;for(W=0;W<256;W++){var V=ye^ye<<1^ye<<2^ye<<3^ye<<4;V=V>>>8^255&V^99,Te[oe]=V,H[V]=oe;var we=L[oe],Re=L[we],Ce=L[Re],ge=257*L[V]^16843008*V;z[oe]=ge<<24|ge>>>8,ne[oe]=ge<<16|ge>>>16,U[oe]=ge<<8|ge>>>24,be[oe]=ge,ge=16843009*Ce^65537*Re^257*we^16843008*oe,He[V]=ge<<24|ge>>>8,K[V]=ge<<16|ge>>>16,E[V]=ge<<8|ge>>>24,M[V]=ge,oe?(oe=we^L[L[L[Ce^we]]],ye^=L[L[ye]]):oe=ye=1}},le.expandKey=function(Te){for(var H=this.uint8ArrayToUint32Array_(Te),ce=!0,z=0;z<H.length&&ce;)ce=H[z]===this.key[z],z++;if(!ce){this.key=H;var ne=this.keySize=H.length;if(ne!==4&&ne!==6&&ne!==8)throw new Error("Invalid aes key size="+ne);var U,be,ke,He,K=this.ksRows=4*(ne+6+1),E=this.keySchedule=new Uint32Array(K),M=this.invKeySchedule=new Uint32Array(K),L=this.sBox,oe=this.rcon,ye=this.invSubMix,W=ye[0],V=ye[1],we=ye[2],Re=ye[3];for(U=0;U<K;U++)U<ne?ke=E[U]=H[U]:(He=ke,U%ne==0?(He=L[(He=He<<8|He>>>24)>>>24]<<24|L[He>>>16&255]<<16|L[He>>>8&255]<<8|L[255&He],He^=oe[U/ne|0]<<24):ne>6&&U%ne==4&&(He=L[He>>>24]<<24|L[He>>>16&255]<<16|L[He>>>8&255]<<8|L[255&He]),E[U]=ke=(E[U-ne]^He)>>>0);for(be=0;be<K;be++)U=K-be,He=3&be?E[U]:E[U-4],M[be]=be<4||U<=4?He:W[L[He>>>24]]^V[L[He>>>16&255]]^we[L[He>>>8&255]]^Re[L[255&He]],M[be]=M[be]>>>0}},le.networkToHostOrderSwap=function(Te){return Te<<24|(65280&Te)<<8|(16711680&Te)>>8|Te>>>24},le.decrypt=function(Te,H,ce){for(var z,ne,U,be,ke,He,K,E,M,L,oe,ye,W,V,we=this.keySize+6,Re=this.invKeySchedule,Ce=this.invSBox,ge=this.invSubMix,qe=ge[0],tt=ge[1],ee=ge[2],ue=ge[3],ie=this.uint8ArrayToUint32Array_(ce),Oe=ie[0],xe=ie[1],Ne=ie[2],Be=ie[3],je=new Int32Array(Te),pe=new Int32Array(je.length),Ie=this.networkToHostOrderSwap;H<je.length;){for(M=Ie(je[H]),L=Ie(je[H+1]),oe=Ie(je[H+2]),ye=Ie(je[H+3]),ke=M^Re[0],He=ye^Re[1],K=oe^Re[2],E=L^Re[3],W=4,V=1;V<we;V++)z=qe[ke>>>24]^tt[He>>16&255]^ee[K>>8&255]^ue[255&E]^Re[W],ne=qe[He>>>24]^tt[K>>16&255]^ee[E>>8&255]^ue[255&ke]^Re[W+1],U=qe[K>>>24]^tt[E>>16&255]^ee[ke>>8&255]^ue[255&He]^Re[W+2],be=qe[E>>>24]^tt[ke>>16&255]^ee[He>>8&255]^ue[255&K]^Re[W+3],ke=z,He=ne,K=U,E=be,W+=4;z=Ce[ke>>>24]<<24^Ce[He>>16&255]<<16^Ce[K>>8&255]<<8^Ce[255&E]^Re[W],ne=Ce[He>>>24]<<24^Ce[K>>16&255]<<16^Ce[E>>8&255]<<8^Ce[255&ke]^Re[W+1],U=Ce[K>>>24]<<24^Ce[E>>16&255]<<16^Ce[ke>>8&255]<<8^Ce[255&He]^Re[W+2],be=Ce[E>>>24]<<24^Ce[ke>>16&255]<<16^Ce[He>>8&255]<<8^Ce[255&K]^Re[W+3],pe[H]=Ie(z^Oe),pe[H+1]=Ie(be^xe),pe[H+2]=Ie(U^Ne),pe[H+3]=Ie(ne^Be),Oe=M,xe=L,Ne=oe,Be=ye,H+=4}return pe.buffer},Z}(),w=N(93),k=N(63),ve=function(){function Z(Te,H){var ce=(H===void 0?{}:H).removePKCS7Padding,z=ce===void 0||ce;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=Te.enableSoftwareAES,this.removePKCS7Padding=z,z)try{var ne=self.crypto;ne&&(this.subtle=ne.subtle||ne.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var le=Z.prototype;return le.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},le.isSync=function(){return this.useSoftware},le.flush=function(){var Te=this.currentResult,H=this.remainderData;if(!Te||H)return w.logger.error("[softwareDecrypt] "+(H?"overflow bytes: "+H.byteLength:"no result")),this.reset(),null;var ce,z,ne,U=new Uint8Array(Te);return this.reset(),this.removePKCS7Padding?(ne=(z=(ce=U).byteLength)&&new DataView(ce.buffer).getUint8(z-1))?(0,R.sliceUint8)(ce,0,z-ne):ce:U},le.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},le.decrypt=function(Te,H,ce){var z=this;return this.useSoftware?new Promise(function(ne,U){z.softwareDecrypt(new Uint8Array(Te),H,ce);var be=z.flush();be?ne(be.buffer):U(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(Te),H,ce)},le.softwareDecrypt=function(Te,H,ce){var z=this.currentIV,ne=this.currentResult,U=this.remainderData;this.logOnce("JS AES decrypt"),U&&(Te=(0,k.appendUint8Array)(U,Te),this.remainderData=null);var be=this.getValidChunk(Te);if(!be.length)return null;z&&(ce=z);var ke=this.softwareDecrypter;ke||(ke=this.softwareDecrypter=new p),ke.expandKey(H);var He=ne;return this.currentResult=ke.decrypt(be.buffer,0,ce),this.currentIV=(0,R.sliceUint8)(be,-16).buffer,He||null},le.webCryptoDecrypt=function(Te,H,ce){var z=this,ne=this.subtle;return this.key===H&&this.fastAesKey||(this.key=H,this.fastAesKey=new $(ne,H)),this.fastAesKey.expandKey().then(function(U){return ne?(z.logOnce("WebCrypto AES decrypt"),new B(ne,new Uint8Array(ce)).decrypt(Te.buffer,U)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(U){return w.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+U.name+": "+U.message),z.onWebCryptoError(Te,H,ce)})},le.onWebCryptoError=function(Te,H,ce){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(Te,H,ce);var z=this.flush();if(z)return z.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},le.getValidChunk=function(Te){var H=Te,ce=Te.length-Te.length%16;return ce!==Te.length&&(H=(0,R.sliceUint8)(Te,0,ce),this.remainderData=(0,R.sliceUint8)(Te,ce)),H},le.logOnce=function(Te){this.logEnabled&&(w.logger.log("[decrypter]: "+Te),this.logEnabled=!1)},Z}()},181:(fe,re,N)=>{"use strict";N.r(re),N.d(re,{canParse:()=>k,decodeFrame:()=>H,getID3Data:()=>p,getID3Frames:()=>Te,getTimeStamp:()=>ve,isFooter:()=>R,isHeader:()=>$,isTimeStampFrame:()=>Z,testables:()=>ke,utf8ArrayToStr:()=>be});var B,$=function(K,E){return E+10<=K.length&&K[E]===73&&K[E+1]===68&&K[E+2]===51&&K[E+3]<255&&K[E+4]<255&&K[E+6]<128&&K[E+7]<128&&K[E+8]<128&&K[E+9]<128},R=function(K,E){return E+10<=K.length&&K[E]===51&&K[E+1]===68&&K[E+2]===73&&K[E+3]<255&&K[E+4]<255&&K[E+6]<128&&K[E+7]<128&&K[E+8]<128&&K[E+9]<128},p=function(K,E){for(var M=E,L=0;$(K,E);)L+=10,L+=w(K,E+6),R(K,E+10)&&(L+=10),E+=L;if(L>0)return K.subarray(M,M+L)},w=function(K,E){var M=0;return M=(127&K[E])<<21,M|=(127&K[E+1])<<14,(M|=(127&K[E+2])<<7)|127&K[E+3]},k=function(K,E){return $(K,E)&&w(K,E+6)+10<=K.length-E},ve=function(K){for(var E=Te(K),M=0;M<E.length;M++){var L=E[M];if(Z(L))return U(L)}},Z=function(K){return K&&K.key==="PRIV"&&K.info==="com.apple.streaming.transportStreamTimestamp"},le=function(K){var E=String.fromCharCode(K[0],K[1],K[2],K[3]),M=w(K,4);return{type:E,size:M,data:K.subarray(10,10+M)}},Te=function(K){for(var E=0,M=[];$(K,E);){for(var L=w(K,E+6),oe=(E+=10)+L;E+8<oe;){var ye=le(K.subarray(E)),W=H(ye);W&&M.push(W),E+=ye.size+10}R(K,E)&&(E+=10)}return M},H=function(K){return K.type==="PRIV"?ce(K):K.type[0]==="W"?ne(K):z(K)},ce=function(K){if(!(K.size<2)){var E=be(K.data,!0),M=new Uint8Array(K.data.subarray(E.length+1));return{key:K.type,info:E,data:M.buffer}}},z=function(K){if(!(K.size<2)){if(K.type==="TXXX"){var E=1,M=be(K.data.subarray(E),!0);E+=M.length+1;var L=be(K.data.subarray(E));return{key:K.type,info:M,data:L}}var oe=be(K.data.subarray(1));return{key:K.type,data:oe}}},ne=function(K){if(K.type==="WXXX"){if(K.size<2)return;var E=1,M=be(K.data.subarray(E),!0);E+=M.length+1;var L=be(K.data.subarray(E));return{key:K.type,info:M,data:L}}var oe=be(K.data);return{key:K.type,data:oe}},U=function(K){if(K.data.byteLength===8){var E=new Uint8Array(K.data),M=1&E[3],L=(E[4]<<23)+(E[5]<<15)+(E[6]<<7)+E[7];return L/=45,M&&(L+=4772185884e-2),Math.round(L)}},be=function(K,E){E===void 0&&(E=!1);var M=He();if(M){var L=M.decode(K);if(E){var oe=L.indexOf("\0");return oe!==-1?L.substring(0,oe):L}return L.replace(/\0/g,"")}for(var ye,W,V,we=K.length,Re="",Ce=0;Ce<we;){if((ye=K[Ce++])===0&&E)return Re;if(ye!==0&&ye!==3)switch(ye>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:Re+=String.fromCharCode(ye);break;case 12:case 13:W=K[Ce++],Re+=String.fromCharCode((31&ye)<<6|63&W);break;case 14:W=K[Ce++],V=K[Ce++],Re+=String.fromCharCode((15&ye)<<12|(63&W)<<6|(63&V)<<0)}}return Re},ke={decodeTextFrame:z};function He(){return B||self.TextDecoder===void 0||(B=new self.TextDecoder("utf-8")),B}},182:(fe,re,N)=>{"use strict";N.r(re),N.d(re,{default:()=>k});var B=N(544),$=N(851),R=N(93),p=N(729),w=N(973);function k(Te){var H=new p.EventEmitter,ce=function(z,ne){Te.postMessage({event:z,data:ne})};H.on($.Events.FRAG_DECRYPTED,ce),H.on($.Events.ERROR,ce),Te.addEventListener("message",function(z){var ne=z.data;switch(ne.cmd){case"init":var U=JSON.parse(ne.config);Te.transmuxer=new B.default(H,ne.typeSupported,U,ne.vendor,ne.id),(0,R.enableLogs)(U.debug,ne.id),function(){var K=function(M){R.logger[M]=function(L){ce("workerLog",{logType:M,message:L})}};for(var E in R.logger)K(E)}(),ce("init",null);break;case"configure":Te.transmuxer.configure(ne.config);break;case"demux":var be=Te.transmuxer.push(ne.data,ne.decryptdata,ne.chunkMeta,ne.state);(0,B.isPromise)(be)?(Te.transmuxer.async=!0,be.then(function(K){ve(Te,K)}).catch(function(K){ce($.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:ne.chunkMeta,fatal:!1,error:K,err:K,reason:"transmuxer-worker push error"})})):(Te.transmuxer.async=!1,ve(Te,be));break;case"flush":var ke=ne.chunkMeta,He=Te.transmuxer.flush(ke);(0,B.isPromise)(He)||Te.transmuxer.async?((0,B.isPromise)(He)||(He=Promise.resolve(He)),He.then(function(K){le(Te,K,ke)}).catch(function(K){ce($.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:ne.chunkMeta,fatal:!1,error:K,err:K,reason:"transmuxer-worker flush error"})})):le(Te,He,ke)}})}function ve(Te,H){if(!((ce=H.remuxResult).audio||ce.video||ce.text||ce.id3||ce.initSegment))return!1;var ce,z=[],ne=H.remuxResult,U=ne.audio,be=ne.video;return U&&Z(z,U),be&&Z(z,be),Te.postMessage({event:"transmuxComplete",data:H},z),!0}function Z(Te,H){H.data1&&Te.push(H.data1.buffer),H.data2&&Te.push(H.data2.buffer)}function le(Te,H,ce){H.reduce(function(z,ne){return ve(Te,ne)||z},!1)||Te.postMessage({event:"transmuxComplete",data:H[0]}),Te.postMessage({event:"flush",data:ce})}},544:(fe,re,N)=>{"use strict";N.r(re),N.d(re,{TransmuxConfig:()=>Nt,TransmuxState:()=>dr,default:()=>Pt,isPromise:()=>zt});var B=N(851),$=N(973),R=N(21),p=N(965),w=N(181),k=N(856);function ve(J,O){return J===void 0&&(J=""),O===void 0&&(O=9e4),{type:J,id:-1,pid:-1,inputTimeScale:O,sequenceNumber:-1,samples:[],dropped:0}}var Z=N(63),le=N(145),Te=function(){function J(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var O=J.prototype;return O.resetInitSegment=function(T,P,D,F){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},O.resetTimeStamp=function(T){this.initPTS=T,this.resetContiguity()},O.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},O.canParse=function(T,P){return!1},O.appendFrame=function(T,P,D){},O.demux=function(T,P){this.cachedData&&(T=(0,Z.appendUint8Array)(this.cachedData,T),this.cachedData=null);var D,F=w.getID3Data(T,0),q=F?F.length:0,Y=this._audioTrack,he=this._id3Track,Le=F?w.getTimeStamp(F):void 0,Ae=T.length;for((this.basePTS===null||this.frameIndex===0&&(0,p.isFiniteNumber)(Le))&&(this.basePTS=H(Le,P,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),F&&F.length>0&&he.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:F,type:k.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});q<Ae;){if(this.canParse(T,q)){var Me=this.appendFrame(Y,T,q);Me?(this.frameIndex++,this.lastPTS=Me.sample.pts,D=q+=Me.length):q=Ae}else w.canParse(T,q)?(F=w.getID3Data(T,q),he.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:F,type:k.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),D=q+=F.length):q++;if(q===Ae&&D!==Ae){var Ve=(0,le.sliceUint8)(T,D);this.cachedData?this.cachedData=(0,Z.appendUint8Array)(this.cachedData,Ve):this.cachedData=Ve}}return{audioTrack:Y,videoTrack:ve(),id3Track:he,textTrack:ve()}},O.demuxSampleAes=function(T,P,D){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},O.flush=function(T){var P=this.cachedData;return P&&(this.cachedData=null,this.demux(P,0)),{audioTrack:this._audioTrack,videoTrack:ve(),id3Track:this._id3Track,textTrack:ve()}},O.destroy=function(){},J}(),H=function(J,O,T){return(0,p.isFiniteNumber)(J)?90*J:9e4*O+(T||0)};let ce=Te;var z=N(93);function ne(J,O){return J[O]===255&&(246&J[O+1])==240}function U(J,O){return 1&J[O+1]?7:9}function be(J,O){return(3&J[O+3])<<11|J[O+4]<<3|(224&J[O+5])>>>5}function ke(J,O){return O+1<J.length&&ne(J,O)}function He(J,O){if(ke(J,O)){var T=U(J,O);if(O+T>=J.length)return!1;var P=be(J,O);if(P<=T)return!1;var D=O+P;return D===J.length||ke(J,D)}return!1}function K(J,O,T,P,D){if(!J.samplerate){var F=function(q,Y,he,Le){var Ae,Me,Ve,Ue,Qe=navigator.userAgent.toLowerCase(),ot=Le,bt=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Ae=1+((192&Y[he+2])>>>6);var We=(60&Y[he+2])>>>2;if(!(We>bt.length-1))return Ve=(1&Y[he+2])<<2,Ve|=(192&Y[he+3])>>>6,z.logger.log("manifest codec:"+Le+", ADTS type:"+Ae+", samplingIndex:"+We),/firefox/i.test(Qe)?We>=6?(Ae=5,Ue=new Array(4),Me=We-3):(Ae=2,Ue=new Array(2),Me=We):Qe.indexOf("android")!==-1?(Ae=2,Ue=new Array(2),Me=We):(Ae=5,Ue=new Array(4),Le&&(Le.indexOf("mp4a.40.29")!==-1||Le.indexOf("mp4a.40.5")!==-1)||!Le&&We>=6?Me=We-3:((Le&&Le.indexOf("mp4a.40.2")!==-1&&(We>=6&&Ve===1||/vivaldi/i.test(Qe))||!Le&&Ve===1)&&(Ae=2,Ue=new Array(2)),Me=We)),Ue[0]=Ae<<3,Ue[0]|=(14&We)>>1,Ue[1]|=(1&We)<<7,Ue[1]|=Ve<<3,Ae===5&&(Ue[1]|=(14&Me)>>1,Ue[2]=(1&Me)<<7,Ue[2]|=8,Ue[3]=0),{config:Ue,samplerate:bt[We],channelCount:Ve,codec:"mp4a.40."+Ae,manifestCodec:ot};q.trigger(B.Events.ERROR,{type:$.ErrorTypes.MEDIA_ERROR,details:$.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+We})}(O,T,P,D);if(!F)return;J.config=F.config,J.samplerate=F.samplerate,J.channelCount=F.channelCount,J.codec=F.codec,J.manifestCodec=F.manifestCodec,z.logger.log("parsed codec:"+J.codec+", rate:"+F.samplerate+", channels:"+F.channelCount)}}function E(J){return 9216e4/J}function M(J,O,T,P,D){var F,q=P+D*E(J.samplerate),Y=function(Qe,ot){var bt=U(Qe,ot);if(ot+bt<=Qe.length){var We=be(Qe,ot)-bt;if(We>0)return{headerLength:bt,frameLength:We}}}(O,T);if(Y){var he=Y.frameLength,Le=Y.headerLength,Ae=Le+he,Me=Math.max(0,T+Ae-O.length);Me?(F=new Uint8Array(Ae-Le)).set(O.subarray(T+Le,O.length),0):F=O.subarray(T+Le,T+Ae);var Ve={unit:F,pts:q};return Me||J.samples.push(Ve),{sample:Ve,length:Ae,missing:Me}}var Ue=O.length-T;return(F=new Uint8Array(Ue)).set(O.subarray(T,O.length),0),{sample:{unit:F,pts:q},length:Ue,missing:-1}}function L(J,O){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,P){return T.__proto__=P,T},L(J,O)}let oe=function(J){var O,T;function P(F,q){var Y;return(Y=J.call(this)||this).observer=void 0,Y.config=void 0,Y.observer=F,Y.config=q,Y}T=J,(O=P).prototype=Object.create(T.prototype),O.prototype.constructor=O,L(O,T);var D=P.prototype;return D.resetInitSegment=function(F,q,Y,he){J.prototype.resetInitSegment.call(this,F,q,Y,he),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:q,duration:he,inputTimeScale:9e4,dropped:0}},P.probe=function(F){if(!F)return!1;for(var q=(w.getID3Data(F,0)||[]).length,Y=F.length;q<Y;q++)if(He(F,q))return z.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(F,q){return function(Y,he){return function(Le,Ae){return Ae+5<Le.length}(Y,he)&&ne(Y,he)&&be(Y,he)<=Y.length-he}(F,q)},D.appendFrame=function(F,q,Y){K(F,this.observer,q,Y,F.manifestCodec);var he=M(F,q,Y,this.basePTS,this.frameIndex);if(he&&he.missing===0)return he},P}(ce);var ye=/\/emsg[-/]ID3/i;let W=function(){function J(T,P){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=P}var O=J.prototype;return O.resetTimeStamp=function(){},O.resetInitSegment=function(T,P,D,F){var q=this.videoTrack=ve("video",1),Y=this.audioTrack=ve("audio",1),he=this.txtTrack=ve("text",1);if(this.id3Track=ve("id3",1),this.timeOffset=0,T&&T.byteLength){var Le=(0,Z.parseInitSegment)(T);if(Le.video){var Ae=Le.video,Me=Ae.id,Ve=Ae.timescale,Ue=Ae.codec;q.id=Me,q.timescale=he.timescale=Ve,q.codec=Ue}if(Le.audio){var Qe=Le.audio,ot=Qe.id,bt=Qe.timescale,We=Qe.codec;Y.id=ot,Y.timescale=bt,Y.codec=We}he.id=Z.RemuxerTrackIdConfig.text,q.sampleDuration=0,q.duration=Y.duration=F}},O.resetContiguity=function(){},J.probe=function(T){return T=T.length>16384?T.subarray(0,16384):T,(0,Z.findBox)(T,["moof"]).length>0},O.demux=function(T,P){this.timeOffset=P;var D=T,F=this.videoTrack,q=this.txtTrack;if(this.config.progressive){this.remainderData&&(D=(0,Z.appendUint8Array)(this.remainderData,T));var Y=(0,Z.segmentValidRange)(D);this.remainderData=Y.remainder,F.samples=Y.valid||new Uint8Array}else F.samples=D;var he=this.extractID3Track(F,P);return q.samples=(0,Z.parseSamples)(P,F),{videoTrack:F,audioTrack:this.audioTrack,id3Track:he,textTrack:this.txtTrack}},O.flush=function(){var T=this.timeOffset,P=this.videoTrack,D=this.txtTrack;P.samples=this.remainderData||new Uint8Array,this.remainderData=null;var F=this.extractID3Track(P,this.timeOffset);return D.samples=(0,Z.parseSamples)(T,P),{videoTrack:P,audioTrack:ve(),id3Track:F,textTrack:ve()}},O.extractID3Track=function(T,P){var D=this.id3Track;if(T.samples.length){var F=(0,Z.findBox)(T.samples,["emsg"]);F&&F.forEach(function(q){var Y=(0,Z.parseEmsg)(q);if(ye.test(Y.schemeIdUri)){var he=(0,p.isFiniteNumber)(Y.presentationTime)?Y.presentationTime/Y.timeScale:P+Y.presentationTimeDelta/Y.timeScale,Le=Y.eventDuration===4294967295?Number.POSITIVE_INFINITY:Y.eventDuration/Y.timeScale;Le<=.001&&(Le=Number.POSITIVE_INFINITY);var Ae=Y.payload;D.samples.push({data:Ae,len:Ae.byteLength,dts:he,pts:he,type:k.MetadataSchema.emsg,duration:Le})}})}return D},O.demuxSampleAes=function(T,P,D){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},O.destroy=function(){},J}();var V=null,we=[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],Re=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Ce=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ge=[0,1,1,4];function qe(J,O,T,P,D){if(!(T+24>O.length)){var F=tt(O,T);if(F&&T+F.frameLength<=O.length){var q=P+D*(9e4*F.samplesPerFrame/F.sampleRate),Y={unit:O.subarray(T,T+F.frameLength),pts:q,dts:q};return J.config=[],J.channelCount=F.channelCount,J.samplerate=F.sampleRate,J.samples.push(Y),{sample:Y,length:F.frameLength,missing:0}}}}function tt(J,O){var T=J[O+1]>>3&3,P=J[O+1]>>1&3,D=J[O+2]>>4&15,F=J[O+2]>>2&3;if(T!==1&&D!==0&&D!==15&&F!==3){var q=J[O+2]>>1&1,Y=J[O+3]>>6,he=1e3*we[14*(T===3?3-P:P===3?3:4)+D-1],Le=Re[3*(T===3?0:T===2?1:2)+F],Ae=Y===3?1:2,Me=Ce[T][P],Ve=ge[P],Ue=8*Me*Ve,Qe=Math.floor(Me*he/Le+q)*Ve;if(V===null){var ot=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);V=ot?parseInt(ot[1]):0}return!!V&&V<=87&&P===2&&he>=224e3&&Y===0&&(J[O+3]=128|J[O+3]),{sampleRate:Le,channelCount:Ae,frameLength:Qe,samplesPerFrame:Ue}}}function ee(J,O){return J[O]===255&&(224&J[O+1])==224&&(6&J[O+1])!=0}function ue(J,O){return O+1<J.length&&ee(J,O)}function ie(J,O){if(O+1<J.length&&ee(J,O)){var T=tt(J,O),P=4;T!=null&&T.frameLength&&(P=T.frameLength);var D=O+P;return D===J.length||ue(J,D)}return!1}let Oe=function(){function J(T){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=T,this.bytesAvailable=T.byteLength,this.word=0,this.bitsAvailable=0}var O=J.prototype;return O.loadWord=function(){var T=this.data,P=this.bytesAvailable,D=T.byteLength-P,F=new Uint8Array(4),q=Math.min(4,P);if(q===0)throw new Error("no bytes available");F.set(T.subarray(D,D+q)),this.word=new DataView(F.buffer).getUint32(0),this.bitsAvailable=8*q,this.bytesAvailable-=q},O.skipBits=function(T){var P;T=Math.min(T,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>T?(this.word<<=T,this.bitsAvailable-=T):(T-=this.bitsAvailable,T-=(P=T>>3)<<3,this.bytesAvailable-=P,this.loadWord(),this.word<<=T,this.bitsAvailable-=T)},O.readBits=function(T){var P=Math.min(this.bitsAvailable,T),D=this.word>>>32-P;if(T>32&&z.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=P,this.bitsAvailable>0)this.word<<=P;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(P=T-P)>0&&this.bitsAvailable?D<<P|this.readBits(P):D},O.skipLZ=function(){var T;for(T=0;T<this.bitsAvailable;++T)if((this.word&2147483648>>>T)!=0)return this.word<<=T,this.bitsAvailable-=T,T;return this.loadWord(),T+this.skipLZ()},O.skipUEG=function(){this.skipBits(1+this.skipLZ())},O.skipEG=function(){this.skipBits(1+this.skipLZ())},O.readUEG=function(){var T=this.skipLZ();return this.readBits(T+1)-1},O.readEG=function(){var T=this.readUEG();return 1&T?1+T>>>1:-1*(T>>>1)},O.readBoolean=function(){return this.readBits(1)===1},O.readUByte=function(){return this.readBits(8)},O.readUShort=function(){return this.readBits(16)},O.readUInt=function(){return this.readBits(32)},O.skipScalingList=function(T){for(var P=8,D=8,F=0;F<T;F++)D!==0&&(D=(P+this.readEG()+256)%256),P=D===0?P:D},O.readSPS=function(){var T,P,D,F=0,q=0,Y=0,he=0,Le=this.readUByte.bind(this),Ae=this.readBits.bind(this),Me=this.readUEG.bind(this),Ve=this.readBoolean.bind(this),Ue=this.skipBits.bind(this),Qe=this.skipEG.bind(this),ot=this.skipUEG.bind(this),bt=this.skipScalingList.bind(this);Le();var We=Le();if(Ae(5),Ue(3),Le(),ot(),We===100||We===110||We===122||We===244||We===44||We===83||We===86||We===118||We===128){var Lt=Me();if(Lt===3&&Ue(1),ot(),ot(),Ue(1),Ve())for(P=Lt!==3?8:12,D=0;D<P;D++)Ve()&&bt(D<6?16:64)}ot();var Qt=Me();if(Qt===0)Me();else if(Qt===1)for(Ue(1),Qe(),Qe(),T=Me(),D=0;D<T;D++)Qe();ot(),Ue(1);var Ot=Me(),xt=Me(),Ut=Ae(1);Ut===0&&Ue(1),Ue(1),Ve()&&(F=Me(),q=Me(),Y=Me(),he=Me());var Ze=[1,1];if(Ve()&&Ve())switch(Le()){case 1:Ze=[1,1];break;case 2:Ze=[12,11];break;case 3:Ze=[10,11];break;case 4:Ze=[16,11];break;case 5:Ze=[40,33];break;case 6:Ze=[24,11];break;case 7:Ze=[20,11];break;case 8:Ze=[32,11];break;case 9:Ze=[80,33];break;case 10:Ze=[18,11];break;case 11:Ze=[15,11];break;case 12:Ze=[64,33];break;case 13:Ze=[160,99];break;case 14:Ze=[4,3];break;case 15:Ze=[3,2];break;case 16:Ze=[2,1];break;case 255:Ze=[Le()<<8|Le(),Le()<<8|Le()]}return{width:Math.ceil(16*(Ot+1)-2*F-2*q),height:(2-Ut)*(xt+1)*16-(Ut?2:4)*(Y+he),pixelRatio:Ze}},O.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},J}(),xe=function(){function J(T,P,D){this.keyData=void 0,this.decrypter=void 0,this.keyData=D,this.decrypter=new R.default(P,{removePKCS7Padding:!1})}var O=J.prototype;return O.decryptBuffer=function(T){return this.decrypter.decrypt(T,this.keyData.key.buffer,this.keyData.iv.buffer)},O.decryptAacSample=function(T,P,D){var F=this,q=T[P].unit;if(!(q.length<=16)){var Y=q.subarray(16,q.length-q.length%16),he=Y.buffer.slice(Y.byteOffset,Y.byteOffset+Y.length);this.decryptBuffer(he).then(function(Le){var Ae=new Uint8Array(Le);q.set(Ae,16),F.decrypter.isSync()||F.decryptAacSamples(T,P+1,D)})}},O.decryptAacSamples=function(T,P,D){for(;;P++){if(P>=T.length)return void D();if(!(T[P].unit.length<32||(this.decryptAacSample(T,P,D),this.decrypter.isSync())))return}},O.getAvcEncryptedData=function(T){for(var P=16*Math.floor((T.length-48)/160)+16,D=new Int8Array(P),F=0,q=32;q<T.length-16;q+=160,F+=16)D.set(T.subarray(q,q+16),F);return D},O.getAvcDecryptedUnit=function(T,P){for(var D=new Uint8Array(P),F=0,q=32;q<T.length-16;q+=160,F+=16)T.set(D.subarray(F,F+16),q);return T},O.decryptAvcSample=function(T,P,D,F,q){var Y=this,he=(0,Z.discardEPB)(q.data),Le=this.getAvcEncryptedData(he);this.decryptBuffer(Le.buffer).then(function(Ae){q.data=Y.getAvcDecryptedUnit(he,Ae),Y.decrypter.isSync()||Y.decryptAvcSamples(T,P,D+1,F)})},O.decryptAvcSamples=function(T,P,D,F){if(T instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;P++,D=0){if(P>=T.length)return void F();for(var q=T[P].units;!(D>=q.length);D++){var Y=q[D];if(!(Y.data.length<=48||Y.type!==1&&Y.type!==5||(this.decryptAvcSample(T,P,D,F,Y),this.decrypter.isSync())))return}}},J}();function Ne(){return Ne=Object.assign?Object.assign.bind():function(J){for(var O=1;O<arguments.length;O++){var T=arguments[O];for(var P in T)Object.prototype.hasOwnProperty.call(T,P)&&(J[P]=T[P])}return J},Ne.apply(this,arguments)}var Be=188;function je(J,O,T,P){return{key:J,frame:!1,pts:O,dts:T,units:[],debug:P,length:0}}function pe(J,O){return(31&J[O+10])<<8|J[O+11]}function Ie(J,O,T,P){var D={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},F=O+3+((15&J[O+1])<<8|J[O+2])-4;for(O+=12+((15&J[O+10])<<8|J[O+11]);O<F;){var q=(31&J[O+1])<<8|J[O+2];switch(J[O]){case 207:if(!P){z.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:D.audio===-1&&(D.audio=q);break;case 21:D.id3===-1&&(D.id3=q);break;case 219:if(!P){z.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:D.avc===-1&&(D.avc=q);break;case 3:case 4:T.mpeg!==!0&&T.mp3!==!0?z.logger.log("MPEG audio found, not supported in this browser"):D.audio===-1&&(D.audio=q,D.segmentCodec="mp3");break;case 36:z.logger.warn("Unsupported HEVC stream type found")}O+=5+((15&J[O+3])<<8|J[O+4])}return D}function Ye(J){var O,T,P,D,F,q=0,Y=J.data;if(!J||J.size===0)return null;for(;Y[0].length<19&&Y.length>1;){var he=new Uint8Array(Y[0].length+Y[1].length);he.set(Y[0]),he.set(Y[1],Y[0].length),Y[0]=he,Y.splice(1,1)}if(((O=Y[0])[0]<<16)+(O[1]<<8)+O[2]===1){if((T=(O[4]<<8)+O[5])&&T>J.size-6)return null;var Le=O[7];192&Le&&(D=536870912*(14&O[9])+4194304*(255&O[10])+16384*(254&O[11])+128*(255&O[12])+(254&O[13])/2,64&Le?D-(F=536870912*(14&O[14])+4194304*(255&O[15])+16384*(254&O[16])+128*(255&O[17])+(254&O[18])/2)>54e5&&(z.logger.warn(Math.round((D-F)/9e4)+"s delta between PTS and DTS, align them"),D=F):F=D);var Ae=(P=O[8])+9;if(J.size<=Ae)return null;J.size-=Ae;for(var Me=new Uint8Array(J.size),Ve=0,Ue=Y.length;Ve<Ue;Ve++){var Qe=(O=Y[Ve]).byteLength;if(Ae){if(Ae>Qe){Ae-=Qe;continue}O=O.subarray(Ae),Qe-=Ae,Ae=0}Me.set(O,q),q+=Qe}return T&&(T-=P+3),{data:Me,pts:D,dts:F,len:T}}return null}function rt(J,O){if(J.units.length&&J.frame){if(J.pts===void 0){var T=O.samples,P=T.length;if(!P)return void O.dropped++;var D=T[P-1];J.pts=D.pts,J.dts=D.dts}O.samples.push(J)}J.debug.length&&z.logger.log(J.pts+"/"+J.dts+":"+J.debug)}let yt=function(){function J(T,P,D){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=T,this.config=P,this.typeSupported=D}J.probe=function(T){var P=J.syncOffset(T);return P>0&&z.logger.warn("MPEG2-TS detected but first sync word found @ offset "+P),P!==-1},J.syncOffset=function(T){for(var P=Math.min(940,T.length-376)+1,D=0;D<P;){if(T[D]===71&&T[D+Be]===71)return D;D++}return-1},J.createTrack=function(T,P){return{container:T==="video"||T==="audio"?"video/mp2t":void 0,type:T,id:Z.RemuxerTrackIdConfig[T],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:T==="audio"?P:void 0}};var O=J.prototype;return O.resetInitSegment=function(T,P,D,F){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=J.createTrack("video"),this._audioTrack=J.createTrack("audio",F),this._id3Track=J.createTrack("id3"),this._txtTrack=J.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=P,this.videoCodec=D,this._duration=F},O.resetTimeStamp=function(){},O.resetContiguity=function(){var T=this._audioTrack,P=this._avcTrack,D=this._id3Track;T&&(T.pesData=null),P&&(P.pesData=null),D&&(D.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},O.demux=function(T,P,D,F){var q;D===void 0&&(D=!1),F===void 0&&(F=!1),D||(this.sampleAes=null);var Y=this._avcTrack,he=this._audioTrack,Le=this._id3Track,Ae=this._txtTrack,Me=Y.pid,Ve=Y.pesData,Ue=he.pid,Qe=Le.pid,ot=he.pesData,bt=Le.pesData,We=null,Lt=this.pmtParsed,Qt=this._pmtId,Ot=T.length;if(this.remainderData&&(Ot=(T=(0,Z.appendUint8Array)(this.remainderData,T)).length,this.remainderData=null),Ot<Be&&!F)return this.remainderData=T,{audioTrack:he,videoTrack:Y,id3Track:Le,textTrack:Ae};var xt=Math.max(0,J.syncOffset(T));(Ot-=(Ot-xt)%Be)<T.byteLength&&!F&&(this.remainderData=new Uint8Array(T.buffer,Ot,T.buffer.byteLength-Ot));for(var Ut=0,Ze=xt;Ze<Ot;Ze+=Be)if(T[Ze]===71){var rr=!!(64&T[Ze+1]),Er=((31&T[Ze+1])<<8)+T[Ze+2],Ft=void 0;if((48&T[Ze+3])>>4>1){if((Ft=Ze+5+T[Ze+4])===Ze+Be)continue}else Ft=Ze+4;switch(Er){case Me:rr&&(Ve&&(q=Ye(Ve))&&this.parseAVCPES(Y,Ae,q,!1),Ve={data:[],size:0}),Ve&&(Ve.data.push(T.subarray(Ft,Ze+Be)),Ve.size+=Ze+Be-Ft);break;case Ue:if(rr){if(ot&&(q=Ye(ot)))switch(he.segmentCodec){case"aac":this.parseAACPES(he,q);break;case"mp3":this.parseMPEGPES(he,q)}ot={data:[],size:0}}ot&&(ot.data.push(T.subarray(Ft,Ze+Be)),ot.size+=Ze+Be-Ft);break;case Qe:rr&&(bt&&(q=Ye(bt))&&this.parseID3PES(Le,q),bt={data:[],size:0}),bt&&(bt.data.push(T.subarray(Ft,Ze+Be)),bt.size+=Ze+Be-Ft);break;case 0:rr&&(Ft+=T[Ft]+1),Qt=this._pmtId=pe(T,Ft);break;case Qt:rr&&(Ft+=T[Ft]+1);var Vt=Ie(T,Ft,this.typeSupported,D);(Me=Vt.avc)>0&&(Y.pid=Me),(Ue=Vt.audio)>0&&(he.pid=Ue,he.segmentCodec=Vt.segmentCodec),(Qe=Vt.id3)>0&&(Le.pid=Qe),We===null||Lt||(z.logger.log("unknown PID '"+We+"' in TS found"),We=null,Ze=xt-188),Lt=this.pmtParsed=!0;break;case 17:case 8191:break;default:We=Er}}else Ut++;Ut>0&&this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:$.ErrorTypes.MEDIA_ERROR,details:$.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Ut+" TS packet/s that do not start with 0x47"}),Y.pesData=Ve,he.pesData=ot,Le.pesData=bt;var hr={audioTrack:he,videoTrack:Y,id3Track:Le,textTrack:Ae};return F&&this.extractRemainingSamples(hr),hr},O.flush=function(){var T,P=this.remainderData;return this.remainderData=null,T=P?this.demux(P,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(T),this.sampleAes?this.decrypt(T,this.sampleAes):T},O.extractRemainingSamples=function(T){var P,D=T.audioTrack,F=T.videoTrack,q=T.id3Track,Y=T.textTrack,he=F.pesData,Le=D.pesData,Ae=q.pesData;if(he&&(P=Ye(he))?(this.parseAVCPES(F,Y,P,!0),F.pesData=null):F.pesData=he,Le&&(P=Ye(Le))){switch(D.segmentCodec){case"aac":this.parseAACPES(D,P);break;case"mp3":this.parseMPEGPES(D,P)}D.pesData=null}else Le!=null&&Le.size&&z.logger.log("last AAC PES packet truncated,might overlap between fragments"),D.pesData=Le;Ae&&(P=Ye(Ae))?(this.parseID3PES(q,P),q.pesData=null):q.pesData=Ae},O.demuxSampleAes=function(T,P,D){var F=this.demux(T,D,!0,!this.config.progressive),q=this.sampleAes=new xe(this.observer,this.config,P);return this.decrypt(F,q)},O.decrypt=function(T,P){return new Promise(function(D){var F=T.audioTrack,q=T.videoTrack;F.samples&&F.segmentCodec==="aac"?P.decryptAacSamples(F.samples,0,function(){q.samples?P.decryptAvcSamples(q.samples,0,0,function(){D(T)}):D(T)}):q.samples&&P.decryptAvcSamples(q.samples,0,0,function(){D(T)})})},O.destroy=function(){this._duration=0},O.parseAVCPES=function(T,P,D,F){var q,Y=this,he=this.parseAVCNALu(T,D.data),Le=this.avcSample,Ae=!1;D.data=null,Le&&he.length&&!T.audFound&&(rt(Le,T),Le=this.avcSample=je(!1,D.pts,D.dts,"")),he.forEach(function(Me){switch(Me.type){case 1:q=!0,Le||(Le=Y.avcSample=je(!0,D.pts,D.dts,"")),Le.frame=!0;var Ve=Me.data;if(Ae&&Ve.length>4){var Ue=new Oe(Ve).readSliceType();Ue!==2&&Ue!==4&&Ue!==7&&Ue!==9||(Le.key=!0)}break;case 5:q=!0,Le||(Le=Y.avcSample=je(!0,D.pts,D.dts,"")),Le.key=!0,Le.frame=!0;break;case 6:q=!0,(0,Z.parseSEIMessageFromNALu)(Me.data,1,D.pts,P.samples);break;case 7:if(q=!0,Ae=!0,!T.sps){var Qe=new Oe(Me.data).readSPS();T.width=Qe.width,T.height=Qe.height,T.pixelRatio=Qe.pixelRatio,T.sps=[Me.data],T.duration=Y._duration;for(var ot=Me.data.subarray(1,4),bt="avc1.",We=0;We<3;We++){var Lt=ot[We].toString(16);Lt.length<2&&(Lt="0"+Lt),bt+=Lt}T.codec=bt}break;case 8:q=!0,T.pps||(T.pps=[Me.data]);break;case 9:q=!1,T.audFound=!0,Le&&rt(Le,T),Le=Y.avcSample=je(!1,D.pts,D.dts,"");break;case 12:q=!0;break;default:q=!1,Le&&(Le.debug+="unknown NAL "+Me.type+" ")}Le&&q&&Le.units.push(Me)}),F&&Le&&(rt(Le,T),this.avcSample=null)},O.getLastNalUnit=function(T){var P,D,F=this.avcSample;if(F&&F.units.length!==0||(F=T[T.length-1]),(P=F)!==null&&P!==void 0&&P.units){var q=F.units;D=q[q.length-1]}return D},O.parseAVCNALu=function(T,P){var D,F,q=P.byteLength,Y=T.naluState||0,he=Y,Le=[],Ae=0,Me=-1,Ve=0;for(Y===-1&&(Me=0,Ve=31&P[0],Y=0,Ae=1);Ae<q;)if(D=P[Ae++],Y)if(Y!==1)if(D)if(D===1){if(Me>=0){var Ue={data:P.subarray(Me,Ae-Y-1),type:Ve};Le.push(Ue)}else{var Qe=this.getLastNalUnit(T.samples);if(Qe&&(he&&Ae<=4-he&&Qe.state&&(Qe.data=Qe.data.subarray(0,Qe.data.byteLength-he)),(F=Ae-Y-1)>0)){var ot=new Uint8Array(Qe.data.byteLength+F);ot.set(Qe.data,0),ot.set(P.subarray(0,F),Qe.data.byteLength),Qe.data=ot,Qe.state=0}}Ae<q?(Me=Ae,Ve=31&P[Ae],Y=0):Y=-1}else Y=0;else Y=3;else Y=D?0:2;else Y=D?0:1;if(Me>=0&&Y>=0){var bt={data:P.subarray(Me,q),type:Ve,state:Y};Le.push(bt)}if(Le.length===0){var We=this.getLastNalUnit(T.samples);if(We){var Lt=new Uint8Array(We.data.byteLength+P.byteLength);Lt.set(We.data,0),Lt.set(P,We.data.byteLength),We.data=Lt}}return T.naluState=Y,Le},O.parseAACPES=function(T,P){var D,F,q,Y,he,Le=0,Ae=this.aacOverFlow,Me=P.data;if(Ae){this.aacOverFlow=null;var Ve=Ae.missing,Ue=Ae.sample.unit.byteLength;if(Ve===-1){var Qe=new Uint8Array(Ue+Me.byteLength);Qe.set(Ae.sample.unit,0),Qe.set(Me,Ue),Me=Qe}else{var ot=Ue-Ve;Ae.sample.unit.set(Me.subarray(0,Ve),ot),T.samples.push(Ae.sample),Le=Ae.missing}}for(D=Le,F=Me.length;D<F-1&&!ke(Me,D);D++);if(D===Le||(D<F-1?(q="AAC PES did not start with ADTS header,offset:"+D,Y=!1):(q="no ADTS header found in AAC PES",Y=!0),z.logger.warn("parsing error:"+q),this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:$.ErrorTypes.MEDIA_ERROR,details:$.ErrorDetails.FRAG_PARSING_ERROR,fatal:Y,reason:q}),!Y)){if(K(T,this.observer,Me,D,this.audioCodec),P.pts!==void 0)he=P.pts;else{if(!Ae)return void z.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var bt=E(T.samplerate);he=Ae.sample.pts+bt}for(var We,Lt=0;D<F;){if(D+=(We=M(T,Me,D,he,Lt)).length,We.missing){this.aacOverFlow=We;break}for(Lt++;D<F-1&&!ke(Me,D);D++);}}},O.parseMPEGPES=function(T,P){var D=P.data,F=D.length,q=0,Y=0,he=P.pts;if(he!==void 0)for(;Y<F;)if(ue(D,Y)){var Le=qe(T,D,Y,he,q);if(!Le)break;Y+=Le.length,q++}else Y++;else z.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},O.parseID3PES=function(T,P){if(P.pts!==void 0){var D=Ne({},P,{type:this._avcTrack?k.MetadataSchema.emsg:k.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});T.samples.push(D)}else z.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},J}();function ht(J,O){return ht=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,P){return T.__proto__=P,T},ht(J,O)}let It=function(J){var O,T;function P(){return J.apply(this,arguments)||this}T=J,(O=P).prototype=Object.create(T.prototype),O.prototype.constructor=O,ht(O,T);var D=P.prototype;return D.resetInitSegment=function(F,q,Y,he){J.prototype.resetInitSegment.call(this,F,q,Y,he),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:q,duration:he,inputTimeScale:9e4,dropped:0}},P.probe=function(F){if(!F)return!1;for(var q=(w.getID3Data(F,0)||[]).length,Y=F.length;q<Y;q++)if(ie(F,q))return z.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(F,q){return function(Y,he){return ee(Y,he)&&4<=Y.length-he}(F,q)},D.appendFrame=function(F,q,Y){if(this.basePTS!==null)return qe(F,q,Y,this.basePTS,this.frameIndex)},P}(ce);var Dt=N(524),St=N(923);function kt(J,O){var T=J==null?void 0:J.codec;return T&&T.length>4?T:T==="hvc1"||T==="hev1"?"hvc1.1.c.L120.90":T==="av01"?"av01.0.04M.08":T==="avc1"||O===St.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}let gt=function(){function J(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var O=J.prototype;return O.destroy=function(){},O.resetTimeStamp=function(T){this.initPTS=T,this.lastEndTime=null},O.resetNextTimestamp=function(){this.lastEndTime=null},O.resetInitSegment=function(T,P,D,F){this.audioCodec=P,this.videoCodec=D,this.generateInitSegment((0,Z.patchEncyptionData)(T,F)),this.emitInitSegment=!0},O.generateInitSegment=function(T){var P=this.audioCodec,D=this.videoCodec;if(!T||!T.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var F=this.initData=(0,Z.parseInitSegment)(T);P||(P=kt(F.audio,St.ElementaryStreamTypes.AUDIO)),D||(D=kt(F.video,St.ElementaryStreamTypes.VIDEO));var q={};F.audio&&F.video?q.audiovideo={container:"video/mp4",codec:P+","+D,initSegment:T,id:"main"}:F.audio?q.audio={container:"audio/mp4",codec:P,initSegment:T,id:"audio"}:F.video?q.video={container:"video/mp4",codec:D,initSegment:T,id:"main"}:z.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=q},O.remux=function(T,P,D,F,q){var Y,he=this.initPTS,Le=this.lastEndTime,Ae={audio:void 0,video:void 0,text:F,id3:D,initSegment:void 0};(0,p.isFiniteNumber)(Le)||(Le=this.lastEndTime=q||0);var Me=P.samples;if(!Me||!Me.length)return Ae;var Ve={initPTS:void 0,timescale:1},Ue=this.initData;if(Ue&&Ue.length||(this.generateInitSegment(Me),Ue=this.initData),!Ue||!Ue.length)return z.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),Ae;this.emitInitSegment&&(Ve.tracks=this.initTracks,this.emitInitSegment=!1);var Qe=(0,Z.getStartDTS)(Ue,Me);(0,p.isFiniteNumber)(he)||(this.initPTS=Ve.initPTS=he=Qe-q);var ot=(0,Z.getDuration)(Me,Ue),bt=T?Qe-he:Le,We=bt+ot;(0,Z.offsetStartDTS)(Ue,Me,he),ot>0?this.lastEndTime=We:(z.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var Lt=!!Ue.audio,Qt=!!Ue.video,Ot="";Lt&&(Ot+="audio"),Qt&&(Ot+="video");var xt={data1:Me,startPTS:bt,startDTS:bt,endPTS:We,endDTS:We,type:Ot,hasAudio:Lt,hasVideo:Qt,nb:1,dropped:0};Ae.audio=xt.type==="audio"?xt:void 0,Ae.video=xt.type!=="audio"?xt:void 0,Ae.initSegment=Ve;var Ut=(Y=this.initPTS)!=null?Y:0;return Ae.id3=(0,Dt.flushTextTrackMetadataCueSamples)(D,q,Ut,Ut),F.samples.length&&(Ae.text=(0,Dt.flushTextTrackUserdataCueSamples)(F,q,Ut)),Ae},J}();var ut;try{ut=self.performance.now.bind(self.performance)}catch{z.logger.debug("Unable to use Performance API on this environment"),ut=self.Date.now}var Rt=[{demux:W,remux:gt},{demux:yt,remux:Dt.default},{demux:oe,remux:Dt.default},{demux:It,remux:Dt.default}],Pt=function(){function J(T,P,D,F,q){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=T,this.typeSupported=P,this.config=D,this.vendor=F,this.id=q}var O=J.prototype;return O.configure=function(T){this.transmuxConfig=T,this.decrypter&&this.decrypter.reset()},O.push=function(T,P,D,F){var q=this,Y=D.transmuxing;Y.executeStart=ut();var he=new Uint8Array(T),Le=this.currentTransmuxState,Ae=this.transmuxConfig;F&&(this.currentTransmuxState=F);var Me=F||Le,Ve=Me.contiguous,Ue=Me.discontinuity,Qe=Me.trackSwitch,ot=Me.accurateTimeOffset,bt=Me.timeOffset,We=Me.initSegmentChange,Lt=Ae.audioCodec,Qt=Ae.videoCodec,Ot=Ae.defaultInitPts,xt=Ae.duration,Ut=Ae.initSegmentData,Ze=function(wr,cr){var Mt=null;return wr.byteLength>0&&cr!=null&&cr.key!=null&&cr.iv!==null&&cr.method!=null&&(Mt=cr),Mt}(he,P);if(Ze&&Ze.method==="AES-128"){var rr=this.getDecrypter();if(!rr.isSync())return this.decryptionPromise=rr.webCryptoDecrypt(he,Ze.key.buffer,Ze.iv.buffer).then(function(wr){var cr=q.push(wr,null,D);return q.decryptionPromise=null,cr}),this.decryptionPromise;var Er=rr.softwareDecrypt(he,Ze.key.buffer,Ze.iv.buffer);if(!Er)return Y.executeEnd=ut(),jt(D);he=new Uint8Array(Er)}var Ft=this.needsProbing(Ue,Qe);Ft&&this.configureTransmuxer(he),(Ue||Qe||We||Ft)&&this.resetInitSegment(Ut,Lt,Qt,xt,P),(Ue||We||Ft)&&this.resetInitialTimestamp(Ot),Ve||this.resetContiguity();var Vt=this.transmux(he,Ze,bt,ot,D),hr=this.currentTransmuxState;return hr.contiguous=!0,hr.discontinuity=!1,hr.trackSwitch=!1,Y.executeEnd=ut(),Vt},O.flush=function(T){var P=this,D=T.transmuxing;D.executeStart=ut();var F=this.decrypter,q=this.currentTransmuxState,Y=this.decryptionPromise;if(Y)return Y.then(function(){return P.flush(T)});var he=[],Le=q.timeOffset;if(F){var Ae=F.flush();Ae&&he.push(this.push(Ae,null,T))}var Me=this.demuxer,Ve=this.remuxer;if(!Me||!Ve)return this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:$.ErrorTypes.MEDIA_ERROR,details:$.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),D.executeEnd=ut(),[jt(T)];var Ue=Me.flush(Le);return zt(Ue)?Ue.then(function(Qe){return P.flushRemux(he,Qe,T),he}):(this.flushRemux(he,Ue,T),he)},O.flushRemux=function(T,P,D){var F=P.audioTrack,q=P.videoTrack,Y=P.id3Track,he=P.textTrack,Le=this.currentTransmuxState,Ae=Le.accurateTimeOffset,Me=Le.timeOffset;z.logger.log("[transmuxer.ts]: Flushed fragment "+D.sn+(D.part>-1?" p: "+D.part:"")+" of level "+D.level);var Ve=this.remuxer.remux(F,q,Y,he,Me,Ae,!0,this.id);T.push({remuxResult:Ve,chunkMeta:D}),D.transmuxing.executeEnd=ut()},O.resetInitialTimestamp=function(T){var P=this.demuxer,D=this.remuxer;P&&D&&(P.resetTimeStamp(T),D.resetTimeStamp(T))},O.resetContiguity=function(){var T=this.demuxer,P=this.remuxer;T&&P&&(T.resetContiguity(),P.resetNextTimestamp())},O.resetInitSegment=function(T,P,D,F,q){var Y=this.demuxer,he=this.remuxer;Y&&he&&(Y.resetInitSegment(T,P,D,F),he.resetInitSegment(T,P,D,q))},O.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},O.transmux=function(T,P,D,F,q){return P&&P.method==="SAMPLE-AES"?this.transmuxSampleAes(T,P,D,F,q):this.transmuxUnencrypted(T,D,F,q)},O.transmuxUnencrypted=function(T,P,D,F){var q=this.demuxer.demux(T,P,!1,!this.config.progressive),Y=q.audioTrack,he=q.videoTrack,Le=q.id3Track,Ae=q.textTrack;return{remuxResult:this.remuxer.remux(Y,he,Le,Ae,P,D,!1,this.id),chunkMeta:F}},O.transmuxSampleAes=function(T,P,D,F,q){var Y=this;return this.demuxer.demuxSampleAes(T,P,D).then(function(he){return{remuxResult:Y.remuxer.remux(he.audioTrack,he.videoTrack,he.id3Track,he.textTrack,D,F,!1,Y.id),chunkMeta:q}})},O.configureTransmuxer=function(T){for(var P,D=this.config,F=this.observer,q=this.typeSupported,Y=this.vendor,he=0,Le=Rt.length;he<Le;he++)if(Rt[he].demux.probe(T)){P=Rt[he];break}P||(z.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),P={demux:W,remux:gt});var Ae=this.demuxer,Me=this.remuxer,Ve=P.remux,Ue=P.demux;Me&&Me instanceof Ve||(this.remuxer=new Ve(F,D,q,Y)),Ae&&Ae instanceof Ue||(this.demuxer=new Ue(F,D,q),this.probe=Ue.probe)},O.needsProbing=function(T,P){return!this.demuxer||!this.remuxer||T||P},O.getDecrypter=function(){var T=this.decrypter;return T||(T=this.decrypter=new R.default(this.config)),T},J}(),jt=function(J){return{remuxResult:{},chunkMeta:J}};function zt(J){return"then"in J&&J.then instanceof Function}var Nt=function(J,O,T,P,D){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=J,this.videoCodec=O,this.initSegmentData=T,this.duration=P,this.defaultInitPts=D},dr=function(J,O,T,P,D,F){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=J,this.contiguous=O,this.accurateTimeOffset=T,this.trackSwitch=P,this.timeOffset=D,this.initSegmentChange=F}},973:(fe,re,N)=>{"use strict";var B,$;N.r(re),N.d(re,{ErrorDetails:()=>$,ErrorTypes:()=>B}),function(R){R.NETWORK_ERROR="networkError",R.MEDIA_ERROR="mediaError",R.KEY_SYSTEM_ERROR="keySystemError",R.MUX_ERROR="muxError",R.OTHER_ERROR="otherError"}(B||(B={})),function(R){R.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",R.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",R.KEY_SYSTEM_NO_SESSION="keySystemNoSession",R.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",R.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",R.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",R.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",R.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",R.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",R.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",R.MANIFEST_LOAD_ERROR="manifestLoadError",R.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",R.MANIFEST_PARSING_ERROR="manifestParsingError",R.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",R.LEVEL_EMPTY_ERROR="levelEmptyError",R.LEVEL_LOAD_ERROR="levelLoadError",R.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",R.LEVEL_SWITCH_ERROR="levelSwitchError",R.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",R.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",R.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",R.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",R.FRAG_LOAD_ERROR="fragLoadError",R.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",R.FRAG_DECRYPT_ERROR="fragDecryptError",R.FRAG_PARSING_ERROR="fragParsingError",R.REMUX_ALLOC_ERROR="remuxAllocError",R.KEY_LOAD_ERROR="keyLoadError",R.KEY_LOAD_TIMEOUT="keyLoadTimeOut",R.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",R.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",R.BUFFER_APPEND_ERROR="bufferAppendError",R.BUFFER_APPENDING_ERROR="bufferAppendingError",R.BUFFER_STALLED_ERROR="bufferStalledError",R.BUFFER_FULL_ERROR="bufferFullError",R.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",R.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",R.INTERNAL_EXCEPTION="internalException",R.INTERNAL_ABORTED="aborted",R.UNKNOWN="unknown"}($||($={}))},851:(fe,re,N)=>{"use strict";var B;N.r(re),N.d(re,{Events:()=>B}),function($){$.MEDIA_ATTACHING="hlsMediaAttaching",$.MEDIA_ATTACHED="hlsMediaAttached",$.MEDIA_DETACHING="hlsMediaDetaching",$.MEDIA_DETACHED="hlsMediaDetached",$.BUFFER_RESET="hlsBufferReset",$.BUFFER_CODECS="hlsBufferCodecs",$.BUFFER_CREATED="hlsBufferCreated",$.BUFFER_APPENDING="hlsBufferAppending",$.BUFFER_APPENDED="hlsBufferAppended",$.BUFFER_EOS="hlsBufferEos",$.BUFFER_FLUSHING="hlsBufferFlushing",$.BUFFER_FLUSHED="hlsBufferFlushed",$.MANIFEST_LOADING="hlsManifestLoading",$.MANIFEST_LOADED="hlsManifestLoaded",$.MANIFEST_PARSED="hlsManifestParsed",$.LEVEL_SWITCHING="hlsLevelSwitching",$.LEVEL_SWITCHED="hlsLevelSwitched",$.LEVEL_LOADING="hlsLevelLoading",$.LEVEL_LOADED="hlsLevelLoaded",$.LEVEL_UPDATED="hlsLevelUpdated",$.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",$.LEVELS_UPDATED="hlsLevelsUpdated",$.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",$.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",$.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",$.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",$.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",$.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",$.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",$.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",$.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",$.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",$.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",$.CUES_PARSED="hlsCuesParsed",$.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",$.INIT_PTS_FOUND="hlsInitPtsFound",$.FRAG_LOADING="hlsFragLoading",$.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",$.FRAG_LOADED="hlsFragLoaded",$.FRAG_DECRYPTED="hlsFragDecrypted",$.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",$.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",$.FRAG_PARSING_METADATA="hlsFragParsingMetadata",$.FRAG_PARSED="hlsFragParsed",$.FRAG_BUFFERED="hlsFragBuffered",$.FRAG_CHANGED="hlsFragChanged",$.FPS_DROP="hlsFpsDrop",$.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",$.ERROR="hlsError",$.DESTROYING="hlsDestroying",$.KEY_LOADING="hlsKeyLoading",$.KEY_LOADED="hlsKeyLoaded",$.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",$.BACK_BUFFER_REACHED="hlsBackBufferReached"}(B||(B={}))},76:(fe,re,N)=>{"use strict";N.r(re),N.d(re,{default:()=>Jn});var B,$=N(945),R=N(965),p=N(851),w=N(973),k=N(93),ve=/^(\d+)x(\d+)$/,Z=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,le=function(){function d(e){for(var t in typeof e=="string"&&(e=d.parseAttrList(e)),e)e.hasOwnProperty(t)&&(this[t]=e[t])}var o=d.prototype;return o.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},o.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var i=new Uint8Array(t.length/2),n=0;n<t.length/2;n++)i[n]=parseInt(t.slice(2*n,2*n+2),16);return i}return null},o.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},o.decimalFloatingPoint=function(e){return parseFloat(this[e])},o.optionalFloat=function(e,t){var i=this[e];return i?parseFloat(i):t},o.enumeratedString=function(e){return this[e]},o.bool=function(e){return this[e]==="YES"},o.decimalResolution=function(e){var t=ve.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},d.parseAttrList=function(e){var t,i={};for(Z.lastIndex=0;(t=Z.exec(e))!==null;){var n=t[2];n.indexOf('"')===0&&n.lastIndexOf('"')===n.length-1&&(n=n.slice(1,-1)),i[t[1]]=n}return i},d}();function Te(){return Te=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},Te.apply(this,arguments)}function H(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}(function(d){d.ID="ID",d.CLASS="CLASS",d.START_DATE="START-DATE",d.DURATION="DURATION",d.END_DATE="END-DATE",d.END_ON_NEXT="END-ON-NEXT",d.PLANNED_DURATION="PLANNED-DURATION",d.SCTE35_OUT="SCTE35-OUT",d.SCTE35_IN="SCTE35-IN"})(B||(B={}));var ce=function(){function d(t,i){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,i){var n=i.attr;for(var a in n)if(Object.prototype.hasOwnProperty.call(t,a)&&t[a]!==n[a]){k.logger.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=a;break}t=Te(new le({}),n,t)}if(this.attr=t,this._startDate=new Date(t[B.START_DATE]),B.END_DATE in this.attr){var r=new Date(this.attr[B.END_DATE]);(0,R.isFiniteNumber)(r.getTime())&&(this._endDate=r)}}var o,e;return o=d,(e=[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var t=this.duration;return t!==null?new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if(B.DURATION in this.attr){var t=this.attr.decimalFloatingPoint(B.DURATION);if((0,R.isFiniteNumber)(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return B.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(B.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(B.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,R.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}])&&H(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}(),z=N(923);function ne(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var U,be,ke,He=function(){function d(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}var o,e;return d.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var i=this.lastPartSn-t.lastPartSn,n=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!n||!!i,this.advanced=this.endSN>t.endSN||i>0||i===0&&n>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},o=d,(e=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&(0,R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return(t=this.partList)!==null&&t!==void 0&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return(t=this.fragments)!==null&&t!==void 0&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return(t=this.partList)!==null&&t!==void 0&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return(t=this.partList)!==null&&t!==void 0&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&ne(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function K(d){return Uint8Array.from(atob(d),function(o){return o.charCodeAt(0)})}function E(d){return Uint8Array.from(unescape(encodeURIComponent(d)),function(o){return o.charCodeAt(0)})}function M(d){switch(d){case be.FAIRPLAY:return U.FAIRPLAY;case be.PLAYREADY:return U.PLAYREADY;case be.WIDEVINE:return U.WIDEVINE;case be.CLEARKEY:return U.CLEARKEY}}function L(d){switch(d){case U.FAIRPLAY:return be.FAIRPLAY;case U.PLAYREADY:return be.PLAYREADY;case U.WIDEVINE:return be.WIDEVINE;case U.CLEARKEY:return be.CLEARKEY}}function oe(d){var o=d.drmSystems,e=d.widevineLicenseUrl,t=o?[U.FAIRPLAY,U.WIDEVINE,U.PLAYREADY,U.CLEARKEY].filter(function(i){return!!o[i]}):[];return!t[U.WIDEVINE]&&e&&t.push(U.WIDEVINE),t}(function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.fps",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="com.widevine.alpha"})(U||(U={})),function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.streamingkeydelivery",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"}(be||(be={})),function(d){d.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"}(ke||(ke={}));var ye=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null,W=N(63),V={},we=function(){function d(e,t,i,n,a){n===void 0&&(n=[1]),a===void 0&&(a=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=n,this.iv=a,this.encrypted=!!e&&e!=="NONE",this.isCommonEncryption=this.encrypted&&e!=="AES-128"}d.clearKeyUriToKeyIdMap=function(){V={}};var o=d.prototype;return o.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;switch(this.keyFormat){case"identity":return this.method==="SAMPLE-AES";case be.FAIRPLAY:case be.WIDEVINE:case be.PLAYREADY:case be.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},o.getDecryptData=function(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method!=="AES-128"||this.iv||k.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=function(x){for(var I=new Uint8Array(16),j=12;j<16;j++)I[j]=x>>8*(15-j)&255;return I}(e);return new d(this.method,this.uri,"identity",this.keyFormatVersions,t)}var i=function(x){var I,j,ae=x.split(":"),me=null;if(ae[0]==="data"&&ae.length===2){var de=ae[1].split(";"),_e=de[de.length-1].split(",");if(_e.length===2){var Ke=_e[0]==="base64",ze=_e[1];Ke?(de.splice(-1,1),me=K(ze)):(I=E(ze).subarray(0,16),(j=new Uint8Array(16)).set(I,16-I.length),me=j)}}return me}(this.uri);if(i)switch(this.keyFormat){case be.WIDEVINE:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case be.PLAYREADY:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,W.mp4pssh)(n,null,i);var a=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2),r=String.fromCharCode.apply(null,Array.from(a)),s=r.substring(r.indexOf("<"),r.length),l=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(l){var u=l.childNodes[0]?l.childNodes[0].nodeValue:l.getAttribute("VALUE");if(u){var c=K(u).subarray(0,16);(function(x){var I=function(j,ae,me){var de=j[ae];j[ae]=j[me],j[me]=de};I(x,0,3),I(x,1,2),I(x,4,5),I(x,6,7)})(c),this.keyId=c}}break;default:var v=i.subarray(0,16);if(v.length!==16){var m=new Uint8Array(16);m.set(v,16-v.length),v=m}this.keyId=v}if(!this.keyId||this.keyId.byteLength!==16){var _=V[this.uri];if(!_){var S=Object.keys(V).length%Number.MAX_SAFE_INTEGER;_=new Uint8Array(16),new DataView(_.buffer,12,4).setUint32(0,S),V[this.uri]=_}this.keyId=_}return this},d}(),Re={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 Ce(d,o){return MediaSource.isTypeSupported((o||"video")+'/mp4;codecs="'+d+'"')}function ge(){return ge=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},ge.apply(this,arguments)}var qe=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+|#EXT-X-SESSION-KEY:([^\n\r]*)[\r\n]+/g,tt=/#EXT-X-MEDIA:(.*)/g,ee=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ue=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),ie=function(){function d(){}return d.findGroup=function(o,e){for(var t=0;t<o.length;t++){var i=o[t];if(i.id===e)return i}},d.convertAVC1ToAVCOTI=function(o){var e=o.split(".");if(e.length>2){var t=e.shift()+".";return(t+=parseInt(e.shift()).toString(16))+("000"+parseInt(e.shift()).toString(16)).slice(-4)}return o},d.resolve=function(o,e){return(0,$.buildAbsoluteURL)(e,o,{alwaysNormalize:!0})},d.parseMasterPlaylist=function(o,e){var t,i=[],n=[],a={},r=[],s=!1;for(qe.lastIndex=0;(t=qe.exec(o))!=null;)if(t[1]){var l,u=new le(t[1]),c={attrs:u,bitrate:u.decimalInteger("AVERAGE-BANDWIDTH")||u.decimalInteger("BANDWIDTH"),name:u.NAME,url:d.resolve(t[2],e)},v=u.decimalResolution("RESOLUTION");v&&(c.width=v.width,c.height=v.height),xe((u.CODECS||"").split(/[ ,]+/).filter(function(x){return x}),c),c.videoCodec&&c.videoCodec.indexOf("avc1")!==-1&&(c.videoCodec=d.convertAVC1ToAVCOTI(c.videoCodec)),(l=c.unknownCodecs)!==null&&l!==void 0&&l.length||n.push(c),i.push(c)}else if(t[3]){var m=new le(t[3]);m["DATA-ID"]&&(s=!0,a[m["DATA-ID"]]=m)}else if(t[4]){var _=t[4],S=Oe(_,e);S.encrypted&&S.isSupported()?r.push(S):k.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+_+'"')}return{levels:n.length>0&&n.length<i.length?n:i,sessionData:s?a:null,sessionKeys:r.length?r:null}},d.parseMasterPlaylistMedia=function(o,e,t,i){var n;i===void 0&&(i=[]);var a=[],r=0;for(tt.lastIndex=0;(n=tt.exec(o))!==null;){var s=new le(n[1]);if(s.TYPE===t){var l={attrs:s,bitrate:0,id:r++,groupId:s["GROUP-ID"],instreamId:s["INSTREAM-ID"],name:s.NAME||s.LANGUAGE||"",type:t,default:s.bool("DEFAULT"),autoselect:s.bool("AUTOSELECT"),forced:s.bool("FORCED"),lang:s.LANGUAGE,url:s.URI?d.resolve(s.URI,e):""};if(i.length){var u=d.findGroup(i,l.groupId)||i[0];Ne(l,u,"audioCodec"),Ne(l,u,"textCodec")}a.push(l)}}return a},d.parseLevelPlaylist=function(o,e,t,i,n){var a,r,s,l=new He(e),u=l.fragments,c=null,v=0,m=0,_=0,S=0,x=null,I=new z.Fragment(i,e),j=-1,ae=!1;for(ee.lastIndex=0,l.m3u8=o;(a=ee.exec(o))!==null;){ae&&(ae=!1,(I=new z.Fragment(i,e)).start=_,I.sn=v,I.cc=S,I.level=t,c&&(I.initSegment=c,I.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null));var me=a[1];if(me){I.duration=parseFloat(me);var de=(" "+a[2]).slice(1);I.title=de||null,I.tagList.push(de?["INF",me,de]:["INF",me])}else if(a[3]){if((0,R.isFiniteNumber)(I.duration)){if(I.start=_,s){I.levelkeys=s;var _e=l.encryptedFragments;!I.levelkeys||!Object.keys(I.levelkeys).some(function(Lr){return I.levelkeys[Lr].isCommonEncryption})||_e.length&&_e[_e.length-1].levelkeys===s||_e.push(I)}I.sn=v,I.level=t,I.cc=S,I.urlId=n,u.push(I),I.relurl=(" "+a[3]).slice(1),Be(I,x),x=I,_+=I.duration,v++,m=0,ae=!0}}else if(a[4]){var Ke=(" "+a[4]).slice(1);x?I.setByteRange(Ke,x):I.setByteRange(Ke)}else if(a[5])I.rawProgramDateTime=(" "+a[5]).slice(1),I.tagList.push(["PROGRAM-DATE-TIME",I.rawProgramDateTime]),j===-1&&(j=u.length);else{if(!(a=a[0].match(ue))){k.logger.warn("No matches on slow regex match for level playlist!");continue}for(r=1;r<a.length&&a[r]===void 0;r++);var ze=(" "+a[r]).slice(1),Ee=(" "+a[r+1]).slice(1),Ge=a[r+2]?(" "+a[r+2]).slice(1):"";switch(ze){case"PLAYLIST-TYPE":l.type=Ee.toUpperCase();break;case"MEDIA-SEQUENCE":v=l.startSN=parseInt(Ee);break;case"SKIP":var Fe=new le(Ee),ct=Fe.decimalInteger("SKIPPED-SEGMENTS");if((0,R.isFiniteNumber)(ct)){l.skippedSegments=ct;for(var Ct=ct;Ct--;)u.unshift(null);v+=ct}var ft=Fe.enumeratedString("RECENTLY-REMOVED-DATERANGES");ft&&(l.recentlyRemovedDateranges=ft.split(" "));break;case"TARGETDURATION":l.targetduration=parseFloat(Ee);break;case"VERSION":l.version=parseInt(Ee);break;case"EXTM3U":break;case"ENDLIST":l.live=!1;break;case"#":(Ee||Ge)&&I.tagList.push(Ge?[Ee,Ge]:[Ee]);break;case"DISCONTINUITY":S++,I.tagList.push(["DIS"]);break;case"GAP":I.tagList.push([ze]);break;case"BITRATE":I.tagList.push([ze,Ee]);break;case"DATERANGE":var Tt=new le(Ee),At=new ce(Tt,l.dateRanges[Tt.ID]);At.isValid||l.skippedSegments?l.dateRanges[At.id]=At:k.logger.warn('Ignoring invalid DATERANGE tag: "'+Ee+'"'),I.tagList.push(["EXT-X-DATERANGE",Ee]);break;case"DISCONTINUITY-SEQUENCE":S=parseInt(Ee);break;case"KEY":var $t=Oe(Ee,e);if($t.isSupported()){if($t.method==="NONE"){s=void 0;break}s||(s={}),s[$t.keyFormat]&&(s=ge({},s)),s[$t.keyFormat]=$t}else k.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+Ee+'"');break;case"START":var Xt=new le(Ee).decimalFloatingPoint("TIME-OFFSET");(0,R.isFiniteNumber)(Xt)&&(l.startTimeOffset=Xt);break;case"MAP":var Gt=new le(Ee);if(I.duration){var Zt=new z.Fragment(i,e);je(Zt,Gt,t,s),c=Zt,I.initSegment=c,c.rawProgramDateTime&&!I.rawProgramDateTime&&(I.rawProgramDateTime=c.rawProgramDateTime)}else je(I,Gt,t,s),c=I,ae=!0;break;case"SERVER-CONTROL":var yr=new le(Ee);l.canBlockReload=yr.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=yr.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&yr.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=yr.optionalFloat("PART-HOLD-BACK",0),l.holdBack=yr.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Ln=new le(Ee);l.partTarget=Ln.decimalFloatingPoint("PART-TARGET");break;case"PART":var Ar=l.partList;Ar||(Ar=l.partList=[]);var wi=m>0?Ar[Ar.length-1]:void 0,Ai=m++,Di=new z.Part(new le(Ee),I,e,Ai,wi);Ar.push(Di),I.duration+=Di.duration;break;case"PRELOAD-HINT":var st=new le(Ee);l.preloadHint=st;break;case"RENDITION-REPORT":var vt=new le(Ee);l.renditionReports=l.renditionReports||[],l.renditionReports.push(vt);break;default:k.logger.warn("line parsed but not handled: "+a)}}}x&&!x.relurl?(u.pop(),_-=x.duration,l.partList&&(l.fragmentHint=x)):l.partList&&(Be(I,x),I.cc=S,l.fragmentHint=I);var di=u.length,xr=u[0],Dr=u[di-1];if((_+=l.skippedSegments*l.targetduration)>0&&di&&Dr){l.averagetargetduration=_/di;var ci=Dr.sn;l.endSN=ci!=="initSegment"?ci:0,l.live||(Dr.endList=!0),xr&&(l.startCC=xr.cc)}else l.endSN=0,l.startCC=0;return l.fragmentHint&&(_+=l.fragmentHint.duration),l.totalduration=_,l.endCC=S,j>0&&function(Lr,Or){for(var Kr=Lr[Or],_r=Or;_r--;){var qr=Lr[_r];if(!qr)return;qr.programDateTime=Kr.programDateTime-1e3*qr.duration,Kr=qr}}(u,j),l},d}();function Oe(d,o){var e,t,i=new le(d),n=(e=i.enumeratedString("METHOD"))!=null?e:"",a=i.URI,r=i.hexadecimalInteger("IV"),s=i.enumeratedString("KEYFORMATVERSIONS"),l=(t=i.enumeratedString("KEYFORMAT"))!=null?t:"identity";a&&i.IV&&!r&&k.logger.error("Invalid IV: "+i.IV);var u=a?ie.resolve(a,o):"",c=(s||"1").split("/").map(Number).filter(Number.isFinite);return new we(n,u,l,c,r)}function xe(d,o){["video","audio","text"].forEach(function(e){var t=d.filter(function(n){return function(a,r){var s=Re[r];return!!s&&s[a.slice(0,4)]===!0}(n,e)});if(t.length){var i=t.filter(function(n){return n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0});o[e+"Codec"]=i.length>0?i[0]:t[0],d=d.filter(function(n){return t.indexOf(n)===-1})}}),o.unknownCodecs=d}function Ne(d,o,e){var t=o[e];t&&(d[e]=t)}function Be(d,o){d.rawProgramDateTime?d.programDateTime=Date.parse(d.rawProgramDateTime):o!=null&&o.programDateTime&&(d.programDateTime=o.endProgramDateTime),(0,R.isFiniteNumber)(d.programDateTime)||(d.programDateTime=null,d.rawProgramDateTime=null)}function je(d,o,e,t){d.relurl=o.URI,o.BYTERANGE&&d.setByteRange(o.BYTERANGE),d.level=e,d.sn="initSegment",t&&(d.levelkeys=t),d.initSegment=null}var pe=N(308);function Ie(d,o){var e=d.url;return e!==void 0&&e.indexOf("data:")!==0||(e=o.url),e}let Ye=function(){function d(e){this.hls=void 0,this.loaders=Object.create(null),this.hls=e,this.registerListeners()}var o=d.prototype;return o.startLoad=function(e){},o.stopLoad=function(){this.destroyInternalLoaders()},o.registerListeners=function(){var e=this.hls;e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},o.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},o.createInternalLoader=function(e){var t=this.hls.config,i=t.pLoader,n=t.loader,a=new(i||n)(t);return e.loader=a,this.loaders[e.type]=a,a},o.getInternalLoader=function(e){return this.loaders[e.type]},o.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},o.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},o.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},o.onManifestLoading=function(e,t){var i=t.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:pe.PlaylistContextType.MANIFEST,url:i,deliveryDirectives:null})},o.onLevelLoading=function(e,t){var i=t.id,n=t.level,a=t.url,r=t.deliveryDirectives;this.load({id:i,groupId:null,level:n,responseType:"text",type:pe.PlaylistContextType.LEVEL,url:a,deliveryDirectives:r})},o.onAudioTrackLoading=function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives;this.load({id:i,groupId:n,level:null,responseType:"text",type:pe.PlaylistContextType.AUDIO_TRACK,url:a,deliveryDirectives:r})},o.onSubtitleTrackLoading=function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives;this.load({id:i,groupId:n,level:null,responseType:"text",type:pe.PlaylistContextType.SUBTITLE_TRACK,url:a,deliveryDirectives:r})},o.load=function(e){var t,i,n,a,r,s,l=this.hls.config,u=this.getInternalLoader(e);if(u){var c=u.context;if(c&&c.url===e.url)return void k.logger.trace("[playlist-loader]: playlist request ongoing");k.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),u.abort()}switch(e.type){case pe.PlaylistContextType.MANIFEST:i=l.manifestLoadingMaxRetry,n=l.manifestLoadingTimeOut,a=l.manifestLoadingRetryDelay,r=l.manifestLoadingMaxRetryTimeout;break;case pe.PlaylistContextType.LEVEL:case pe.PlaylistContextType.AUDIO_TRACK:case pe.PlaylistContextType.SUBTITLE_TRACK:i=0,n=l.levelLoadingTimeOut;break;default:i=l.levelLoadingMaxRetry,n=l.levelLoadingTimeOut,a=l.levelLoadingRetryDelay,r=l.levelLoadingMaxRetryTimeout}if(u=this.createInternalLoader(e),(t=e.deliveryDirectives)!==null&&t!==void 0&&t.part&&(e.type===pe.PlaylistContextType.LEVEL&&e.level!==null?s=this.hls.levels[e.level].details:e.type===pe.PlaylistContextType.AUDIO_TRACK&&e.id!==null?s=this.hls.audioTracks[e.id].details:e.type===pe.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(s=this.hls.subtitleTracks[e.id].details),s)){var v=s.partTarget,m=s.targetduration;v&&m&&(n=Math.min(1e3*Math.max(3*v,.8*m),n))}var _={timeout:n,maxRetry:i,retryDelay:a,maxRetryDelay:r,highWaterMark:0},S={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};u.load(e,_,S)},o.loadsuccess=function(e,t,i,n){n===void 0&&(n=null),this.resetInternalLoader(i.type);var a=e.data;a.indexOf("#EXTM3U")===0?(t.parsing.start=performance.now(),a.indexOf("#EXTINF:")>0||a.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,t,i,n):this.handleMasterPlaylist(e,t,i,n)):this.handleManifestParsingError(e,i,"no EXTM3U delimiter",n)},o.loaderror=function(e,t,i){i===void 0&&(i=null),this.handleNetworkError(t,i,!1,e)},o.loadtimeout=function(e,t,i){i===void 0&&(i=null),this.handleNetworkError(t,i,!0)},o.handleMasterPlaylist=function(e,t,i,n){var a=this.hls,r=e.data,s=Ie(e,i),l=ie.parseMasterPlaylist(r,s),u=l.levels,c=l.sessionData,v=l.sessionKeys;if(u.length){var m=u.map(function(j){return{id:j.attrs.AUDIO,audioCodec:j.audioCodec}}),_=u.map(function(j){return{id:j.attrs.SUBTITLES,textCodec:j.textCodec}}),S=ie.parseMasterPlaylistMedia(r,s,"AUDIO",m),x=ie.parseMasterPlaylistMedia(r,s,"SUBTITLES",_),I=ie.parseMasterPlaylistMedia(r,s,"CLOSED-CAPTIONS");S.length&&(S.some(function(j){return!j.url})||!u[0].audioCodec||u[0].attrs.AUDIO||(k.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),S.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new le({}),bitrate:0,url:""}))),a.trigger(p.Events.MANIFEST_LOADED,{levels:u,audioTracks:S,subtitles:x,captions:I,url:s,stats:t,networkDetails:n,sessionData:c,sessionKeys:v})}else this.handleManifestParsingError(e,i,"no level found in manifest",n)},o.handleTrackOrLevelPlaylist=function(e,t,i,n){var a=this.hls,r=i.id,s=i.level,l=i.type,u=Ie(e,i),c=(0,R.isFiniteNumber)(r)?r:0,v=(0,R.isFiniteNumber)(s)?s:c,m=function(x){switch(x.type){case pe.PlaylistContextType.AUDIO_TRACK:return pe.PlaylistLevelType.AUDIO;case pe.PlaylistContextType.SUBTITLE_TRACK:return pe.PlaylistLevelType.SUBTITLE;default:return pe.PlaylistLevelType.MAIN}}(i),_=ie.parseLevelPlaylist(e.data,u,v,m,c);if(_.fragments.length){if(l===pe.PlaylistContextType.MANIFEST){var S={attrs:new le({}),bitrate:0,details:_,name:"",url:u};a.trigger(p.Events.MANIFEST_LOADED,{levels:[S],audioTracks:[],url:u,stats:t,networkDetails:n,sessionData:null,sessionKeys:null})}t.parsing.end=performance.now(),i.levelDetails=_,this.handlePlaylistLoaded(e,t,i,n)}else a.trigger(p.Events.ERROR,{type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:u,reason:"no fragments found in level",level:typeof i.level=="number"?i.level:void 0})},o.handleManifestParsingError=function(e,t,i,n){this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===pe.PlaylistContextType.MANIFEST,url:e.url,reason:i,response:e,context:t,networkDetails:n})},o.handleNetworkError=function(e,t,i,n){i===void 0&&(i=!1),k.logger.warn("[playlist-loader]: A network "+(i?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var a=w.ErrorDetails.UNKNOWN,r=!1,s=this.getInternalLoader(e);switch(e.type){case pe.PlaylistContextType.MANIFEST:a=i?w.ErrorDetails.MANIFEST_LOAD_TIMEOUT:w.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case pe.PlaylistContextType.LEVEL:a=i?w.ErrorDetails.LEVEL_LOAD_TIMEOUT:w.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case pe.PlaylistContextType.AUDIO_TRACK:a=i?w.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:w.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case pe.PlaylistContextType.SUBTITLE_TRACK:a=i?w.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:w.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1}s&&this.resetInternalLoader(e.type);var l={type:w.ErrorTypes.NETWORK_ERROR,details:a,fatal:r,url:e.url,loader:s,context:e,networkDetails:t};n&&(l.response=n),this.hls.trigger(p.Events.ERROR,l)},o.handlePlaylistLoaded=function(e,t,i,n){var a=i.type,r=i.level,s=i.id,l=i.groupId,u=i.loader,c=i.levelDetails,v=i.deliveryDirectives;if(c!=null&&c.targetduration){if(u)switch(c.live&&(u.getCacheAge&&(c.ageHeader=u.getCacheAge()||0),u.getCacheAge&&!isNaN(c.ageHeader)||(c.ageHeader=0)),a){case pe.PlaylistContextType.MANIFEST:case pe.PlaylistContextType.LEVEL:this.hls.trigger(p.Events.LEVEL_LOADED,{details:c,level:r||0,id:s||0,stats:t,networkDetails:n,deliveryDirectives:v});break;case pe.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(p.Events.AUDIO_TRACK_LOADED,{details:c,id:s||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:v});break;case pe.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(p.Events.SUBTITLE_TRACK_LOADED,{details:c,id:s||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:v})}}else this.handleManifestParsingError(e,i,"invalid target duration",n)},d}();function rt(d,o){var e;try{e=new Event("addtrack")}catch{(e=document.createEvent("Event")).initEvent("addtrack",!1,!1)}e.track=d,o.dispatchEvent(e)}function yt(d,o){var e=d.mode;if(e==="disabled"&&(d.mode="hidden"),d.cues&&!d.cues.getCueById(o.id))try{if(d.addCue(o),!d.cues.getCueById(o.id))throw new Error("addCue is failed for: "+o)}catch(i){k.logger.debug("[texttrack-utils]: "+i);var t=new self.TextTrackCue(o.startTime,o.endTime,o.text);t.id=o.id,d.addCue(t)}e==="disabled"&&(d.mode=e)}function ht(d){var o=d.mode;if(o==="disabled"&&(d.mode="hidden"),d.cues)for(var e=d.cues.length;e--;)d.removeCue(d.cues[e]);o==="disabled"&&(d.mode=o)}function It(d,o,e,t){var i=d.mode;if(i==="disabled"&&(d.mode="hidden"),d.cues&&d.cues.length>0)for(var n=function(r,s,l){var u=[],c=function(S,x){if(x<S[0].startTime)return 0;var I=S.length-1;if(x>S[I].endTime)return-1;for(var j=0,ae=I;j<=ae;){var me=Math.floor((ae+j)/2);if(x<S[me].startTime)ae=me-1;else{if(!(x>S[me].startTime&&j<I))return me;j=me+1}}return S[j].startTime-x<x-S[ae].startTime?j:ae}(r,s);if(c>-1)for(var v=c,m=r.length;v<m;v++){var _=r[v];if(_.startTime>=s&&_.endTime<=l)u.push(_);else if(_.startTime>l)return u}return u}(d.cues,o,e),a=0;a<n.length;a++)t&&!t(n[a])||d.removeCue(n[a]);i==="disabled"&&(d.mode=i)}var Dt=N(181),St=N(856);function kt(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var gt=function(){var d=kt();try{new d(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function ut(d,o){return d.getTime()/1e3-o}let Rt=function(){function d(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var o=d.prototype;return o.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},o._registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},o._unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},o.onMediaAttached=function(e,t){this.media=t.media},o.onMediaDetaching=function(){this.id3Track&&(ht(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},o.onManifestLoading=function(){this.dateRangeCuesAppended={}},o.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},o.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var i=e[t];if(i.kind==="metadata"&&i.label==="id3")return rt(i,this.media),i}return this.media.addTextTrack("metadata","id3")}},o.onFragParsingMetadata=function(e,t){if(this.media){var i=this.hls.config,n=i.enableEmsgMetadataCues,a=i.enableID3MetadataCues;if(n||a){var r=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var s=kt(),l=0;l<r.length;l++){var u=r[l].type;if((u!==St.MetadataSchema.emsg||n)&&a){var c=Dt.getID3Frames(r[l].data);if(c){var v=r[l].pts,m=v+r[l].duration;m>gt&&(m=gt),m-v<=0&&(m=v+.25);for(var _=0;_<c.length;_++){var S=c[_];if(!Dt.isTimeStampFrame(S)){this.updateId3CueEnds(v);var x=new s(v,m,"");x.value=S,u&&(x.type=u),this.id3Track.addCue(x)}}}}}}}},o.updateId3CueEnds=function(e){var t,i=(t=this.id3Track)===null||t===void 0?void 0:t.cues;if(i)for(var n=i.length;n--;){var a=i[n];a.startTime<e&&a.endTime===gt&&(a.endTime=e)}},o.onBufferFlushing=function(e,t){var i=t.startOffset,n=t.endOffset,a=t.type,r=this.id3Track,s=this.hls;if(s){var l=s.config,u=l.enableEmsgMetadataCues,c=l.enableID3MetadataCues;r&&(u||c)&&It(r,i,n,a==="audio"?function(v){return v.type===St.MetadataSchema.audioId3&&c}:a==="video"?function(v){return v.type===St.MetadataSchema.emsg&&u}:function(v){return v.type===St.MetadataSchema.audioId3&&c||v.type===St.MetadataSchema.emsg&&u})}},o.onLevelUpdated=function(e,t){var i=this,n=t.details;if(this.media&&n.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,r=this.id3Track,s=n.dateRanges,l=Object.keys(s);if(r)for(var u=Object.keys(a).filter(function(j){return!l.includes(j)}),c=function(j){var ae=u[j];Object.keys(a[ae].cues).forEach(function(me){r.removeCue(a[ae].cues[me])}),delete a[ae]},v=u.length;v--;)c(v);var m=n.fragments[n.fragments.length-1];if(l.length!==0&&(0,R.isFiniteNumber)(m==null?void 0:m.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var _=m.programDateTime/1e3-m.start,S=kt(),x=function(j){var ae=l[j],me=s[ae],de=a[ae],_e=(de==null?void 0:de.cues)||{},Ke=(de==null?void 0:de.durationKnown)||!1,ze=ut(me.startDate,_),Ee=gt,Ge=me.endDate;if(Ge)Ee=ut(Ge,_),Ke=!0;else if(me.endOnNext&&!Ke){var Fe=l.reduce(function(Xt,Gt){var Zt=s[Gt];return Zt.class===me.class&&Zt.id!==Gt&&Zt.startDate>me.startDate&&Xt.push(Zt),Xt},[]).sort(function(Xt,Gt){return Xt.startDate.getTime()-Gt.startDate.getTime()})[0];Fe&&(Ee=ut(Fe.startDate,_),Ke=!0)}for(var ct,Ct=Object.keys(me.attr),ft=0;ft<Ct.length;ft++){var Tt=Ct[ft];if(Tt!==B.ID&&Tt!==B.CLASS&&Tt!==B.START_DATE&&Tt!==B.DURATION&&Tt!==B.END_DATE&&Tt!==B.END_ON_NEXT){var At=_e[Tt];if(At)Ke&&!de.durationKnown&&(At.endTime=Ee);else{var $t=me.attr[Tt];At=new S(ze,Ee,""),Tt!==B.SCTE35_OUT&&Tt!==B.SCTE35_IN||(ct=$t,$t=Uint8Array.from(ct.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),At.value={key:Tt,data:$t},At.type=St.MetadataSchema.dateRange,i.id3Track.addCue(At),_e[Tt]=At}}}a[ae]={cues:_e,dateRange:me,durationKnown:Ke}},I=0;I<l.length;I++)x(I)}}},d}();function Pt(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var jt=function(){function d(i){var n=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return n.timeupdate()},this.hls=i,this.config=i.config,this.registerListeners()}var o,e,t=d.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},t.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(p.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(p.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(p.Events.ERROR,this.onError)},t.onMediaAttached=function(i,n){this.media=n.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},t.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},t.onLevelUpdated=function(i,n){var a=n.details;this.levelDetails=a,a.advanced&&this.timeupdate(),!a.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},t.onError=function(i,n){n.details===w.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,k.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},t.timeupdate=function(){var i=this.media,n=this.levelDetails;if(i&&n){this.currentTime=i.currentTime;var a=this.computeLatency();if(a!==null){this._latency=a;var r=this.config,s=r.lowLatencyMode,l=r.maxLiveSyncPlaybackRate;if(s&&l!==1){var u=this.targetLatency;if(u!==null){var c=a-u,v=c<Math.min(this.maxLatency,u+n.targetduration);if(n.live&&v&&c>.05&&this.forwardBufferLength>1){var m=Math.min(2,Math.max(1,l)),_=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20;i.playbackRate=Math.min(m,Math.max(1,_))}else i.playbackRate!==1&&i.playbackRate!==0&&(i.playbackRate=1)}}}}},t.estimateLiveEdge=function(){var i=this.levelDetails;return i===null?null:i.edge+i.age},t.computeLatency=function(){var i=this.estimateLiveEdge();return i===null?null:i-this.currentTime},o=d,(e=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var i=this.config,n=this.levelDetails;return i.liveMaxLatencyDuration!==void 0?i.liveMaxLatencyDuration:n?i.liveMaxLatencyDurationCount*n.targetduration:0}},{key:"targetLatency",get:function(){var i=this.levelDetails;if(i===null)return null;var n=i.holdBack,a=i.partHoldBack,r=i.targetduration,s=this.config,l=s.liveSyncDuration,u=s.liveSyncDurationCount,c=s.lowLatencyMode,v=this.hls.userConfig,m=c&&a||n;(v.liveSyncDuration||v.liveSyncDurationCount||m===0)&&(m=l!==void 0?l:u*r);var _=r;return m+Math.min(1*this.stallCount,_)}},{key:"liveSyncPosition",get:function(){var i=this.estimateLiveEdge(),n=this.targetLatency,a=this.levelDetails;if(i===null||n===null||a===null)return null;var r=a.edge,s=i-n-this.edgeStalled,l=r-a.totalduration,u=r-(this.config.lowLatencyMode&&a.partTarget||a.targetduration);return Math.min(Math.max(l,s),u)}},{key:"drift",get:function(){var i=this.levelDetails;return i===null?1:i.drift}},{key:"edgeStalled",get:function(){var i=this.levelDetails;if(i===null)return 0;var n=3*(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.max(i.age-n,0)}},{key:"forwardBufferLength",get:function(){var i=this.media,n=this.levelDetails;if(!i||!n)return 0;var a=i.buffered.length;return(a?i.buffered.end(a-1):n.edge)-this.currentTime}}])&&Pt(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function zt(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var Nt,dr=["NONE","TYPE-0","TYPE-1","TYPE-2",null];(function(d){d.No="",d.Yes="YES",d.v2="v2"})(Nt||(Nt={}));var J=function(){function d(o,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=o,this.part=e,this.skip=t}return d.prototype.addDirectives=function(o){var e=new self.URL(o);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},d}(),O=function(){function d(t){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this.attrs=t.attrs,this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(function(i){return i}).join(",").replace(/\.[^.,]+/g,"")}var o,e;return o=d,(e=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var i=t%this.url.length;this._urlId!==i&&(this.details=void 0,this._urlId=i)}}])&&zt(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function T(){return T=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},T.apply(this,arguments)}function P(d,o,e){switch(o){case"audio":d.audioGroupIds||(d.audioGroupIds=[]),d.audioGroupIds.push(e);break;case"text":d.textGroupIds||(d.textGroupIds=[]),d.textGroupIds.push(e)}}function D(d){var o={};d.forEach(function(e){var t=e.groupId||"";e.id=o[t]=o[t]||0,o[t]++})}function F(d,o){var e=o.startPTS;if((0,R.isFiniteNumber)(e)){var t,i=0;o.sn>d.sn?(i=e-d.start,t=d):(i=d.start-e,t=o),t.duration!==i&&(t.duration=i)}else o.sn>d.sn?d.cc===o.cc&&d.minEndPTS?o.start=d.start+(d.minEndPTS-d.start):o.start=d.start+d.duration:o.start=Math.max(d.start-o.duration,0)}function q(d,o,e,t,i,n){t-e<=0&&(k.logger.warn("Fragment should have a positive duration",o),t=e+o.duration,n=i+o.duration);var a=e,r=t,s=o.startPTS,l=o.endPTS;if((0,R.isFiniteNumber)(s)){var u=Math.abs(s-e);(0,R.isFiniteNumber)(o.deltaPTS)?o.deltaPTS=Math.max(u,o.deltaPTS):o.deltaPTS=u,a=Math.max(e,s),e=Math.min(e,s),i=Math.min(i,o.startDTS),r=Math.min(t,l),t=Math.max(t,l),n=Math.max(n,o.endDTS)}o.duration=t-e;var c=e-o.start;o.start=o.startPTS=e,o.maxStartPTS=a,o.startDTS=i,o.endPTS=t,o.minEndPTS=r,o.endDTS=n;var v,m=o.sn;if(!d||m<d.startSN||m>d.endSN)return 0;var _=m-d.startSN,S=d.fragments;for(S[_]=o,v=_;v>0;v--)F(S[v],S[v-1]);for(v=_;v<S.length-1;v++)F(S[v],S[v+1]);return d.fragmentHint&&F(S[S.length-1],d.fragmentHint),d.PTSKnown=d.alignedSliding=!0,c}function Y(d,o){var e=o.startSN+o.skippedSegments-d.startSN,t=d.fragments;e<0||e>=t.length||he(o,t[e].start)}function he(d,o){if(o){for(var e=d.fragments,t=d.skippedSegments;t<e.length;t++)e[t].start+=o;d.fragmentHint&&(d.fragmentHint.start+=o)}}var Le=function(){function d(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=k.logger.log.bind(k.logger,t+":"),this.warn=k.logger.warn.bind(k.logger,t+":"),this.hls=e}var o=d.prototype;return o.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},o.onError=function(e,t){!t.fatal||t.type!==w.ErrorTypes.NETWORK_ERROR&&t.type!==w.ErrorTypes.KEY_SYSTEM_ERROR||this.stopLoad()},o.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},o.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},o.stopLoad=function(){this.canLoad=!1,this.clearTimer()},o.switchParams=function(e,t){var i=t==null?void 0:t.renditionReports;if(i)for(var n=0;n<i.length;n++){var a=i[n],r=void 0;try{r=new self.URL(a.URI,t.url).href}catch(c){k.logger.warn("Could not construct new URL for Rendition Report: "+c),r=a.URI||""}if(r===e.slice(-r.length)){var s=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn),l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}return new J(s,l>=0?l:void 0,Nt.No)}}},o.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},o.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},o.playlistLoaded=function(e,t,i){var n=this,a=t.details,r=t.stats,s=self.performance.now(),l=r.loading.first?Math.max(0,s-r.loading.first):0;if(a.advancedDateTime=Date.now()-l,a.live||i!=null&&i.live){if(a.reloaded(i),i&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),i&&a.fragments.length>0&&function(Ge,Fe){for(var ct=null,Ct=Ge.fragments,ft=Ct.length-1;ft>=0;ft--){var Tt=Ct[ft].initSegment;if(Tt){ct=Tt;break}}Ge.fragmentHint&&delete Ge.fragmentHint.endPTS;var At,$t,Xt,Gt,Zt,yr=0;if(function(st,vt,di){for(var xr=vt.skippedSegments,Dr=Math.max(st.startSN,vt.startSN)-vt.startSN,ci=(st.fragmentHint?1:0)+(xr?vt.endSN:Math.min(st.endSN,vt.endSN))-vt.startSN,Lr=vt.startSN-st.startSN,Or=vt.fragmentHint?vt.fragments.concat(vt.fragmentHint):vt.fragments,Kr=st.fragmentHint?st.fragments.concat(st.fragmentHint):st.fragments,_r=Dr;_r<=ci;_r++){var qr=Kr[Lr+_r],Yi=Or[_r];xr&&!Yi&&_r<xr&&(Yi=vt.fragments[_r]=qr),qr&&Yi&&di(qr,Yi)}}(Ge,Fe,function(st,vt){st.relurl&&(yr=st.cc-vt.cc),(0,R.isFiniteNumber)(st.startPTS)&&(0,R.isFiniteNumber)(st.endPTS)&&(vt.start=vt.startPTS=st.startPTS,vt.startDTS=st.startDTS,vt.appendedPTS=st.appendedPTS,vt.maxStartPTS=st.maxStartPTS,vt.endPTS=st.endPTS,vt.endDTS=st.endDTS,vt.minEndPTS=st.minEndPTS,vt.duration=st.endPTS-st.startPTS,vt.duration&&(At=vt),Fe.PTSKnown=Fe.alignedSliding=!0),vt.elementaryStreams=st.elementaryStreams,vt.loader=st.loader,vt.stats=st.stats,vt.urlId=st.urlId,st.initSegment&&(vt.initSegment=st.initSegment,ct=st.initSegment)}),ct&&(Fe.fragmentHint?Fe.fragments.concat(Fe.fragmentHint):Fe.fragments).forEach(function(st){var vt;st.initSegment&&st.initSegment.relurl!==((vt=ct)===null||vt===void 0?void 0:vt.relurl)||(st.initSegment=ct)}),Fe.skippedSegments)if(Fe.deltaUpdateFailed=Fe.fragments.some(function(st){return!st}),Fe.deltaUpdateFailed){k.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var Ln=Fe.skippedSegments;Ln--;)Fe.fragments.shift();Fe.startSN=Fe.fragments[0].sn,Fe.startCC=Fe.fragments[0].cc}else Fe.canSkipDateRanges&&(Fe.dateRanges=($t=Ge.dateRanges,Xt=Fe.dateRanges,Gt=Fe.recentlyRemovedDateranges,Zt=T({},$t),Gt&&Gt.forEach(function(st){delete Zt[st]}),Object.keys(Xt).forEach(function(st){var vt=new ce(Xt[st].attr,Zt[st]);vt.isValid?Zt[st]=vt:k.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(Xt[st].attr)+'"')}),Zt));var Ar=Fe.fragments;if(yr){k.logger.warn("discontinuity sliding from playlist, take drift into account");for(var wi=0;wi<Ar.length;wi++)Ar[wi].cc+=yr}Fe.skippedSegments&&(Fe.startCC=Fe.fragments[0].cc),function(st,vt,di){if(st&&vt)for(var xr=0,Dr=0,ci=st.length;Dr<=ci;Dr++){var Lr=st[Dr],Or=vt[Dr+xr];Lr&&Or&&Lr.index===Or.index&&Lr.fragment.sn===Or.fragment.sn?(Kr=Lr,(_r=Or).elementaryStreams=Kr.elementaryStreams,_r.stats=Kr.stats):xr--}var Kr,_r}(Ge.partList,Fe.partList),At?q(Fe,At,At.startPTS,At.endPTS,At.startDTS,At.endDTS):Y(Ge,Fe),Ar.length&&(Fe.totalduration=Fe.edge-Ar[0].start),Fe.driftStartTime=Ge.driftStartTime,Fe.driftStart=Ge.driftStart;var Ai=Fe.advancedDateTime;if(Fe.advanced&&Ai){var Di=Fe.edge;Fe.driftStart||(Fe.driftStartTime=Ai,Fe.driftStart=Di),Fe.driftEndTime=Ai,Fe.driftEnd=Di}else Fe.driftEndTime=Ge.driftEndTime,Fe.driftEnd=Ge.driftEnd,Fe.advancedDateTime=Ge.advancedDateTime}(i,a),!this.canLoad||!a.live)return;var u,c=void 0,v=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var m=this.hls.config.lowLatencyMode,_=a.lastPartSn,S=a.endSN,x=a.lastPartIndex,I=_===S;x!==-1?(c=I?S+1:_,v=I?m?0:x:x+1):c=S+1;var j=a.age,ae=j+a.ageHeader,me=Math.min(ae-a.partTarget,1.5*a.targetduration);if(me>0){if(i&&me>i.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+me+" with playlist age: "+a.age),me=0;else{var de=Math.floor(me/a.targetduration);c+=de,v!==void 0&&(v+=Math.round(me%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+j.toFixed(2)+"s goal: "+me+" skip sn "+de+" to part "+v)}a.tuneInGoal=me}if(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,v),m||!I)return void this.loadPlaylist(u)}else u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,v);var _e=this.hls.mainForwardBufferInfo,Ke=_e?_e.end-_e.len:0,ze=function(Ge,Fe){Fe===void 0&&(Fe=1/0);var ct=1e3*Ge.targetduration;if(Ge.updated){var Ct=Ge.fragments;if(Ct.length&&4*ct>Fe){var ft=1e3*Ct[Ct.length-1].duration;ft<ct&&(ct=ft)}}else ct/=2;return Math.round(ct)}(a,1e3*(a.edge-Ke));a.updated?s>this.requestScheduled+ze&&(this.requestScheduled=r.loading.start):this.requestScheduled=-1,c!==void 0&&a.canBlockReload?this.requestScheduled=r.loading.first+ze-(1e3*a.partTarget||1e3):this.requestScheduled=(this.requestScheduled===-1?s:this.requestScheduled)+ze;var Ee=this.requestScheduled-s;Ee=Math.max(0,Ee),this.log("reload live playlist "+e+" in "+Math.round(Ee)+" ms"),this.timer=self.setTimeout(function(){return n.loadPlaylist(u)},Ee)}else this.clearTimer()},o.getDeliveryDirectives=function(e,t,i,n){var a=function(r,s){var l=r.canSkipUntil,u=r.canSkipDateRanges,c=r.endSN;return l&&(s!==void 0?s-c:0)<l?u?Nt.v2:Nt.Yes:Nt.No}(e,i);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,a=Nt.No),new J(i,n,a)},o.retryLoadingOrFail=function(e){var t,i=this,n=this.hls.config,a=this.retryCount<n.levelLoadingMaxRetry;if(a)if(this.requestScheduled=-1,this.retryCount++,e.details.indexOf("LoadTimeOut")>-1&&(t=e.context)!==null&&t!==void 0&&t.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+e.details+'"'),this.loadPlaylist();else{var r=Math.min(Math.pow(2,this.retryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return i.loadPlaylist()},r),this.warn("retry playlist loading #"+this.retryCount+" in "+r+' ms after "'+e.details+'"')}else this.warn('cannot recover from error "'+e.details+'"'),this.clearTimer(),e.fatal=!0;return a},d}();function Ae(){return Ae=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},Ae.apply(this,arguments)}function Me(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Ve(d,o){return Ve=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ve(d,o)}var Ue,Qe=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),ot=function(d){var o,e;function t(r){var s;return(s=d.call(this,r,"[level-controller]")||this)._levels=[],s._firstLevel=-1,s._startLevel=void 0,s.currentLevelIndex=-1,s.manualLevelIndex=-1,s.onParsedComplete=void 0,s._registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ve(o,e);var i,n,a=t.prototype;return a._registerListeners=function(){var r=this.hls;r.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),r.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),r.on(p.Events.ERROR,this.onError,this)},a._unregisterListeners=function(){var r=this.hls;r.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),r.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),r.off(p.Events.ERROR,this.onError,this)},a.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,d.prototype.destroy.call(this)},a.startLoad=function(){this._levels.forEach(function(r){r.loadError=0}),d.prototype.startLoad.call(this)},a.onManifestLoaded=function(r,s){var l,u,c=[],v=[],m=[],_={},S=!1,x=!1,I=!1;if(s.levels.forEach(function(de){var _e=de.attrs;S=S||!(!de.width||!de.height),x=x||!!de.videoCodec,I=I||!!de.audioCodec,Qe&&de.audioCodec&&de.audioCodec.indexOf("mp4a.40.34")!==-1&&(de.audioCodec=void 0);var Ke=de.bitrate+"-"+de.attrs.RESOLUTION+"-"+de.attrs.CODECS;(u=_[Ke])?u.url.push(de.url):(u=new O(de),_[Ke]=u,c.push(u)),_e&&(_e.AUDIO&&P(u,"audio",_e.AUDIO),_e.SUBTITLES&&P(u,"text",_e.SUBTITLES))}),(S||x)&&I&&(c=c.filter(function(de){var _e=de.videoCodec,Ke=de.width,ze=de.height;return!!_e||!(!Ke||!ze)})),c=c.filter(function(de){var _e=de.audioCodec,Ke=de.videoCodec;return(!_e||Ce(_e,"audio"))&&(!Ke||Ce(Ke,"video"))}),s.audioTracks&&D(v=s.audioTracks.filter(function(de){return!de.audioCodec||Ce(de.audioCodec,"audio")})),s.subtitles&&D(m=s.subtitles),c.length>0){l=c[0].bitrate,c.sort(function(de,_e){return de.attrs["HDCP-LEVEL"]!==_e.attrs["HDCP-LEVEL"]?(de.attrs["HDCP-LEVEL"]||"")>(_e.attrs["HDCP-LEVEL"]||"")?1:-1:de.bitrate!==_e.bitrate?de.bitrate-_e.bitrate:de.attrs.SCORE!==_e.attrs.SCORE?de.attrs.decimalFloatingPoint("SCORE")-_e.attrs.decimalFloatingPoint("SCORE"):S&&de.height!==_e.height?de.height-_e.height:0}),this._levels=c;for(var j=0;j<c.length;j++)if(c[j].bitrate===l){this._firstLevel=j,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+l);break}var ae=I&&!x,me={levels:c,audioTracks:v,subtitleTracks:m,sessionData:s.sessionData,sessionKeys:s.sessionKeys,firstLevel:this._firstLevel,stats:s.stats,audio:I,video:x,altAudio:!ae&&v.some(function(de){return!!de.url})};this.hls.trigger(p.Events.MANIFEST_PARSED,me),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:s.url,reason:"no level with compatible codecs found in manifest"})},a.onError=function(r,s){var l,u;if(d.prototype.onError.call(this,r,s),!s.fatal){var c=s.context,v=this._levels[this.currentLevelIndex];if(c&&(c.type===pe.PlaylistContextType.AUDIO_TRACK&&v.audioGroupIds&&c.groupId===v.audioGroupIds[v.urlId]||c.type===pe.PlaylistContextType.SUBTITLE_TRACK&&v.textGroupIds&&c.groupId===v.textGroupIds[v.urlId]))this.redundantFailover(this.currentLevelIndex);else{var m,_=!1,S=!0;switch(s.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:if(s.frag){var x=s.frag.type===pe.PlaylistLevelType.MAIN?s.frag.level:this.currentLevelIndex,I=this._levels[x];I?(I.fragmentError++,I.fragmentError>this.hls.config.fragLoadingMaxRetry&&(m=x)):m=x}break;case w.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var j=v.attrs["HDCP-LEVEL"];j&&(this.hls.maxHdcpLevel=dr[dr.indexOf(j)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'));case w.ErrorDetails.FRAG_PARSING_ERROR:case w.ErrorDetails.KEY_SYSTEM_NO_SESSION:m=((l=s.frag)===null||l===void 0?void 0:l.type)===pe.PlaylistLevelType.MAIN?s.frag.level:this.currentLevelIndex,s.levelRetry=!1;break;case w.ErrorDetails.LEVEL_LOAD_ERROR:case w.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(S=!1),m=c.level),_=!0;break;case w.ErrorDetails.REMUX_ALLOC_ERROR:m=(u=s.level)!=null?u:this.currentLevelIndex,_=!0}m!==void 0&&this.recoverLevel(s,m,_,S)}}},a.recoverLevel=function(r,s,l,u){var c=r.details,v=this._levels[s];if(v.loadError++,l){if(!this.retryLoadingOrFail(r))return void(this.currentLevelIndex=-1);r.levelRetry=!0}if(u){var m=v.url.length;if(m>1&&v.loadError<m)r.levelRetry=!0,this.redundantFailover(s);else if(this.manualLevelIndex===-1){for(var _=-1,S=this._levels,x=S.length;x--;){var I=(x+this.currentLevelIndex)%S.length;if(I!==this.currentLevelIndex&&S[I].loadError===0){_=I;break}}_>-1&&this.currentLevelIndex!==_?(this.warn(c+": switch to "+_),r.levelRetry=!0,this.hls.nextAutoLevel=_):r.levelRetry===!1&&(r.fatal=!0)}}},a.redundantFailover=function(r){var s=this._levels[r],l=s.url.length;if(l>1){var u=(s.urlId+1)%l;this.warn("Switching to redundant URL-id "+u),this._levels.forEach(function(c){c.urlId=u}),this.level=r}},a.onFragLoaded=function(r,s){var l=s.frag;if(l!==void 0&&l.type===pe.PlaylistLevelType.MAIN){var u=this._levels[l.level];u!==void 0&&(u.fragmentError=0,u.loadError=0)}},a.onLevelLoaded=function(r,s){var l,u,c=s.level,v=s.details,m=this._levels[c];if(!m)return this.warn("Invalid level index "+c),void((u=s.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(v.deltaUpdateFailed=!0));c===this.currentLevelIndex?(m.fragmentError===0&&(m.loadError=0,this.retryCount=0),this.playlistLoaded(c,s,m.details)):(l=s.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(v.deltaUpdateFailed=!0)},a.onAudioTrackSwitched=function(r,s){var l=this.hls.levels[this.currentLevelIndex];if(l&&l.audioGroupIds){for(var u=-1,c=this.hls.audioTracks[s.id].groupId,v=0;v<l.audioGroupIds.length;v++)if(l.audioGroupIds[v]===c){u=v;break}u!==l.urlId&&(l.urlId=u,this.startLoad())}},a.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var s=this.currentLevelIndex,l=this._levels[s];if(this.canLoad&&l&&l.url.length>0){var u=l.urlId,c=l.url[u];if(r)try{c=r.addDirectives(c)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("Attempt loading level index "+s+(r?" at sn "+r.msn+" part "+r.part:"")+" with URL-id "+u+" "+c),this.clearTimer(),this.hls.trigger(p.Events.LEVEL_LOADING,{url:c,level:s,id:u,deliveryDirectives:r||null})}},a.removeLevel=function(r,s){var l=function(c,v){return v!==s},u=this._levels.filter(function(c,v){return v!==r||c.url.length>1&&s!==void 0&&(c.url=c.url.filter(l),c.audioGroupIds&&(c.audioGroupIds=c.audioGroupIds.filter(l)),c.textGroupIds&&(c.textGroupIds=c.textGroupIds.filter(l)),c.urlId=0,!0)}).map(function(c,v){var m=c.details;return m!=null&&m.fragments&&m.fragments.forEach(function(_){_.level=v}),c});this._levels=u,this.hls.trigger(p.Events.LEVELS_UPDATED,{levels:u})},i=t,(n=[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(r){var s,l=this._levels;if(l.length!==0&&(this.currentLevelIndex!==r||(s=l[r])===null||s===void 0||!s.details)){if(r<0||r>=l.length){var u=r<0;if(this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.OTHER_ERROR,details:w.ErrorDetails.LEVEL_SWITCH_ERROR,level:r,fatal:u,reason:"invalid level idx"}),u)return;r=Math.min(r,l.length-1)}this.clearTimer();var c=this.currentLevelIndex,v=l[c],m=l[r];this.log("switching to level "+r+" from "+c),this.currentLevelIndex=r;var _=Ae({},m,{level:r,maxBitrate:m.maxBitrate,uri:m.uri,urlId:m.urlId});delete _._urlId,this.hls.trigger(p.Events.LEVEL_SWITCHING,_);var S=m.details;if(!S||S.live){var x=this.switchParams(m.uri,v==null?void 0:v.details);this.loadPlaylist(x)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(r){this.manualLevelIndex=r,this._startLevel===void 0&&(this._startLevel=r),r!==-1&&(this.level=r)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(r){this._firstLevel=r}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var r=this.hls.config.startLevel;return r!==void 0?r:this._firstLevel}return this._startLevel},set:function(r){this._startLevel=r}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(r){this.level=r,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=r)}}])&&Me(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Le);(function(d){d.NOT_LOADED="NOT_LOADED",d.APPENDING="APPENDING",d.PARTIAL="PARTIAL",d.OK="OK"})(Ue||(Ue={}));var bt=function(){function d(e){this.activeFragment=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}var o=d.prototype;return o._registerListeners=function(){var e=this.hls;e.on(p.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.Events.FRAG_LOADED,this.onFragLoaded,this)},o._unregisterListeners=function(){var e=this.hls;e.off(p.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.Events.FRAG_LOADED,this.onFragLoaded,this)},o.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},o.getAppendedFrag=function(e,t){if(t===pe.PlaylistLevelType.MAIN){var i=this.activeFragment,n=this.activeParts;if(!i)return null;if(n)for(var a=n.length;a--;){var r=n[a],s=r?r.end:i.appendedPTS;if(r.start<=e&&s!==void 0&&e<=s)return a>9&&(this.activeParts=n.slice(a-9)),r}else if(i.start<=e&&i.appendedPTS!==void 0&&e<=i.appendedPTS)return i}return this.getBufferedFrag(e,t)},o.getBufferedFrag=function(e,t){for(var i=this.fragments,n=Object.keys(i),a=n.length;a--;){var r=i[n[a]];if((r==null?void 0:r.body.type)===t&&r.buffered){var s=r.body;if(s.start<=e&&e<=s.end)return s}}return null},o.detectEvictedFragments=function(e,t,i){var n=this;this.timeRanges&&(this.timeRanges[e]=t),Object.keys(this.fragments).forEach(function(a){var r=n.fragments[a];if(r)if(r.buffered||r.loaded){var s=r.range[e];s&&s.time.some(function(l){var u=!n.isTimeBuffered(l.startPTS,l.endPTS,t);return u&&n.removeFragment(r.body),u})}else r.body.type===i&&n.removeFragment(r.body)})},o.detectPartialFragments=function(e){var t=this,i=this.timeRanges,n=e.frag,a=e.part;if(i&&n.sn!=="initSegment"){var r=Lt(n),s=this.fragments[r];s&&(Object.keys(i).forEach(function(l){var u=n.elementaryStreams[l];if(u){var c=i[l],v=a!==null||u.partial===!0;s.range[l]=t.getBufferedTimes(n,a,v,c)}}),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,s.body.endList&&(this.endListFragments[s.body.type]=s)):this.removeFragment(s.body))}},o.fragBuffered=function(e){var t=Lt(e),i=this.fragments[t];i&&(i.loaded=null,i.buffered=!0)},o.getBufferedTimes=function(e,t,i,n){for(var a={time:[],partial:i},r=t?t.start:e.start,s=t?t.end:e.end,l=e.minEndPTS||s,u=e.maxStartPTS||r,c=0;c<n.length;c++){var v=n.start(c)-this.bufferPadding,m=n.end(c)+this.bufferPadding;if(u>=v&&l<=m){a.time.push({startPTS:Math.max(r,n.start(c)),endPTS:Math.min(s,n.end(c))});break}if(r<m&&s>v)a.partial=!0,a.time.push({startPTS:Math.max(r,n.start(c)),endPTS:Math.min(s,n.end(c))});else if(s<=v)break}return a},o.getPartialFragment=function(e){var t,i,n,a=null,r=0,s=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach(function(u){var c=l[u];c&&We(c)&&(i=c.body.start-s,n=c.body.end+s,e>=i&&e<=n&&(t=Math.min(e-i,n-e),r<=t&&(a=c.body,r=t)))}),a},o.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||We(t))},o.getState=function(e){var t=Lt(e),i=this.fragments[t];return i?i.buffered?We(i)?Ue.PARTIAL:Ue.OK:Ue.APPENDING:Ue.NOT_LOADED},o.isTimeBuffered=function(e,t,i){for(var n,a,r=0;r<i.length;r++){if(n=i.start(r)-this.bufferPadding,a=i.end(r)+this.bufferPadding,e>=n&&t<=a)return!0;if(t<=n)return!1}return!1},o.onFragLoaded=function(e,t){var i=t.frag,n=t.part;if(i.sn!=="initSegment"&&!i.bitrateTest&&!n){var a=Lt(i);this.fragments[a]={body:i,loaded:t,buffered:!1,range:Object.create(null)}}},o.onBufferAppended=function(e,t){var i=this,n=t.frag,a=t.part,r=t.timeRanges;if(n.type===pe.PlaylistLevelType.MAIN)if(this.activeFragment!==n&&(this.activeFragment=n,n.appendedPTS=void 0),a){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(a)}else this.activeParts=null;this.timeRanges=r,Object.keys(r).forEach(function(l){var u=r[l];if(i.detectEvictedFragments(l,u),!a&&n.type===pe.PlaylistLevelType.MAIN){var c=n.elementaryStreams[l];if(!c)return;for(var v=0;v<u.length;v++){var m=u.end(v);m<=c.endPTS&&m>c.startPTS?n.appendedPTS=Math.max(m,n.appendedPTS||0):n.appendedPTS=c.endPTS}}})},o.onFragBuffered=function(e,t){this.detectPartialFragments(t)},o.hasFragment=function(e){var t=Lt(e);return!!this.fragments[t]},o.removeFragmentsInRange=function(e,t,i){var n=this;Object.keys(this.fragments).forEach(function(a){var r=n.fragments[a];if(r&&r.buffered){var s=r.body;s.type===i&&s.start<t&&s.end>e&&n.removeFragment(s)}})},o.removeFragment=function(e){var t=Lt(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),e.appendedPTS=void 0,delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},o.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},d}();function We(d){var o,e;return d.buffered&&(((o=d.range.video)===null||o===void 0?void 0:o.partial)||((e=d.range.audio)===null||e===void 0?void 0:e.partial))}function Lt(d){return d.type+"_"+d.level+"_"+d.urlId+"_"+d.sn}function Qt(d){var o=typeof Map=="function"?new Map:void 0;return Qt=function(e){if(e===null||(t=e,Function.toString.call(t).indexOf("[native code]")===-1))return e;var t;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(e))return o.get(e);o.set(e,i)}function i(){return Ot(e,arguments,Ze(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ut(i,e)},Qt(d)}function Ot(d,o,e){return Ot=xt()?Reflect.construct.bind():function(t,i,n){var a=[null];a.push.apply(a,i);var r=new(Function.bind.apply(t,a));return n&&Ut(r,n.prototype),r},Ot.apply(null,arguments)}function xt(){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 Ut(d,o){return Ut=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ut(d,o)}function Ze(d){return Ze=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},Ze(d)}var rr=Math.pow(2,17),Er=function(){function d(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var o=d.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(e,t){var i=this,n=e.url;if(!n)return Promise.reject(new Vt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(n?"part list":"url")));this.abort();var a=this.config,r=a.fLoader,s=a.loader;return new Promise(function(l,u){i.loader&&i.loader.destroy();var c=i.loader=e.loader=r?new r(a):new s(a),v=Ft(e),m={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:e.sn==="initSegment"?1/0:rr};e.stats=c.stats,c.load(v,m,{onSuccess:function(_,S,x,I){i.resetLoader(e,c);var j=_.data;x.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(j.slice(0,16)),j=j.slice(16)),l({frag:e,part:null,payload:j,networkDetails:I})},onError:function(_,S,x){i.resetLoader(e,c),u(new Vt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:_,networkDetails:x}))},onAbort:function(_,S,x){i.resetLoader(e,c),u(new Vt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:x}))},onTimeout:function(_,S,x){i.resetLoader(e,c),u(new Vt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:x}))},onProgress:function(_,S,x,I){t&&t({frag:e,part:null,payload:x,networkDetails:I})}})})},o.loadPart=function(e,t,i){var n=this;this.abort();var a=this.config,r=a.fLoader,s=a.loader;return new Promise(function(l,u){n.loader&&n.loader.destroy();var c=n.loader=e.loader=r?new r(a):new s(a),v=Ft(e,t),m={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:rr};t.stats=c.stats,c.load(v,m,{onSuccess:function(_,S,x,I){n.resetLoader(e,c),n.updateStatsFromPart(e,t);var j={frag:e,part:t,payload:_.data,networkDetails:I};i(j),l(j)},onError:function(_,S,x){n.resetLoader(e,c),u(new Vt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:_,networkDetails:x}))},onAbort:function(_,S,x){e.stats.aborted=t.stats.aborted,n.resetLoader(e,c),u(new Vt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,networkDetails:x}))},onTimeout:function(_,S,x){n.resetLoader(e,c),u(new Vt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,networkDetails:x}))}})})},o.updateStatsFromPart=function(e,t){var i=e.stats,n=t.stats,a=n.total;if(i.loaded+=n.loaded,a){var r=Math.round(e.duration/t.duration),s=Math.min(Math.round(i.loaded/a),r),l=(r-s)*Math.round(i.loaded/s);i.total=i.loaded+l}else i.total=Math.max(i.loaded,i.total);var u=i.loading,c=n.loading;u.start?u.first+=c.first-c.start:(u.start=c.start,u.first=c.first),u.end=c.end},o.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},d}();function Ft(d,o){o===void 0&&(o=null);var e=o||d,t={frag:d,part:o,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},i=e.byteRangeStartOffset,n=e.byteRangeEndOffset;if((0,R.isFiniteNumber)(i)&&(0,R.isFiniteNumber)(n)){var a,r=i,s=n;if(d.sn==="initSegment"&&((a=d.decryptdata)===null||a===void 0?void 0:a.method)==="AES-128"){var l=n-i;l%16&&(s=n+(16-l%16)),i!==0&&(t.resetIV=!0,r=i-16)}t.rangeStart=r,t.rangeEnd=s}return t}var Vt=function(d){var o,e;function t(i){for(var n,a=arguments.length,r=new Array(a>1?a-1:0),s=1;s<a;s++)r[s-1]=arguments[s];return(n=d.call.apply(d,[this].concat(r))||this).data=void 0,n.data=i,n}return e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ut(o,e),t}(Qt(Error)),hr=function(){function d(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var o=d.prototype;return o.abort=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.abort()}},o.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},o.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},o.createKeyLoadError=function(e,t,i,n){return t===void 0&&(t=w.ErrorDetails.KEY_LOAD_ERROR),new Vt({type:w.ErrorTypes.NETWORK_ERROR,details:t,fatal:!1,frag:e,networkDetails:i})},o.loadClear=function(e,t){var i=this;if(this.emeController&&this.config.emeEnabled)for(var n=e.sn,a=e.cc,r=function(l){var u=t[l];if(a<=u.cc&&(n==="initSegment"||n<u.sn))return i.emeController.selectKeySystemFormat(u).then(function(c){u.setKeyFormat(c)}),"break"},s=0;s<t.length&&r(s)!=="break";s++);},o.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(i){return t.loadInternal(e,i)}):this.loadInternal(e)},o.loadInternal=function(e,t){var i,n;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var r=t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(e,w.ErrorDetails.KEY_LOAD_ERROR,null,r))}var s=a.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,w.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+s+'"'));var l,u=this.keyUriToKeyInfo[s];if((i=u)!==null&&i!==void 0&&i.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if((n=u)!==null&&n!==void 0&&n.keyLoadPromise)switch((l=u.mediaKeySessionContext)===null||l===void 0?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise}switch(u=this.keyUriToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return a.keyFormat==="identity"?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,w.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+a.method+'"'))}},o.loadKeyEME=function(e,t){var i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n=this.emeController.loadKey(i);if(n)return(e.keyLoadPromise=n.then(function(a){return e.mediaKeySessionContext=a,i})).catch(function(a){throw e.keyLoadPromise=null,a})}return Promise.resolve(i)},o.loadKeyHTTP=function(e,t){var i=this,n=this.config,a=new n.loader(n);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise(function(r,s){var l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},u={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:n.fragLoadingRetryDelay,maxRetryDelay:n.fragLoadingMaxRetryTimeout,highWaterMark:0},c={onSuccess:function(v,m,_,S){var x=_.frag,I=_.keyInfo,j=_.url;if(!x.decryptdata||I!==i.keyUriToKeyInfo[j])return s(i.createKeyLoadError(x,w.ErrorDetails.KEY_LOAD_ERROR,S,"after key load, decryptdata unset or changed"));I.decryptdata.key=x.decryptdata.key=new Uint8Array(v.data),x.keyLoader=null,I.loader=null,r({frag:x,keyInfo:I})},onError:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,w.ErrorDetails.KEY_LOAD_ERROR,_))},onTimeout:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,w.ErrorDetails.KEY_LOAD_TIMEOUT,_))},onAbort:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,w.ErrorDetails.INTERNAL_ABORTED,_))}};a.load(l,u,c)})},o.resetLoader=function(e){var t=e.frag,i=e.keyInfo,n=e.url,a=i.loader;t.keyLoader===a&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],a&&a.destroy()},d}(),wr=function(){function d(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var o=d.prototype;return o.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},o.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},o.onHandlerDestroyed=function(){},o.hasInterval=function(){return!!this._tickInterval},o.hasNextTick=function(){return!!this._tickTimer},o.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},o.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},o.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},o.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},o.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},o.doTick=function(){},d}(),cr={length:0,start:function(){return 0},end:function(){return 0}},Mt=function(){function d(){}return d.isBuffered=function(o,e){try{if(o){for(var t=d.getBuffered(o),i=0;i<t.length;i++)if(e>=t.start(i)&&e<=t.end(i))return!0}}catch{}return!1},d.bufferInfo=function(o,e,t){try{if(o){var i,n=d.getBuffered(o),a=[];for(i=0;i<n.length;i++)a.push({start:n.start(i),end:n.end(i)});return this.bufferedInfo(a,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},d.bufferedInfo=function(o,e,t){e=Math.max(0,e),o.sort(function(S,x){return S.start-x.start||x.end-S.end});var i=[];if(t)for(var n=0;n<o.length;n++){var a=i.length;if(a){var r=i[a-1].end;o[n].start-r<t?o[n].end>r&&(i[a-1].end=o[n].end):i.push(o[n])}else i.push(o[n])}else i=o;for(var s,l=0,u=e,c=e,v=0;v<i.length;v++){var m=i[v].start,_=i[v].end;if(e+t>=m&&e<_)u=m,l=(c=_)-e;else if(e+t<m){s=m;break}}return{len:l,start:u||0,end:c||0,nextStart:s}},d.getBuffered=function(o){try{return o.buffered}catch(e){return k.logger.log("failed to get media.buffered",e),cr}},d}(),vi=function(d,o,e,t,i,n){t===void 0&&(t=0),i===void 0&&(i=-1),n===void 0&&(n=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=d,this.sn=o,this.id=e,this.size=t,this.part=i,this.partial=n};function Ci(d,o){for(var e=null,t=0,i=d.length;t<i;t++){var n=d[t];if(n&&n.cc===o){e=n;break}}return e}function Tr(d,o){if(d){var e=d.start+o;d.start=d.startPTS=e,d.endPTS=e+d.duration}}function Zr(d,o){for(var e=o.fragments,t=0,i=e.length;t<i;t++)Tr(e[t],d);o.fragmentHint&&Tr(o.fragmentHint,d),o.alignedSliding=!0}function xi(d,o){if(d.hasProgramDateTime&&o.hasProgramDateTime){var e=d.fragments,t=o.fragments;if(e.length&&t.length){var i=t[Math.round(t.length/2)-1],n=Ci(e,i.cc)||e[Math.round(e.length/2)-1],a=i.programDateTime,r=n.programDateTime;a!==null&&r!==null&&Zr((r-a)/1e3-(n.start-i.start),d)}}}let Oi=function(d,o){for(var e=0,t=d.length-1,i=null,n=null;e<=t;){var a=o(n=d[i=(e+t)/2|0]);if(a>0)e=i+1;else{if(!(a<0))return n;t=i-1}}return null};function ei(d,o,e,t){e===void 0&&(e=0),t===void 0&&(t=0);var i=null;if(d?i=o[d.sn-o[0].sn+1]||null:e===0&&o[0].start===0&&(i=o[0]),i&&ti(e,t,i)===0)return i;var n=Oi(o,ti.bind(null,e,t));return!n||n===d&&i?i:n}function ti(d,o,e){if(d===void 0&&(d=0),o===void 0&&(o=0),e.start<=d&&e.start+e.duration>d)return 0;var t=Math.min(o,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-t<=d?1:e.start-t>d&&e.start?-1:0}function Mr(d,o,e){var t=1e3*Math.min(o,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>d}var Yr=N(21);let Zi=function(d){for(var o="",e=d.length,t=0;t<e;t++)o+="["+d.start(t).toFixed(3)+","+d.end(t).toFixed(3)+"]";return o};function Mi(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Fr(d,o){return Fr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Fr(d,o)}var mr="STOPPED",Et="IDLE",Fi="KEY_LOADING",Nr="FRAG_LOADING",Ir="FRAG_LOADING_WAITING_RETRY",ri="WAITING_TRACK",br="PARSING",Ur="PARSED",Wr="ENDED",Sr="ERROR",Pr="WAITING_INIT_PTS",Br="WAITING_LEVEL",ii=function(d){var o,e;function t(r,s,l,u){var c;return(c=d.call(this)||this).hls=void 0,c.fragPrevious=null,c.fragCurrent=null,c.fragmentTracker=void 0,c.transmuxer=null,c._state=mr,c.media=null,c.mediaBuffer=null,c.config=void 0,c.bitrateTest=!1,c.lastCurrentTime=0,c.nextLoadPosition=0,c.startPosition=0,c.loadedmetadata=!1,c.fragLoadError=0,c.retryDate=0,c.levels=null,c.fragmentLoader=void 0,c.keyLoader=void 0,c.levelLastLoaded=null,c.startFragRequested=!1,c.decrypter=void 0,c.initPTS=[],c.onvseeking=null,c.onvended=null,c.logPrefix="",c.log=void 0,c.warn=void 0,c.logPrefix=u,c.log=k.logger.log.bind(k.logger,u+":"),c.warn=k.logger.warn.bind(k.logger,u+":"),c.hls=r,c.fragmentLoader=new Er(r.config),c.keyLoader=l,c.fragmentTracker=s,c.config=r.config,c.decrypter=new Yr.default(r.config),r.on(p.Events.LEVEL_SWITCHING,c.onLevelSwitching,function(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}(c)),c}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Fr(o,e);var i,n,a=t.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(r){},a.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var r=this.fragCurrent;r&&(r.abortRequests(),this.fragmentTracker.removeFragment(r)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=mr},a._streamEnded=function(r,s){if(s.live||r.nextStart||!r.end||!this.media)return!1;var l=s.partList;if(l!=null&&l.length){var u=l[l.length-1];return Mt.isBuffered(this.media,u.start+u.duration/2)}var c=s.fragments[s.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(c)},a.getLevelDetails=function(){var r;if(this.levels&&this.levelLastLoaded!==null)return(r=this.levels[this.levelLastLoaded])===null||r===void 0?void 0:r.details},a.onMediaAttached=function(r,s){var l=this.media=this.mediaBuffer=s.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),l.addEventListener("seeking",this.onvseeking),l.addEventListener("ended",this.onvended);var u=this.config;this.levels&&u.autoStartLoad&&this.state===mr&&this.startLoad(u.startPosition)},a.onMediaDetaching=function(){var r=this.media;r!=null&&r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),r&&this.onvseeking&&this.onvended&&(r.removeEventListener("seeking",this.onvseeking),r.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var r=this.config,s=this.fragCurrent,l=this.media,u=this.mediaBuffer,c=this.state,v=l?l.currentTime:0,m=Mt.bufferInfo(u||l,v,r.maxBufferHole);if(this.log("media seeking to "+((0,R.isFiniteNumber)(v)?v.toFixed(3):v)+", state: "+c),this.state===Wr)this.resetLoadingState();else if(s){var _=r.maxFragLookUpTolerance,S=s.start-_,x=s.start+s.duration+_;if(!m.len||x<m.start||S>m.end){var I=v>x;(v<S||I)&&(I&&s.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),s.abortRequests()),this.resetLoadingState())}}l&&(this.lastCurrentTime=v),this.loadedmetadata||m.len||(this.nextLoadPosition=this.startPosition=v),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onLevelSwitching=function(r,s){this.fragLoadError=0},a.onHandlerDestroying=function(){this.stopLoad(),d.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=mr,this.hls.off(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,d.prototype.onHandlerDestroyed.call(this)},a.loadFragment=function(r,s,l){this._loadFragForPlayback(r,s,l)},a._loadFragForPlayback=function(r,s,l){var u=this;this._doFragLoad(r,s,l,function(c){if(u.fragContextChanged(r))return u.warn("Fragment "+r.sn+(c.part?" p: "+c.part.index:"")+" of level "+r.level+" was dropped during download."),void u.fragmentTracker.removeFragment(r);r.stats.chunkCount++,u._handleFragmentLoadProgress(c)}).then(function(c){if(c){u.fragLoadError=0;var v=u.state;u.fragContextChanged(r)?(v===Nr||!u.fragCurrent&&v===br)&&(u.fragmentTracker.removeFragment(r),u.state=Et):("payload"in c&&(u.log("Loaded fragment "+r.sn+" of level "+r.level),u.hls.trigger(p.Events.FRAG_LOADED,c)),u._handleFragmentLoadComplete(c))}}).catch(function(c){u.state!==mr&&u.state!==Sr&&(u.warn(c),u.resetFragmentLoading(r))})},a.flushMainBuffer=function(r,s,l){if(l===void 0&&(l=null),r-s){var u={startOffset:r,endOffset:s,type:l};this.fragLoadError=0,this.hls.trigger(p.Events.BUFFER_FLUSHING,u)}},a._loadInitSegment=function(r,s){var l=this;this._doFragLoad(r,s).then(function(u){if(!u||l.fragContextChanged(r)||!l.levels)throw new Error("init load aborted");return u}).then(function(u){var c=l.hls,v=u.payload,m=r.decryptdata;if(v&&v.byteLength>0&&m&&m.key&&m.iv&&m.method==="AES-128"){var _=self.performance.now();return l.decrypter.decrypt(new Uint8Array(v),m.key.buffer,m.iv.buffer).then(function(S){var x=self.performance.now();return c.trigger(p.Events.FRAG_DECRYPTED,{frag:r,payload:S,stats:{tstart:_,tdecrypt:x}}),u.payload=S,u})}return u}).then(function(u){var c=l.fragCurrent,v=l.hls,m=l.levels;if(!m)throw new Error("init load aborted, missing levels");m[r.level].details;var _=r.stats;l.state=Et,l.fragLoadError=0,r.data=new Uint8Array(u.payload),_.parsing.start=_.buffering.start=self.performance.now(),_.parsing.end=_.buffering.end=self.performance.now(),u.frag===c&&v.trigger(p.Events.FRAG_BUFFERED,{stats:_,frag:c,part:null,id:r.type}),l.tick()}).catch(function(u){l.state!==mr&&l.state!==Sr&&(l.warn(u),l.resetFragmentLoading(r))})},a.fragContextChanged=function(r){var s=this.fragCurrent;return!r||!s||r.level!==s.level||r.sn!==s.sn||r.urlId!==s.urlId},a.fragBufferedComplete=function(r,s){var l,u,c=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+r.type+" sn: "+r.sn+(s?" part: "+s.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+r.level+" "+(c?Zi(Mt.getBuffered(c)):"(detached)")),this.state=Et,c&&(!this.loadedmetadata&&r.type==pe.PlaylistLevelType.MAIN&&c.buffered.length&&((l=this.fragCurrent)===null||l===void 0?void 0:l.sn)===((u=this.fragPrevious)===null||u===void 0?void 0:u.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},a.seekToStartPos=function(){},a._handleFragmentLoadComplete=function(r){var s=this.transmuxer;if(s){var l=r.frag,u=r.part,c=r.partsLoaded,v=!c||c.length===0||c.some(function(_){return!_}),m=new vi(l.level,l.sn,l.stats.chunkCount+1,0,u?u.index:-1,!v);s.flush(m)}},a._handleFragmentLoadProgress=function(r){},a._doFragLoad=function(r,s,l,u){var c,v=this;if(l===void 0&&(l=null),!this.levels)throw new Error("frag load aborted, missing levels");var m=null;if(!r.encrypted||(c=r.decryptdata)!==null&&c!==void 0&&c.key?!r.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(r,s.encryptedFragments):(this.log("Loading key for "+r.sn+" of ["+s.startSN+"-"+s.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+r.level),this.state=Fi,this.fragCurrent=r,m=this.keyLoader.load(r).then(function(j){if(!v.fragContextChanged(j.frag))return v.hls.trigger(p.Events.KEY_LOADED,j),j}),this.hls.trigger(p.Events.KEY_LOADING,{frag:r}),this.throwIfFragContextChanged("KEY_LOADING")),l=Math.max(r.start,l||0),this.config.lowLatencyMode&&s){var _=s.partList;if(_&&u){l>r.end&&s.fragmentHint&&(r=s.fragmentHint);var S=this.getNextPart(_,r,l);if(S>-1){var x=_[S];return this.log("Loading part sn: "+r.sn+" p: "+x.index+" cc: "+r.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+S+"-"+(_.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+r.level+", target: "+parseFloat(l.toFixed(3))),this.nextLoadPosition=x.start+x.duration,this.state=Nr,this.hls.trigger(p.Events.FRAG_LOADING,{frag:r,part:_[S],targetBufferTime:l}),this.throwIfFragContextChanged("FRAG_LOADING parts"),m?m.then(function(j){return!j||v.fragContextChanged(j.frag)?null:v.doFragPartsLoad(r,_,S,u)}).catch(function(j){return v.handleFragLoadError(j)}):this.doFragPartsLoad(r,_,S,u).catch(function(j){return v.handleFragLoadError(j)})}if(!r.url||this.loadedEndOfParts(_,l))return Promise.resolve(null)}}this.log("Loading fragment "+r.sn+" cc: "+r.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+r.level+", target: "+parseFloat(l.toFixed(3))),(0,R.isFiniteNumber)(r.sn)&&!this.bitrateTest&&(this.nextLoadPosition=r.start+r.duration),this.state=Nr,this.hls.trigger(p.Events.FRAG_LOADING,{frag:r,targetBufferTime:l}),this.throwIfFragContextChanged("FRAG_LOADING");var I=this.config.progressive;return I&&m?m.then(function(j){return!j||v.fragContextChanged(j==null?void 0:j.frag)?null:v.fragmentLoader.load(r,u)}).catch(function(j){return v.handleFragLoadError(j)}):Promise.all([this.fragmentLoader.load(r,I?u:void 0),m]).then(function(j){var ae=j[0];return!I&&ae&&u&&u(ae),ae}).catch(function(j){return v.handleFragLoadError(j)})},a.throwIfFragContextChanged=function(r){if(this.fragCurrent===null)throw new Error("frag load aborted, context changed in "+r)},a.doFragPartsLoad=function(r,s,l,u){var c=this;return new Promise(function(v,m){var _=[];(function S(x){var I=s[x];c.fragmentLoader.loadPart(r,I,u).then(function(j){_[I.index]=j;var ae=j.part;c.hls.trigger(p.Events.FRAG_LOADED,j);var me=s[x+1];if(!me||me.fragment!==r)return v({frag:r,part:ae,partsLoaded:_});S(x+1)}).catch(m)})(l)})},a.handleFragLoadError=function(r){if("data"in r){var s=r.data;r.data&&s.details===w.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(s.frag,s.part):this.hls.trigger(p.Events.ERROR,s)}else this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.OTHER_ERROR,details:w.ErrorDetails.INTERNAL_EXCEPTION,err:r,fatal:!0});return null},a._handleTransmuxerFlush=function(r){var s=this.getCurrentContext(r);if(s&&this.state===br){var l=s.frag,u=s.part,c=s.level,v=self.performance.now();l.stats.parsing.end=v,u&&(u.stats.parsing.end=v),this.updateLevelTiming(l,u,c,r.partial)}else this.fragCurrent||this.state===mr||this.state===Sr||(this.state=Et)},a.getCurrentContext=function(r){var s=this.levels,l=r.level,u=r.sn,c=r.part;if(!s||!s[l])return this.warn("Levels object was unset while buffering fragment "+u+" of level "+l+". The current chunk will not be buffered."),null;var v=s[l],m=c>-1?function(S,x,I){if(!S||!S.details)return null;var j=S.details.partList;if(j)for(var ae=j.length;ae--;){var me=j[ae];if(me.index===I&&me.fragment.sn===x)return me}return null}(v,u,c):null,_=m?m.fragment:function(S,x,I){if(!S||!S.details)return null;var j=S.details,ae=j.fragments[x-j.startSN];return ae||((ae=j.fragmentHint)&&ae.sn===x?ae:x<j.startSN&&I&&I.sn===x?I:null)}(v,u,this.fragCurrent);return _?{frag:_,part:m,level:v}:null},a.bufferFragmentData=function(r,s,l,u){if(r&&this.state===br){var c=r.data1,v=r.data2,m=c;if(c&&v&&(m=(0,W.appendUint8Array)(c,v)),m&&m.length){var _={type:r.type,frag:s,part:l,chunkMeta:u,parent:s.type,data:m};this.hls.trigger(p.Events.BUFFER_APPENDING,_),r.dropped&&r.independent&&!l&&this.flushBufferGap(s)}}},a.flushBufferGap=function(r){var s=this.media;if(s)if(Mt.isBuffered(s,s.currentTime)){var l=s.currentTime,u=Mt.bufferInfo(s,l,0),c=r.duration,v=Math.min(2*this.config.maxFragLookUpTolerance,.25*c),m=Math.max(Math.min(r.start-v,u.end-v),l+v);r.start-m>v&&this.flushMainBuffer(m,r.start)}else this.flushMainBuffer(0,r.start)},a.getFwdBufferInfo=function(r,s){var l=this.config,u=this.getLoadPosition();if(!(0,R.isFiniteNumber)(u))return null;var c=Mt.bufferInfo(r,u,l.maxBufferHole);if(c.len===0&&c.nextStart!==void 0){var v=this.fragmentTracker.getBufferedFrag(u,s);if(v&&c.nextStart<v.end)return Mt.bufferInfo(r,u,Math.max(c.nextStart,l.maxBufferHole))}return c},a.getMaxBufferLength=function(r){var s,l=this.config;return s=r?Math.max(8*l.maxBufferSize/r,l.maxBufferLength):l.maxBufferLength,Math.min(s,l.maxMaxBufferLength)},a.reduceMaxBufferLength=function(r){var s=this.config,l=r||s.maxBufferLength;return s.maxMaxBufferLength>=l&&(s.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+s.maxMaxBufferLength+"s"),!0)},a.getNextFragment=function(r,s){var l=s.fragments,u=l.length;if(!u)return null;var c,v=this.config,m=l[0].start;if(s.live){var _=v.initialLiveManifestSize;if(u<_)return this.warn("Not enough fragments to start playback (have: "+u+", need: "+_+")"),null;s.PTSKnown||this.startFragRequested||this.startPosition!==-1||(c=this.getInitialLiveFragment(s,l),this.startPosition=c?this.hls.liveSyncPosition||c.start:r)}else r<=m&&(c=l[0]);if(!c){var S=v.lowLatencyMode?s.partEnd:s.fragmentEnd;c=this.getFragmentAtPosition(r,S,s)}return this.mapToInitFragWhenRequired(c)},a.mapToInitFragWhenRequired=function(r){return r==null||!r.initSegment||r!=null&&r.initSegment.data||this.bitrateTest?r:r.initSegment},a.getNextPart=function(r,s,l){for(var u=-1,c=!1,v=!0,m=0,_=r.length;m<_;m++){var S=r[m];if(v=v&&!S.independent,u>-1&&l<S.start)break;var x=S.loaded;x?u=-1:(c||S.independent||v)&&S.fragment===s&&(u=m),c=x}return u},a.loadedEndOfParts=function(r,s){var l=r[r.length-1];return l&&s>l.start&&l.loaded},a.getInitialLiveFragment=function(r,s){var l=this.fragPrevious,u=null;if(l){if(r.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+l.programDateTime),u=function(_,S,x){if(S===null||!Array.isArray(_)||!_.length||!(0,R.isFiniteNumber)(S)||S<(_[0].programDateTime||0)||S>=(_[_.length-1].endProgramDateTime||0))return null;x=x||0;for(var I=0;I<_.length;++I){var j=_[I];if(Mr(S,x,j))return j}return null}(s,l.endProgramDateTime,this.config.maxFragLookUpTolerance)),!u){var c=l.sn+1;if(c>=r.startSN&&c<=r.endSN){var v=s[c-r.startSN];l.cc===v.cc&&(u=v,this.log("Live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=function(_,S){return Oi(_,function(x){return x.cc<S?1:x.cc>S?-1:0})}(s,l.cc),u&&this.log("Live playlist, switching playlist, load frag with same CC: "+u.sn))}}else{var m=this.hls.liveSyncPosition;m!==null&&(u=this.getFragmentAtPosition(m,this.bitrateTest?r.fragmentEnd:r.edge,r))}return u},a.getFragmentAtPosition=function(r,s,l){var u,c=this.config,v=this.fragPrevious,m=l.fragments,_=l.endSN,S=l.fragmentHint,x=c.maxFragLookUpTolerance,I=!!(c.lowLatencyMode&&l.partList&&S);if(I&&S&&!this.bitrateTest&&(m=m.concat(S),_=S.sn),u=r<s?ei(v,m,r,r>s-x?0:x):m[m.length-1]){var j=u.sn-l.startSN;if(this.fragmentTracker.getState(u)===Ue.OK&&(v=u),v&&u.sn===v.sn&&!I&&v&&u.level===v.level){var ae=m[j+1];u.sn<_&&this.fragmentTracker.getState(ae)!==Ue.OK?(this.log("SN "+u.sn+" just loaded, load next one: "+ae.sn),u=ae):u=null}}return u},a.synchronizeToLiveEdge=function(r){var s=this.config,l=this.media;if(l){var u=this.hls.liveSyncPosition,c=l.currentTime,v=r.fragments[0].start,m=r.edge,_=c>=v-s.maxFragLookUpTolerance&&c<=m;if(u!==null&&l.duration>u&&(c<u||!_)){var S=s.liveMaxLatencyDuration!==void 0?s.liveMaxLatencyDuration:s.liveMaxLatencyDurationCount*r.targetduration;(!_&&l.readyState<4||c<m-S)&&(this.loadedmetadata||(this.nextLoadPosition=u),l.readyState&&(this.warn("Playback: "+c.toFixed(3)+" is located too far from the end of live sliding playlist: "+m+", reset currentTime to : "+u.toFixed(3)),l.currentTime=u))}}},a.alignPlaylists=function(r,s){var l=this.levels,u=this.levelLastLoaded,c=this.fragPrevious,v=u!==null?l[u]:null,m=r.fragments.length;if(!m)return this.warn("No fragments in live playlist"),0;var _=r.fragments[0].start,S=!s,x=r.alignedSliding&&(0,R.isFiniteNumber)(_);if(S||!x&&!_){(function(j,ae,me){ae&&(function(de,_e,Ke){if(function(Ee,Ge,Fe){return!(!Ge.details||!(Fe.endCC>Fe.startCC||Ee&&Ee.cc<Fe.startCC))}(de,Ke,_e)){var ze=function(Ee,Ge,Fe){Fe===void 0&&(Fe=0);var ct=Ee.fragments,Ct=Ge.fragments;if(Ct.length&&ct.length){var ft=Ci(ct,Ct[0].cc);if(ft&&(!ft||ft.startPTS))return ft;k.logger.log("No frag in previous level to align on")}else k.logger.log("No fragments to align")}(Ke.details,_e);ze&&(0,R.isFiniteNumber)(ze.start)&&(k.logger.log("Adjusting PTS using last level due to CC increase within current level "+_e.url),Zr(ze.start,_e))}}(j,me,ae),!me.alignedSliding&&ae.details&&function(de,_e){if(_e.fragments.length&&de.hasProgramDateTime&&_e.hasProgramDateTime){var Ke=_e.fragments[0].programDateTime,ze=de.fragments[0].programDateTime,Ee=(ze-Ke)/1e3+_e.fragments[0].start;Ee&&(0,R.isFiniteNumber)(Ee)&&(k.logger.log("Adjusting PTS using programDateTime delta "+(ze-Ke)+"ms, sliding:"+Ee.toFixed(3)+" "+de.url+" "),Zr(Ee,de))}}(me,ae.details),me.alignedSliding||!ae.details||me.skippedSegments||Y(ae.details,me))})(c,v,r);var I=r.fragments[0].start;return this.log("Live playlist sliding: "+I.toFixed(2)+" start-sn: "+(s?s.startSN:"na")+"->"+r.startSN+" prev-sn: "+(c?c.sn:"na")+" fragments: "+m),I}return _},a.waitForCdnTuneIn=function(r){return r.live&&r.canBlockReload&&r.partTarget&&r.tuneInGoal>Math.max(r.partHoldBack,3*r.partTarget)},a.setStartPosition=function(r,s){var l=this.startPosition;if(l<s&&(l=-1),l===-1||this.lastCurrentTime===-1){var u=r.startTimeOffset;(0,R.isFiniteNumber)(u)?(l=s+u,u<0&&(l+=r.totalduration),l=Math.min(Math.max(s,l),s+r.totalduration),this.log("Start time offset "+u+" found in playlist, adjust startPosition to "+l),this.startPosition=l):r.live?l=this.hls.liveSyncPosition||s:this.startPosition=l=0,this.lastCurrentTime=l}this.nextLoadPosition=l},a.getLoadPosition=function(){var r=this.media,s=0;return this.loadedmetadata&&r?s=r.currentTime:this.nextLoadPosition&&(s=this.nextLoadPosition),s},a.handleFragLoadAborted=function(r,s){this.transmuxer&&r.sn!=="initSegment"&&r.stats.aborted&&(this.warn("Fragment "+r.sn+(s?" part"+s.index:"")+" of level "+r.level+" was aborted"),this.resetFragmentLoading(r))},a.resetFragmentLoading=function(r){this.fragCurrent&&(this.fragContextChanged(r)||this.state===Ir)||(this.state=Et)},a.onFragmentOrKeyLoadError=function(r,s){if(s.fatal)return this.stopLoad(),void(this.state=Sr);var l=this.config;if(s.chunkMeta){var u=this.getCurrentContext(s.chunkMeta);u&&(s.frag=u.frag,s.levelRetry=!0,this.fragLoadError=l.fragLoadingMaxRetry)}var c=s.frag;if(c&&c.type===r)if(this.fragCurrent,this.fragLoadError+1<=l.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var v=Math.min(Math.pow(2,this.fragLoadError)*l.fragLoadingRetryDelay,l.fragLoadingMaxRetryTimeout);this.warn("Fragment "+c.sn+" of "+r+" "+c.level+" failed to load, retrying in "+v+"ms"),this.retryDate=self.performance.now()+v,this.fragLoadError++,this.state=Ir}else s.levelRetry?(r===pe.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=Et):(k.logger.error(s.details+" reaches max retry, redispatch as fatal ..."),s.fatal=!0,this.hls.stopLoad(),this.state=Sr)},a.afterBufferFlushed=function(r,s,l){if(r){var u=Mt.getBuffered(r);this.fragmentTracker.detectEvictedFragments(s,u,l),this.state===Wr&&this.resetLoadingState()}},a.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Et},a.resetStartWhenNotLoaded=function(r){if(!this.loadedmetadata){this.startFragRequested=!1;var s=this.levels?this.levels[r].details:null;s!=null&&s.live?(this.startPosition=-1,this.setStartPosition(s,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},a.updateLevelTiming=function(r,s,l,u){var c=this,v=l.details;Object.keys(r.elementaryStreams).reduce(function(m,_){var S=r.elementaryStreams[_];if(S){var x=S.endPTS-S.startPTS;if(x<=0)return c.warn("Could not parse fragment "+r.sn+" "+_+" duration reliably ("+x+")"),m||!1;var I=u?0:q(v,r,S.startPTS,S.endPTS,S.startDTS,S.endDTS);return c.hls.trigger(p.Events.LEVEL_PTS_UPDATED,{details:v,level:l,drift:I,type:_,frag:r,start:S.startPTS,end:S.endPTS}),!0}return m},!1)||(this.warn("Found no media in fragment "+r.sn+" of level "+l.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=Ur,this.hls.trigger(p.Events.FRAG_PARSED,{frag:r,part:s})},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i=t,(n=[{key:"state",get:function(){return this._state},set:function(r){var s=this._state;s!==r&&(this._state=r,this.log(s+"->"+r))}}])&&Mi(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(wr);function ni(){return self.MediaSource||self.WebKitMediaSource}function ai(){return self.SourceBuffer||self.WebKitSourceBuffer}var pi=function(){var d=ENTRY_MODULE,o={},e=function i(n){var a=o[n];if(a!==void 0)return a.exports;var r=o[n]={exports:{}};return d[n].call(r.exports,r,r.exports,i),r.exports};e.m=d,e.n=function(i){var n=i&&i.__esModule?function(){return i.default}:function(){return i};return e.d(n,{a:n}),n},e.d=function(i,n){for(var a in n)e.o(n,a)&&!e.o(i,a)&&Object.defineProperty(i,a,{enumerable:!0,get:n[a]})},e.o=function(i,n){return Object.prototype.hasOwnProperty.call(i,n)},e.r=function(i){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var t=e(ENTRY_MODULE);return t.default||t}.toString().split("ENTRY_MODULE"),Ni="\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)";function Yt(d){return(d+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function si(d,o,e){var t={};t[e]=[];var i=o.toString().replace(/^"[^"]+"/,"function"),n=i.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||i.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!n)return t;for(var a,r=n[1],s=new RegExp("(\\\\n|\\W)"+Yt(r)+Ni,"g");a=s.exec(i);)a[3]!=="dll-reference"&&t[e].push(a[3]);for(s=new RegExp("\\("+Yt(r)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)'+Ni,"g");a=s.exec(i);)d[a[2]]||(t[e].push(a[1]),d[a[2]]=N(a[1]).m),t[a[2]]=t[a[2]]||[],t[a[2]].push(a[4]);for(var l,u=Object.keys(t),c=0;c<u.length;c++)for(var v=0;v<t[u[c]].length;v++)l=t[u[c]][v],isNaN(1*l)||(t[u[c]][v]=1*t[u[c]][v]);return t}function en(d){return Object.keys(d).reduce(function(o,e){return o||d[e].length>0},!1)}function Ui(d,o,e,t){var i=d[t].map(function(n){return'"'+n+'": '+o[t][n].toString().replace(/^"[^"]+"/,"function")}).join(",");return pi[0]+"{"+i+"}"+pi[1]+'"'+e+'"'+pi[2]}var Cr=N(544),gi=N(729),Xr=N.n(gi),zr=ni()||{isTypeSupported:function(){return!1}},mi=function(){function d(e,t,i,n){var a=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;var s=function(v,m){(m=m||{}).frag=a.frag,m.id=a.id,a.hls.trigger(v,m)};this.observer=new gi.EventEmitter,this.observer.on(p.Events.FRAG_DECRYPTED,s),this.observer.on(p.Events.ERROR,s);var l={mp4:zr.isTypeSupported("video/mp4"),mpeg:zr.isTypeSupported("audio/mpeg"),mp3:zr.isTypeSupported('audio/mp4; codecs="mp3"')},u=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"){var c;k.logger.log("demuxing in webworker");try{c=this.worker=function(v,m){m=m||{};var _={main:N.m},S=m.all?{main:Object.keys(_.main)}:function(me,de){for(var _e={main:[de]},Ke={main:[]},ze={main:{}};en(_e);)for(var Ee=Object.keys(_e),Ge=0;Ge<Ee.length;Ge++){var Fe=Ee[Ge],ct=_e[Fe].pop();if(ze[Fe]=ze[Fe]||{},!ze[Fe][ct]&&me[Fe][ct]){ze[Fe][ct]=!0,Ke[Fe]=Ke[Fe]||[],Ke[Fe].push(ct);for(var Ct=si(me,me[Fe][ct],Fe),ft=Object.keys(Ct),Tt=0;Tt<ft.length;Tt++)_e[ft[Tt]]=_e[ft[Tt]]||[],_e[ft[Tt]]=_e[ft[Tt]].concat(Ct[ft[Tt]])}}return Ke}(_,v),x="";Object.keys(S).filter(function(me){return me!=="main"}).forEach(function(me){for(var de=0;S[me][de];)de++;S[me].push(de),_[me][de]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",x=x+"var "+me+" = ("+Ui(S,_,de,modules)+`)();
|
|
9
|
-
`}),x=x+"new (("+Ui(S,_,v,"main")+")())(self);";var I=new window.Blob([x],{type:"text/javascript"}),j=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(I),ae=new window.Worker(j);return ae.objectURL=j,ae}(182),this.onwmsg=this.onWorkerMessage.bind(this),c.addEventListener("message",this.onwmsg),c.onerror=function(v){a.useWorker=!1,k.logger.warn("Exception in webworker, fallback to inline"),a.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.OTHER_ERROR,details:w.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(v.message+" ("+v.filename+":"+v.lineno+")")})},c.postMessage({cmd:"init",typeSupported:l,vendor:u,id:t,config:JSON.stringify(r)})}catch(v){k.logger.warn("Error in worker:",v),k.logger.error("Error while initializing DemuxerWorker, fallback to inline"),c&&self.URL.revokeObjectURL(c.objectURL),this.transmuxer=new Cr.default(this.observer,l,r,u,t),this.worker=null}}else this.transmuxer=new Cr.default(this.observer,l,r,u,t)}var o=d.prototype;return o.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var i=this.observer;i&&i.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},o.push=function(e,t,i,n,a,r,s,l,u,c){var v,m,_=this;u.transmuxing.start=self.performance.now();var S=this.transmuxer,x=this.worker,I=r?r.start:a.start,j=a.decryptdata,ae=this.frag,me=!(ae&&a.cc===ae.cc),de=!(ae&&u.level===ae.level),_e=ae?u.sn-ae.sn:-1,Ke=this.part?u.part-this.part.index:-1,ze=_e===0&&u.id>1&&u.id===(ae==null?void 0:ae.stats.chunkCount),Ee=!de&&(_e===1||_e===0&&(Ke===1||ze&&Ke<=0)),Ge=self.performance.now();(de||_e||a.stats.parsing.start===0)&&(a.stats.parsing.start=Ge),!r||!Ke&&Ee||(r.stats.parsing.start=Ge);var Fe=!(ae&&((v=a.initSegment)===null||v===void 0?void 0:v.url)===((m=ae.initSegment)===null||m===void 0?void 0:m.url)),ct=new Cr.TransmuxState(me,Ee,l,de,I,Fe);if(!Ee||me||Fe){k.logger.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
|
10
|
-
discontinuity: `+
|
|
11
|
-
trackSwitch: `+
|
|
12
|
-
contiguous: `+
|
|
13
|
-
accurateTimeOffset: `+
|
|
14
|
-
timeOffset: `+
|
|
15
|
-
initSegmentChange: `+Fe);var Ct=new Cr.TransmuxConfig(i,n,t,s,c);this.configureTransmuxer(Ct)}if(this.frag=a,this.part=r,x)x.postMessage({cmd:"demux",data:e,decryptdata:j,chunkMeta:u,state:ct},e instanceof ArrayBuffer?[e]:[]);else if(S){var ft=S.push(e,j,u,ct);(0,Cr.isPromise)(ft)?(S.async=!0,ft.then(function(Tt){_.handleTransmuxComplete(Tt)}).catch(function(Tt){_.transmuxerError(Tt,u,"transmuxer-interface push error")})):(S.async=!1,this.handleTransmuxComplete(ft))}},o.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var i=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:e});else if(i){var a=i.flush(e);(0,Cr.isPromise)(a)||i.async?((0,Cr.isPromise)(a)||(a=Promise.resolve(a)),a.then(function(r){t.handleFlushResult(r,e)}).catch(function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")})):this.handleFlushResult(a,e)}},o.transmuxerError=function(e,t,i){this.hls&&this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i})},o.handleFlushResult=function(e,t){var i=this;e.forEach(function(n){i.handleTransmuxComplete(n)}),this.onFlush(t)},o.onWorkerMessage=function(e){var t=e.data,i=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":k.logger[t.data.logType]&&k.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,i.trigger(t.event,t.data)}},o.configureTransmuxer=function(e){var t=this.worker,i=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):i&&i.configure(e)},o.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},d}(),Bi=function(){function d(e,t,i,n){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=i,this.hls=n}var o=d.prototype;return o.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},o.poll=function(e,t){var i=this.config,n=this.media,a=this.stalled;if(n!==null){var r=n.currentTime,s=n.seeking,l=this.seeking&&!s,u=!this.seeking&&s;if(this.seeking=s,r===e){if((u||l)&&(this.stalled=null),!(n.paused&&!s||n.ended||n.playbackRate===0)&&Mt.getBuffered(n).length){var c=Mt.bufferInfo(n,r,0),v=c.len>0,m=c.nextStart||0;if(v||m){if(s){var _=c.len>2,S=!m||t&&t.start<=r||m-r>2&&!this.fragmentTracker.getPartialFragment(r);if(_||S)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var x,I=Math.max(m,c.start||0)-r,j=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,ae=!(j==null||(x=j.details)===null||x===void 0)&&x.live?2*j.details.targetduration:2;if(I>0&&I<=ae)return void this._trySkipBufferHole(null)}var me=self.performance.now();if(a!==null){var de=me-a;if(s||!(de>=250)||(this._reportStall(c),this.media)){var _e=Mt.bufferInfo(n,r,i.maxBufferHole);this._tryFixBufferStall(_e,de)}}else this.stalled=me}}}else if(this.moved=!0,a!==null){if(this.stallReported){var Ke=self.performance.now()-a;k.logger.warn("playback not stuck anymore @"+r+", after "+Math.round(Ke)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},o._tryFixBufferStall=function(e,t){var i=this.config,n=this.fragmentTracker,a=this.media;if(a!==null){var r=a.currentTime,s=n.getPartialFragment(r);if(s&&(this._trySkipBufferHole(s)||!this.media))return;e.len>i.maxBufferHole&&t>1e3*i.highBufferWatchdogPeriod&&(k.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},o._reportStall=function(e){var t=this.hls,i=this.media;!this.stallReported&&i&&(this.stallReported=!0,k.logger.warn("Playback stalling at @"+i.currentTime+" due to low buffer ("+JSON.stringify(e)+")"),t.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e.len}))},o._trySkipBufferHole=function(e){var t=this.config,i=this.hls,n=this.media;if(n===null)return 0;for(var a=n.currentTime,r=0,s=Mt.getBuffered(n),l=0;l<s.length;l++){var u=s.start(l);if(a+t.maxBufferHole>=r&&a<u){var c=Math.max(u+.05,n.currentTime+.1);return k.logger.warn("skipping hole, adjusting currentTime from "+a+" to "+c),this.moved=!0,this.stalled=null,n.currentTime=c,e&&i.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+a+" to "+c,frag:e}),c}r=s.end(l)}return 0},o._tryNudgeBuffer=function(){var e=this.config,t=this.hls,i=this.media,n=this.nudgeRetry;if(i!==null){var a=i.currentTime;if(this.nudgeRetry++,n<e.nudgeMaxRetry){var r=a+(n+1)*e.nudgeOffset;k.logger.warn("Nudging 'currentTime' from "+a+" to "+r),i.currentTime=r,t.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else k.logger.error("Playhead still not moving while enough data buffered @"+a+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},d}();function Hr(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function yi(d,o){return yi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},yi(d,o)}var tn=function(d){var o,e;function t(r,s,l){var u;return(u=d.call(this,r,s,l,"[stream-controller]")||this).audioCodecSwap=!1,u.gapController=null,u.level=-1,u._forceStartLoad=!1,u.altAudio=!1,u.audioOnly=!1,u.fragPlaying=null,u.onvplaying=null,u.onvseeked=null,u.fragLastKbps=0,u.couldBacktrack=!1,u.backtrackFragment=null,u.audioCodecSwitch=!1,u.videoBuffer=null,u._registerListeners(),u}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,yi(o,e);var i,n,a=t.prototype;return a._registerListeners=function(){var r=this.hls;r.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(p.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(p.Events.ERROR,this.onError,this),r.on(p.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(p.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(p.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(p.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var r=this.hls;r.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(p.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(p.Events.ERROR,this.onError,this),r.off(p.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(p.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(p.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(p.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},a.startLoad=function(r){if(this.levels){var s=this.lastCurrentTime,l=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var u=l.startLevel;u===-1&&(l.config.testBandwidth&&this.levels.length>1?(u=0,this.bitrateTest=!0):u=l.nextAutoLevel),this.level=l.nextLoadLevel=u,this.loadedmetadata=!1}s>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+s.toFixed(3)),r=s),this.state=Et,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=mr},a.stopLoad=function(){this._forceStartLoad=!1,d.prototype.stopLoad.call(this)},a.doTick=function(){switch(this.state){case Et:this.doTickIdle();break;case Br:var r,s=this.levels,l=this.level,u=s==null||(r=s[l])===null||r===void 0?void 0:r.details;if(u&&(!u.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(u))break;this.state=Et;break}break;case Ir:var c,v=self.performance.now(),m=this.retryDate;(!m||v>=m||(c=this.media)!==null&&c!==void 0&&c.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=Et)}this.onTickEnd()},a.onTickEnd=function(){d.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},a.doTickIdle=function(){var r=this.hls,s=this.levelLastLoaded,l=this.levels,u=this.media,c=r.config,v=r.nextLoadLevel;if(s!==null&&(u||!this.startFragRequested&&c.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&l&&l[v]){var m=l[v],_=this.getMainFwdBufferInfo();if(_!==null){var S=this.getLevelDetails();if(S&&this._streamEnded(_,S)){var x={};return this.altAudio&&(x.type="video"),this.hls.trigger(p.Events.BUFFER_EOS,x),void(this.state=Wr)}this.level=r.nextLoadLevel=v;var I=m.details;if(!I||this.state===Br||I.live&&this.levelLastLoaded!==v)return this.level=v,void(this.state=Br);if(!(_.len>=this.getMaxBufferLength(m.maxBitrate))){this.backtrackFragment&&this.backtrackFragment.start>_.end&&(this.backtrackFragment=null);var j=this.backtrackFragment?this.backtrackFragment.start:_.end,ae=this.getNextFragment(j,I);if(this.couldBacktrack&&!this.fragPrevious&&ae&&ae.sn!=="initSegment"&&this.fragmentTracker.getState(ae)!==Ue.OK){var me,de=((me=this.backtrackFragment)!=null?me:ae).sn-I.startSN,_e=I.fragments[de-1];_e&&ae.cc===_e.cc&&(ae=_e,this.fragmentTracker.removeFragment(_e))}else this.backtrackFragment&&_.len&&(this.backtrackFragment=null);if(ae&&this.fragmentTracker.getState(ae)===Ue.OK&&this.nextLoadPosition>j){var Ke=this.audioOnly&&!this.altAudio?z.ElementaryStreamTypes.AUDIO:z.ElementaryStreamTypes.VIDEO,ze=(Ke===z.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;ze&&this.afterBufferFlushed(ze,Ke,pe.PlaylistLevelType.MAIN),ae=this.getNextFragment(this.nextLoadPosition,I)}ae&&(!ae.initSegment||ae.initSegment.data||this.bitrateTest||(ae=ae.initSegment),this.loadFragment(ae,I,j))}}}},a.loadFragment=function(r,s,l){var u,c=this.fragmentTracker.getState(r);this.fragCurrent=r,c===Ue.NOT_LOADED?r.sn==="initSegment"?this._loadInitSegment(r,s):this.bitrateTest?(this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r,s)):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,s,l)):c===Ue.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((u=this.media)===null||u===void 0?void 0:u.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},a.getAppendedFrag=function(r){var s=this.fragmentTracker.getAppendedFrag(r,pe.PlaylistLevelType.MAIN);return s&&"fragment"in s?s.fragment:s},a.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,pe.PlaylistLevelType.MAIN)},a.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},a.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},a.nextLevelSwitch=function(){var r=this.levels,s=this.media;if(s!=null&&s.readyState){var l,u=this.getAppendedFrag(s.currentTime);if(u&&u.start>1&&this.flushMainBuffer(0,u.start-1),!s.paused&&r){var c=r[this.hls.nextLoadLevel],v=this.fragLastKbps;l=v&&this.fragCurrent?this.fragCurrent.duration*c.maxBitrate/(1e3*v)+1:0}else l=0;var m=this.getBufferedFrag(s.currentTime+l);if(m){var _=this.followingBufferedFrag(m);if(_){this.abortCurrentFrag();var S=_.maxStartPTS?_.maxStartPTS:_.start,x=_.duration,I=Math.max(m.end,S+Math.min(Math.max(x-this.config.maxFragLookUpTolerance,.5*x),.75*x));this.flushMainBuffer(I,Number.POSITIVE_INFINITY)}}}},a.abortCurrentFrag=function(){var r=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,r&&r.abortRequests(),this.state){case Fi:case Nr:case Ir:case br:case Ur:this.state=Et}this.nextLoadPosition=this.getLoadPosition()},a.flushMainBuffer=function(r,s){d.prototype.flushMainBuffer.call(this,r,s,this.altAudio?"video":null)},a.onMediaAttached=function(r,s){d.prototype.onMediaAttached.call(this,r,s);var l=s.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),l.addEventListener("playing",this.onvplaying),l.addEventListener("seeked",this.onvseeked),this.gapController=new Bi(this.config,l,this.fragmentTracker,this.hls)},a.onMediaDetaching=function(){var r=this.media;r&&this.onvplaying&&this.onvseeked&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),d.prototype.onMediaDetaching.call(this)},a.onMediaPlaying=function(){this.tick()},a.onMediaSeeked=function(){var r=this.media,s=r?r.currentTime:null;(0,R.isFiniteNumber)(s)&&this.log("Media seeked to "+s.toFixed(3)),this.tick()},a.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},a.onManifestParsed=function(r,s){var l,u,c,v=!1,m=!1;s.levels.forEach(function(_){(l=_.audioCodec)&&(l.indexOf("mp4a.40.2")!==-1&&(v=!0),l.indexOf("mp4a.40.5")!==-1&&(m=!0))}),this.audioCodecSwitch=v&&m&&typeof((c=ai())==null||(u=c.prototype)===null||u===void 0?void 0:u.changeType)!="function",this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=s.levels,this.startFragRequested=!1},a.onLevelLoading=function(r,s){var l=this.levels;if(l&&this.state===Et){var u=l[s.level];(!u.details||u.details.live&&this.levelLastLoaded!==s.level||this.waitForCdnTuneIn(u.details))&&(this.state=Br)}},a.onLevelLoaded=function(r,s){var l,u=this.levels,c=s.level,v=s.details,m=v.totalduration;if(u){this.log("Level "+c+" loaded ["+v.startSN+","+v.endSN+"], cc ["+v.startCC+", "+v.endCC+"] duration:"+m);var _=this.fragCurrent;!_||this.state!==Nr&&this.state!==Ir||_.level!==s.level&&_.loader&&(this.state=Et,this.backtrackFragment=null,_.abortRequests());var S=u[c],x=0;if(v.live||(l=S.details)!==null&&l!==void 0&&l.live){if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed)return;x=this.alignPlaylists(v,S.details)}if(S.details=v,this.levelLastLoaded=c,this.hls.trigger(p.Events.LEVEL_UPDATED,{details:v,level:c}),this.state===Br){if(this.waitForCdnTuneIn(v))return;this.state=Et}this.startFragRequested?v.live&&this.synchronizeToLiveEdge(v):this.setStartPosition(v,x),this.tick()}else this.warn("Levels were reset while loading level "+c)},a._handleFragmentLoadProgress=function(r){var s,l=r.frag,u=r.part,c=r.payload,v=this.levels;if(v){var m=v[l.level],_=m.details;if(_){var S=m.videoCodec,x=_.PTSKnown||!_.live,I=(s=l.initSegment)===null||s===void 0?void 0:s.data,j=this._getAudioCodec(m),ae=this.transmuxer=this.transmuxer||new mi(this.hls,pe.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),me=u?u.index:-1,de=me!==-1,_e=new vi(l.level,l.sn,l.stats.chunkCount,c.byteLength,me,de),Ke=this.initPTS[l.cc];ae.push(c,I,j,S,l,u,_.totalduration,x,_e,Ke)}else this.warn("Dropping fragment "+l.sn+" of level "+l.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered")},a.onAudioTrackSwitching=function(r,s){var l=this.altAudio,u=!!s.url,c=s.id;if(!u){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var v=this.fragCurrent;v&&(this.log("Switching to main audio track, cancel main fragment load"),v.abortRequests()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var m=this.hls;l&&m.trigger(p.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),m.trigger(p.Events.AUDIO_TRACK_SWITCHED,{id:c})}},a.onAudioTrackSwitched=function(r,s){var l=s.id,u=!!this.hls.audioTracks[l].url;if(u){var c=this.videoBuffer;c&&this.mediaBuffer!==c&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=c)}this.altAudio=u,this.tick()},a.onBufferCreated=function(r,s){var l,u,c=s.tracks,v=!1;for(var m in c){var _=c[m];if(_.id==="main"){if(u=m,l=_,m==="video"){var S=c[m];S&&(this.videoBuffer=S.buffer)}}else v=!0}v&&l?(this.log("Alternate track found, use "+u+".buffered to schedule main fragment loading"),this.mediaBuffer=l.buffer):this.mediaBuffer=this.media},a.onFragBuffered=function(r,s){var l=s.frag,u=s.part;if(!l||l.type===pe.PlaylistLevelType.MAIN){if(this.fragContextChanged(l))return this.warn("Fragment "+l.sn+(u?" p: "+u.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Ur&&(this.state=Et));var c=u?u.stats:l.stats;this.fragLastKbps=Math.round(8*c.total/(c.buffering.end-c.loading.first)),l.sn!=="initSegment"&&(this.fragPrevious=l),this.fragBufferedComplete(l,u)}},a.onError=function(r,s){if(s.type!==w.ErrorTypes.KEY_SYSTEM_ERROR)switch(s.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.FRAG_PARSING_ERROR:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(pe.PlaylistLevelType.MAIN,s);break;case w.ErrorDetails.LEVEL_LOAD_ERROR:case w.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==Sr&&(s.fatal?(this.warn(""+s.details),this.state=Sr):s.levelRetry||this.state!==Br||(this.state=Et));break;case w.ErrorDetails.BUFFER_FULL_ERROR:if(s.parent==="main"&&(this.state===br||this.state===Ur)){var l=!0,u=this.getFwdBufferInfo(this.media,pe.PlaylistLevelType.MAIN);u&&u.len>.5&&(l=!this.reduceMaxBufferLength(u.len)),l&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}else this.onFragmentOrKeyLoadError(pe.PlaylistLevelType.MAIN,s)},a.checkBuffer=function(){var r=this.media,s=this.gapController;if(r&&s&&r.readyState){if(this.loadedmetadata||!Mt.getBuffered(r).length){var l=this.state!==Et?this.fragCurrent:null;s.poll(this.lastCurrentTime,l)}this.lastCurrentTime=r.currentTime}},a.onFragLoadEmergencyAborted=function(){this.state=Et,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},a.onBufferFlushed=function(r,s){var l=s.type;if(l!==z.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var u=(l===z.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(u,l,pe.PlaylistLevelType.MAIN)}},a.onLevelsUpdated=function(r,s){this.levels=s.levels},a.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},a.seekToStartPos=function(){var r=this.media;if(r){var s=r.currentTime,l=this.startPosition;if(l>=0&&s<l){if(r.seeking)return void this.log("could not seek to "+l+", already seeking at "+s);var u=Mt.getBuffered(r),c=(u.length?u.start(0):0)-l;c>0&&(c<this.config.maxBufferHole||c<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+c+" to match buffer start"),l+=c,this.startPosition=l),this.log("seek to target start position "+l+" from current time "+s),r.currentTime=l}}},a._getAudioCodec=function(r){var s=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&s&&(this.log("Swapping audio codec"),s=s.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),s},a._loadBitrateTestFrag=function(r,s){var l=this;r.bitrateTest=!0,this._doFragLoad(r,s).then(function(u){var c=l.hls;if(u&&!c.nextLoadLevel&&!l.fragContextChanged(r)){l.fragLoadError=0,l.state=Et,l.startFragRequested=!1,l.bitrateTest=!1;var v=r.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),c.trigger(p.Events.FRAG_LOADED,u),r.bitrateTest=!1}})},a._handleTransmuxComplete=function(r){var s,l="main",u=this.hls,c=r.remuxResult,v=r.chunkMeta,m=this.getCurrentContext(v);if(!m)return this.warn("The loading context changed while buffering fragment "+v.sn+" of level "+v.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(v.level);var _=m.frag,S=m.part,x=m.level,I=c.video,j=c.text,ae=c.id3,me=c.initSegment,de=x.details,_e=this.altAudio?void 0:c.audio;if(!this.fragContextChanged(_)){if(this.state=br,me){me.tracks&&(this._bufferInitSegment(x,me.tracks,_,v),u.trigger(p.Events.FRAG_PARSING_INIT_SEGMENT,{frag:_,id:l,tracks:me.tracks}));var Ke=me.initPTS,ze=me.timescale;(0,R.isFiniteNumber)(Ke)&&(this.initPTS[_.cc]=Ke,u.trigger(p.Events.INIT_PTS_FOUND,{frag:_,id:l,initPTS:Ke,timescale:ze}))}if(I&&c.independent!==!1){if(de){var Ee=I.startPTS,Ge=I.endPTS,Fe=I.startDTS,ct=I.endDTS;if(S)S.elementaryStreams[I.type]={startPTS:Ee,endPTS:Ge,startDTS:Fe,endDTS:ct};else if(I.firstKeyFrame&&I.independent&&v.id===1&&(this.couldBacktrack=!0),I.dropped&&I.independent){var Ct=this.getMainFwdBufferInfo();if((Ct?Ct.end:this.getLoadPosition())+this.config.maxBufferHole<(I.firstKeyFramePTS?I.firstKeyFramePTS:Ee)-this.config.maxBufferHole)return void this.backtrack(_);_.setElementaryStreamInfo(I.type,_.start,Ge,_.start,ct,!0)}_.setElementaryStreamInfo(I.type,Ee,Ge,Fe,ct),this.backtrackFragment&&(this.backtrackFragment=_),this.bufferFragmentData(I,_,S,v)}}else if(c.independent===!1)return void this.backtrack(_);if(_e){var ft=_e.startPTS,Tt=_e.endPTS,At=_e.startDTS,$t=_e.endDTS;S&&(S.elementaryStreams[z.ElementaryStreamTypes.AUDIO]={startPTS:ft,endPTS:Tt,startDTS:At,endDTS:$t}),_.setElementaryStreamInfo(z.ElementaryStreamTypes.AUDIO,ft,Tt,At,$t),this.bufferFragmentData(_e,_,S,v)}if(de&&ae!=null&&(s=ae.samples)!==null&&s!==void 0&&s.length){var Xt={id:l,frag:_,details:de,samples:ae.samples};u.trigger(p.Events.FRAG_PARSING_METADATA,Xt)}if(de&&j){var Gt={id:l,frag:_,details:de,samples:j.samples};u.trigger(p.Events.FRAG_PARSING_USERDATA,Gt)}}},a._bufferInitSegment=function(r,s,l,u){var c=this;if(this.state===br){this.audioOnly=!!s.audio&&!s.video,this.altAudio&&!this.audioOnly&&delete s.audio;var v=s.audio,m=s.video,_=s.audiovideo;if(v){var S=r.audioCodec,x=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(S&&(S=S.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),v.metadata.channelCount!==1&&x.indexOf("firefox")===-1&&(S="mp4a.40.5")),x.indexOf("android")!==-1&&v.container!=="audio/mpeg"&&(S="mp4a.40.2",this.log("Android: force audio codec to "+S)),r.audioCodec&&r.audioCodec!==S&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+S+'"'),v.levelCodec=S,v.id="main",this.log("Init audio buffer, container:"+v.container+", codecs[selected/level/parsed]=["+(S||"")+"/"+(r.audioCodec||"")+"/"+v.codec+"]")}m&&(m.levelCodec=r.videoCodec,m.id="main",this.log("Init video buffer, container:"+m.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+m.codec+"]")),_&&this.log("Init audiovideo buffer, container:"+_.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+_.codec+"]"),this.hls.trigger(p.Events.BUFFER_CODECS,s),Object.keys(s).forEach(function(I){var j=s[I].initSegment;j!=null&&j.byteLength&&c.hls.trigger(p.Events.BUFFER_APPENDING,{type:I,data:j,frag:l,part:null,chunkMeta:u,parent:l.type})}),this.tick()}},a.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,pe.PlaylistLevelType.MAIN)},a.backtrack=function(r){this.couldBacktrack=!0,this.backtrackFragment=r,this.resetTransmuxer(),this.flushBufferGap(r),this.fragmentTracker.removeFragment(r),this.fragPrevious=null,this.nextLoadPosition=r.start,this.state=Et},a.checkFragmentChanged=function(){var r=this.media,s=null;if(r&&r.readyState>1&&r.seeking===!1){var l=r.currentTime;if(Mt.isBuffered(r,l)?s=this.getAppendedFrag(l):Mt.isBuffered(r,l+.1)&&(s=this.getAppendedFrag(l+.1)),s){this.backtrackFragment=null;var u=this.fragPlaying,c=s.level;u&&s.sn===u.sn&&u.level===c&&s.urlId===u.urlId||(this.fragPlaying=s,this.hls.trigger(p.Events.FRAG_CHANGED,{frag:s}),u&&u.level===c||this.hls.trigger(p.Events.LEVEL_SWITCHED,{level:c}))}}},i=t,(n=[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentFrag",get:function(){var r=this.media;return r?this.fragPlaying||this.getAppendedFrag(r.currentTime):null}},{key:"currentProgramDateTime",get:function(){var r=this.media;if(r){var s=r.currentTime,l=this.currentFrag;if(l&&(0,R.isFiniteNumber)(s)&&(0,R.isFiniteNumber)(l.programDateTime)){var u=l.programDateTime+1e3*(s-l.start);return new Date(u)}}return null}},{key:"currentLevel",get:function(){var r=this.currentFrag;return r?r.level:-1}},{key:"nextBufferedFrag",get:function(){var r=this.currentFrag;return r?this.followingBufferedFrag(r):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&Hr(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(ii);let oi=function(){function d(e,t,i){t===void 0&&(t=0),i===void 0&&(i=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}var o=d.prototype;return o.sample=function(e,t){var i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e},o.getTotalWeight=function(){return this.totalWeight_},o.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},d}(),rn=function(){function d(e,t,i){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new oi(e),this.fast_=new oi(t)}var o=d.prototype;return o.update=function(e,t){var i=this.slow_,n=this.fast_;this.slow_.halfLife!==e&&(this.slow_=new oi(e,i.getEstimate(),i.getTotalWeight())),this.fast_.halfLife!==t&&(this.fast_=new oi(t,n.getEstimate(),n.getTotalWeight()))},o.sample=function(e,t){var i=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/i;this.fast_.sample(i,n),this.slow_.sample(i,n)},o.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},o.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},o.destroy=function(){},d}();function nn(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}let an=function(){function d(i){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=i;var n=i.config;this.bwEstimator=new rn(n.abrEwmaSlowVoD,n.abrEwmaFastVoD,n.abrEwmaDefaultEstimate),this.registerListeners()}var o,e,t=d.prototype;return t.registerListeners=function(){var i=this.hls;i.on(p.Events.FRAG_LOADING,this.onFragLoading,this),i.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this),i.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(p.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){var i=this.hls;i.off(p.Events.FRAG_LOADING,this.onFragLoading,this),i.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this),i.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(p.Events.ERROR,this.onError,this)},t.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},t.onFragLoading=function(i,n){var a,r=n.frag;r.type===pe.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=r,this.partCurrent=(a=n.part)!=null?a:null,this.timer=self.setInterval(this.onCheck,100)))},t.onLevelLoaded=function(i,n){var a=this.hls.config;n.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD)},t._abandonRulesCheck=function(){var i=this.fragCurrent,n=this.partCurrent,a=this.hls,r=a.autoLevelEnabled,s=a.media;if(i&&s){var l=n?n.stats:i.stats,u=n?n.duration:i.duration;if(l.aborted||l.loaded&&l.loaded===l.total||i.level===0)return this.clearTimer(),void(this._nextAutoLevel=-1);if(r&&!s.paused&&s.playbackRate&&s.readyState){var c=a.mainForwardBufferInfo;if(c!==null){var v=performance.now()-l.loading.start,m=Math.abs(s.playbackRate);if(!(v<=500*u/m)){var _=l.loaded&&l.loading.first,S=this.bwEstimator.getEstimate(),x=a.levels,I=a.minAutoLevel,j=x[i.level],ae=l.total||Math.max(l.loaded,Math.round(u*j.maxBitrate/8)),me=_?1e3*l.loaded/v:0,de=me?(ae-l.loaded)/me:8*ae/S,_e=c.len/m;if(!(de<=_e)){var Ke,ze=Number.POSITIVE_INFINITY;for(Ke=i.level-1;Ke>I;Ke--){var Ee=x[Ke].maxBitrate;if((ze=me?u*Ee/(6.4*me):u*Ee/S)<_e)break}ze>=de||(k.logger.warn("Fragment "+i.sn+(n?" part "+n.index:"")+" of level "+i.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+Ke+`
|
|
16
|
-
|
|
17
|
-
Estimated load time for current fragment: `+
|
|
18
|
-
Estimated load time for
|
|
19
|
-
Time to underbuffer: `+_e.toFixed(3)+" s"),a.nextLoadLevel=Ke,_&&this.bwEstimator.sample(v,l.loaded),this.clearTimer(),(i.loader||i.keyLoader)&&(this.fragCurrent=this.partCurrent=null,i.abortRequests()),a.trigger(p.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:n,stats:l}))}}}}}},t.onFragLoaded=function(i,n){var a=n.frag,r=n.part;if(a.type===pe.PlaylistLevelType.MAIN&&(0,R.isFiniteNumber)(a.sn)){var s=r?r.stats:a.stats,l=r?r.duration:a.duration;if(this.clearTimer(),this.lastLoadedFragLevel=a.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[a.level],c=(u.loaded?u.loaded.bytes:0)+s.loaded,v=(u.loaded?u.loaded.duration:0)+l;u.loaded={bytes:c,duration:v},u.realBitrate=Math.round(8*c/v)}if(a.bitrateTest){var m={stats:s,frag:a,part:r,id:a.type};this.onFragBuffered(p.Events.FRAG_BUFFERED,m)}}},t.onFragBuffered=function(i,n){var a=n.frag,r=n.part,s=r?r.stats:a.stats;if(!s.aborted&&a.type===pe.PlaylistLevelType.MAIN&&a.sn!=="initSegment"){var l=s.parsing.end-s.loading.start;this.bwEstimator.sample(l,s.loaded),s.bwEstimate=this.bwEstimator.getEstimate(),a.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}},t.onError=function(i,n){var a;if(((a=n.frag)===null||a===void 0?void 0:a.type)===pe.PlaylistLevelType.MAIN){if(n.type===w.ErrorTypes.KEY_SYSTEM_ERROR)return void this.clearTimer();switch(n.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:this.clearTimer()}}},t.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},t.getNextABRAutoLevel=function(){var i=this.fragCurrent,n=this.partCurrent,a=this.hls,r=a.maxAutoLevel,s=a.config,l=a.minAutoLevel,u=a.media,c=n?n.duration:i?i.duration:0,v=u&&u.playbackRate!==0?Math.abs(u.playbackRate):1,m=this.bwEstimator?this.bwEstimator.getEstimate():s.abrEwmaDefaultEstimate,_=a.mainForwardBufferInfo,S=(_?_.len:0)/v,x=this.findBestLevel(m,l,r,S,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(x>=0)return x;k.logger.trace((S?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var I=c?Math.min(c,s.maxStarvationDelay):s.maxStarvationDelay,j=s.abrBandWidthFactor,ae=s.abrBandWidthUpFactor;if(!S){var me=this.bitrateTestDelay;me&&(I=(c?Math.min(c,s.maxLoadingDelay):s.maxLoadingDelay)-me,k.logger.trace("bitrate test took "+Math.round(1e3*me)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*I)+" ms"),j=ae=1)}return x=this.findBestLevel(m,l,r,S+I,j,ae),Math.max(x,0)},t.findBestLevel=function(i,n,a,r,s,l){for(var u,c=this.fragCurrent,v=this.partCurrent,m=this.lastLoadedFragLevel,_=this.hls.levels,S=_[m],x=!(S==null||(u=S.details)===null||u===void 0||!u.live),I=S==null?void 0:S.codecSet,j=v?v.duration:c?c.duration:0,ae=a;ae>=n;ae--){var me=_[ae];if(me&&(!I||me.codecSet===I)){var de,_e=me.details,Ke=(v?_e==null?void 0:_e.partTarget:_e==null?void 0:_e.averagetargetduration)||j;de=ae<=m?s*i:l*i;var ze=_[ae].maxBitrate,Ee=ze*Ke/de;if(k.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+ae+"/"+Math.round(de)+"/"+ze+"/"+Ke+"/"+r+"/"+Ee),de>ze&&(Ee===0||!(0,R.isFiniteNumber)(Ee)||x&&!this.bitrateTestDelay||Ee<r))return ae}}return-1},o=d,(e=[{key:"nextAutoLevel",get:function(){var i=this._nextAutoLevel,n=this.bwEstimator;if(i!==-1&&!n.canEstimate())return i;var a=this.getNextABRAutoLevel();return i!==-1&&this.hls.levels[a].loadError?i:(i!==-1&&(a=Math.min(i,a)),a)},set:function(i){this._nextAutoLevel=i}}])&&nn(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();var Hi=function(){function d(){this.chunks=[],this.dataLength=0}var o=d.prototype;return o.push=function(e){this.chunks.push(e),this.dataLength+=e.length},o.flush=function(){var e,t=this.chunks,i=this.dataLength;return t.length?(e=t.length===1?t[0]:function(n,a){for(var r=new Uint8Array(a),s=0,l=0;l<n.length;l++){var u=n[l];r.set(u,s),s+=u.length}return r}(t,i),this.reset(),e):new Uint8Array(0)},o.reset=function(){this.chunks.length=0,this.dataLength=0},d}();function li(){return li=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},li.apply(this,arguments)}function Ei(d,o){return Ei=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ei(d,o)}var ui=function(d){var o,e;function t(n,a,r){var s;return(s=d.call(this,n,a,r,"[audio-stream-controller]")||this).videoBuffer=null,s.videoTrackCC=-1,s.waitingVideoCC=-1,s.audioSwitch=!1,s.trackId=-1,s.waitingData=null,s.mainDetails=null,s.bufferFlushed=!1,s.cachedTrackLoadedData=null,s._registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ei(o,e);var i=t.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var n=this.hls;n.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(p.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.on(p.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(p.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(p.Events.ERROR,this.onError,this),n.on(p.Events.BUFFER_RESET,this.onBufferReset,this),n.on(p.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(p.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var n=this.hls;n.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(p.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.off(p.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(p.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(p.Events.ERROR,this.onError,this),n.off(p.Events.BUFFER_RESET,this.onBufferReset,this),n.off(p.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(p.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i.onInitPtsFound=function(n,a){var r=a.frag,s=a.id,l=a.initPTS;if(s==="main"){var u=r.cc;this.initPTS[r.cc]=l,this.log("InitPTS for cc: "+u+" found from main: "+l),this.videoTrackCC=u,this.state===Pr&&this.tick()}},i.startLoad=function(n){if(!this.levels)return this.startPosition=n,void(this.state=mr);var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,a>0&&n===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),n=a,this.state=Et):(this.loadedmetadata=!1,this.state=ri),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()},i.doTick=function(){switch(this.state){case Et:this.doTickIdle();break;case ri:var n,a=this.levels,r=this.trackId,s=a==null||(n=a[r])===null||n===void 0?void 0:n.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=Pr}break;case Ir:var l,u=performance.now(),c=this.retryDate;(!c||u>=c||(l=this.media)!==null&&l!==void 0&&l.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Et);break;case Pr:var v=this.waitingData;if(v){var m=v.frag,_=v.part,S=v.cache,x=v.complete;if(this.initPTS[m.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Nr;var I={frag:m,part:_,payload:S.flush(),networkDetails:null};this._handleFragmentLoadProgress(I),x&&d.prototype._handleFragmentLoadComplete.call(this,I)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+m.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var j=this.getLoadPosition(),ae=Mt.bufferInfo(this.mediaBuffer,j,this.config.maxBufferHole);ti(ae.end,this.config.maxFragLookUpTolerance,m)<0&&(this.log("Waiting fragment cc ("+m.cc+") @ "+m.start+" cancelled because another fragment at "+ae.end+" is needed"),this.clearWaitingFragment())}}else this.state=Et}this.onTickEnd()},i.clearWaitingFragment=function(){var n=this.waitingData;n&&(this.fragmentTracker.removeFragment(n.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Et)},i.resetLoadingState=function(){this.clearWaitingFragment(),d.prototype.resetLoadingState.call(this)},i.onTickEnd=function(){var n=this.media;n&&n.readyState&&(this.lastCurrentTime=n.currentTime)},i.doTickIdle=function(){var n=this.hls,a=this.levels,r=this.media,s=this.trackId,l=n.config;if(a&&a[s]&&(r||!this.startFragRequested&&l.startFragPrefetch)){var u=a[s].details;if(!u||u.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(u))this.state=ri;else{var c=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&c&&(this.bufferFlushed=!1,this.afterBufferFlushed(c,z.ElementaryStreamTypes.AUDIO,pe.PlaylistLevelType.AUDIO));var v=this.getFwdBufferInfo(c,pe.PlaylistLevelType.AUDIO);if(v!==null){var m=this.audioSwitch;if(!m&&this._streamEnded(v,u))return n.trigger(p.Events.BUFFER_EOS,{type:"audio"}),void(this.state=Wr);var _=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,pe.PlaylistLevelType.MAIN);if(!(v.len>=this.getMaxBufferLength(_==null?void 0:_.len))||m){var S=u.fragments[0].start,x=v.end;if(m&&r){var I=this.getLoadPosition();x=I,u.PTSKnown&&I<S&&(v.end>S||v.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=S+.05)}if(!(_&&x>_.end+u.targetduration)&&(_&&_.len||!v.len)){var j=this.getNextFragment(x,u);j?this.loadFragment(j,u,x):this.bufferFlushed=!0}}}}}},i.getMaxBufferLength=function(n){var a=d.prototype.getMaxBufferLength.call(this);return n?Math.max(a,n):a},i.onMediaDetaching=function(){this.videoBuffer=null,d.prototype.onMediaDetaching.call(this)},i.onAudioTracksUpdated=function(n,a){var r=a.audioTracks;this.resetTransmuxer(),this.levels=r.map(function(s){return new O(s)})},i.onAudioTrackSwitching=function(n,a){var r=!!a.url;this.trackId=a.id;var s=this.fragCurrent;s&&s.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=Et):this.state=mr,this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},i.onLevelLoaded=function(n,a){this.mainDetails=a.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(p.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},i.onAudioTrackLoaded=function(n,a){var r;if(this.mainDetails!=null){var s=this.levels,l=a.details,u=a.id;if(s){this.log("Track "+u+" loaded ["+l.startSN+","+l.endSN+"],duration:"+l.totalduration);var c=s[u],v=0;if(l.live||(r=c.details)!==null&&r!==void 0&&r.live){var m=this.mainDetails;if(l.fragments[0]||(l.deltaUpdateFailed=!0),l.deltaUpdateFailed||!m)return;!c.details&&l.hasProgramDateTime&&m.hasProgramDateTime?(xi(l,m),v=l.fragments[0].start):v=this.alignPlaylists(l,c.details)}c.details=l,this.levelLastLoaded=u,this.startFragRequested||!this.mainDetails&&l.live||this.setStartPosition(c.details,v),this.state!==ri||this.waitForCdnTuneIn(l)||(this.state=Et),this.tick()}else this.warn("Audio tracks were reset while loading level "+u)}else this.cachedTrackLoadedData=a},i._handleFragmentLoadProgress=function(n){var a,r=n.frag,s=n.part,l=n.payload,u=this.config,c=this.trackId,v=this.levels;if(v){var m=v[c],_=m.details,S=u.defaultAudioCodec||m.audioCodec||"mp4a.40.2",x=this.transmuxer;x||(x=this.transmuxer=new mi(this.hls,pe.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var I=this.initPTS[r.cc],j=(a=r.initSegment)===null||a===void 0?void 0:a.data;if(I!==void 0){var ae=s?s.index:-1,me=ae!==-1,de=new vi(r.level,r.sn,r.stats.chunkCount,l.byteLength,ae,me);x.push(l,j,S,"",r,s,_.totalduration,!1,de,I)}else this.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+_.startSN+" ,"+_.endSN+"],track "+c),(this.waitingData=this.waitingData||{frag:r,part:s,cache:new Hi,complete:!1}).cache.push(new Uint8Array(l)),this.waitingVideoCC=this.videoTrackCC,this.state=Pr}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},i._handleFragmentLoadComplete=function(n){this.waitingData?this.waitingData.complete=!0:d.prototype._handleFragmentLoadComplete.call(this,n)},i.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},i.onBufferCreated=function(n,a){var r=a.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer||null)},i.onFragBuffered=function(n,a){var r,s=a.frag,l=a.part;s.type===pe.PlaylistLevelType.AUDIO?this.fragContextChanged(s)?this.warn("Fragment "+s.sn+(l?" p: "+l.index:"")+" of level "+s.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):(s.sn!=="initSegment"&&(this.fragPrevious=s,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(p.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(s,l)):this.loadedmetadata||s.type!==pe.PlaylistLevelType.MAIN||(r=this.videoBuffer||this.media)!==null&&r!==void 0&&r.buffered.length&&(this.loadedmetadata=!0)},i.onError=function(n,a){if(a.type!==w.ErrorTypes.KEY_SYSTEM_ERROR)switch(a.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.FRAG_PARSING_ERROR:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(pe.PlaylistLevelType.AUDIO,a);break;case w.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case w.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==Sr&&this.state!==mr&&(this.state=a.fatal?Sr:Et,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case w.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===br||this.state===Ur)){var r=!0,s=this.getFwdBufferInfo(this.mediaBuffer,pe.PlaylistLevelType.AUDIO);s&&s.len>.5&&(r=!this.reduceMaxBufferLength(s.len)),r&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}else this.onFragmentOrKeyLoadError(pe.PlaylistLevelType.AUDIO,a)},i.onBufferFlushed=function(n,a){a.type===z.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0,this.state===Wr&&(this.state=Et))},i._handleTransmuxComplete=function(n){var a,r="audio",s=this.hls,l=n.remuxResult,u=n.chunkMeta,c=this.getCurrentContext(u);if(!c)return this.warn("The loading context changed while buffering fragment "+u.sn+" of level "+u.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(u.level);var v=c.frag,m=c.part,_=c.level.details,S=l.audio,x=l.text,I=l.id3,j=l.initSegment;if(!this.fragContextChanged(v)&&_){if(this.state=br,this.audioSwitch&&S&&this.completeAudioSwitch(),j!=null&&j.tracks&&(this._bufferInitSegment(j.tracks,v,u),s.trigger(p.Events.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:r,tracks:j.tracks})),S){var ae=S.startPTS,me=S.endPTS,de=S.startDTS,_e=S.endDTS;m&&(m.elementaryStreams[z.ElementaryStreamTypes.AUDIO]={startPTS:ae,endPTS:me,startDTS:de,endDTS:_e}),v.setElementaryStreamInfo(z.ElementaryStreamTypes.AUDIO,ae,me,de,_e),this.bufferFragmentData(S,v,m,u)}if(I!=null&&(a=I.samples)!==null&&a!==void 0&&a.length){var Ke=li({id:r,frag:v,details:_},I);s.trigger(p.Events.FRAG_PARSING_METADATA,Ke)}if(x){var ze=li({id:r,frag:v,details:_},x);s.trigger(p.Events.FRAG_PARSING_USERDATA,ze)}}},i._bufferInitSegment=function(n,a,r){if(this.state===br){n.video&&delete n.video;var s=n.audio;if(s){s.levelCodec=s.codec,s.id="audio",this.log("Init audio buffer, container:"+s.container+", codecs[parsed]=["+s.codec+"]"),this.hls.trigger(p.Events.BUFFER_CODECS,n);var l=s.initSegment;if(l!=null&&l.byteLength){var u={type:"audio",frag:a,part:null,chunkMeta:r,parent:a.type,data:l};this.hls.trigger(p.Events.BUFFER_APPENDING,u)}this.tick()}}},i.loadFragment=function(n,a,r){var s=this.fragmentTracker.getState(n);this.fragCurrent=n,(this.audioSwitch||s===Ue.NOT_LOADED||s===Ue.PARTIAL)&&(n.sn==="initSegment"?this._loadInitSegment(n,a):a.live&&!(0,R.isFiniteNumber)(this.initPTS[n.cc])?(this.log("Waiting for video PTS in continuity counter "+n.cc+" of live stream before loading audio fragment "+n.sn+" of level "+this.trackId),this.state=Pr):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,n,a,r)))},i.completeAudioSwitch=function(){var n=this.hls,a=this.media,r=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,n.trigger(p.Events.AUDIO_TRACK_SWITCHED,{id:r})},t}(ii);let Ti=ui;function Gi(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Qr(d,o){return Qr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Qr(d,o)}let sn=function(d){var o,e;function t(r){var s;return(s=d.call(this,r,"[audio-track-controller]")||this).tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.trackName="",s.selectDefaultTrack=!0,s.registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Qr(o,e);var i,n,a=t.prototype;return a.registerListeners=function(){var r=this.hls;r.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(p.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.on(p.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var r=this.hls;r.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(p.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.off(p.Events.ERROR,this.onError,this)},a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,d.prototype.destroy.call(this)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},a.onManifestParsed=function(r,s){this.tracks=s.audioTracks||[]},a.onAudioTrackLoaded=function(r,s){var l=s.id,u=s.details,c=this.tracksInGroup[l];if(c){var v=c.details;c.details=s.details,this.log("audioTrack "+l+" loaded ["+u.startSN+"-"+u.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,v))}else this.warn("Invalid audio track id "+l)},a.onLevelLoading=function(r,s){this.switchLevel(s.level)},a.onLevelSwitching=function(r,s){this.switchLevel(s.level)},a.switchLevel=function(r){var s=this.hls.levels[r];if(s!=null&&s.audioGroupIds){var l=s.audioGroupIds[s.urlId];if(this.groupId!==l){this.groupId=l;var u=this.tracks.filter(function(v){return!l||v.groupId===l});this.selectDefaultTrack&&!u.some(function(v){return v.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=u;var c={audioTracks:u};this.log("Updating audio tracks, "+u.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(p.Events.AUDIO_TRACKS_UPDATED,c),this.selectInitialTrack()}}},a.onError=function(r,s){d.prototype.onError.call(this,r,s),!s.fatal&&s.context&&s.context.type===pe.PlaylistContextType.AUDIO_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},a.setAudioTrack=function(r){var s=this.tracksInGroup;if(r<0||r>=s.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var l=s[this.trackId];this.log("Now switching to audio-track index "+r);var u=s[r],c=u.id,v=u.groupId,m=v===void 0?"":v,_=u.name,S=u.type,x=u.url;if(this.trackId=r,this.trackName=_,this.selectDefaultTrack=!1,this.hls.trigger(p.Events.AUDIO_TRACK_SWITCHING,{id:c,groupId:m,name:_,type:S,url:x}),!u.details||u.details.live){var I=this.switchParams(u.url,l==null?void 0:l.details);this.loadPlaylist(I)}}},a.selectInitialTrack=function(){this.tracksInGroup;var r=this.trackName,s=this.findTrackId(r)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},a.findTrackId=function(r){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var u=s[l];if((!this.selectDefaultTrack||u.default)&&(!r||r===u.name))return u.id}return-1},a.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,u=s.groupId,c=s.url;if(r)try{c=r.addDirectives(c)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(p.Events.AUDIO_TRACK_LOADING,{url:c,id:l,groupId:u,deliveryDirectives:r||null})}},i=t,(n=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1,this.setAudioTrack(r)}}])&&Gi(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Le);function on(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function bi(d,o){return bi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},bi(d,o)}var ln=function(d){var o,e;function t(r,s,l){var u;return(u=d.call(this,r,s,l,"[subtitle-stream-controller]")||this).levels=[],u.currentTrackId=-1,u.tracksBuffered=[],u.mainDetails=null,u._registerListeners(),u}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,bi(o,e);var i,n,a=t.prototype;return a.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},a._registerListeners=function(){var r=this.hls;r.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(p.Events.ERROR,this.onError,this),r.on(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.on(p.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.on(p.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(p.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var r=this.hls;r.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(p.Events.ERROR,this.onError,this),r.off(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.off(p.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.off(p.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(p.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a.startLoad=function(r){this.stopLoad(),this.state=Et,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()},a.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},a.onLevelLoaded=function(r,s){this.mainDetails=s.details},a.onSubtitleFragProcessed=function(r,s){var l=s.frag,u=s.success;if(this.fragPrevious=l,this.state=Et,u){var c=this.tracksBuffered[this.currentTrackId];if(c){for(var v,m=l.start,_=0;_<c.length;_++)if(m>=c[_].start&&m<=c[_].end){v=c[_];break}var S=l.start+l.duration;v?v.end=S:(v={start:m,end:S},c.push(v)),this.fragmentTracker.fragBuffered(l)}}},a.onBufferFlushing=function(r,s){var l=s.startOffset,u=s.endOffset;if(l===0&&u!==Number.POSITIVE_INFINITY){var c=this.currentTrackId,v=this.levels;if(!v.length||!v[c]||!v[c].details)return;var m=u-v[c].details.targetduration;if(m<=0)return;s.endOffsetSubtitles=Math.max(0,m),this.tracksBuffered.forEach(function(_){for(var S=0;S<_.length;)if(_[S].end<=m)_.shift();else{if(!(_[S].start<m))break;_[S].start=m,S++}}),this.fragmentTracker.removeFragmentsInRange(l,m,pe.PlaylistLevelType.SUBTITLE)}},a.onFragBuffered=function(r,s){var l;this.loadedmetadata||s.frag.type!==pe.PlaylistLevelType.MAIN||(l=this.media)!==null&&l!==void 0&&l.buffered.length&&(this.loadedmetadata=!0)},a.onError=function(r,s){var l=s.frag;l&&l.type===pe.PlaylistLevelType.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state=Et)},a.onSubtitleTracksUpdated=function(r,s){var l=this,u=s.subtitleTracks;this.tracksBuffered=[],this.levels=u.map(function(c){return new O(c)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(c){l.tracksBuffered[c.id]=[]}),this.mediaBuffer=null},a.onSubtitleTrackSwitch=function(r,s){if(this.currentTrackId=s.id,this.levels.length&&this.currentTrackId!==-1){var l=this.levels[this.currentTrackId];l!=null&&l.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,l&&this.setInterval(500)}else this.clearInterval()},a.onSubtitleTrackLoaded=function(r,s){var l,u=s.details,c=s.id,v=this.currentTrackId,m=this.levels;if(m.length){var _=m[v];if(!(c>=m.length||c!==v)&&_){this.mediaBuffer=this.mediaBufferTimeRanges;var S=0;if(u.live||(l=_.details)!==null&&l!==void 0&&l.live){var x=this.mainDetails;if(u.deltaUpdateFailed||!x)return;var I=x.fragments[0];_.details?(S=this.alignPlaylists(u,_.details))===0&&I&&he(u,S=I.start):u.hasProgramDateTime&&x.hasProgramDateTime?(xi(u,x),S=u.fragments[0].start):I&&he(u,S=I.start)}_.details=u,this.levelLastLoaded=c,this.startFragRequested||!this.mainDetails&&u.live||this.setStartPosition(_.details,S),this.tick(),u.live&&!this.fragCurrent&&this.media&&this.state===Et&&(ei(null,u.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),_.details=void 0))}}},a._handleFragmentLoadComplete=function(r){var s=this,l=r.frag,u=r.payload,c=l.decryptdata,v=this.hls;if(!this.fragContextChanged(l)&&u&&u.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var m=performance.now();this.decrypter.decrypt(new Uint8Array(u),c.key.buffer,c.iv.buffer).then(function(_){var S=performance.now();v.trigger(p.Events.FRAG_DECRYPTED,{frag:l,payload:_,stats:{tstart:m,tdecrypt:S}})}).catch(function(_){s.warn(_.name+": "+_.message),s.state=Et})}},a.doTick=function(){if(this.media){if(this.state===Et){var r=this.currentTrackId,s=this.levels;if(!s.length||!s[r]||!s[r].details)return;var l=s[r].details,u=l.targetduration,c=this.config,v=this.getLoadPosition(),m=Mt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],v-u,c.maxBufferHole),_=m.end,S=m.len,x=this.getFwdBufferInfo(this.media,pe.PlaylistLevelType.MAIN);if(S>this.getMaxBufferLength(x==null?void 0:x.len)+u)return;var I=l.fragments,j=I.length,ae=l.edge,me=null,de=this.fragPrevious;if(_<ae){var _e=c.maxFragLookUpTolerance;!(me=ei(de,I,Math.max(I[0].start,_),_e))&&de&&de.start<I[0].start&&(me=I[0])}else me=I[j-1];if(!me)return;me=this.mapToInitFragWhenRequired(me),this.fragmentTracker.getState(me)===Ue.NOT_LOADED&&this.loadFragment(me,l,_)}}else this.state=Et},a.getMaxBufferLength=function(r){var s=d.prototype.getMaxBufferLength.call(this);return r?Math.max(s,r):s},a.loadFragment=function(r,s,l){this.fragCurrent=r,r.sn==="initSegment"?this._loadInitSegment(r,s):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,s,l))},i=t,(n=[{key:"mediaBufferTimeRanges",get:function(){return new un(this.tracksBuffered[this.currentTrackId]||[])}}])&&on(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(ii),un=function(d){this.buffered=void 0;var o=function(e,t,i){if((t>>>=0)>i-1)throw new DOMException("Failed to execute '"+e+"' on 'TimeRanges': The index provided ("+t+") is greater than the maximum bound ("+i+")");return d[t][e]};this.buffered={get length(){return d.length},end:function(e){return o("end",e,d.length)},start:function(e){return o("start",e,d.length)}}};function dn(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function _i(d,o){return _i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_i(d,o)}function Si(d){for(var o=[],e=0;e<d.length;e++){var t=d[e];t.kind==="subtitles"&&t.label&&o.push(d[e])}return o}let cn=function(d){var o,e;function t(r){var s;return(s=d.call(this,r,"[subtitle-track-controller]")||this).media=null,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.selectDefaultTrack=!0,s.queuedDefaultTrack=-1,s.trackChangeListener=function(){return s.onTextTracksChanged()},s.asyncPollTrackChange=function(){return s.pollTrackChange(0)},s.useTextTrackPolling=!1,s.subtitlePollingInterval=-1,s._subtitleDisplay=!0,s.registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,_i(o,e);var i,n,a=t.prototype;return a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,d.prototype.destroy.call(this)},a.registerListeners=function(){var r=this.hls;r.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(p.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(p.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var r=this.hls;r.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(p.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(p.Events.ERROR,this.onError,this)},a.onMediaAttached=function(r,s){this.media=s.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},a.pollTrackChange=function(r){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,r)},a.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Si(this.media.textTracks).forEach(function(r){ht(r)}),this.subtitleTrack=-1,this.media=null)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},a.onManifestParsed=function(r,s){this.tracks=s.subtitleTracks},a.onSubtitleTrackLoaded=function(r,s){var l=s.id,u=s.details,c=this.trackId,v=this.tracksInGroup[c];if(v){var m=v.details;v.details=s.details,this.log("subtitle track "+l+" loaded ["+u.startSN+"-"+u.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,m))}else this.warn("Invalid subtitle track id "+l)},a.onLevelLoading=function(r,s){this.switchLevel(s.level)},a.onLevelSwitching=function(r,s){this.switchLevel(s.level)},a.switchLevel=function(r){var s=this.hls.levels[r];if(s!=null&&s.textGroupIds){var l=s.textGroupIds[s.urlId];if(this.groupId!==l){var u=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,c=this.tracks.filter(function(_){return!l||_.groupId===l});this.tracksInGroup=c;var v=this.findTrackId(u==null?void 0:u.name)||this.findTrackId();this.groupId=l;var m={subtitleTracks:c};this.log("Updating subtitle tracks, "+c.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(p.Events.SUBTITLE_TRACKS_UPDATED,m),v!==-1&&this.setSubtitleTrack(v,u)}}},a.findTrackId=function(r){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var u=s[l];if((!this.selectDefaultTrack||u.default)&&(!r||r===u.name))return u.id}return-1},a.onError=function(r,s){d.prototype.onError.call(this,r,s),!s.fatal&&s.context&&s.context.type===pe.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},a.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,u=s.groupId,c=s.url;if(r)try{c=r.addDirectives(c)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("Loading subtitle playlist for id "+l),this.hls.trigger(p.Events.SUBTITLE_TRACK_LOADING,{url:c,id:l,groupId:u,deliveryDirectives:r||null})}},a.toggleTrackModes=function(r){var s=this,l=this.media,u=this.trackId;if(l){var c=Si(l.textTracks),v=c.filter(function(S){return S.groupId===s.groupId});if(r===-1)[].slice.call(c).forEach(function(S){S.mode="disabled"});else{var m=v[u];m&&(m.mode="disabled")}var _=v[r];_&&(_.mode=this.subtitleDisplay?"showing":"hidden")}},a.setSubtitleTrack=function(r,s){var l,u=this.tracksInGroup;if(this.media){if(this.trackId!==r&&this.toggleTrackModes(r),!(this.trackId===r&&(r===-1||(l=u[r])!==null&&l!==void 0&&l.details)||r<-1||r>=u.length)){this.clearTimer();var c=u[r];if(this.log("Switching to subtitle track "+r),this.trackId=r,c){var v=c.id,m=c.groupId,_=m===void 0?"":m,S=c.name,x=c.type,I=c.url;this.hls.trigger(p.Events.SUBTITLE_TRACK_SWITCH,{id:v,groupId:_,name:S,type:x,url:I});var j=this.switchParams(c.url,s==null?void 0:s.details);this.loadPlaylist(j)}else this.hls.trigger(p.Events.SUBTITLE_TRACK_SWITCH,{id:r})}}else this.queuedDefaultTrack=r},a.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var r=-1,s=Si(this.media.textTracks),l=0;l<s.length;l++)if(s[l].mode==="hidden")r=l;else if(s[l].mode==="showing"){r=l;break}this.subtitleTrack!==r&&(this.subtitleTrack=r)}},i=t,(n=[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(r){this._subtitleDisplay=r,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(r,s)}}])&&dn(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Le);var pt,fr=function(){function d(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var o=d.prototype;return o.append=function(e,t){var i=this.queues[t];i.push(e),i.length===1&&this.buffers[t]&&this.executeNext(t)},o.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},o.appendBlocker=function(e){var t,i=new Promise(function(a){t=a}),n={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(n,e),i},o.executeNext=function(e){var t=this.buffers,i=this.queues,n=t[e],a=i[e];if(a.length){var r=a[0];try{r.execute()}catch(s){k.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),r.onError(s),n&&n.updating||(a.shift(),this.executeNext(e))}}},o.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},o.current=function(e){return this.queues[e][0]},d}(),Gr=ni(),ji=/([ha]vc.)(?:\.[^.,]+)+/,hn=function(){function d(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var i=t.hls,n=t.media,a=t.mediaSource;k.logger.log("[buffer-controller]: Media source opened"),n&&(t.updateMediaElementDuration(),i.trigger(p.Events.MEDIA_ATTACHED,{media:n})),a&&a.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){k.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){k.logger.log("[buffer-controller]: Media source ended")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var o=d.prototype;return o.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},o.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},o.registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.Events.BUFFER_RESET,this.onBufferReset,this),e.on(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.Events.BUFFER_EOS,this.onBufferEos,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.Events.FRAG_PARSED,this.onFragParsed,this),e.on(p.Events.FRAG_CHANGED,this.onFragChanged,this)},o.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.Events.BUFFER_RESET,this.onBufferReset,this),e.off(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.Events.BUFFER_EOS,this.onBufferEos,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.Events.FRAG_PARSED,this.onFragParsed,this),e.off(p.Events.FRAG_CHANGED,this.onFragChanged,this)},o._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new fr(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},o.onManifestParsed=function(e,t){var i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.details=null,k.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},o.onMediaAttaching=function(e,t){var i=this.media=t.media;if(i&&Gr){var n=this.mediaSource=new Gr;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(n),this._objectUrl=i.src}},o.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,i=this._objectUrl;if(t){if(k.logger.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(n){k.logger.warn("[buffer-controller]: onMediaDetaching: "+n.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(i&&self.URL.revokeObjectURL(i),e.src===i?(e.removeAttribute("src"),e.load()):k.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(p.Events.MEDIA_DETACHED,void 0)},o.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){var i=e.sourceBuffer[t];try{i&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(i),e.sourceBuffer[t]=void 0)}catch(n){k.logger.warn("[buffer-controller]: Failed to reset the "+t+" buffer",n)}}),this._initSourceBuffer()},o.onBufferCodecs=function(e,t){var i=this,n=this.getSourceBufferTypes().length;Object.keys(t).forEach(function(a){if(n){var r=i.tracks[a];if(r&&typeof r.buffer.changeType=="function"){var s=t[a],l=s.id,u=s.codec,c=s.levelCodec,v=s.container,m=s.metadata,_=(r.levelCodec||r.codec).replace(ji,"$1"),S=(c||u).replace(ji,"$1");if(_!==S){var x=v+";codecs="+(c||u);i.appendChangeType(a,x),k.logger.log("[buffer-controller]: switching codec "+_+" to "+S),i.tracks[a]={buffer:r.buffer,codec:u,container:v,levelCodec:c,metadata:m,id:l}}}}else i.pendingTracks[a]=t[a]}),n||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},o.appendChangeType=function(e,t){var i=this,n=this.operationQueue,a={execute:function(){var r=i.sourceBuffer[e];r&&(k.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),r.changeType(t)),n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(r){k.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",r)}};n.append(a,e)},o.onBufferAppending=function(e,t){var i=this,n=this.hls,a=this.operationQueue,r=this.tracks,s=t.data,l=t.type,u=t.frag,c=t.part,v=t.chunkMeta,m=v.buffering[l],_=self.performance.now();m.start=_;var S=u.stats.buffering,x=c?c.stats.buffering:null;S.start===0&&(S.start=_),x&&x.start===0&&(x.start=_);var I=r.audio,j=!1;l==="audio"&&(I==null?void 0:I.container)==="audio/mpeg"&&(j=!this.lastMpegAudioChunk||v.id===1||this.lastMpegAudioChunk.sn!==v.sn,this.lastMpegAudioChunk=v);var ae=u.start,me={execute:function(){if(m.executeStart=self.performance.now(),j){var de=i.sourceBuffer[l];if(de){var _e=ae-de.timestampOffset;Math.abs(_e)>=.1&&(k.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+ae+" (delta: "+_e+") sn: "+u.sn+")"),de.timestampOffset=ae)}}i.appendExecutor(s,l)},onStart:function(){},onComplete:function(){var de=self.performance.now();m.executeEnd=m.end=de,S.first===0&&(S.first=de),x&&x.first===0&&(x.first=de);var _e=i.sourceBuffer,Ke={};for(var ze in _e)Ke[ze]=Mt.getBuffered(_e[ze]);i.appendError=0,i.hls.trigger(p.Events.BUFFER_APPENDED,{type:l,frag:u,part:c,chunkMeta:v,parent:u.type,timeRanges:Ke})},onError:function(de){k.logger.error("[buffer-controller]: Error encountered while trying to append to the "+l+" SourceBuffer",de);var _e={type:w.ErrorTypes.MEDIA_ERROR,parent:u.type,details:w.ErrorDetails.BUFFER_APPEND_ERROR,err:de,fatal:!1};de.code===DOMException.QUOTA_EXCEEDED_ERR?_e.details=w.ErrorDetails.BUFFER_FULL_ERROR:(i.appendError++,_e.details=w.ErrorDetails.BUFFER_APPEND_ERROR,i.appendError>n.config.appendErrorMaxRetry&&(k.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),_e.fatal=!0,n.stopLoad())),n.trigger(p.Events.ERROR,_e)}};a.append(me,l)},o.onBufferFlushing=function(e,t){var i=this,n=this.operationQueue,a=function(r){return{execute:i.removeExecutor.bind(i,r,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){i.hls.trigger(p.Events.BUFFER_FLUSHED,{type:r})},onError:function(s){k.logger.warn("[buffer-controller]: Failed to remove from "+r+" SourceBuffer",s)}}};t.type?n.append(a(t.type),t.type):this.getSourceBufferTypes().forEach(function(r){n.append(a(r),r)})},o.onFragParsed=function(e,t){var i=this,n=t.frag,a=t.part,r=[],s=a?a.elementaryStreams:n.elementaryStreams;s[z.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(s[z.ElementaryStreamTypes.AUDIO]&&r.push("audio"),s[z.ElementaryStreamTypes.VIDEO]&&r.push("video")),r.length===0&&k.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers(function(){var l=self.performance.now();n.stats.buffering.end=l,a&&(a.stats.buffering.end=l);var u=a?a.stats:n.stats;i.hls.trigger(p.Events.FRAG_BUFFERED,{frag:n,part:a,stats:u,id:n.type})},r)},o.onFragChanged=function(e,t){this.flushBackBuffer()},o.onBufferEos=function(e,t){var i=this;this.getSourceBufferTypes().reduce(function(n,a){var r=i.sourceBuffer[a];return!r||t.type&&t.type!==a||(r.ending=!0,r.ended||(r.ended=!0,k.logger.log("[buffer-controller]: "+a+" sourceBuffer now EOS"))),n&&!(r&&!r.ended)},!0)&&(k.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){i.getSourceBufferTypes().forEach(function(a){var r=i.sourceBuffer[a];r&&(r.ending=!1)});var n=i.mediaSource;n&&n.readyState==="open"?(k.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),n.endOfStream()):n&&k.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+n.readyState)}))},o.onLevelUpdated=function(e,t){var i=t.details;i.fragments.length&&(this.details=i,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},o.flushBackBuffer=function(){var e=this.hls,t=this.details,i=this.media,n=this.sourceBuffer;if(i&&t!==null){var a=this.getSourceBufferTypes();if(a.length){var r=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if((0,R.isFiniteNumber)(r)&&!(r<0)){var s=i.currentTime,l=t.levelTargetDuration,u=Math.max(r,l),c=Math.floor(s/l)*l-u;a.forEach(function(v){var m=n[v];if(m){var _=Mt.getBuffered(m);if(_.length>0&&c>_.start(0)){if(e.trigger(p.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(p.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(m.ended&&_.end(_.length-1)-s<2*l)return void k.logger.info("[buffer-controller]: Cannot flush "+v+" back buffer while SourceBuffer is in ended state");e.trigger(p.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:v})}}})}}}},o.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var e=this.details,t=this.hls,i=this.media,n=this.mediaSource,a=e.fragments[0].start+e.totalduration,r=i.duration,s=(0,R.isFiniteNumber)(n.duration)?n.duration:0;e.live&&t.config.liveDurationInfinity?(k.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(a>s&&a>r||!(0,R.isFiniteNumber)(r))&&(k.logger.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),n.duration=a)}},o.updateSeekableRange=function(e){var t=this.mediaSource,i=e.fragments;if(i.length&&e.live&&t!=null&&t.setLiveSeekableRange){var n=Math.max(0,i[0].start),a=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,a)}},o.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,i=this.pendingTracks,n=Object.keys(i).length;if(n&&!e||n===2){this.createSourceBuffers(i),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length===0)return void this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});a.forEach(function(r){t.executeNext(r)})}},o.createSourceBuffers=function(e){var t=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var n=0;for(var a in e)if(!t[a]){var r=e[a];if(!r)throw Error("source buffer exists for track "+a+", however track does not");var s=r.levelCodec||r.codec,l=r.container+";codecs="+s;k.logger.log("[buffer-controller]: creating sourceBuffer("+l+")");try{var u=t[a]=i.addSourceBuffer(l),c=a;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[a]={buffer:u,codec:s,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id},n++}catch(v){k.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+v.message),this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:v,mimeType:l})}}n&&this.hls.trigger(p.Events.BUFFER_CREATED,{tracks:this.tracks})},o._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},o._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},o._onSBUpdateError=function(e,t){k.logger.error("[buffer-controller]: "+e+" SourceBuffer error",t),this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var i=this.operationQueue.current(e);i&&i.onError(t)},o.removeExecutor=function(e,t,i){var n=this.media,a=this.mediaSource,r=this.operationQueue,s=this.sourceBuffer[e];if(!n||!a||!s)return k.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(e);var l=(0,R.isFiniteNumber)(n.duration)?n.duration:1/0,u=(0,R.isFiniteNumber)(a.duration)?a.duration:1/0,c=Math.max(0,t),v=Math.min(i,l,u);v>c&&!s.ending?(s.ended=!1,k.logger.log("[buffer-controller]: Removing ["+c+","+v+"] from the "+e+" SourceBuffer"),s.remove(c,v)):r.shiftAndExecuteNext(e)},o.appendExecutor=function(e,t){var i=this.operationQueue,n=this.sourceBuffer[t];if(!n)return k.logger.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void i.shiftAndExecuteNext(t);n.ended=!1,n.appendBuffer(e)},o.blockBuffers=function(e,t){var i=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length)return k.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var n=this.operationQueue,a=t.map(function(r){return n.appendBlocker(r)});Promise.all(a).then(function(){e(),t.forEach(function(r){var s=i.sourceBuffer[r];s&&s.updating||n.shiftAndExecuteNext(r)})})},o.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},o.addBufferListener=function(e,t,i){var n=this.sourceBuffer[e];if(n){var a=i.bind(this,e);this.listeners[e].push({event:t,listener:a}),n.addEventListener(t,a)}},o.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(i){t.removeEventListener(i.event,i.listener)})},d}(),g={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},h=function(d){var o=d;return g.hasOwnProperty(d)&&(o=g[d]),String.fromCharCode(o)},f=15,y=100,b={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},C={17:2,18:4,21:6,22:8,23:10,19:13,20:15},A={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},G={25:2,26:4,29:6,30:8,31:10,27:13,28:15},se=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];(function(d){d[d.ERROR=0]="ERROR",d[d.TEXT=1]="TEXT",d[d.WARNING=2]="WARNING",d[d.INFO=2]="INFO",d[d.DEBUG=3]="DEBUG",d[d.DATA=3]="DATA"})(pt||(pt={}));var Q=function(){function d(){this.time=null,this.verboseLevel=pt.ERROR}return d.prototype.log=function(o,e){if(this.verboseLevel>=o){var t=typeof e=="function"?e():e;k.logger.log(this.time+" ["+o+"] "+t)}},d}(),Pe=function(d){for(var o=[],e=0;e<d.length;e++)o.push(d[e].toString(16));return o},at=function(){function d(e,t,i,n,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=i||!1,this.background=n||"black",this.flash=a||!1}var o=d.prototype;return o.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},o.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],i=0;i<t.length;i++){var n=t[i];e.hasOwnProperty(n)&&(this[n]=e[n])}},o.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},o.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},o.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},o.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},d}(),Je=function(){function d(e,t,i,n,a,r){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new at(t,i,n,a,r)}var o=d.prototype;return o.reset=function(){this.uchar=" ",this.penState.reset()},o.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},o.setPenState=function(e){this.penState.copy(e)},o.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},o.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},o.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},d}(),it=function(){function d(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<y;t++)this.chars.push(new Je);this.logger=e,this.pos=0,this.currPenState=new at}var o=d.prototype;return o.equals=function(e){for(var t=!0,i=0;i<y;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t},o.copy=function(e){for(var t=0;t<y;t++)this.chars[t].copy(e.chars[t])},o.isEmpty=function(){for(var e=!0,t=0;t<y;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},o.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(pt.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>y&&(this.logger.log(pt.DEBUG,"Too large cursor position "+this.pos),this.pos=y)},o.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)},o.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},o.insertChar=function(e){var t=this;e>=144&&this.backSpace();var i=h(e);this.pos>=y?this.logger.log(pt.ERROR,function(){return"Cannot insert "+e.toString(16)+" ("+i+") at position "+t.pos+". Skipping it!"}):(this.chars[this.pos].setChar(i,this.currPenState),this.moveCursor(1))},o.clearFromPos=function(e){var t;for(t=e;t<y;t++)this.chars[t].reset()},o.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},o.clearToEndOfRow=function(){this.clearFromPos(this.pos)},o.getTextString=function(){for(var e=[],t=!0,i=0;i<y;i++){var n=this.chars[i].uchar;n!==" "&&(t=!1),e.push(n)}return t?"":e.join("")},o.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},d}(),Xe=function(){function d(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<f;t++)this.rows.push(new it(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var o=d.prototype;return o.reset=function(){for(var e=0;e<f;e++)this.rows[e].clear();this.currRow=14},o.equals=function(e){for(var t=!0,i=0;i<f;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t},o.copy=function(e){for(var t=0;t<f;t++)this.rows[t].copy(e.rows[t])},o.isEmpty=function(){for(var e=!0,t=0;t<f;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},o.backSpace=function(){this.rows[this.currRow].backSpace()},o.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},o.insertChar=function(e){this.rows[this.currRow].insertChar(e)},o.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},o.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},o.setCursor=function(e){this.logger.log(pt.INFO,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},o.setPAC=function(e){this.logger.log(pt.INFO,function(){return"pacData = "+JSON.stringify(e)});var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var i=0;i<f;i++)this.rows[i].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var r=a.rows[n].cueStartTime,s=this.logger.time;if(r&&s!==null&&r<s)for(var l=0;l<this.nrRollUpRows;l++)this.rows[t-this.nrRollUpRows+l+1].copy(a.rows[n+l])}}this.currRow=t;var u=this.rows[this.currRow];if(e.indent!==null){var c=e.indent,v=Math.max(c-1,0);u.setCursor(e.indent),e.color=u.chars[v].penState.foreground}var m={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(m)},o.setBkgData=function(e){this.logger.log(pt.INFO,function(){return"bkgData = "+JSON.stringify(e)}),this.backSpace(),this.setPen(e),this.insertChar(32)},o.setRollUpRows=function(e){this.nrRollUpRows=e},o.rollUp=function(){var e=this;if(this.nrRollUpRows!==null){this.logger.log(pt.TEXT,function(){return e.getDisplayText()});var t=this.currRow+1-this.nrRollUpRows,i=this.rows.splice(t,1)[0];i.clear(),this.rows.splice(this.currRow,0,i),this.logger.log(pt.INFO,"Rolling up")}else this.logger.log(pt.DEBUG,"roll_up but nrRollUpRows not set yet")},o.getDisplayText=function(e){e=e||!1;for(var t=[],i="",n=-1,a=0;a<f;a++){var r=this.rows[a].getTextString();r&&(n=a+1,e?t.push("Row "+n+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join(`
|
|
20
|
-
`)),i},o.getTextAndFormat=function(){return this.rows},d}(),nt=function(){function d(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Xe(i),this.nonDisplayedMemory=new Xe(i),this.lastOutputScreen=new Xe(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}var o=d.prototype;return o.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},o.getHandler=function(){return this.outputFilter},o.setHandler=function(e){this.outputFilter=e},o.setPAC=function(e){this.writeScreen.setPAC(e)},o.setBkgData=function(e){this.writeScreen.setBkgData(e)},o.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(pt.INFO,function(){return"MODE="+e}),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},o.insertChars=function(e){for(var t=this,i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);var n=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(pt.INFO,function(){return n+": "+t.writeScreen.getDisplayText(!0)}),this.mode!=="MODE_PAINT-ON"&&this.mode!=="MODE_ROLL-UP"||(this.logger.log(pt.TEXT,function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},o.ccRCL=function(){this.logger.log(pt.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},o.ccBS=function(){this.logger.log(pt.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},o.ccAOF=function(){},o.ccAON=function(){},o.ccDER=function(){this.logger.log(pt.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},o.ccRU=function(e){this.logger.log(pt.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},o.ccFON=function(){this.logger.log(pt.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},o.ccRDC=function(){this.logger.log(pt.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},o.ccTR=function(){this.logger.log(pt.INFO,"TR"),this.setMode("MODE_TEXT")},o.ccRTD=function(){this.logger.log(pt.INFO,"RTD"),this.setMode("MODE_TEXT")},o.ccEDM=function(){this.logger.log(pt.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},o.ccCR=function(){this.logger.log(pt.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},o.ccENM=function(){this.logger.log(pt.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},o.ccEOC=function(){var e=this;if(this.logger.log(pt.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(pt.TEXT,function(){return"DISP: "+e.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},o.ccTO=function(e){this.logger.log(pt.INFO,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},o.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var i=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][i]}this.logger.log(pt.INFO,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},o.outputDataUpdate=function(e){e===void 0&&(e=!1);var t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime!==null||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},o.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},d}(),wt=function(){function d(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var n=new Q;this.channels=[null,new nt(e,t,n),new nt(e+1,i,n)],this.cmdHistory={a:null,b:null},this.logger=n}var o=d.prototype;return o.getHandler=function(e){return this.channels[e].getHandler()},o.setHandler=function(e,t){this.channels[e].setHandler(t)},o.addData=function(e,t){var i,n,a,r=!1;this.logger.time=e;for(var s=0;s<t.length;s+=2)if(n=127&t[s],a=127&t[s+1],n!==0||a!==0){if(this.logger.log(pt.DATA,"["+Pe([t[s],t[s+1]])+"] -> ("+Pe([n,a])+")"),(i=this.parseCmd(n,a))||(i=this.parseMidrow(n,a)),i||(i=this.parsePAC(n,a)),i||(i=this.parseBackgroundAttributes(n,a)),!i&&(r=this.parseChars(n,a))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(r):this.logger.log(pt.WARNING,"No channel found yet. TEXT-MODE?")}i||r||this.logger.log(pt.WARNING,"Couldn't parse cleaned data "+Pe([n,a])+" orig: "+Pe([t[s],t[s+1]]))}},o.parseCmd=function(e,t){var i=this.cmdHistory;if(!((e===20||e===28||e===21||e===29)&&t>=32&&t<=47||(e===23||e===31)&&t>=33&&t<=35))return!1;if(Jt(e,t,i))return Bt(null,null,i),this.logger.log(pt.DEBUG,"Repeated command ("+Pe([e,t])+") is dropped"),!0;var n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),Bt(e,t,i),this.currentChannel=n,!0},o.parseMidrow=function(e,t){var i=0;if((e===17||e===25)&&t>=32&&t<=47){if((i=e===17?1:2)!==this.currentChannel)return this.logger.log(pt.ERROR,"Mismatch channel in midrow parsing"),!1;var n=this.channels[i];return!!n&&(n.ccMIDROW(t),this.logger.log(pt.DEBUG,"MIDROW ("+Pe([e,t])+")"),!0)}return!1},o.parsePAC=function(e,t){var i,n=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(e===16||e===24)&&t>=64&&t<=95))return!1;if(Jt(e,t,n))return Bt(null,null,n),!0;var a=e<=23?1:2;i=t>=64&&t<=95?a===1?b[e]:A[e]:a===1?C[e]:G[e];var r=this.channels[a];return!!r&&(r.setPAC(this.interpretPAC(i,t)),Bt(e,t,n),this.currentChannel=a,!0)},o.interpretPAC=function(e,t){var i,n={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,n.underline=(1&i)==1,i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((i-16)/2),n},o.parseChars=function(e,t){var i,n,a=null,r=null;if(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19?(n=r===17?t+80:r===18?t+112:t+144,this.logger.log(pt.INFO,"Special char '"+h(n)+"' in channel "+i),a=[n]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var s=Pe(a);this.logger.log(pt.DEBUG,"Char codes = "+s.join(",")),Bt(e,t,this.cmdHistory)}return a},o.parseBackgroundAttributes=function(e,t){var i;if(!((e===16||e===24)&&t>=32&&t<=47||(e===23||e===31)&&t>=45&&t<=47))return!1;var n={};e===16||e===24?(i=Math.floor((t-32)/2),n.background=se[i],t%2==1&&(n.background=n.background+"_semi")):t===45?n.background="transparent":(n.foreground="black",t===47&&(n.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(n),Bt(e,t,this.cmdHistory),!0},o.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}},o.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var i=this.channels[t];i&&i.cueSplitAtTime(e)}},d}();function Bt(d,o,e){e.a=d,e.b=o}function Jt(d,o,e){return e.a===d&&e.b===o}let ir=wt;var mt=function(){function d(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}var o=d.prototype;return o.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},o.newCue=function(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)},o.reset=function(){this.cueRanges=[],this.startTime=null},d}();let Wt=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var d=["","lr","rl"],o=["start","middle","end","left","right"];function e(a,r){if(typeof r!="string"||!Array.isArray(a))return!1;var s=r.toLowerCase();return!!~a.indexOf(s)&&s}function t(a){return e(o,a)}function i(a){for(var r=arguments.length,s=new Array(r>1?r-1:0),l=1;l<r;l++)s[l-1]=arguments[l];for(var u=1;u<arguments.length;u++){var c=arguments[u];for(var v in c)a[v]=c[v]}return a}function n(a,r,s){var l=this,u={enumerable:!0};l.hasBeenReset=!1;var c="",v=!1,m=a,_=r,S=s,x=null,I="",j=!0,ae="auto",me="start",de=50,_e="middle",Ke=50,ze="middle";Object.defineProperty(l,"id",i({},u,{get:function(){return c},set:function(Ee){c=""+Ee}})),Object.defineProperty(l,"pauseOnExit",i({},u,{get:function(){return v},set:function(Ee){v=!!Ee}})),Object.defineProperty(l,"startTime",i({},u,{get:function(){return m},set:function(Ee){if(typeof Ee!="number")throw new TypeError("Start time must be set to a number.");m=Ee,this.hasBeenReset=!0}})),Object.defineProperty(l,"endTime",i({},u,{get:function(){return _},set:function(Ee){if(typeof Ee!="number")throw new TypeError("End time must be set to a number.");_=Ee,this.hasBeenReset=!0}})),Object.defineProperty(l,"text",i({},u,{get:function(){return S},set:function(Ee){S=""+Ee,this.hasBeenReset=!0}})),Object.defineProperty(l,"region",i({},u,{get:function(){return x},set:function(Ee){x=Ee,this.hasBeenReset=!0}})),Object.defineProperty(l,"vertical",i({},u,{get:function(){return I},set:function(Ee){var Ge=function(Fe){return e(d,Fe)}(Ee);if(Ge===!1)throw new SyntaxError("An invalid or illegal string was specified.");I=Ge,this.hasBeenReset=!0}})),Object.defineProperty(l,"snapToLines",i({},u,{get:function(){return j},set:function(Ee){j=!!Ee,this.hasBeenReset=!0}})),Object.defineProperty(l,"line",i({},u,{get:function(){return ae},set:function(Ee){if(typeof Ee!="number"&&Ee!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");ae=Ee,this.hasBeenReset=!0}})),Object.defineProperty(l,"lineAlign",i({},u,{get:function(){return me},set:function(Ee){var Ge=t(Ee);if(!Ge)throw new SyntaxError("An invalid or illegal string was specified.");me=Ge,this.hasBeenReset=!0}})),Object.defineProperty(l,"position",i({},u,{get:function(){return de},set:function(Ee){if(Ee<0||Ee>100)throw new Error("Position must be between 0 and 100.");de=Ee,this.hasBeenReset=!0}})),Object.defineProperty(l,"positionAlign",i({},u,{get:function(){return _e},set:function(Ee){var Ge=t(Ee);if(!Ge)throw new SyntaxError("An invalid or illegal string was specified.");_e=Ge,this.hasBeenReset=!0}})),Object.defineProperty(l,"size",i({},u,{get:function(){return Ke},set:function(Ee){if(Ee<0||Ee>100)throw new Error("Size must be between 0 and 100.");Ke=Ee,this.hasBeenReset=!0}})),Object.defineProperty(l,"align",i({},u,{get:function(){return ze},set:function(Ee){var Ge=t(Ee);if(!Ge)throw new SyntaxError("An invalid or illegal string was specified.");ze=Ge,this.hasBeenReset=!0}})),l.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}();var er=function(){function d(){}return d.prototype.decode=function(o,e){if(!o)return"";if(typeof o!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(o))},d}();function _t(d){function o(t,i,n,a){return 3600*(0|t)+60*(0|i)+(0|n)+parseFloat(a||0)}var e=d.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?o(e[2],e[3],0,e[4]):o(e[1],e[2],e[3],e[4]):null}var et=function(){function d(){this.values=Object.create(null)}var o=d.prototype;return o.set=function(e,t){this.get(e)||t===""||(this.values[e]=t)},o.get=function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t},o.has=function(e){return e in this.values},o.alt=function(e,t,i){for(var n=0;n<i.length;++n)if(t===i[n]){this.set(e,t);break}},o.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},o.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1},d}();function dt(d,o,e,t){var i=t?d.split(t):[d];for(var n in i)if(typeof i[n]=="string"){var a=i[n].split(e);a.length===2&&o(a[0],a[1])}}var $e=new Wt(0,0,""),lt=$e.align==="middle"?"middle":"center";function Ht(d,o,e){var t=d;function i(){var a=_t(d);if(a===null)throw new Error("Malformed timestamp: "+t);return d=d.replace(/^[^\sa-zA-Z-]+/,""),a}function n(){d=d.replace(/^\s+/,"")}if(n(),o.startTime=i(),n(),d.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+t);d=d.slice(3),n(),o.endTime=i(),n(),function(a,r){var s=new et;dt(a,function(c,v){var m;switch(c){case"region":for(var _=e.length-1;_>=0;_--)if(e[_].id===v){s.set(c,e[_].region);break}break;case"vertical":s.alt(c,v,["rl","lr"]);break;case"line":m=v.split(","),s.integer(c,m[0]),s.percent(c,m[0])&&s.set("snapToLines",!1),s.alt(c,m[0],["auto"]),m.length===2&&s.alt("lineAlign",m[1],["start",lt,"end"]);break;case"position":m=v.split(","),s.percent(c,m[0]),m.length===2&&s.alt("positionAlign",m[1],["start",lt,"end","line-left","line-right","auto"]);break;case"size":s.percent(c,v);break;case"align":s.alt(c,v,["start",lt,"end","left","right"])}},/:/,/\s/),r.region=s.get("region",null),r.vertical=s.get("vertical","");var l=s.get("line","auto");l==="auto"&&$e.line===-1&&(l=-1),r.line=l,r.lineAlign=s.get("lineAlign","start"),r.snapToLines=s.get("snapToLines",!0),r.size=s.get("size",100),r.align=s.get("align",lt);var u=s.get("position","auto");u==="auto"&&$e.position===50&&(u=r.align==="start"||r.align==="left"?0:r.align==="end"||r.align==="right"?100:50),r.position=u}(d,o)}function Kt(d){return d.replace(/<br(?: \/)?>/gi,`
|
|
21
|
-
|
|
22
|
-
`;)++u;var c=l.slice(0,u);return l[u]==="\r"&&++u,l[u]===`
|
|
23
|
-
`&&++u,t.buffer=l.slice(u),c}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;var a=(n=i()).match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var r=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(r?r=!1:n=i(),t.state){case"HEADER":/:/.test(n)?dt(n,function(l,u){},/:/):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new Wt(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Ht(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=n.indexOf("-->")!==-1;if(!n||s&&(r=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
|
|
24
|
-
`)
|
|
18
|
+
`))this.processLine(this.buffer.substring(0,h)),this.buffer=this.buffer.substring(h+1)},fr.prototype.processLine=function(p){var h=p.indexOf(":"),g=sn(p,h),b=g[0],L=g.length===2?Ur(g[1]):void 0;if(b[0]!=="#")this.currentUri.uri=b,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(b){case tn:if(!isFinite(L)||L<0)return;this.manifest.targetDuration=L,this.setHoldBack();break;case hr:Nr(this.manifest,g),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case pi:Nr(this.manifest,g),this.setHoldBack();break;case rn:L===0?this.currentUri.duration=.01:L>0&&(this.currentUri.duration=L);break;case Fn:var w=L,k=new Date(w);this.manifest.dateTimeString||(this.manifest.dateTimeString=w,this.manifest.dateTimeObject=k),this.currentUri.dateTimeString=w,this.currentUri.dateTimeObject=k;break;case nn:Nr(this.manifest,g);break;case mi:var x=gr(g[1]),U=$e(x);Object.assign(this.manifest.sessionData,U)}},fr.prototype.setHoldBack=function(){var p=this.manifest,h=p.serverControl,g=p.targetDuration,b=p.partTargetDuration;if(h){var L="holdBack",w="partHoldBack",k=g&&3*g,x=b&&2*b;g&&!h.hasOwnProperty(L)&&(h[L]=k),k&&h[L]<k&&(h[L]=k),b&&!h.hasOwnProperty(w)&&(h[w]=3*b),b&&h[w]<x&&(h[w]=x)}};var Nr=function(p,h){var g,b=vr(h[0].replace("#EXT-X-",""));Br(h[1])?(g={},g=Object.assign(an(h[1]),g)):g=Ur(h[1]),p[b]=g},vr=function(p){return p.toLowerCase().replace(/-(\w)/g,function(h){return h[1].toUpperCase()})},Ur=function(p){if(p.toLowerCase()==="yes"||p.toLowerCase()==="no")return p.toLowerCase()==="yes";var h=p.indexOf(":")!==-1?p:parseFloat(p);return isNaN(h)?p:h},yi=function(p){var h={},g=p.split("=");return g.length>1&&(h[vr(g[0])]=Ur(g[1])),h},an=function(p){for(var h=p.split(","),g={},b=0;h.length>b;b++){var L=h[b],w=yi(L);g=Object.assign(w,g)}return g},Br=function(p){return p.indexOf("=")>-1},sn=function(p,h){return h===-1?[p]:[p.substring(0,h),p.substring(h+1)]},gr=function(p){var h={};if(p){var g=p.search(",");return[p.slice(0,g),p.slice(g+1)].forEach(function(b,L){for(var w=b.replace(/['"]+/g,"").split("="),k=0;k<w.length;k++)w[k]==="DATA-ID"&&(h["DATA-ID"]=w[1-k]),w[k]==="VALUE"&&(h.VALUE=w[1-k])}),{data:h}}},Ti=fr,Nn={safeCall:function(p,h,g,b){var L=b;if(p&&typeof p[h]=="function")try{L=p[h].apply(p,g)}catch(w){ke.info("safeCall error",w)}return L},safeIncrement:M,getComputedStyle:function(p,h){var g;if(p&&h&&z()&&typeof z().getComputedStyle=="function")return Vt&&Vt.has(p)&&(g=Vt.get(p)),g||(g=z().getComputedStyle(p,null),Vt&&Vt.set(p,g)),g.getPropertyValue(h)},secondsToMs:function(p){return Math.floor(1e3*p)},assign:Object.assign,headersStringToObject:we,cdnHeadersToRequestId:We,extractHostnameAndDomain:_,extractHostname:ee,manifestParser:Ti,generateShortID:Te,generateUUID:ne,now:Fe.now},Ei={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 Un(p,h){return function(g){if(Array.isArray(g))return g}(p)||function(g,b){var L=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(L!=null){var w,k,x=[],U=!0,O=!1;try{for(L=L.call(g);!(U=(w=L.next()).done)&&(x.push(w.value),!b||x.length!==b);U=!0);}catch(W){O=!0,k=W}finally{try{U||L.return==null||L.return()}finally{if(O)throw k}}return x}}(p,h)||function(g,b){if(g){if(typeof g=="string")return Hr(g,b);var L=Object.prototype.toString.call(g).slice(8,-1);return L==="Object"&&g.constructor&&(L=g.constructor.name),L==="Map"||L==="Set"?Array.from(g):L==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(L)?Hr(g,b):void 0}}(p,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
19
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Hr(p,h){(h==null||h>p.length)&&(h=p.length);for(var g=0,b=new Array(h);g<h;g++)b[g]=p[g];return b}var Ze={},jt=function p(h){var g=arguments;typeof h=="string"?p.hasOwnProperty(h)?z().setTimeout(function(){g=Array.prototype.splice.call(g,1),p[h].apply(null,g)},0):ke.warn("`"+h+"` is an unknown task"):typeof h=="function"?z().setTimeout(function(){h(p)},0):ke.warn("`"+h+"` is invalid.")},nr={loaded:Fe.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(p,h){return function(g,b,L){var w=en(Ee(b),3),k=w[0],x=w[1],U=w[2],O=g.log,W=g.utils.getComputedStyle,pe=g.utils.secondsToMs;if(!k)return O.error("No element was found with the `"+x+"` query selector.");if(U!=="video"&&U!=="audio")return O.error("The element of `"+x+"` was not a media element.");k.mux&&(k.mux.destroy(),delete k.mux,O.warn("Already monitoring this video element, replacing existing event listeners")),(L=Object.assign({automaticErrorTracking:!0},L)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:g.VERSION},L.data),L.getPlayheadTime=function(){return pe(k.currentTime)},L.getStateData=function(){var he,se,fe=this.hlsjs&&this.hlsjs.url,Ce=this.dashjs&&gi(this.dashjs.getSource==="function")&&this.dashjs.getSource(),Ge={player_is_paused:k.paused,player_playhead_time:pe(k.currentTime),player_width:parseInt(W(k,"width")),player_height:parseInt(W(k,"height")),player_autoplay_on:k.autoplay,player_preload_on:k.preload,player_language_code:k.lang,player_is_fullscreen:Jt()&&!!(Jt().fullscreenElement||Jt().webkitFullscreenElement||Jt().mozFullScreenElement||Jt().msFullscreenElement),video_poster_url:k.poster,video_source_url:fe||Ce||k.currentSrc,video_source_duration:pe(k.duration),video_source_height:k.videoHeight,video_source_width:k.videoWidth,view_dropped_frame_count:(he=k)===null||he===void 0||(se=he.getVideoPlaybackQuality)===null||se===void 0?void 0:se.call(he).droppedVideoFrames},tt=L.getPlayheadTime();if(k.getStartDate&&tt>0){var ht=k.getStartDate();if(ht&&typeof ht.getTime=="function"&&ht.getTime()){var pt=ht.getTime();if(Ge.player_program_time=pt+tt,k.seekable.length>0){var ue=pt+k.seekable.end(k.seekable.length-1);Ge.player_live_edge_program_time=ue}}}return Ge},k.mux=k.mux||{},k.mux.deleted=!1,k.mux.emit=function(he,se){g.emit(x,he,se)};var ie=function(){O.error("The monitor for this video element has already been destroyed.")};k.mux.destroy=function(){Object.keys(k.mux.listeners).forEach(function(he){k.removeEventListener(he,k.mux.listeners[he],!1)}),delete k.mux.listeners,k.mux.destroy=ie,k.mux.swapElement=ie,k.mux.emit=ie,k.mux.addHLSJS=ie,k.mux.addDashJS=ie,k.mux.removeHLSJS=ie,k.mux.removeDashJS=ie,k.mux.deleted=!0,g.emit(x,"destroy")},k.mux.swapElement=function(he){var se=en(Ee(he),3),fe=se[0],Ce=se[1],Ge=se[2];return fe?Ge!=="video"&&Ge!=="audio"?g.log.error("The element of `"+Ce+"` was not a media element."):(fe.muxId=k.muxId,delete k.muxId,fe.mux=fe.mux||{},fe.mux.listeners=Object.assign({},k.mux.listeners),delete k.mux.listeners,Object.keys(fe.mux.listeners).forEach(function(tt){k.removeEventListener(tt,fe.mux.listeners[tt],!1),fe.addEventListener(tt,fe.mux.listeners[tt],!1)}),fe.mux.swapElement=k.mux.swapElement,fe.mux.destroy=k.mux.destroy,delete k.mux,void(k=fe)):g.log.error("No element was found with the `"+Ce+"` query selector.")},k.mux.addHLSJS=function(he){g.addHLSJS(x,he)},k.mux.addDashJS=function(he){g.addDashJS(x,he)},k.mux.removeHLSJS=function(){g.removeHLSJS(x)},k.mux.removeDashJS=function(){g.removeDashJS(x)},g.init(x,L),g.emit(x,"playerready"),k.paused||(g.emit(x,"play"),k.readyState>2&&g.emit(x,"playing")),k.mux.listeners={},On.forEach(function(he){(he!=="error"||L.automaticErrorTracking)&&(k.mux.listeners[he]=function(){var se={};if(he==="error"){if(!k.error||k.error.code===1)return;se.player_error_code=k.error.code,se.player_error_message=Mn[k.error.code]||k.error.message}g.emit(x,he,se)},k.addEventListener(he,k.mux.listeners[he],!1))})}(jt,p,h)},destroyMonitor:function(p){var h=Un(Ee(p),1)[0];h&&h.mux&&typeof h.mux.destroy=="function"?h.mux.destroy():ke.error("A video element monitor for `"+p+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(p,h){var g=ae(p);Ze[g]?Ze[g].addHLSJS(h):ke.error("A monitor for `"+g+"` has not been initialized.")},addDashJS:function(p,h){var g=ae(p);Ze[g]?Ze[g].addDashJS(h):ke.error("A monitor for `"+g+"` has not been initialized.")},removeHLSJS:function(p){var h=ae(p);Ze[h]?Ze[h].removeHLSJS():ke.error("A monitor for `"+h+"` has not been initialized.")},removeDashJS:function(p){var h=ae(p);Ze[h]?Ze[h].removeDashJS():ke.error("A monitor for `"+h+"` has not been initialized.")},init:function(p,h){ut()&&h&&h.respectDoNotTrack&&ke.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var g=ae(p);Ze[g]=new vi(jt,g,h)},emit:function(p,h,g){var b=ae(p);Ze[b]?(Ze[b].emit(h,g),h==="destroy"&&delete Ze[b]):ke.error("A monitor for `"+b+"` has not been initialized.")},checkDoNotTrack:ut,log:ke,utils:Nn,events:Ei,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(jt,nr),z()!==void 0&&typeof z().addEventListener=="function"&&z().addEventListener("pagehide",function(p){p.persisted||(jt.WINDOW_UNLOADING=!0)},!1);var Gr=jt},655:function(G,Q,q){var te,z;function ne(Te){return ne=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(ae){return typeof ae}:function(ae){return ae&&typeof Symbol=="function"&&ae.constructor===Symbol&&ae!==Symbol.prototype?"symbol":typeof ae},ne(Te);}(function(Te){var ae=!1;if((z=typeof(te=Te)=="function"?te.call(Q,q,Q,G):te)===void 0||(G.exports=z),ae=!0,ne(Q)==="object"&&(G.exports=Te(),ae=!0),!ae){var Ee=window.Cookies,Ae=window.Cookies=Te();Ae.noConflict=function(){return window.Cookies=Ee,Ae}}})(function(){var Te=function(){for(var ae=0,Ee={};ae<arguments.length;ae++){var Ae=arguments[ae];for(var Ie in Ae)Ee[Ie]=Ae[Ie]}return Ee};return function ae(Ee){function Ae(Ie,Ye,ke){var ut;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(ke=Te({path:"/"},Ae.defaults,ke)).expires=="number"){var Fe=new Date;Fe.setMilliseconds(Fe.getMilliseconds()+864e5*ke.expires),ke.expires=Fe}try{ut=JSON.stringify(Ye),/^[\{\[]/.test(ut)&&(Ye=ut)}catch{}return Ye=Ee.write?Ee.write(Ye,Ie):encodeURIComponent(String(Ye)).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,"=",Ye,ke.expires?"; expires="+ke.expires.toUTCString():"",ke.path?"; path="+ke.path:"",ke.domain?"; domain="+ke.domain:"",ke.secure?"; secure":""].join("")}Ie||(ut={});for(var ee=document.cookie?document.cookie.split("; "):[],_=/(%[0-9A-Z]{2})+/g,re=0;re<ee.length;re++){var M=ee[re].split("="),Ke=M.slice(1).join("=");Ke.charAt(0)==='"'&&(Ke=Ke.slice(1,-1));try{var St=M[0].replace(_,decodeURIComponent);if(Ke=Ee.read?Ee.read(Ke,St):Ee(Ke,St)||Ke.replace(_,decodeURIComponent),this.json)try{Ke=JSON.parse(Ke)}catch{}if(Ie===St){ut=Ke;break}Ie||(ut[St]=Ke)}catch{}}return ut}}return Ae.set=Ae,Ae.get=function(Ie){return Ae.call(Ae,Ie)},Ae.getJSON=function(){return Ae.apply({json:!0},[].slice.call(arguments))},Ae.defaults={},Ae.remove=function(Ie,Ye){Ae(Ie,"",Te(Ye,{expires:-1}))},Ae.withConverter=ae,Ae}(function(){})})},153:function(G,Q,q){var te,z=q.g!==void 0?q.g:typeof window!="undefined"?window:{},ne=q(558);typeof document!="undefined"?te=document:(te=z["__GLOBAL_DOCUMENT_CACHE@4"])||(te=z["__GLOBAL_DOCUMENT_CACHE@4"]=ne),G.exports=te},48:function(G,Q,q){var te;te=typeof window!="undefined"?window:q.g!==void 0?q.g:typeof self!="undefined"?self:{},G.exports=te},640:function(G,Q,q){var te,z;(function(ne,Te){"use strict";te=function(){var ae=function(){},Ee="undefined",Ae=typeof window!==Ee&&typeof window.navigator!==Ee&&/Trident\/|MSIE /.test(window.navigator.userAgent),Ie=["trace","debug","info","warn","error"];function Ye(we,We){var $e=we[We];if(typeof $e.bind=="function")return $e.bind(we);try{return Function.prototype.bind.call($e,we)}catch{return function(){return Function.prototype.apply.apply($e,[we,arguments])}}}function ke(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function ut(we){return we==="debug"&&(we="log"),typeof console!==Ee&&(we==="trace"&&Ae?ke:console[we]!==void 0?Ye(console,we):console.log!==void 0?Ye(console,"log"):ae)}function Fe(we,We){for(var $e=0;$e<Ie.length;$e++){var P=Ie[$e];this[P]=$e<we?ae:this.methodFactory(P,we,We)}this.log=this.debug}function ee(we,We,$e){return function(){typeof console!==Ee&&(Fe.call(this,We,$e),this[we].apply(this,arguments))}}function _(we,We,$e){return ut(we)||ee.apply(this,arguments)}function re(we,We,$e){var P,He=this;We=We==null?"WARN":We;var dt="loglevel";function Be(Se){var ze=(Ie[Se]||"silent").toUpperCase();if(typeof window!==Ee&&dt){try{return void(window.localStorage[dt]=ze)}catch{}try{window.document.cookie=encodeURIComponent(dt)+"="+ze+";"}catch{}}}function Ht(){var Se;if(typeof window!==Ee&&dt){try{Se=window.localStorage[dt]}catch{}if(typeof Se===Ee)try{var ze=window.document.cookie,Gt=ze.indexOf(encodeURIComponent(dt)+"=");Gt!==-1&&(Se=/^([^;]+)/.exec(ze.slice(Gt))[1])}catch{}return He.levels[Se]===void 0&&(Se=void 0),Se}}function ur(){if(typeof window!==Ee&&dt){try{return void window.localStorage.removeItem(dt)}catch{}try{window.document.cookie=encodeURIComponent(dt)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof we=="string"?dt+=":"+we:typeof we=="symbol"&&(dt=void 0),He.name=we,He.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},He.methodFactory=$e||_,He.getLevel=function(){return P},He.setLevel=function(Se,ze){if(typeof Se=="string"&&He.levels[Se.toUpperCase()]!==void 0&&(Se=He.levels[Se.toUpperCase()]),!(typeof Se=="number"&&Se>=0&&Se<=He.levels.SILENT))throw"log.setLevel() called with invalid level: "+Se;if(P=Se,ze!==!1&&Be(Se),Fe.call(He,Se,we),typeof console===Ee&&Se<He.levels.SILENT)return"No console available for logging"},He.setDefaultLevel=function(Se){We=Se,Ht()||He.setLevel(Se,!1)},He.resetLevel=function(){He.setLevel(We,!1),ur()},He.enableAll=function(Se){He.setLevel(He.levels.TRACE,Se)},He.disableAll=function(Se){He.setLevel(He.levels.SILENT,Se)};var Mt=Ht();Mt==null&&(Mt=We),He.setLevel(Mt,!1)}var M=new re,Ke={};M.getLogger=function(we){if(typeof we!="symbol"&&typeof we!="string"||we==="")throw new TypeError("You must supply a name when creating a logger.");var We=Ke[we];return We||(We=Ke[we]=new re(we,M.getLevel(),M.methodFactory)),We};var St=typeof window!==Ee?window.log:void 0;return M.noConflict=function(){return typeof window!==Ee&&window.log===M&&(window.log=St),M},M.getLoggers=function(){return Ke},M.default=M,M},(z=typeof te=="function"?te.call(Q,q,Q,G):te)===void 0||(G.exports=z)})()},375:function(G,Q){"use strict";var q=Object.prototype.hasOwnProperty;function te(ne){try{return decodeURIComponent(ne.replace(/\+/g," "))}catch{return null}}function z(ne){try{return encodeURIComponent(ne)}catch{return null}}Q.stringify=function(ne,Te){Te=Te||"";var ae,Ee,Ae=[];for(Ee in typeof Te!="string"&&(Te="?"),ne)if(q.call(ne,Ee)){if((ae=ne[Ee])||ae!=null&&!isNaN(ae)||(ae=""),Ee=z(Ee),ae=z(ae),Ee===null||ae===null)continue;Ae.push(Ee+"="+ae)}return Ae.length?Te+Ae.join("&"):""},Q.parse=function(ne){for(var Te,ae=/([^=?#&]+)=?([^&]*)/g,Ee={};Te=ae.exec(ne);){var Ae=te(Te[1]),Ie=te(Te[2]);Ae===null||Ie===null||Ae in Ee||(Ee[Ae]=Ie)}return Ee}},558:function(){}},H={};function j(G){var Q=H[G];if(Q!==void 0)return Q.exports;var q=H[G]={exports:{}};return F[G].call(q.exports,q,q.exports,j),q.exports}return j.n=function(G){var Q=G&&G.__esModule?function(){return G.default}:function(){return G};return j.d(Q,{a:Q}),Q},j.d=function(G,Q){for(var q in Q)j.o(Q,q)&&!j.o(G,q)&&Object.defineProperty(G,q,{enumerable:!0,get:Q[q]})},j.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),j.o=function(G,Q){return Object.prototype.hasOwnProperty.call(G,Q)},j(80)}()},typeof yn=="object"&&typeof pa=="object"?pa.exports=I():typeof yn=="object"?yn.mux=I():D.mux=I()})()});var As=Ss((ws,ma)=>{(function D(I){var F,H;F=this,H=function(){"use strict";function j(s,n){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);n&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),e.push.apply(e,t)}return e}function G(s){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?j(Object(e),!0).forEach(function(t){te(s,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):j(Object(e)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(e,t))})}return s}function Q(s,n){for(var e=0;e<n.length;e++){var t=n[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,ut(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 te(s,n,e){return(n=ut(n))in s?Object.defineProperty(s,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[n]=e,s}function z(){return z=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(s[t]=e[t])}return s},z.apply(this,arguments)}function ne(s,n){s.prototype=Object.create(n.prototype),s.prototype.constructor=s,ae(s,n)}function Te(s){return Te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Te(s)}function ae(s,n){return ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ae(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 Ae(s,n,e){return Ae=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&&ae(o,i.prototype),o},Ae.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 Ae(e,arguments,Te(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ae(r,e)},Ie(s)}function Ye(s,n){(n==null||n>s.length)&&(n=s.length);for(var e=0,t=new Array(n);e<n;e++)t[e]=s[e];return t}function ke(s,n){var e=typeof Symbol!="undefined"&&s[Symbol.iterator]||s["@@iterator"];if(e)return(e=e.call(s)).next.bind(e);if(Array.isArray(s)||(e=function(r,i){if(r){if(typeof r=="string")return Ye(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)?Ye(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 ut(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 Fe={};(function(s,n){var e,t,r,i,a;e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(o,l,d){if(d=d||{},o=o.trim(),!(l=l.trim())){if(!d.alwaysNormalize)return o;var u=a.parseURL(o);if(!u)throw new Error("Error trying to parse base URL.");return u.path=a.normalizePath(u.path),a.buildURLFromParts(u)}var c=a.parseURL(l);if(!c)throw new Error("Error trying to parse relative URL.");if(c.scheme)return d.alwaysNormalize?(c.path=a.normalizePath(c.path),a.buildURLFromParts(c)):l;var f=a.parseURL(o);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var v=t.exec(f.path);f.netLoc=v[1],f.path=v[2]}f.netLoc&&!f.path&&(f.path="/");var m={scheme:f.scheme,netLoc:c.netLoc,path:null,params:c.params,query:c.query,fragment:c.fragment};if(!c.netLoc&&(m.netLoc=f.netLoc,c.path[0]!=="/"))if(c.path){var T=f.path,S=T.substring(0,T.lastIndexOf("/")+1)+c.path;m.path=a.normalizePath(S)}else m.path=f.path,c.params||(m.params=f.params,c.query||(m.query=f.query));return m.path===null&&(m.path=d.alwaysNormalize?a.normalizePath(c.path):c.path),a.buildURLFromParts(m)},parseURL:function(o){var l=e.exec(o);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(o){for(o=o.split("").reverse().join("").replace(r,"");o.length!==(o=o.replace(i,"")).length;);return o.split("").reverse().join("")},buildURLFromParts:function(o){return o.scheme+o.netLoc+o.path+o.params+o.query+o.fragment}},s.exports=a})({get exports(){return Fe},set exports(s){Fe=s}});var ee=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},_=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}({}),re=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}({}),M=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(){},St={trace:Ke,debug:Ke,log:Ke,warn:Ke,info:Ke,error:Ke},we=St;function We(s){var n=self.console[s];return n?n.bind(self.console,"["+s+"] >"):Ke}function $e(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){we[a]=e[a]?e[a].bind(e):We(a)})})(s,"debug","log","info","warn","error");try{we.log('Debug logs enabled for "'+n+'" in hls.js version 1.4.0')}catch{we=St}}else we=St}var P=we,He=/^(\d+)x(\d+)$/,dt=/(.+?)=(".*?"|.*?)(?:,|$)/g,Be=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=He.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(dt.lastIndex=0;(t=dt.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 Ht(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var ur=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=z(new Be({}),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"]);ee(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(ee(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&&ee(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),s}(),Mt=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}},Se="audio",ze="video",Gt="audiovideo",_r=function(){function s(n){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[Se]=null,e[ze]=null,e[Gt]=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=Fe.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(n){this._url=n}}]),s}(),br=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 Mt,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.type=t,i}ne(n,s);var e=n.prototype;return e.setKeyFormat=function(t){if(this.levelkeys){var r=this.levelkeys[t];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},e.abortRequests=function(){var t,r;(t=this.loader)==null||t.abort(),(r=this.keyLoader)==null||r.abort()},e.setElementaryStreamInfo=function(t,r,i,a,o,l){l===void 0&&(l=!1);var d=this.elementaryStreams,u=d[t];u?(u.startPTS=Math.min(u.startPTS,r),u.endPTS=Math.max(u.endPTS,i),u.startDTS=Math.min(u.startDTS,a),u.endDTS=Math.max(u.endDTS,o)):d[t]={startPTS:r,endPTS:i,startDTS:a,endDTS:o,partial:l}},e.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[Se]=null,t[ze]=null,t[Gt]=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||!ee(this.programDateTime))return null;var t=ee(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}(_r),Ai=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 Mt,o.duration=e.decimalFloatingPoint("DURATION"),o.gap=e.bool("GAP"),o.independent=e.bool("INDEPENDENT"),o.relurl=e.enumeratedString("URI"),o.fragment=t,o.index=i;var l=e.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,a),a&&(o.fragOffset=a.fragOffset+a.duration),o}return ne(n,s),q(n,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),n}(_r),Ln=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&&ee(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 Xr(s){return Uint8Array.from(atob(s),function(n){return n.charCodeAt(0)})}function Ri(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=Xr(l)):(n=Di(l).subarray(0,16),(e=new Uint8Array(16)).set(n,16-n.length),r=e)}}return r}function Di(s){return Uint8Array.from(unescape(encodeURIComponent(s)),function(n){return n.charCodeAt(0)})}var qe={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Qr="org.w3.clearkey",Jr="com.apple.streamingkeydelivery",dr="com.microsoft.playready",Sr="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function $r(s){switch(s){case Jr:return qe.FAIRPLAY;case dr:return qe.PLAYREADY;case Sr:return qe.WIDEVINE;case Qr:return qe.CLEARKEY}}var Ii="edef8ba979d64acea3c827dcd51d21ed";function Zr(s){switch(s){case qe.FAIRPLAY:return Jr;case qe.PLAYREADY:return dr;case qe.WIDEVINE:return Sr;case qe.CLEARKEY:return Qr}}function ei(s){var n=s.drmSystems,e=s.widevineLicenseUrl,t=n?[qe.FAIRPLAY,qe.WIDEVINE,qe.PLAYREADY,qe.CLEARKEY].filter(function(r){return!!n[r]}):[];return!t[qe.WIDEVINE]&&e&&t.push(qe.WIDEVINE),t}var ti=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function zt(s,n,e){return Uint8Array.prototype.slice?s.slice(n,e):new Uint8Array(Array.prototype.slice.call(s,n,e))}var Lr,ri=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},ii=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},kr=function(s,n){for(var e=n,t=0;ri(s,n);)t+=10,t+=wr(s,n+6),ii(s,n+10)&&(t+=10),n+=t;if(t>0)return s.subarray(e,e+t)},wr=function(s,n){var e=0;return e=(127&s[n])<<21,e|=(127&s[n+1])<<14,e|=(127&s[n+2])<<7,e|=127&s[n+3]},xi=function(s,n){return ri(s,n)&&wr(s,n+6)+10<=s.length-n},Ci=function(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"},Pi=function(s){var n=String.fromCharCode(s[0],s[1],s[2],s[3]),e=wr(s,4);return{type:n,size:e,data:s.subarray(10,10+e)}},Oi=function(s){for(var n=0,e=[];ri(s,n);){for(var t=wr(s,n+6),r=(n+=10)+t;n+8<r;){var i=Pi(s.subarray(n)),a=kn(i);a&&e.push(a),n+=i.size+10}ii(s,n)&&(n+=10)}return e},kn=function(s){return s.type==="PRIV"?Mi(s):s.type[0]==="W"?An(s):wn(s)},Mi=function(s){if(!(s.size<2)){var n=Tt(s.data,!0),e=new Uint8Array(s.data.subarray(n.length+1));return{key:s.type,info:n,data:e.buffer}}},wn=function(s){if(!(s.size<2)){if(s.type==="TXXX"){var n=1,e=Tt(s.data.subarray(n),!0);n+=e.length+1;var t=Tt(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=Tt(s.data.subarray(1));return{key:s.type,data:r}}},An=function(s){if(s.type==="WXXX"){if(s.size<2)return;var n=1,e=Tt(s.data.subarray(n),!0);n+=e.length+1;var t=Tt(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=Tt(s.data);return{key:s.type,data:r}},Fi=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)}},Tt=function(s,n){n===void 0&&(n=!1);var e=Ni();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 Ni(){return Lr||self.TextDecoder===void 0||(Lr=new self.TextDecoder("utf-8")),Lr}var Et=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},Ar=Math.pow(2,32)-1,Rn=[].push,ni={video:1,audio:2,id3:3,text:4};function et(s){return String.fromCharCode.apply(null,s)}function Ui(s,n){var e=s[n]<<8|s[n+1];return e<0?65536+e:e}function _e(s,n){var e=Bi(s,n);return e<0?4294967296+e:e}function Bi(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 xe(s,n){var e=[];if(!n.length)return e;for(var t=s.byteLength,r=0;r<t;){var i=_e(s,r),a=i>1?r+i:t;if(et(s.subarray(r+4,r+8))===n[0])if(n.length===1)e.push(s.subarray(r+8,a));else{var o=xe(s.subarray(r+8,a),n.slice(1));o.length&&Rn.apply(e,o)}r=a}return e}function Dn(s){var n=[],e=s[0],t=8,r=_e(s,t);t+=4,t+=e===0?8:16,t+=2;var i=s.length+0,a=Ui(s,t);t+=2;for(var o=0;o<a;o++){var l=t,d=_e(s,l);l+=4;var u=2147483647&d;if((2147483648&d)>>>31==1)return P.warn("SIDX has hierarchical references (not supported)"),null;var c=_e(s,l);l+=4,n.push({referenceSize:u,subsegmentDuration:c,info:{duration:c/r,start:i,end:i+u-1}}),i+=u,t=l+=4}return{earliestPresentationTime:0,timescale:r,version:e,referencesCount:a,references:n}}function si(s){for(var n=[],e=xe(s,["moov","trak"]),t=0;t<e.length;t++){var r=e[t],i=xe(r,["tkhd"])[0];if(i){var a=i[0],o=a===0?12:20,l=_e(i,o),d=xe(r,["mdia","mdhd"])[0];if(d){var u=_e(d,o=(a=d[0])===0?12:20),c=xe(r,["mdia","hdlr"])[0];if(c){var f=et(c.subarray(8,12)),v={soun:Se,vide:ze}[f];if(v){var m=xe(r,["mdia","minf","stbl","stsd"])[0],T=void 0;m&&(T=et(m.subarray(12,16))),n[l]={timescale:u,type:v},n[v]={timescale:u,id:l,codec:T}}}}}}return xe(s,["moov","mvex","trex"]).forEach(function(S){var y=_e(S,4),E=n[y];E&&(E.default={duration:_e(S,12),flags:_e(S,20)})}),n}function oi(s){var n=xe(s,["schm"])[0];if(n){var e=et(n.subarray(4,8));if(e==="cbcs"||e==="cenc")return xe(s,["schi","tenc"])[0]}return P.error("[eme] missing 'schm' box"),null}function Hi(s){var n=_e(s,0),e=8;1&n&&(e+=4),4&n&&(e+=4);for(var t=0,r=_e(s,4),i=0;i<r;i++)256&n&&(t+=_e(s,e),e+=4),512&n&&(e+=4),1024&n&&(e+=4),2048&n&&(e+=4);return t}function Kt(s,n){var e=new Uint8Array(s.length+n.length);return e.set(s),e.set(n,s.length),e}function Gi(s,n){var e=[],t=n.samples,r=n.timescale,i=n.id,a=!1;return xe(t,["moof"]).map(function(o){var l=o.byteOffset-8;xe(o,["traf"]).map(function(d){var u=xe(d,["tfdt"]).map(function(c){var f=c[0],v=_e(c,4);return f===1&&(v*=Math.pow(2,32),v+=_e(c,8)),v/r})[0];return u!==void 0&&(s=u),xe(d,["tfhd"]).map(function(c){var f=_e(c,4),v=16777215&_e(c,0),m=0,T=(16&v)!=0,S=0,y=(32&v)!=0,E=8;f===i&&((1&v)!=0&&(E+=8),(2&v)!=0&&(E+=4),(8&v)!=0&&(m=_e(c,E),E+=4),T&&(S=_e(c,E),E+=4),y&&(E+=4),n.type==="video"&&(a=function(R){if(!R)return!1;var A=R.indexOf("."),C=A<0?R:R.substring(0,A);return C==="hvc1"||C==="hev1"||C==="dvh1"||C==="dvhe"}(n.codec)),xe(d,["trun"]).map(function(R){var A=R[0],C=16777215&_e(R,0),N=(1&C)!=0,B=0,Y=(4&C)!=0,K=(256&C)!=0,V=0,$=(512&C)!=0,X=0,le=(1024&C)!=0,ye=(2048&C)!=0,oe=0,ve=_e(R,4),me=8;N&&(B=_e(R,me),me+=4),Y&&(me+=4);for(var ge=B+l,Le=0;Le<ve;Le++){if(K?(V=_e(R,me),me+=4):V=m,$?(X=_e(R,me),me+=4):X=S,le&&(me+=4),ye&&(oe=A===0?_e(R,me):Bi(R,me),me+=4),n.type===ze)for(var De=0;De<X;){var Oe=_e(t,ge);In(a,t[ge+=4])&&li(t.subarray(ge,ge+Oe),a?2:1,s+oe/r,e),ge+=Oe,De+=Oe+4}s+=V/r}}))})})}),e}function In(s,n){if(s){var e=n>>1&63;return e===39||e===40}return(31&n)==6}function li(s,n,e,t){var r=ui(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=Ui(r,i);if(i+=2,c===49){var f=_e(r,i);if(i+=4,f===1195456820){var v=r[i++];if(v===3){var m=r[i++],T=64&m,S=T?2+3*(31&m):0,y=new Uint8Array(S);if(T){y[0]=m;for(var E=1;E<S;E++)y[E]=r[i++]}t.push({type:v,payloadType:a,pts:e,bytes:y})}}}}}else if(a===5&&o<u){if(l=!0,o>16){for(var R=[],A=0;A<16;A++){var C=r[i++].toString(16);R.push(C.length==1?"0"+C:C),A!==3&&A!==5&&A!==7&&A!==9||R.push("-")}for(var N=o-16,B=new Uint8Array(N),Y=0;Y<N;Y++)B[Y]=r[i++];t.push({payloadType:a,pts:e,uuid:R.join(""),userData:Tt(B),userDataBytes:B})}}else if(o<u)i+=o;else if(o>u)break}}function ui(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 xn(s,n,e){if(s.byteLength!==16)throw new RangeError("Invalid system id");var t,r,i;if(n){t=1,r=new Uint8Array(16*n.length);for(var a=0;a<n.length;a++){var o=n[a];if(o.byteLength!==16)throw new RangeError("Invalid key");r.set(o,16*a)}}else t=0,r=new Uint8Array;t>0?(i=new Uint8Array(4),n.length>0&&new DataView(i.buffer).setUint32(0,n.length,!1)):i=new Uint8Array;var l=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(l.buffer).setUint32(0,e.byteLength,!1),function(d){for(var u=arguments.length,c=new Array(u>1?u-1:0),f=1;f<u;f++)c[f-1]=arguments[f];for(var v=c.length,m=8,T=v;T--;)m+=c[T].byteLength;var S=new Uint8Array(m);for(S[0]=m>>24&255,S[1]=m>>16&255,S[2]=m>>8&255,S[3]=255&m,S.set(d,4),T=0,m=8;T<v;T++)S.set(c[T],m),m+=c[T].byteLength;return S}([112,115,115,104],new Uint8Array([t,0,0,0]),s,i,r,l,e||new Uint8Array)}var Rr={},Dr=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(){Rr={}};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 Jr:case Sr:case dr:case Qr: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(S){for(var y=new Uint8Array(16),E=12;E<16;E++)y[E]=S>>8*(15-E)&255;return y}(e);return new s(this.method,this.uri,"identity",this.keyFormatVersions,t)}var r=Ri(this.uri);if(r)switch(this.keyFormat){case Sr:this.pssh=r,r.length>=22&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case dr:var i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=xn(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=Xr(u).subarray(0,16);(function(S){var y=function(E,R,A){var C=E[R];E[R]=E[A],E[A]=C};y(S,0,3),y(S,1,2),y(S,4,5),y(S,6,7)})(c),this.keyId=c}}break;default:var f=r.subarray(0,16);if(f.length!==16){var v=new Uint8Array(16);v.set(f,16-f.length),f=v}this.keyId=f}if(!this.keyId||this.keyId.byteLength!==16){var m=Rr[this.uri];if(!m){var T=Object.keys(Rr).length%Number.MAX_SAFE_INTEGER;m=new Uint8Array(16),new DataView(m.buffer,12,4).setUint32(0,T),Rr[this.uri]=m}this.keyId=m}return this},s}(),di=/\{\$([a-zA-Z0-9-_]+)\}/g;function Ir(s){return di.test(s)}function ct(s,n,e){if(s.variableList!==null||s.hasVariableRefs)for(var t=e.length;t--;){var r=e[t],i=n[r];i&&(n[r]=ci(s,i))}}function ci(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 Ki(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 Ft(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 Cn={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 xr(s,n){return MediaSource.isTypeSupported((n||"video")+'/mp4;codecs="'+s+'"')}var qi=/#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,Vi=/#EXT-X-MEDIA:(.*)/g,ji=/^#EXT(?:INF|-X-TARGETDURATION):/m,hi=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),rr=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("|")),Nt=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 Fe.buildAbsoluteURL(e,n,{alwaysNormalize:!0})},s.isMediaPlaylist=function(n){return ji.test(n)},s.parseMasterPlaylist=function(n,e){var t,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Ir(n)},i=[];for(qi.lastIndex=0;(t=qi.exec(n))!=null;)if(t[1]){var a,o=new Be(t[1]);ct(r,o,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=ci(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),Cr((o.CODECS||"").split(/[ ,]+/).filter(function(R){return R}),d),d.videoCodec&&d.videoCodec.indexOf("avc1")!==-1&&(d.videoCodec=s.convertAVC1ToAVCOTI(d.videoCodec)),(a=d.unknownCodecs)!=null&&a.length||i.push(d),r.levels.push(d)}else if(t[3]){var c=t[3],f=t[4];switch(c){case"SESSION-DATA":var v=new Be(f);ct(r,v,["DATA-ID","LANGUAGE","VALUE","URI"]);var m=v["DATA-ID"];m&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[m]=v);break;case"SESSION-KEY":var T=Wi(f,e,r);T.encrypted&&T.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(T)):P.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+f+'"');break;case"DEFINE":var S=new Be(f);ct(r,S,["NAME","VALUE","QUERYPARAM"]),Ki(r,S,e);break;case"CONTENT-STEERING":var y=new Be(f);ct(r,y,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:s.resolve(y["SERVER-URI"],e),pathwayId:y["PATHWAY-ID"]||"."};break;case"START":r.startTimeOffset=fi(f)}}var E=i.length>0&&i.length<r.levels.length;return r.levels=E?i:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},s.parseMasterPlaylistMedia=function(n,e,t){var r,i={},a=t.levels,o={AUDIO:a.map(function(T){return{id:T.attrs.AUDIO,audioCodec:T.audioCodec}}),SUBTITLES:a.map(function(T){return{id:T.attrs.SUBTITLES,textCodec:T.textCodec}}),"CLOSED-CAPTIONS":[]},l=0;for(Vi.lastIndex=0;(r=Vi.exec(n))!==null;){var d=new Be(r[1]),u=d.TYPE;if(u){var c=o[u],f=i[u]||[];i[u]=f,ct(t,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var v={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",instreamId:d["INSTREAM-ID"],name:d.NAME||d.LANGUAGE||"",type:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:d.LANGUAGE,url:d.URI?s.resolve(d.URI,e):""};if(c!=null&&c.length){var m=s.findGroup(c,v.groupId)||c[0];Yi(v,m,"audioCodec"),Yi(v,m,"textCodec")}f.push(v)}}return i},s.parseLevelPlaylist=function(n,e,t,r,i,a){var o,l,d,u=new Ln(e),c=u.fragments,f=null,v=0,m=0,T=0,S=0,y=null,E=new br(r,e),R=-1,A=!1;for(hi.lastIndex=0,u.m3u8=n,u.hasVariableRefs=Ir(n);(o=hi.exec(n))!==null;){A&&(A=!1,(E=new br(r,e)).start=T,E.sn=v,E.cc=S,E.level=t,f&&(E.initSegment=f,E.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null));var C=o[1];if(C){E.duration=parseFloat(C);var N=(" "+o[2]).slice(1);E.title=N||null,E.tagList.push(N?["INF",C,N]:["INF",C])}else if(o[3]){if(ee(E.duration)){E.start=T,d&&Qi(E,d,u),E.sn=v,E.level=t,E.cc=S,E.urlId=i,c.push(E);var B=(" "+o[3]).slice(1);E.relurl=ci(u,B),zi(E,y),y=E,T+=E.duration,v++,m=0,A=!0}}else if(o[4]){var Y=(" "+o[4]).slice(1);y?E.setByteRange(Y,y):E.setByteRange(Y)}else if(o[5])E.rawProgramDateTime=(" "+o[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),R===-1&&(R=c.length);else{if(!(o=o[0].match(rr))){P.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<o.length&&o[l]===void 0;l++);var K=(" "+o[l]).slice(1),V=(" "+o[l+1]).slice(1),$=o[l+2]?(" "+o[l+2]).slice(1):"";switch(K){case"PLAYLIST-TYPE":u.type=V.toUpperCase();break;case"MEDIA-SEQUENCE":v=u.startSN=parseInt(V);break;case"SKIP":var X=new Be(V);ct(u,X,["RECENTLY-REMOVED-DATERANGES"]);var le=X.decimalInteger("SKIPPED-SEGMENTS");if(ee(le)){u.skippedSegments=le;for(var ye=le;ye--;)c.unshift(null);v+=le}var oe=X.enumeratedString("RECENTLY-REMOVED-DATERANGES");oe&&(u.recentlyRemovedDateranges=oe.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||$)&&E.tagList.push($?[V,$]:[V]);break;case"DISCONTINUITY":S++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([K]);break;case"BITRATE":E.tagList.push([K,V]);break;case"DATERANGE":var ve=new Be(V);ct(u,ve,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),ct(u,ve,ve.clientAttrs);var me=new ur(ve,u.dateRanges[ve.ID]);me.isValid||u.skippedSegments?u.dateRanges[me.id]=me:P.warn('Ignoring invalid DATERANGE tag: "'+V+'"'),E.tagList.push(["EXT-X-DATERANGE",V]);break;case"DEFINE":var ge=new Be(V);ct(u,ge,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in ge?Ft(u,ge,a):Ki(u,ge,e);break;case"DISCONTINUITY-SEQUENCE":S=parseInt(V);break;case"KEY":var Le=Wi(V,e,u);if(Le.isSupported()){if(Le.method==="NONE"){d=void 0;break}d||(d={}),d[Le.keyFormat]&&(d=z({},d)),d[Le.keyFormat]=Le}else P.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+V+'"');break;case"START":u.startTimeOffset=fi(V);break;case"MAP":var De=new Be(V);if(ct(u,De,["BYTERANGE","URI"]),E.duration){var Oe=new br(r,e);Xi(Oe,De,t,d),f=Oe,E.initSegment=f,f.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=f.rawProgramDateTime)}else Xi(E,De,t,d),f=E,A=!0;break;case"SERVER-CONTROL":var Ue=new Be(V);u.canBlockReload=Ue.bool("CAN-BLOCK-RELOAD"),u.canSkipUntil=Ue.optionalFloat("CAN-SKIP-UNTIL",0),u.canSkipDateRanges=u.canSkipUntil>0&&Ue.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=Ue.optionalFloat("PART-HOLD-BACK",0),u.holdBack=Ue.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var yt=new Be(V);u.partTarget=yt.decimalFloatingPoint("PART-TARGET");break;case"PART":var rt=u.partList;rt||(rt=u.partList=[]);var Ut=m>0?rt[rt.length-1]:void 0,Ct=m++,Pt=new Be(V);ct(u,Pt,["BYTERANGE","URI"]);var it=new Ai(Pt,E,e,Ct,Ut);rt.push(it),E.duration+=it.duration;break;case"PRELOAD-HINT":var st=new Be(V);ct(u,st,["URI"]),u.preloadHint=st;break;case"RENDITION-REPORT":var Yt=new Be(V);ct(u,Yt,["URI"]),u.renditionReports=u.renditionReports||[],u.renditionReports.push(Yt);break;default:P.warn("line parsed but not handled: "+o)}}}y&&!y.relurl?(c.pop(),T-=y.duration,u.partList&&(u.fragmentHint=y)):u.partList&&(zi(E,y),E.cc=S,u.fragmentHint=E,d&&Qi(E,d,u));var or=c.length,bt=c[0],Si=c[or-1];if((T+=u.skippedSegments*u.targetduration)>0&&or&&Si){u.averagetargetduration=T/or;var Li=Si.sn;u.endSN=Li!=="initSegment"?Li:0,u.live||(Si.endList=!0),bt&&(u.startCC=bt.cc)}else u.endSN=0,u.startCC=0;return u.fragmentHint&&(T+=u.fragmentHint.duration),u.totalduration=T,u.endCC=S,R>0&&function(pn,Yr){for(var Er=pn[Yr],ki=Yr;ki--;){var er=pn[ki];if(!er)return;er.programDateTime=Er.programDateTime-1e3*er.duration,Er=er}}(c,R),u},s}();function Wi(s,n,e){var t,r,i=new Be(s);ct(e,i,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var a=(t=i.METHOD)!=null?t:"",o=i.URI,l=i.hexadecimalInteger("IV"),d=i.KEYFORMATVERSIONS,u=(r=i.KEYFORMAT)!=null?r:"identity";o&&i.IV&&!l&&P.error("Invalid IV: "+i.IV);var c=o?Nt.resolve(o,n):"",f=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Dr(a,c,u,f,l)}function fi(s){var n=new Be(s).decimalFloatingPoint("TIME-OFFSET");return ee(n)?n:null}function Cr(s,n){["video","audio","text"].forEach(function(e){var t=s.filter(function(i){return function(a,o){var l=Cn[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 Yi(s,n,e){var t=n[e];t&&(s[e]=t)}function zi(s,n){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):n!=null&&n.programDateTime&&(s.programDateTime=n.endProgramDateTime),ee(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function Xi(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 Qi(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 Xt="manifest",Qt="level",Lt="audioTrack",kt="subtitleTrack",Me="main",wt="audio",At="subtitle";function Ji(s){switch(s.type){case Lt:return wt;case kt:return At;default:return Me}}function Pr(s,n){var e=s.url;return e!==void 0&&e.indexOf("data:")!==0||(e=n.url),e}var $i=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(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(_.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.unregisterListeners=function(){var e=this.hls;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(_.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:Xt,url:r,deliveryDirectives:null})},n.onLevelLoading=function(e,t){var r=t.id,i=t.level,a=t.url,o=t.deliveryDirectives;this.load({id:r,level:i,responseType:"text",type:Qt,url:a,deliveryDirectives:o})},n.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,o=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:Lt,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:kt,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===Xt?o.manifestLoadPolicy.default:z({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),l=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part&&(e.type===Qt&&e.level!==null?i=this.hls.levels[e.level].details:e.type===Lt&&e.id!==null?i=this.hls.audioTracks[e.id].details:e.type===kt&&e.id!==null&&(i=this.hls.subtitleTracks[e.id].details),i)){var u=i.partTarget,c=i.targetduration;if(u&&c){var f=1e3*Math.max(3*u,.8*c);r=z({},r,{maxTimeToFirstByteMs:Math.min(f,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,r.maxTimeToFirstByteMs)})}}var v=r.errorRetry||r.timeoutRetry||{},m={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:v.maxNumRetry||0,retryDelay:v.retryDelayMs||0,maxRetryDelay:v.maxRetryDelayMs||0},T={onSuccess:function(S,y,E,R){var A=a.getInternalLoader(E);a.resetInternalLoader(E.type);var C=S.data;C.indexOf("#EXTM3U")===0?(y.parsing.start=performance.now(),Nt.isMediaPlaylist(C)?a.handleTrackOrLevelPlaylist(S,y,E,R||null,A):a.handleMasterPlaylist(S,y,E,R)):a.handleManifestParsingError(S,E,new Error("no EXTM3U delimiter"),R||null,y)},onError:function(S,y,E,R){a.handleNetworkError(y,E,!1,S,R)},onTimeout:function(S,y,E){a.handleNetworkError(y,E,!0,void 0,S)}};l.load(e,m,T)},n.handleMasterPlaylist=function(e,t,r,i){var a=this.hls,o=e.data,l=Pr(e,r),d=Nt.parseMasterPlaylist(o,l);if(d.playlistParsingError)this.handleManifestParsingError(e,r,d.playlistParsingError,i,t);else{var u=d.contentSteering,c=d.levels,f=d.sessionData,v=d.sessionKeys,m=d.startTimeOffset,T=d.variableList;this.variableList=T;var S=Nt.parseMasterPlaylistMedia(o,l,d),y=S.AUDIO,E=y===void 0?[]:y,R=S.SUBTITLES,A=S["CLOSED-CAPTIONS"];E.length&&(E.some(function(C){return!C.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"),E.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Be({}),bitrate:0,url:""}))),a.trigger(_.MANIFEST_LOADED,{levels:c,audioTracks:E,subtitles:R,captions:A,contentSteering:u,url:l,stats:t,networkDetails:i,sessionData:f,sessionKeys:v,startTimeOffset:m,variableList:T})}},n.handleTrackOrLevelPlaylist=function(e,t,r,i,a){var o=this.hls,l=r.id,d=r.level,u=r.type,c=Pr(e,r),f=ee(l)?l:0,v=ee(d)?d:f,m=Ji(r),T=Nt.parseLevelPlaylist(e.data,c,v,m,f,this.variableList);if(u===Xt){var S={attrs:new Be({}),bitrate:0,details:T,name:"",url:c};o.trigger(_.MANIFEST_LOADED,{levels:[S],audioTracks:[],url:c,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=T,this.handlePlaylistLoaded(T,e,t,r,i,a)},n.handleManifestParsingError=function(e,t,r,i,a){this.hls.trigger(_.ERROR,{type:re.NETWORK_ERROR,details:M.MANIFEST_PARSING_ERROR,fatal:t.type===Xt,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:a})},n.handleNetworkError=function(e,t,r,i,a){r===void 0&&(r=!1);var o="A network "+(r?"timeout":"error"+(i?" (status "+i.code+")":""))+" occurred while loading "+e.type;e.type===Qt?o+=": "+e.level+" id: "+e.id:e.type!==Lt&&e.type!==kt||(o+=" id: "+e.id+' group-id: "'+e.groupId+'"');var l=new Error(o);P.warn("[playlist-loader]: "+o);var d=M.UNKNOWN,u=!1,c=this.getInternalLoader(e);switch(e.type){case Xt:d=r?M.MANIFEST_LOAD_TIMEOUT:M.MANIFEST_LOAD_ERROR,u=!0;break;case Qt:d=r?M.LEVEL_LOAD_TIMEOUT:M.LEVEL_LOAD_ERROR,u=!1;break;case Lt:d=r?M.AUDIO_TRACK_LOAD_TIMEOUT:M.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case kt:d=r?M.SUBTITLE_TRACK_LOAD_TIMEOUT:M.SUBTITLE_LOAD_ERROR,u=!1}c&&this.resetInternalLoader(e.type);var f={type:re.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(_.ERROR,f)},n.handlePlaylistLoaded=function(e,t,r,i,a,o){var l=this.hls,d=i.type,u=i.level,c=i.id,f=i.groupId,v=i.deliveryDirectives,m=Pr(t,i),T=Ji(i),S=typeof i.level=="number"&&T===Me?u:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var y=e.playlistParsingError;if(y)l.trigger(_.ERROR,{type:re.NETWORK_ERROR,details:M.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:y,reason:y.message,response:t,context:i,level:S,parent:T,networkDetails:a,stats:r});else switch(e.live&&o&&(o.getCacheAge&&(e.ageHeader=o.getCacheAge()||0),o.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),d){case Xt:case Qt:l.trigger(_.LEVEL_LOADED,{details:e,level:S||0,id:c||0,stats:r,networkDetails:a,deliveryDirectives:v});break;case Lt:l.trigger(_.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v});break;case kt:l.trigger(_.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v})}}else{var E=new Error("No Segments found in Playlist");l.trigger(_.ERROR,{type:re.NETWORK_ERROR,details:M.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:E,reason:E.message,response:t,context:i,level:S,parent:T,networkDetails:a,stats:r})}},s}();function Or(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 Zi(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 ir(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 Xe(s,n,e,t){var r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0)for(var i=function(o,l,d){var u=[],c=function(T,S){if(S<T[0].startTime)return 0;var y=T.length-1;if(S>T[y].endTime)return-1;for(var E=0,R=y;E<=R;){var A=Math.floor((R+E)/2);if(S<T[A].startTime)R=A-1;else{if(!(S>T[A].startTime&&E<y))return A;E=A+1}}return T[E].startTime-S<S-T[R].startTime?E:R}(o,l);if(c>-1)for(var f=c,v=o.length;f<v;f++){var m=o[f];if(m.startTime>=l&&m.endTime<=d)u.push(m);else if(m.startTime>d)return u}return u}(s.cues,n,e),a=0;a<i.length;a++)t&&!t(i[a])||s.removeCue(i[a]);r==="disabled"&&(s.mode=r)}var qt="org.id3",Pn="com.apple.quicktime.HLS",cr="https://aomedia.org/emsg/ID3";function vi(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var Mr=function(){var s=vi();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Jt(s,n){return s.getTime()/1e3-n}var gi=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(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this)},n._unregisterListeners=function(){var e=this.hls;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this)},n.onMediaAttached=function(e,t){this.media=t.media},n.onMediaDetaching=function(){this.id3Track&&(ir(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 Or(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=vi(),d=0;d<o.length;d++){var u=o[d].type;if((u!==cr||i)&&a){var c=Oi(o[d].data);if(c){var f=o[d].pts,v=f+o[d].duration;v>Mr&&(v=Mr),v-f<=0&&(v=f+.25);for(var m=0;m<c.length;m++){var T=c[m];if(!Ci(T)){this.updateId3CueEnds(f);var S=new l(f,v,"");S.value=T,u&&(S.type=u),this.id3Track.addCue(S)}}}}}}}},n.updateId3CueEnds=function(e){var t,r=(t=this.id3Track)==null?void 0:t.cues;if(r)for(var i=r.length;i--;){var a=r[i];a.startTime<e&&a.endTime===Mr&&(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)&&Xe(o,r,i,a==="audio"?function(f){return f.type===qt&&c}:a==="video"?function(f){return f.type===cr&&u}:function(f){return f.type===qt&&c||f.type===cr&&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(E){return!d.includes(E)}),c=function(){var E=u[f];Object.keys(a[E].cues).forEach(function(R){o.removeCue(a[E].cues[R])}),delete a[E]},f=u.length;f--;)c();var v=i.fragments[i.fragments.length-1];if(d.length!==0&&ee(v==null?void 0:v.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var m=v.programDateTime/1e3-v.start,T=vi(),S=function(){var E=d[y],R=l[E],A=a[E],C=(A==null?void 0:A.cues)||{},N=(A==null?void 0:A.durationKnown)||!1,B=Jt(R.startDate,m),Y=Mr,K=R.endDate;if(K)Y=Jt(K,m),N=!0;else if(R.endOnNext&&!N){var V=d.reduce(function(ge,Le){var De=l[Le];return De.class===R.class&&De.id!==Le&&De.startDate>R.startDate&&ge.push(De),ge},[]).sort(function(ge,Le){return ge.startDate.getTime()-Le.startDate.getTime()})[0];V&&(Y=Jt(V.startDate,m),N=!0)}for(var $,X,le=Object.keys(R.attr),ye=0;ye<le.length;ye++){var oe=le[ye];if((X=oe)!=="ID"&&X!=="CLASS"&&X!=="START-DATE"&&X!=="DURATION"&&X!=="END-DATE"&&X!=="END-ON-NEXT"){var ve=C[oe];if(ve)N&&!A.durationKnown&&(ve.endTime=Y);else{var me=R.attr[oe];ve=new T(B,Y,""),Ht(oe)&&($=me,me=Uint8Array.from($.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),ve.value={key:oe,data:me},ve.type=Pn,ve.id=E,r.id3Track.addCue(ve),C[oe]=ve}}}a[E]={cues:C,dateRange:R,durationKnown:N}},y=0;y<d.length;y++)S()}}},s}(),en=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(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(_.ERROR,this.onError,this)},n.unregisterListeners=function(){this.hls.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(_.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(_.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===M.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}(),Fr=["NONE","TYPE-0","TYPE-1",null],Vt="",On="YES",Mn="v2",tn=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}(),hr=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 pi(s,n){var e=n.startPTS;if(ee(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 rn(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(ee(l)){var u=Math.abs(l-e);ee(n.deltaPTS)?n.deltaPTS=Math.max(u,n.deltaPTS):n.deltaPTS=u,a=Math.max(e,l),e=Math.min(e,l),r=Math.min(r,n.startDTS),o=Math.min(t,d),t=Math.max(t,d),i=Math.max(i,n.endDTS)}var c=e-n.start;n.start!==0&&(n.start=e),n.duration=t-n.start,n.startPTS=e,n.maxStartPTS=a,n.startDTS=r,n.endPTS=t,n.minEndPTS=o,n.endDTS=i;var f,v=n.sn;if(!s||v<s.startSN||v>s.endSN)return 0;var m=v-s.startSN,T=s.fragments;for(T[m]=n,f=m;f>0;f--)pi(T[f],T[f-1]);for(f=m;f<T.length-1;f++)pi(T[f],T[f+1]);return s.fragmentHint&&pi(T[T.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,c}function Fn(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,E,R){for(var A=E.skippedSegments,C=Math.max(y.startSN,E.startSN)-E.startSN,N=(y.fragmentHint?1:0)+(A?E.endSN:Math.min(y.endSN,E.endSN))-E.startSN,B=E.startSN-y.startSN,Y=E.fragmentHint?E.fragments.concat(E.fragmentHint):E.fragments,K=y.fragmentHint?y.fragments.concat(y.fragmentHint):y.fragments,V=C;V<=N;V++){var $=K[B+V],X=Y[V];A&&!X&&V<A&&(X=E.fragments[V]=$),$&&X&&R($,X)}}(s,n,function(y,E){y.relurl&&(c=y.cc-E.cc),ee(y.startPTS)&&ee(y.endPTS)&&(E.start=E.startPTS=y.startPTS,E.startDTS=y.startDTS,E.maxStartPTS=y.maxStartPTS,E.endPTS=y.endPTS,E.endDTS=y.endDTS,E.minEndPTS=y.minEndPTS,E.duration=y.endPTS-y.startPTS,E.duration&&(a=E),n.PTSKnown=n.alignedSliding=!0),E.elementaryStreams=y.elementaryStreams,E.loader=y.loader,E.stats=y.stats,E.urlId=y.urlId,y.initSegment&&(E.initSegment=y.initSegment,e=y.initSegment)}),e&&(n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments).forEach(function(y){var E;y.initSegment&&y.initSegment.relurl!==((E=e)==null?void 0:E.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=z({},o),d&&d.forEach(function(y){delete u[y]}),Object.keys(l).forEach(function(y){var E=new ur(l[y].attr,u[y]);E.isValid?u[y]=E: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 m=0;m<v.length;m++)v[m].cc+=c}n.skippedSegments&&(n.startCC=n.fragments[0].cc),function(y,E,R){if(y&&E)for(var A=0,C=0,N=y.length;C<=N;C++){var B=y[C],Y=E[C+A];B&&Y&&B.index===Y.index&&B.fragment.sn===Y.fragment.sn?R(B,Y):A--}}(s.partList,n.partList,function(y,E){E.elementaryStreams=y.elementaryStreams,E.stats=y.stats}),a?rn(n,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):nn(s,n),v.length&&(n.totalduration=n.edge-v[0].start),n.driftStartTime=s.driftStartTime,n.driftStart=s.driftStart;var T=n.advancedDateTime;if(n.advanced&&T){var S=n.edge;n.driftStart||(n.driftStartTime=T,n.driftStart=S),n.driftEndTime=T,n.driftEnd=S}else n.driftEndTime=s.driftEndTime,n.driftEnd=s.driftEnd,n.advancedDateTime=s.advancedDateTime}function nn(s,n){var e=n.startSN+n.skippedSegments-s.startSN,t=s.fragments;e<0||e>=t.length||mi(n,t[e].start)}function mi(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 fr(s,n,e){var t;return s!=null&&s.details?Nr((t=s.details)==null?void 0:t.partList,n,e):null}function Nr(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 vr(s){switch(s.details){case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_TIMEOUT:case M.LEVEL_LOAD_TIMEOUT:case M.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ur(s,n){var e=vr(n);return s.default[(e?"timeout":"error")+"Retry"]}function yi(s,n){var e=s.backoff==="linear"?1:Math.pow(2,n);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function an(s){return G(G({},s),{errorRetry:null,timeoutRetry:null})}function Br(s,n,e,t){return!!s&&n<s.maxNumRetry&&(function(r){return r===0&&navigator.onLine===!1||!!r&&(r<400||r>499)}(t)||!!e)}var sn=function(s,n){for(var e=0,t=s.length-1,r=null,i=null;e<=t;){var a=n(i=s[r=(e+t)/2|0]);if(a>0)e=r+1;else{if(!(a<0))return i;t=r-1}}return null};function gr(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&&Ti(e,t,r)===0)return r;var i=sn(n,Ti.bind(null,e,t));return!i||i===s&&r?r:i}function Ti(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 Nn(s,n,e){var t=1e3*Math.min(n,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>s}var Ei,Un=3e5,Hr=0,Ze=2,jt=5,nr=0,Gr=1,p=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(_.ERROR,this.onError,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(_.ERROR,this.onError,this),e.off(_.ERROR,this.onErrorOut,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this))},n.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},n.startLoad=function(e){this.playlistError=0},n.stopLoad=function(){},n.getVariantLevelIndex=function(e){return(e==null?void 0:e.type)===Me?e.level:this.hls.loadLevel},n.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},n.onError=function(e,t){var r;if(!t.fatal){var i=this.hls,a=t.context;switch(t.details){case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Ze);case M.LEVEL_EMPTY_ERROR:case M.LEVEL_PARSING_ERROR:var o,l,d=t.parent===Me?t.level:i.loadLevel;return void(t.details===M.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 M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:return void(typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.SUBTITLE_LOAD_ERROR:case M.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var u=i.levels[i.loadLevel];if(u&&(a.type===Lt&&a.groupId===u.audioGroupId||a.type===kt&&a.groupId===u.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=Ze,void(t.errorAction.flags=Gr)}return;case M.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:Ze,flags:p,hdcpLevel:f}));case M.BUFFER_ADD_CODEC_ERROR:case M.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:i.loadLevel));case M.INTERNAL_EXCEPTION:case M.BUFFER_APPENDING_ERROR:case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:case M.LEVEL_SWITCH_ERROR:case M.BUFFER_STALLED_ERROR:case M.BUFFER_SEEK_OVER_HOLE:case M.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:Hr,flags:nr})}if(t.type===re.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=Ur(this.hls.config.playlistLoadPolicy,e),o=this.playlistError++,l=(r=e.response)==null?void 0:r.code;return Br(a,o,vr(e),l)?{action:jt,flags:nr,retryConfig:a,retryCount:o}:(i=e.context)!=null&&i.deliveryDirectives?{action:Hr,flags:nr,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=Ur(e.details.startsWith("key")?l:o,e),u=t.levels.reduce(function(m,T){return m+T.fragmentError},0);if(i){var c;e.details!==M.FRAG_GAP&&i.fragmentError++;var f=(c=e.response)==null?void 0:c.code;if(Br(d,u,vr(e),f))return{action:jt,flags:nr,retryConfig:d,retryCount:u}}var v=this.getLevelSwitchAction(e,r);return d&&(v.retryConfig=d,v.retryCount=u),v},n.getLevelSwitchAction=function(e,t){var r=this.hls;t==null&&(t=r.loadLevel);var i=this.hls.levels[t];if(i&&(i.loadError++,r.autoLevelEnabled)){for(var a,o,l=-1,d=r.levels,u=(a=e.frag)==null?void 0:a.type,c=(o=e.context)!=null?o:{},f=c.type,v=c.groupId,m=d.length;m--;){var T=(m+r.loadLevel)%d.length;if(T!==r.loadLevel&&d[T].loadError===0){var S=d[T];if(e.details===M.FRAG_GAP&&e.frag){var y=d[T].details;if(y){var E=gr(e.frag,y.fragments,e.frag.start);if(E!=null&&E.gap)continue}}else if(f===Lt&&v===S.audioGroupId||f===kt&&v===S.textGroupId||u===wt&&i.audioGroupId===S.audioGroupId||u===At&&i.textGroupId===S.textGroupId)continue;l=T;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,{action:Ze,flags:nr,nextAutoLevel:l}}return{action:Ze,flags:Gr}},n.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case Hr:break;case Ze:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===M.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 nr:this.switchLevel(e,o);break;case Gr:r.resolved||(r.resolved=this.redundantFailover(e));break;case p:a&&(t.maxHdcpLevel=Fr[Fr.indexOf(a)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(e,o)}},n.switchLevel=function(e,t){t!==void 0&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},n.redundantFailover=function(e){var t=this,r=this.hls,i=this.penalizedRenditions,a=e.parent===Me?e.level:r.loadLevel,o=r.levels[a],l=o.url.length,d=e.frag?e.frag.urlId:o.urlId;o.urlId!==d||e.frag&&!o.details||this.penalizeRendition(o,e);for(var u=function(){var v=(d+c)%l,m=i[v];if(!m||function(T,S,y){if(performance.now()-T.lastErrorPerfMs>Un)return!0;var E=T.details;if(S.details===M.FRAG_GAP&&E&&S.frag){var R=S.frag.start,A=gr(null,E.fragments,R);if(A&&!A.gap)return!0}if(y&&T.errors.length<y.errors.length){var C=T.errors[T.errors.length-1];if(E&&C.frag&&S.frag&&Math.abs(C.frag.start-S.frag.start)>3*E.targetduration)return!0}return!1}(m,e,i[d]))return t.warn("Switching to Redundant Stream "+(v+1)+"/"+l+': "'+o.url[v]+'" after '+e.details),t.playlistError=0,r.levels.forEach(function(T){T.urlId=v}),r.nextLoadLevel=a,{v:!0}},c=1;c<l;c++){var f=u();if(typeof f=="object")return f.v}return!1},n.penalizeRendition=function(e,t){var r=this.penalizedRenditions,i=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(t),i.details=e.details,r[e.urlId]=i},s}(),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 tn(u,c>=0?c:void 0,Vt)}}},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&&Fn(r,a),!this.canLoad||!a.live)return;var u,c=void 0,f=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var v=this.hls.config.lowLatencyMode,m=a.lastPartSn,T=a.endSN,S=a.lastPartIndex,y=m===T;S!==-1?(c=y?T+1:m,f=y?v?0:S:S+1):c=T+1;var E=a.age,R=E+a.ageHeader,A=Math.min(R-a.partTarget,1.5*a.targetduration);if(A>0){if(r&&A>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+A+" with playlist age: "+a.age),A=0;else{var C=Math.floor(A/a.targetduration);c+=C,f!==void 0&&(f+=Math.round(A%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+E.toFixed(2)+"s goal: "+A+" skip sn "+C+" to part "+f)}a.tuneInGoal=A}if(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,f),v||!y)return void this.loadPlaylist(u)}else a.canBlockReload&&(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,f));var N=this.hls.mainForwardBufferInfo,B=N?N.end-N.len:0,Y=function(V,$){$===void 0&&($=1/0);var X=1e3*V.targetduration;if(V.updated){var le=V.fragments;if(le.length&&4*X>$){var ye=1e3*le[le.length-1].duration;ye<X&&(X=ye)}}else X/=2;return Math.round(X)}(a,1e3*(a.edge-B));a.updated&&l>this.requestScheduled+Y&&(this.requestScheduled=o.loading.start),c!==void 0&&a.canBlockReload?this.requestScheduled=o.loading.first+Y-(1e3*a.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+Y<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=Y);var K=this.requestScheduled-l;K=Math.max(0,K),this.log("reload live playlist "+e+" in "+Math.round(K)+" ms"),this.timer=self.setTimeout(function(){return i.loadPlaylist(u)},K)}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?Mn:On:Vt}(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=Vt),new tn(r,i,a)},n.checkRetry=function(e){var t=this,r=e.details,i=vr(e),a=e.errorAction,o=a||{},l=o.action,d=o.retryCount,u=d===void 0?0:d,c=o.retryConfig,f=l===jt&&!!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 m=yi(c,u);this.timer=self.setTimeout(function(){return t.loadPlaylist()},m),this.warn("Retrying playlist loading "+(u+1)+"/"+c.maxNumRetry+' after "'+r+'" in '+m+"ms")}e.levelRetry=!0,a.resolved=!0}return f},s}(),b=function(s){function n(t,r){var i;return(i=s.call(this,t,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}ne(n,s);var e=n.prototype;return e._registerListeners=function(){var t=this.hls;t.on(_.MANIFEST_LOADING,this.onManifestLoading,this),t.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(_.LEVEL_LOADED,this.onLevelLoaded,this),t.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(_.FRAG_LOADED,this.onFragLoaded,this),t.on(_.ERROR,this.onError,this)},e._unregisterListeners=function(){var t=this.hls;t.off(_.MANIFEST_LOADING,this.onManifestLoading,this),t.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(_.LEVEL_LOADED,this.onLevelLoaded,this),t.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(_.FRAG_LOADED,this.onFragLoaded,this),t.off(_.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&&(Ei||(Ei=/chrome|firefox/i.test(navigator.userAgent)),Ei&&(l.audioCodec=void 0));var c=u.AUDIO,f=u.CODECS,v=u["FRAME-RATE"],m=u["PATHWAY-ID"],T=u.RESOLUTION,S=u.SUBTITLES,y=(m||".")+"-"+l.bitrate+"-"+T+"-"+v+"-"+f;(i=o[y])?i.addFallback(l):(i=new hr(l),o[y]=i,a.push(i)),L(i,"audio",c),L(i,"text",S)}),this.filterAndSortMediaOptions(a,r)},e.filterAndSortMediaOptions=function(t,r){var i=this,a=[],o=[],l=!1,d=!1,u=!1,c=t.filter(function(E){var R=E.audioCodec,A=E.videoCodec,C=E.width,N=E.height,B=E.unknownCodecs;return l||(l=!(!C||!N)),d||(d=!!A),u||(u=!!R),!(B!=null&&B.length)&&(!R||xr(R,"audio"))&&(!A||xr(A,"video"))});if((l||d)&&u&&(c=c.filter(function(E){var R=E.videoCodec,A=E.width,C=E.height;return!!R||!(!A||!C)})),c.length!==0){r.audioTracks&&w(a=r.audioTracks.filter(function(E){return!E.audioCodec||xr(E.audioCodec,"audio")})),r.subtitles&&w(o=r.subtitles);var f=c.slice(0);c.sort(function(E,R){return E.attrs["HDCP-LEVEL"]!==R.attrs["HDCP-LEVEL"]?(E.attrs["HDCP-LEVEL"]||"")>(R.attrs["HDCP-LEVEL"]||"")?1:-1:E.bitrate!==R.bitrate?E.bitrate-R.bitrate:E.attrs["FRAME-RATE"]!==R.attrs["FRAME-RATE"]?E.attrs.decimalFloatingPoint("FRAME-RATE")-R.attrs.decimalFloatingPoint("FRAME-RATE"):E.attrs.SCORE!==R.attrs.SCORE?E.attrs.decimalFloatingPoint("SCORE")-R.attrs.decimalFloatingPoint("SCORE"):l&&E.height!==R.height?E.height-R.height:0});var v=f[0];if(this.steering&&(c=this.steering.filterParsedLevels(c)).length!==f.length){for(var m=0;m<f.length;m++)if(f[m].pathwayId===c[0].pathwayId){v=f[m];break}}this._levels=c;for(var T=0;T<c.length;T++)if(c[T]===v){this._firstLevel=T,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+v.bitrate);break}var S=u&&!d,y={levels:c,audioTracks:a,subtitleTracks:o,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:u,video:d,altAudio:!S&&a.some(function(E){return!!E.url})};this.hls.trigger(_.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 E=new Error("no level with compatible codecs found in manifest");i.hls.trigger(_.ERROR,{type:re.MEDIA_ERROR,details:M.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:E,reason:E.message})}})},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===Qt&&r.context.level===this.level&&this.checkRetry(r)},e.onFragLoaded=function(t,r){var i=r.frag;if(i!==void 0&&i.type===Me){var a=this._levels[i.level];a!==void 0&&(a.loadError=0)}},e.onLevelLoaded=function(t,r){var i,a,o=r.level,l=r.details,d=this._levels[o];if(!d)return this.warn("Invalid level index "+o),void((a=r.deliveryDirectives)!=null&&a.skip&&(l.deltaUpdateFailed=!0));o===this.currentLevelIndex?(d.fragmentError===0&&(d.loadError=0),this.playlistLoaded(o,r,d.details)):(i=r.deliveryDirectives)!=null&&i.skip&&(l.deltaUpdateFailed=!0)},e.onAudioTrackSwitched=function(t,r){var i=this.currentLevel;if(i){var a=this.hls.audioTracks[r.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==a){for(var o=-1,l=0;l<i.audioGroupIds.length;l++)if(i.audioGroupIds[l]===a){o=l;break}o!==-1&&o!==i.urlId&&(i.urlId=o,this.canLoad&&this.startLoad())}}},e.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var a=i.urlId,o=i.uri;if(t)try{o=t.addDirectives(o)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}var l=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+((t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:"")+" with"+(l?" Pathway "+l:"")+" URI "+(a+1)+"/"+i.url.length+" "+o),this.clearTimer(),this.hls.trigger(_.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(_.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(_.ERROR,{type:re.OTHER_ERROR,details:M.LEVEL_SWITCH_ERROR,level:t,fatal:a,error:i,reason:i.message}),a)return;t=Math.min(t,r.length-1)}var o=this.currentLevelIndex,l=this.currentLevel,d=l?l.attrs["PATHWAY-ID"]:void 0,u=r[t],c=u.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=u,o!==t||!u.details||!l||d!==c){this.log("Switching to level "+t+(c?" with Pathway "+c:"")+" from level "+o+(d?" with Pathway "+d:""));var f=z({},u,{level:t,maxBitrate:u.maxBitrate,attrs:u.attrs,uri:u.uri,urlId:u.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(_.LEVEL_SWITCHING,f);var v=u.details;if(!v||v.live){var m=this.switchParams(u.uri,l==null?void 0:l.details);this.loadPlaylist(m)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}]),n}(g);function L(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 w(s){var n={};s.forEach(function(e){var t=e.groupId||"";e.id=n[t]=n[t]||0,n[t]++})}var k="NOT_LOADED",x="APPENDING",U="PARTIAL",O="OK",W=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(_.BUFFER_APPENDED,this.onBufferAppended,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this)},n._unregisterListeners=function(){var e=this.hls;e.off(_.BUFFER_APPENDED,this.onBufferAppended,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.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===Me){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=ie(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=ie(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&&pe(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||pe(t))},n.getState=function(e){var t=ie(e),r=this.fragments[t];return r?r.buffered?pe(r)?U:O:x:k},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=ie(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===Me){var d=l?l.body:null;if(d!==i){l&&d&&d.sn!==i.sn&&(l.buffered=!0,this.fragments[ie(d)]=l);var u=ie(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 m=i.elementaryStreams[f];if(!m)return;for(var T=0;T<v.length;T++){var S=v.end(T);S<=m.endPTS&&S>m.startPTS?l.appendedPTS=Math.max(S,l.appendedPTS||0):l.appendedPTS=m.endPTS}}})},n.onFragBuffered=function(e,t){this.detectPartialFragments(t)},n.hasFragment=function(e){var t=ie(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=ie(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 pe(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 ie(s){return s.type+"_"+s.level+"_"+s.urlId+"_"+s.sn}var he=Math.pow(2,17),se=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 Ge({type:re.NETWORK_ERROR,details:M.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(Ce(e));else{var c=r.loader=e.loader=o?new o(a):new l(a),f=fe(e),v=an(a.fragLoadPolicy.default),m={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:he};e.stats=c.stats,c.load(f,m,{onSuccess:function(T,S,y,E){r.resetLoader(e,c);var R=T.data;y.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(R.slice(0,16)),R=R.slice(16)),d({frag:e,part:null,payload:R,networkDetails:E})},onError:function(T,S,y,E){r.resetLoader(e,c),u(new Ge({type:re.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:G({url:i,data:void 0},T),error:new Error("HTTP Error "+T.code+" "+T.text),networkDetails:y,stats:E}))},onAbort:function(T,S,y){r.resetLoader(e,c),u(new Ge({type:re.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:y,stats:T}))},onTimeout:function(T,S,y){r.resetLoader(e,c),u(new Ge({type:re.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+m.timeout+"ms"),networkDetails:y,stats:T}))},onProgress:function(T,S,y,E){t&&t({frag:e,part:null,payload:y,networkDetails:E})}})}})},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(Ce(e,t));else{var c=i.loader=e.loader=o?new o(a):new l(a),f=fe(e,t),v=an(a.fragLoadPolicy.default),m={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:he};t.stats=c.stats,c.load(f,m,{onSuccess:function(T,S,y,E){i.resetLoader(e,c),i.updateStatsFromPart(e,t);var R={frag:e,part:t,payload:T.data,networkDetails:E};r(R),d(R)},onError:function(T,S,y,E){i.resetLoader(e,c),u(new Ge({type:re.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:G({url:f.url,data:void 0},T),error:new Error("HTTP Error "+T.code+" "+T.text),networkDetails:y,stats:E}))},onAbort:function(T,S,y){e.stats.aborted=t.stats.aborted,i.resetLoader(e,c),u(new Ge({type:re.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:y,stats:T}))},onTimeout:function(T,S,y){i.resetLoader(e,c),u(new Ge({type:re.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+m.timeout+"ms"),networkDetails:y,stats:T}))}})}})},n.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,a=i.total;if(r.loaded+=i.loaded,a){var o=Math.round(e.duration/t.duration),l=Math.min(Math.round(r.loaded/a),o),d=(o-l)*Math.round(r.loaded/l);r.total=r.loaded+d}else r.total=Math.max(r.loaded,r.total);var u=r.loading,c=i.loading;u.start?u.first+=c.first-c.start:(u.start=c.start,u.first=c.first),u.end=c.end},n.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},s}();function fe(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(ee(r)&&ee(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 Ce(s,n){var e=new Error("GAP "+(s.gap?"tag":"attribute")+" found"),t={type:re.MEDIA_ERROR,details:M.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return n&&(t.part=n),(n||s).stats.aborted=!0,new Ge(t)}var Ge=function(s){function n(e){var t;return(t=s.call(this,e.error.message)||this).data=void 0,t.data=e,t}return ne(n,s),n}(Ie(Error)),tt=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=M.KEY_LOAD_ERROR),new Ge({type:re.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,M.KEY_LOAD_ERROR,o))}var l=a.uri;if(!l)return Promise.reject(this.createKeyLoadError(e,M.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,M.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+a.method+'"')))}},n.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then(function(a){return e.mediaKeySessionContext=a,r})).catch(function(a){throw e.keyLoadPromise=null,a})}return Promise.resolve(r)},n.loadKeyHTTP=function(e,t){var r=this,i=this.config,a=new i.loader(i);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise(function(o,l){var d={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},u=i.keyLoadPolicy.default,c={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:function(v,m,T,S){var y=T.frag,E=T.keyInfo,R=T.url;if(!y.decryptdata||E!==r.keyUriToKeyInfo[R])return l(r.createKeyLoadError(y,M.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),S));E.decryptdata.key=y.decryptdata.key=new Uint8Array(v.data),y.keyLoader=null,E.loader=null,o({frag:y,keyInfo:E})},onError:function(v,m,T,S){r.resetLoader(m),l(r.createKeyLoadError(t,M.KEY_LOAD_ERROR,new Error("HTTP Error "+v.code+" loading key "+v.text),T,G({url:d.url,data:void 0},v)))},onTimeout:function(v,m,T){r.resetLoader(m),l(r.createKeyLoadError(t,M.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:function(v,m,T){r.resetLoader(m),l(r.createKeyLoadError(t,M.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};a.load(d,c,f)})},n.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url,a=r.loader;t.keyLoader===a&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],a&&a.destroy()},s}(),ht=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}(),pt={length:0,start:function(){return 0},end:function(){return 0}},ue=function(){function s(){}return s.isBuffered=function(n,e){try{if(n){for(var t=s.getBuffered(n),r=0;r<t.length;r++)if(e>=t.start(r)&&e<=t.end(r))return!0}}catch{}return!1},s.bufferInfo=function(n,e,t){try{if(n){var r,i=s.getBuffered(n),a=[];for(r=0;r<i.length;r++)a.push({start:i.start(r),end:i.end(r)});return this.bufferedInfo(a,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},s.bufferedInfo=function(n,e,t){e=Math.max(0,e),n.sort(function(T,S){var y=T.start-S.start;return y||S.end-T.end});var r=[];if(t)for(var i=0;i<n.length;i++){var a=r.length;if(a){var o=r[a-1].end;n[i].start-o<t?n[i].end>o&&(r[a-1].end=n[i].end):r.push(n[i])}else r.push(n[i])}else r=n;for(var l,d=0,u=e,c=e,f=0;f<r.length;f++){var v=r[f].start,m=r[f].end;if(e+t>=v&&e<m)u=v,d=(c=m)-e;else if(e+t<v){l=v;break}}return{len:d,start:u||0,end:c||0,nextStart:l}},s.getBuffered=function(n){try{return n.buffered}catch(e){return P.log("failed to get media.buffered",e),pt}},s}(),Ve=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 Pe(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 J(s,n){if(s){var e=s.start+n;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function de(s,n){for(var e=n.fragments,t=0,r=e.length;t<r;t++)J(e[t],s);n.fragmentHint&&J(n.fragmentHint,s),n.alignedSliding=!0}function Z(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=Pe(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&&ee(a.start)&&(P.log("Adjusting PTS using last level due to CC increase within current level "+r.url),de(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&&ee(o)&&(P.log("Adjusting PTS using programDateTime delta "+(a-i)+"ms, sliding:"+o.toFixed(3)+" "+t.url+" "),de(o,t))}}(e,n.details),e.alignedSliding||!n.details||e.skippedSegments||nn(n.details,e))}function be(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=Pe(e,r.cc)||e[Math.round(e.length/2)-1],a=r.programDateTime,o=i.programDateTime;a!==null&&o!==null&&de((o-a)/1e3-(i.start-r.start),s)}}}var Re=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}(),Qe=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}(),ft=function(){function s(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var n=s.prototype;return n.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},n.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],o=r[2],l=r[3],d=this.invSubMix,u=d[0],c=d[1],f=d[2],v=d[3],m=new Uint32Array(256),T=0,S=0,y=0;for(y=0;y<256;y++)m[y]=y<128?y<<1:y<<1^283;for(y=0;y<256;y++){var E=S^S<<1^S<<2^S<<3^S<<4;E=E>>>8^255&E^99,e[T]=E,t[E]=T;var R=m[T],A=m[R],C=m[A],N=257*m[E]^16843008*E;i[T]=N<<24|N>>>8,a[T]=N<<16|N>>>16,o[T]=N<<8|N>>>24,l[T]=N,N=16843009*C^65537*A^257*R^16843008*T,u[E]=N<<24|N>>>8,c[E]=N<<16|N>>>16,f[E]=N<<8|N>>>24,v[E]=N,T?(T=R^m[m[m[C^R]]],S^=m[m[S]]):T=S=1}},n.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var a=this.keySize=t.length;if(a!==4&&a!==6&&a!==8)throw new Error("Invalid aes key size="+a);var o,l,d,u,c=this.ksRows=4*(a+6+1),f=this.keySchedule=new Uint32Array(c),v=this.invKeySchedule=new Uint32Array(c),m=this.sBox,T=this.rcon,S=this.invSubMix,y=S[0],E=S[1],R=S[2],A=S[3];for(o=0;o<c;o++)o<a?d=f[o]=t[o]:(u=d,o%a==0?(u=m[(u=u<<8|u>>>24)>>>24]<<24|m[u>>>16&255]<<16|m[u>>>8&255]<<8|m[255&u],u^=T[o/a|0]<<24):a>6&&o%a==4&&(u=m[u>>>24]<<24|m[u>>>16&255]<<16|m[u>>>8&255]<<8|m[255&u]),f[o]=d=(f[o-a]^u)>>>0);for(l=0;l<c;l++)o=c-l,u=3&l?f[o]:f[o-4],v[l]=l<4||o<=4?u:y[m[u>>>24]]^E[m[u>>>16&255]]^R[m[u>>>8&255]]^A[m[255&u]],v[l]=v[l]>>>0}},n.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},n.decrypt=function(e,t,r){for(var i,a,o,l,d,u,c,f,v,m,T,S,y,E,R=this.keySize+6,A=this.invKeySchedule,C=this.invSBox,N=this.invSubMix,B=N[0],Y=N[1],K=N[2],V=N[3],$=this.uint8ArrayToUint32Array_(r),X=$[0],le=$[1],ye=$[2],oe=$[3],ve=new Int32Array(e),me=new Int32Array(ve.length),ge=this.networkToHostOrderSwap;t<ve.length;){for(v=ge(ve[t]),m=ge(ve[t+1]),T=ge(ve[t+2]),S=ge(ve[t+3]),d=v^A[0],u=S^A[1],c=T^A[2],f=m^A[3],y=4,E=1;E<R;E++)i=B[d>>>24]^Y[u>>16&255]^K[c>>8&255]^V[255&f]^A[y],a=B[u>>>24]^Y[c>>16&255]^K[f>>8&255]^V[255&d]^A[y+1],o=B[c>>>24]^Y[f>>16&255]^K[d>>8&255]^V[255&u]^A[y+2],l=B[f>>>24]^Y[d>>16&255]^K[u>>8&255]^V[255&c]^A[y+3],d=i,u=a,c=o,f=l,y+=4;i=C[d>>>24]<<24^C[u>>16&255]<<16^C[c>>8&255]<<8^C[255&f]^A[y],a=C[u>>>24]<<24^C[c>>16&255]<<16^C[f>>8&255]<<8^C[255&d]^A[y+1],o=C[c>>>24]<<24^C[f>>16&255]<<16^C[d>>8&255]<<8^C[255&u]^A[y+2],l=C[f>>>24]<<24^C[d>>16&255]<<16^C[u>>8&255]<<8^C[255&c]^A[y+3],me[t]=ge(i^X),me[t+1]=ge(l^le),me[t+2]=ge(o^ye),me[t+3]=ge(a^oe),X=v,le=m,ye=T,oe=S,t+=4}return me.buffer},s}(),Je=function(){function s(e,t){var r=(t===void 0?{}:t).removePKCS7Padding,i=r===void 0||r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var n=s.prototype;return n.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},n.isSync=function(){return this.useSoftware},n.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,a,o=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=o).byteLength,(a=i&&new DataView(r.buffer).getUint8(i-1))?zt(r,0,i-a):r):o},n.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},n.decrypt=function(e,t,r){var i=this;return this.useSoftware?new Promise(function(a,o){i.softwareDecrypt(new Uint8Array(e),t,r);var l=i.flush();l?a(l.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)},n.softwareDecrypt=function(e,t,r){var i=this.currentIV,a=this.currentResult,o=this.remainderData;this.logOnce("JS AES decrypt"),o&&(e=Kt(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 ft),d.expandKey(t);var u=a;return this.currentResult=d.decrypt(l.buffer,0,r),this.currentIV=zt(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 Qe(a,t)),this.fastAesKey.expandKey().then(function(o){return a?(i.logOnce("WebCrypto AES decrypt"),new Re(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=zt(e,0,r),this.remainderData=zt(e,r)),t},n.logOnce=function(e){this.logEnabled&&(P.log("[decrypter]: "+e),this.logEnabled=!1)},s}(),nt=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},Ne="STOPPED",ce="IDLE",Rt="KEY_LOADING",Dt="FRAG_LOADING",mt="FRAG_LOADING_WAITING_RETRY",je="WAITING_TRACK",gt="PARSING",Kr="PARSED",pr="ENDED",ar="ERROR",_i="WAITING_INIT_PTS",qr="WAITING_LEVEL",Bn=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=Ne,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 se(t.config),l.keyLoader=i,l.fragmentTracker=r,l.config=t.config,l.decrypter=new Je(t.config),t.on(_.MANIFEST_LOADED,l.onManifestLoaded,function(d){if(d===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d}(l)),l}ne(n,s);var e=n.prototype;return e.doTick=function(){this.onTickEnd()},e.onTickEnd=function(){},e.startLoad=function(t){},e.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();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=Ne},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 ue.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===Ne&&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=ue.bufferInfo(a||i,l,t.maxBufferHole);if(this.log("media seeking to "+(ee(l)?l.toFixed(3):l)+", state: "+o),this.state===pr)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=Ne,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===Dt||!a.fragCurrent&&l===gt)&&(a.fragmentTracker.removeFragment(t),a.state=ce):("payload"in o&&(a.log("Loaded fragment "+t.sn+" of level "+t.level),a.hls.trigger(_.FRAG_LOADED,o)),a._handleFragmentLoadComplete(o))}}).catch(function(o){a.state!==Ne&&a.state!==ar&&(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(_.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(_.ERROR,{type:re.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:c,reason:c.message,frag:t}),c}).then(function(c){var f=self.performance.now();return o.trigger(_.FRAG_DECRYPTED,{frag:t,payload:c,stats:{tstart:u,tdecrypt:f}}),a.payload=c,a})}return a}).then(function(a){var o=i.fragCurrent,l=i.hls;if(!i.levels)throw new Error("init load aborted, missing levels");var d=t.stats;i.state=ce,r.fragmentError=0,t.data=new Uint8Array(a.payload),d.parsing.start=d.buffering.start=self.performance.now(),d.parsing.end=d.buffering.end=self.performance.now(),a.frag===o&&l.trigger(_.FRAG_BUFFERED,{stats:d,frag:o,part:null,id:t.type}),i.tick()}).catch(function(a){i.state!==Ne&&i.state!==ar&&(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?nt(ue.getBuffered(d)):"(detached)")+")"),this.state=ce,d&&(!this.loadedmetadata&&t.type==Me&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},e.seekToStartPos=function(){},e._handleFragmentLoadComplete=function(t){var r=this.transmuxer;if(r){var i=t.frag,a=t.part,o=t.partsLoaded,l=!o||o.length===0||o.some(function(u){return!u}),d=new Ve(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=Rt,this.fragCurrent=t,u=this.keyLoader.load(t).then(function(y){if(!l.fragContextChanged(y.frag))return l.hls.trigger(_.KEY_LOADED,y),l.state===Rt&&(l.state=ce),y}),this.hls.trigger(_.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,m=c[f];return this.log("Loading part sn: "+t.sn+" p: "+m.index+" cc: "+t.cc+" of playlist ["+d.startSN+"-"+d.endSN+"] parts [0-"+f+"-"+(c.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=m.start+m.duration,this.state=Dt,v=u?u.then(function(y){return!y||l.fragContextChanged(y.frag)?null:l.doFragPartsLoad(t,m,r,a)}).catch(function(y){return l.handleFragLoadError(y)}):this.doFragPartsLoad(t,m,r,a).catch(function(y){return l.handleFragLoadError(y)}),this.hls.trigger(_.FRAG_LOADING,{frag:t,part:m,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):v}if(!t.url||this.loadedEndOfParts(c,i))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(d?"of ["+d.startSN+"-"+d.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),ee(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Dt;var T,S=this.config.progressive;return T=S&&u?u.then(function(y){return!y||l.fragContextChanged(y==null?void 0:y.frag)?null:l.fragmentLoader.load(t,a)}).catch(function(y){return l.handleFragLoadError(y)}):Promise.all([this.fragmentLoader.load(t,S?a:void 0),u]).then(function(y){var E=y[0];return!S&&E&&a&&a(E),E}).catch(function(y){return l.handleFragLoadError(y)}),this.hls.trigger(_.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):T},e.doFragPartsLoad=function(t,r,i,a){var o=this;return new Promise(function(l,d){var u,c=[],f=(u=i.details)==null?void 0:u.partList;(function v(m){o.fragmentLoader.loadPart(t,m,a).then(function(T){c[m.index]=T;var S=T.part;o.hls.trigger(_.FRAG_LOADED,T);var y=fr(i,t.sn,m.index+1)||Nr(f,t.sn,m.index+1);if(!y)return l({frag:t,part:S,partsLoaded:c});v(y)}).catch(d)})(r)})},e.handleFragLoadError=function(t){if("data"in t){var r=t.data;t.data&&r.details===M.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(_.ERROR,r)}else this.hls.trigger(_.ERROR,{type:re.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},e._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(r&&this.state===gt){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===Ne||this.state===ar||(this.state=ce)},e.getCurrentContext=function(t){var r=this.levels,i=this.fragCurrent,a=t.level,o=t.sn,l=t.part;if(r==null||!r[a])return this.warn("Levels object was unset while buffering fragment "+o+" of level "+a+". The current chunk will not be buffered."),null;var d=r[a],u=l>-1?fr(d,o,l):null,c=u?u.fragment:function(f,v,m){if(f==null||!f.details)return null;var T=f.details,S=T.fragments[v-T.startSN];return S||((S=T.fragmentHint)&&S.sn===v?S:v<T.startSN&&m&&m.sn===v?m:null)}(d,o,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:u,level:d}):null},e.bufferFragmentData=function(t,r,i,a){var o;if(t&&this.state===gt){var l=t.data1,d=t.data2,u=l;if(l&&d&&(u=Kt(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(_.BUFFER_APPENDING,c),t.dropped&&t.independent&&!i&&this.flushBufferGap(r)}}},e.flushBufferGap=function(t){var r=this.media;if(r)if(ue.isBuffered(r,r.currentTime)){var i=r.currentTime,a=ue.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 ee(i)?this.getFwdBufferInfoAtPos(t,i,r):null},e.getFwdBufferInfoAtPos=function(t,r,i){var a=this.config.maxBufferHole,o=ue.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 ue.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===O||i===U&&!!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||!ee(c)||c<(u[0].programDateTime||0)||c>=(u[u.length-1].endProgramDateTime||0))return null;f=f||0;for(var v=0;v<u.length;++v){var m=u[v];if(Nn(c,f,m))return m}return null}(r,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!a){var o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){var l=r[o-t.startSN];i.cc===l.cc&&(a=l,this.log("Live playlist, switching playlist, load frag with next SN: "+a.sn))}a||(a=function(u,c){return sn(u,function(f){return f.cc<c?1:f.cc>c?-1:0})}(r,i.cc),a&&this.log("Live playlist, switching playlist, load frag with same CC: "+a.sn))}}else{var d=this.hls.liveSyncPosition;d!==null&&(a=this.getFragmentAtPosition(d,this.bitrateTest?t.fragmentEnd:t.edge,t))}return a},e.getFragmentAtPosition=function(t,r,i){var a,o=this.config,l=this.fragPrevious,d=i.fragments,u=i.endSN,c=i.fragmentHint,f=o.maxFragLookUpTolerance,v=!!(o.lowLatencyMode&&i.partList&&c);if(v&&c&&!this.bitrateTest&&(d=d.concat(c),u=c.sn),a=t<r?gr(l,d,t,t>r-f?0:f):d[d.length-1]){var m=a.sn-i.startSN,T=this.fragmentTracker.getState(a);if((T===O||T===U&&a.gap)&&(l=a),l&&a.sn===l.sn&&!v&&l&&a.level===l.level){var S=d[m+1];a=a.sn<u&&this.fragmentTracker.getState(S)!==O?S: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&&ee(u);if(c||!f&&!u){Z(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&&ee(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===mt)||(this.state=ce)},e.onFragmentOrKeyLoadError=function(t,r){if(r.chunkMeta&&!r.frag){var i=this.getCurrentContext(r.chunkMeta);i&&(r.frag=i.frag)}var a=r.frag;if(a&&a.type===t&&this.levels)if(this.fragContextChanged(a)){var o;this.warn("Frag load error must match current frag to retry "+a.url+" > "+((o=this.fragCurrent)==null?void 0:o.url))}else{var l=r.details===M.FRAG_GAP;l&&this.fragmentTracker.fragBuffered(a,!0);var d=r.errorAction,u=d||{},c=u.action,f=u.retryCount,v=f===void 0?0:f,m=u.retryConfig;if(d&&c===jt&&m){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var T=yi(m,v);this.warn("Fragment "+a.sn+" of "+t+" "+a.level+" errored with "+r.details+", retrying loading "+(v+1)+"/"+m.maxNumRetry+" in "+T+"ms"),d.resolved=!0,this.retryDate=self.performance.now()+T,this.state=mt}else m&&d?(this.resetFragmentErrors(t),v<m.maxNumRetry?l||(d.resolved=!0):P.warn(r.details+" reached or exceeded max retry ("+v+")")):this.state=ar;this.tickImmediate()}},e.reduceLengthAndFlushBuffer=function(t){if(this.state===gt||this.state===Kr){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===wt&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Ne&&(this.state=ce)},e.afterBufferFlushed=function(t,r,i){if(t){var a=ue.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,a,i),this.state===pr&&this.resetLoadingState()}},e.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=ce},e.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var r=this.levels?this.levels[t].details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},e.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(t.level),this.resetLoadingState()},e.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},e.updateLevelTiming=function(t,r,i,a){var o,l=this,d=i.details;if(d){if(Object.keys(t.elementaryStreams).reduce(function(c,f){var v=t.elementaryStreams[f];if(v){var m=v.endPTS-v.startPTS;if(m<=0)return l.warn("Could not parse fragment "+t.sn+" "+f+" duration reliably ("+m+")"),c||!1;var T=a?0:rn(d,t,v.startPTS,v.endPTS,v.startDTS,v.endDTS);return l.hls.trigger(_.LEVEL_PTS_UPDATED,{details:d,level:i,drift:T,type:f,frag:t,start:v.startPTS,end:v.endPTS}),!0}return c},!1))i.fragmentError=0;else if(((o=this.transmuxer)==null?void 0:o.error)===null){var u=new Error("Found no media in fragment "+t.sn+" of level "+i.id+" resetting transmuxer to fallback to playlist timing");if(this.warn(u.message),this.hls.trigger(_.ERROR,{type:re.MEDIA_ERROR,details:M.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=Kr,this.hls.trigger(_.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}(ht);function Hn(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}function Aa(){return self.SourceBuffer||self.WebKitSourceBuffer}function Wt(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 Ra=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=Kt(this.cachedData,e),this.cachedData=null);var r,i=kr(e,0),a=i?i.length:0,o=this._audioTrack,l=this._id3Track,d=i?function(v){for(var m=Oi(v),T=0;T<m.length;T++){var S=m[T];if(Ci(S))return Fi(S)}}(i):void 0,u=e.length;for((this.basePTS===null||this.frameIndex===0&&ee(d))&&(this.basePTS=Qs(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:qt,duration:Number.POSITIVE_INFINITY});a<u;){if(this.canParse(e,a)){var c=this.appendFrame(o,e,a);c?(this.frameIndex++,this.lastPTS=c.sample.pts,r=a+=c.length):a=u}else xi(e,a)?(i=kr(e,a),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:qt,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===u&&r!==u){var f=zt(e,r);this.cachedData?this.cachedData=Kt(this.cachedData,f):this.cachedData=f}}return{audioTrack:o,videoTrack:Wt(),id3Track:l,textTrack:Wt()}},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:Wt(),id3Track:this._id3Track,textTrack:Wt()}},n.destroy=function(){},s}(),Qs=function(s,n,e){return ee(s)?90*s:9e4*n+(e?9e4*e.baseTime/e.timescale:0)};function Da(s,n){return s[n]===255&&(246&s[n+1])==240}function Ia(s,n){return 1&s[n+1]?7:9}function Gn(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&&Da(s,n)}function Js(s,n){if(on(s,n)){var e=Ia(s,n);if(n+e>=s.length)return!1;var t=Gn(s,n);if(t<=e)return!1;var r=n+t;return r===s.length||on(s,r)}return!1}function xa(s,n,e,t,r){if(!s.samplerate){var i=function(a,o,l,d){var u,c,f,v,m=navigator.userAgent.toLowerCase(),T=d,S=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];u=1+((192&o[l+2])>>>6);var y=(60&o[l+2])>>>2;if(!(y>S.length-1))return f=(1&o[l+2])<<2,f|=(192&o[l+3])>>>6,P.log("manifest codec:"+d+", ADTS type:"+u+", samplingIndex:"+y),/firefox/i.test(m)?y>=6?(u=5,v=new Array(4),c=y-3):(u=2,v=new Array(2),c=y):m.indexOf("android")!==-1?(u=2,v=new Array(2),c=y):(u=5,v=new Array(4),d&&(d.indexOf("mp4a.40.29")!==-1||d.indexOf("mp4a.40.5")!==-1)||!d&&y>=6?c=y-3:((d&&d.indexOf("mp4a.40.2")!==-1&&(y>=6&&f===1||/vivaldi/i.test(m))||!d&&f===1)&&(u=2,v=new Array(2)),c=y)),v[0]=u<<3,v[0]|=(14&y)>>1,v[1]|=(1&y)<<7,v[1]|=f<<3,u===5&&(v[1]|=(14&c)>>1,v[2]=(1&c)<<7,v[2]|=8,v[3]=0),{config:v,samplerate:S[y],channelCount:f,codec:"mp4a.40."+u,manifestCodec:T};a.trigger(_.ERROR,{type:re.MEDIA_ERROR,details:M.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 Ca(s){return 9216e4/s}function Pa(s,n,e,t,r){var i,a=t+r*Ca(s.samplerate),o=function(m,T){var S=Ia(m,T);if(T+S<=m.length){var y=Gn(m,T)-S;if(y>0)return{headerLength:S,frameLength:y}}}(n,e);if(o){var l=o.frameLength,d=o.headerLength,u=d+l,c=Math.max(0,e+u-n.length);c?(i=new Uint8Array(u-d)).set(n.subarray(e+d,n.length),0):i=n.subarray(e+d,e+u);var f={unit:i,pts:a};return c||s.samples.push(f),{sample:f,length:u,missing:c}}var v=n.length-e;return(i=new Uint8Array(v)).set(n.subarray(e,n.length),0),{sample:{unit:i,pts:a},length:v,missing:-1}}var $s=function(s){function n(t,r){var i;return(i=s.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}ne(n,s);var e=n.prototype;return e.resetInitSegment=function(t,r,i,a){s.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var r=(kr(t,0)||[]).length,i=t.length;r<i;r++)if(Js(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)&&Da(i,a)&&Gn(i,a)<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){xa(t,this.observer,r,i,t.manifestCodec);var a=Pa(t,r,i,this.basePTS,this.frameIndex);if(a&&a.missing===0)return a},n}(Ra),Zs=/\/emsg[-/]ID3/i,eo=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=Wt("video",1),o=this.audioTrack=Wt("audio",1),l=this.txtTrack=Wt("text",1);if(this.id3Track=Wt("id3",1),this.timeOffset=0,e!=null&&e.byteLength){var d=si(e);if(d.video){var u=d.video,c=u.id,f=u.timescale,v=u.codec;a.id=c,a.timescale=l.timescale=f,a.codec=v}if(d.audio){var m=d.audio,T=m.id,S=m.timescale,y=m.codec;o.id=T,o.timescale=S,o.codec=y}l.id=ni.text,a.sampleDuration=0,a.duration=o.duration=i}},n.resetContiguity=function(){},s.probe=function(e){return xe(e=e.length>16384?e.subarray(0,16384):e,["moof"]).length>0},n.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Kt(this.remainderData,e));var o=function(d){var u={valid:null,remainder:null},c=xe(d,["moof"]);if(!c)return u;if(c.length<2)return u.remainder=d,u;var f=c[c.length-1];return u.valid=zt(d,0,f.byteOffset-8),u.remainder=zt(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=Gi(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=Gi(e,t),{videoTrack:t,audioTrack:Wt(),id3Track:i,textTrack:Wt()}},n.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=xe(e.samples,["emsg"]);i&&i.forEach(function(a){var o=function(c){var f=c[0],v="",m="",T=0,S=0,y=0,E=0,R=0,A=0;if(f===0){for(;et(c.subarray(A,A+1))!=="\0";)v+=et(c.subarray(A,A+1)),A+=1;for(v+=et(c.subarray(A,A+1)),A+=1;et(c.subarray(A,A+1))!=="\0";)m+=et(c.subarray(A,A+1)),A+=1;m+=et(c.subarray(A,A+1)),A+=1,T=_e(c,12),S=_e(c,16),E=_e(c,20),R=_e(c,24),A=28}else if(f===1){T=_e(c,A+=4);var C=_e(c,A+=4),N=_e(c,A+=4);for(A+=4,y=Math.pow(2,32)*C+N,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")),E=_e(c,A),R=_e(c,A+=4),A+=4;et(c.subarray(A,A+1))!=="\0";)v+=et(c.subarray(A,A+1)),A+=1;for(v+=et(c.subarray(A,A+1)),A+=1;et(c.subarray(A,A+1))!=="\0";)m+=et(c.subarray(A,A+1)),A+=1;m+=et(c.subarray(A,A+1)),A+=1}return{schemeIdUri:v,value:m,timeScale:T,presentationTime:y,presentationTimeDelta:S,eventDuration:E,id:R,payload:c.subarray(A,c.byteLength)}}(a);if(Zs.test(o.schemeIdUri)){var l=ee(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:cr,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}(),ln=null,to=[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],ro=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],io=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],no=[0,1,1,4];function Oa(s,n,e,t,r){if(!(e+24>n.length)){var i=Ma(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 Ma(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*to[14*(e===3?3-t:t===3?3:4)+r-1],d=ro[3*(e===3?0:e===2?1:2)+i],u=o===3?1:2,c=io[e][t],f=no[t],v=8*c*f,m=Math.floor(c*l/d+a)*f;if(ln===null){var T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ln=T?parseInt(T[1]):0}return!!ln&&ln<=87&&t===2&&l>=224e3&&o===0&&(s[n+3]=128|s[n+3]),{sampleRate:d,channelCount:u,frameLength:m,samplesPerFrame:v}}}function Kn(s,n){return s[n]===255&&(224&s[n+1])==224&&(6&s[n+1])!=0}function Fa(s,n){return n+1<s.length&&Kn(s,n)}function ao(s,n){if(n+1<s.length&&Kn(s,n)){var e=Ma(s,n),t=4;e!=null&&e.frameLength&&(t=e.frameLength);var r=n+t;return r===s.length||Fa(s,r)}return!1}var Na=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),m=this.skipEG.bind(this),T=this.skipUEG.bind(this),S=this.skipScalingList.bind(this);d();var y=d();if(u(5),v(3),d(),T(),y===100||y===110||y===122||y===244||y===44||y===83||y===86||y===118||y===128){var E=c();if(E===3&&v(1),T(),T(),v(1),f())for(t=E!==3?8:12,r=0;r<t;r++)f()&&S(r<6?16:64)}T();var R=c();if(R===0)c();else if(R===1)for(v(1),m(),m(),e=c(),r=0;r<e;r++)m();T(),v(1);var A=c(),C=c(),N=u(1);N===0&&v(1),v(1),f()&&(i=c(),a=c(),o=c(),l=c());var B=[1,1];if(f()&&f())switch(d()){case 1:B=[1,1];break;case 2:B=[12,11];break;case 3:B=[10,11];break;case 4:B=[16,11];break;case 5:B=[40,33];break;case 6:B=[24,11];break;case 7:B=[20,11];break;case 8:B=[32,11];break;case 9:B=[80,33];break;case 10:B=[18,11];break;case 11:B=[15,11];break;case 12:B=[64,33];break;case 13:B=[160,99];break;case 14:B=[4,3];break;case 15:B=[3,2];break;case 16:B=[2,1];break;case 255:B=[d()<<8|d(),d()<<8|d()]}return{width:Math.ceil(16*(A+1)-2*i-2*a),height:(2-N)*(C+1)*16-(N?2:4)*(o+l),pixelRatio:B}},n.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},s}(),so=function(){function s(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Je(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=ui(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}(),_t=188,oo=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-_t)+1,i=0;i<r;){for(var a=!1,o=i;o<t&&e[o]===71;o+=_t)if(a||qn(e,o)!==0||(a=!0),a&&o+_t>r)return i;i++}return-1},s.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:ni[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var n=s.prototype;return n.resetInitSegment=function(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=s.createTrack("video"),this._audioTrack=s.createTrack("audio",i),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=i},n.resetTimeStamp=function(){},n.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},n.demux=function(e,t,r,i){var a;r===void 0&&(r=!1),i===void 0&&(i=!1),r||(this.sampleAes=null);var o=this._avcTrack,l=this._audioTrack,d=this._id3Track,u=this._txtTrack,c=o.pid,f=o.pesData,v=l.pid,m=d.pid,T=l.pesData,S=d.pesData,y=null,E=this.pmtParsed,R=this._pmtId,A=e.length;if(this.remainderData&&(A=(e=Kt(this.remainderData,e)).length,this.remainderData=null),A<_t&&!i)return this.remainderData=e,{audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};var C=Math.max(0,s.syncOffset(e));(A-=(A-C)%_t)<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,A,e.buffer.byteLength-A));for(var N=0,B=C;B<A;B+=_t)if(e[B]===71){var Y=!!(64&e[B+1]),K=qn(e,B),V=void 0;if((48&e[B+3])>>4>1){if((V=B+5+e[B+4])===B+_t)continue}else V=B+4;switch(K){case c:Y&&(f&&(a=Vr(f))&&this.parseAVCPES(o,u,a,!1),f={data:[],size:0}),f&&(f.data.push(e.subarray(V,B+_t)),f.size+=B+_t-V);break;case v:if(Y){if(T&&(a=Vr(T)))switch(l.segmentCodec){case"aac":this.parseAACPES(l,a);break;case"mp3":this.parseMPEGPES(l,a)}T={data:[],size:0}}T&&(T.data.push(e.subarray(V,B+_t)),T.size+=B+_t-V);break;case m:Y&&(S&&(a=Vr(S))&&this.parseID3PES(d,a),S={data:[],size:0}),S&&(S.data.push(e.subarray(V,B+_t)),S.size+=B+_t-V);break;case 0:Y&&(V+=e[V]+1),R=this._pmtId=lo(e,V);break;case R:Y&&(V+=e[V]+1);var $=uo(e,V,this.typeSupported,r);(c=$.avc)>0&&(o.pid=c),(v=$.audio)>0&&(l.pid=v,l.segmentCodec=$.segmentCodec),(m=$.id3)>0&&(d.pid=m),y===null||E||(P.warn("MPEG-TS PMT found at "+B+" after unknown PID '"+y+"'. Backtracking to sync byte @"+C+" to parse all TS packets."),y=null,B=C-188),E=this.pmtParsed=!0;break;case 17:case 8191:break;default:y=K}}else N++;if(N>0){var X=new Error("Found "+N+" TS packet/s that do not start with 0x47");this.observer.emit(_.ERROR,_.ERROR,{type:re.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:X,reason:X.message})}o.pesData=f,l.pesData=T,d.pesData=S;var le={audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};return i&&this.extractRemainingSamples(le),le},n.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},n.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,a=e.id3Track,o=e.textTrack,l=i.pesData,d=r.pesData,u=a.pesData;if(l&&(t=Vr(l))?(this.parseAVCPES(i,o,t,!0),i.pesData=null):i.pesData=l,d&&(t=Vr(d))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else d!=null&&d.size&&P.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=d;u&&(t=Vr(u))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=u},n.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),a=this.sampleAes=new so(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&&(Vn(d,e),d=this.avcSample=un(!1,r.pts,r.dts,"")),l.forEach(function(c){switch(c.type){case 1:a=!0,d||(d=o.avcSample=un(!0,r.pts,r.dts,"")),d.frame=!0;var f=c.data;if(u&&f.length>4){var v=new Na(f).readSliceType();v!==2&&v!==4&&v!==7&&v!==9||(d.key=!0)}break;case 5:a=!0,d||(d=o.avcSample=un(!0,r.pts,r.dts,"")),d.key=!0,d.frame=!0;break;case 6:a=!0,li(c.data,1,r.pts,t.samples);break;case 7:if(a=!0,u=!0,!e.sps){var m=c.data,T=new Na(m).readSPS();e.width=T.width,e.height=T.height,e.pixelRatio=T.pixelRatio,e.sps=[m],e.duration=o._duration;for(var S=m.subarray(1,4),y="avc1.",E=0;E<3;E++){var R=S[E].toString(16);R.length<2&&(R="0"+R),y+=R}e.codec=y}break;case 8:a=!0,e.pps||(e.pps=[c.data]);break;case 9:a=!1,e.audFound=!0,d&&Vn(d,e),d=o.avcSample=un(!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&&(Vn(d,e),this.avcSample=null)},n.getLastNalUnit=function(e){var t,r,i=this.avcSample;if(i&&i.units.length!==0||(i=e[e.length-1]),(t=i)!=null&&t.units){var a=i.units;r=a[a.length-1]}return r},n.parseAVCNALu=function(e,t){var r,i,a=t.byteLength,o=e.naluState||0,l=o,d=[],u=0,c=-1,f=0;for(o===-1&&(c=0,f=31&t[0],o=0,u=1);u<a;)if(r=t[u++],o)if(o!==1)if(r)if(r===1){if(c>=0){var v={data:t.subarray(c,u-o-1),type:f};d.push(v)}else{var m=this.getLastNalUnit(e.samples);if(m&&(l&&u<=4-l&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-l)),(i=u-o-1)>0)){var T=new Uint8Array(m.data.byteLength+i);T.set(m.data,0),T.set(t.subarray(0,i),m.data.byteLength),m.data=T,m.state=0}}u<a?(c=u,f=31&t[u],o=0):o=-1}else o=0;else o=3;else o=r?0:2;else o=r?0:1;if(c>=0&&o>=0){var S={data:t.subarray(c,a),type:f,state:o};d.push(S)}if(d.length===0){var y=this.getLastNalUnit(e.samples);if(y){var E=new Uint8Array(y.data.byteLength+t.byteLength);E.set(y.data,0),E.set(t,y.data.byteLength),y.data=E}}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 m,T=r<i-1;m=T?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES";var S=new Error(m);if(P.warn("parsing error: "+m),this.observer.emit(_.ERROR,_.ERROR,{type:re.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,levelRetry:T,error:S,reason:m}),!T)return}if(xa(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=Ca(e.samplerate);a=l.sample.pts+y}for(var E,R=0;r<i;){if(r+=(E=Pa(e,d,r,a,R)).length,E.missing){this.aacOverFlow=E;break}for(R++;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(Fa(r,o)){var d=Oa(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=z({},t,{type:this._avcTrack?cr:qt,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else P.warn("[tsdemuxer]: ID3 PES unknown PTS")},s}();function un(s,n,e,t){return{key:s,frame:!1,pts:n,dts:e,units:[],debug:t,length:0}}function qn(s,n){return((31&s[n+1])<<8)+s[n+2]}function lo(s,n){return(31&s[n+10])<<8|s[n+11]}function uo(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=qn(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 Vr(s){var n,e,t,r,i,a=0,o=s.data;if(!s||s.size===0)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(((n=o[0])[0]<<16)+(n[1]<<8)+n[2]===1){if((e=(n[4]<<8)+n[5])&&e>s.size-6)return null;var d=n[7];192&d&&(r=536870912*(14&n[9])+4194304*(255&n[10])+16384*(254&n[11])+128*(255&n[12])+(254&n[13])/2,64&d?r-(i=536870912*(14&n[14])+4194304*(255&n[15])+16384*(254&n[16])+128*(255&n[17])+(254&n[18])/2)>54e5&&(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 m=(n=o[f]).byteLength;if(u){if(u>m){u-=m;continue}n=n.subarray(u),m-=u,u=0}c.set(n,a),a+=m}return e&&(e-=t+3),{data:c,pts:r,dts:i,len:e}}return null}function Vn(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 co=function(s){function n(){return s.apply(this,arguments)||this}ne(n,s);var e=n.prototype;return e.resetInitSegment=function(t,r,i,a){s.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var r=(kr(t,0)||[]).length,i=t.length;r<i;r++)if(ao(t,r))return P.log("MPEG Audio sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return Kn(i,a)&&4<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){if(this.basePTS!==null)return Oa(t,r,i,this.basePTS,this.frameIndex)},n}(Ra),Ua=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}(),sr=Math.pow(2,32)-1,at=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/(sr+1)),r=Math.floor(e%(sr+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/(sr+1)),r=Math.floor(e%(sr+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/(sr+1)),o=Math.floor(t%(sr+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/(sr+1)),a=Math.floor(e%(sr+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 jn(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 bi(s,n){return n===void 0&&(n=!1),jn(s,1e3,1/9e4,n)}at.types=void 0,at.HDLR_TYPES=void 0,at.STTS=void 0,at.STSC=void 0,at.STCO=void 0,at.STSZ=void 0,at.VMHD=void 0,at.SMHD=void 0,at.STSD=void 0,at.FTYP=void 0,at.DINF=void 0;var dn=null,Wn=null,Yn=function(){function s(e,t,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,dn===null){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);dn=a?parseInt(a[1]):0}if(Wn===null){var o=navigator.userAgent.match(/Safari\/(\d+)/i);Wn=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,It(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,m,T,S=a,y=a,E=e.pid>-1,R=t.pid>-1,A=t.samples.length,C=e.samples.length>0,N=l&&A>0||A>1;if((!E||C)&&(!R||N)||this.ISGenerated||l){this.ISGenerated||(f=this.generateIS(e,t,a,o));var B,Y=this.isVideoContiguous,K=-1;if(N&&(K=function(ye){for(var oe=0;oe<ye.length;oe++)if(ye[oe].key)return oe;return-1}(t.samples),!Y&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,K>0){P.warn("[mp4-remuxer]: Dropped "+K+" out of "+A+" video samples due to a missing keyframe");var V=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(K),t.dropped+=K,B=y+=(t.samples[0].pts-V)/t.inputTimeScale}else K===-1&&(P.warn("[mp4-remuxer]: No keyframe found out of "+A+" video samples"),T=!1);if(this.ISGenerated){if(C&&N){var $=this.getVideoStartPts(t.samples),X=(It(e.samples[0].pts,$)-$)/t.inputTimeScale;S+=Math.max(0,X),y+=Math.max(0,-X)}if(C){if(e.samplerate||(P.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),f=this.generateIS(e,t,a,o)),c=this.remuxAudio(e,S,this.isAudioContiguous,o,R||N||d===wt?y:void 0),N){var le=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,Y,le)}}else N&&(u=this.remuxVideo(t,y,Y,0));u&&(u.firstKeyFrame=K,u.independent=K!==-1,u.firstKeyFramePTS=B)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(m=Ba(r,a,this._initPTS,this._initDTS)),i.samples.length&&(v=Ha(i,a,this._initPTS))),{audio:c,video:u,initSegment:f,independent:T,text:v,id3:m}},n.generateIS=function(e,t,r,i){var a,o,l,d=e.samples,u=t.samples,c=this.typeSupported,f={},v=this._initPTS,m=!v||i,T="audio/mp4";if(m&&(a=o=1/0),e.config&&d.length&&(e.timescale=e.samplerate,e.segmentCodec==="mp3"&&(c.mpeg?(T="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3")),f.audio={id:"audio",container:T,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&c.mpeg?new Uint8Array(0):at.initSegment([e]),metadata:{channelCount:e.channelCount}},m&&(l=e.inputTimeScale,v&&l===v.timescale?m=!1:a=o=d[0].pts-Math.round(l*r))),t.sps&&t.pps&&u.length&&(t.timescale=t.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:at.initSegment([t]),metadata:{width:t.width,height:t.height}},m))if(l=t.inputTimeScale,v&&l===v.timescale)m=!1;else{var S=this.getVideoStartPts(u),y=Math.round(l*r);o=Math.min(o,It(u[0].dts,S)-y),a=Math.min(a,S-y)}if(Object.keys(f).length)return this.ISGenerated=!0,m?(this._initPTS={baseTime:a,timescale:l},this._initDTS={baseTime:o,timescale:l}):a=l=void 0,{tracks:f,initPTS:a,timescale:l}},n.remuxVideo=function(e,t,r,i){var a,o,l=e.inputTimeScale,d=e.samples,u=[],c=d.length,f=this._initPTS,v=this.nextAvcDts,m=8,T=this.videoSampleDuration,S=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,E=!1;r&&v!==null||(v=t*l-(d[0].pts-It(d[0].dts,d[0].pts)));for(var R=f.baseTime*l/f.timescale,A=0;A<c;A++){var C=d[A];C.pts=It(C.pts-R,v),C.dts=It(C.dts-R,v),C.dts<d[A>0?A-1:A].dts&&(E=!0)}E&&d.sort(function(mn,_s){var ul=mn.dts-_s.dts,dl=mn.pts-_s.pts;return ul||dl}),a=d[0].dts;var N=(o=d[d.length-1].dts)-a,B=N?Math.round(N/(c-1)):T||e.inputTimeScale/30;if(r){var Y=a-v,K=Y>B,V=Y<-1;if((K||V)&&(K?P.warn("AVC: "+bi(Y,!0)+" ms ("+Y+"dts) hole between fragments detected, filling it"):P.warn("AVC: "+bi(-Y,!0)+" ms ("+Y+"dts) overlapping between fragments detected"),!V||v>d[0].pts)){a=v;var $=d[0].pts-Y;d[0].dts=a,d[0].pts=$,P.log("Video: First PTS/DTS adjusted: "+bi($,!0)+"/"+bi(a,!0)+", delta: "+bi(Y,!0)+" ms")}}a=Math.max(0,a);for(var X=0,le=0,ye=0;ye<c;ye++){for(var oe=d[ye],ve=oe.units,me=ve.length,ge=0,Le=0;Le<me;Le++)ge+=ve[Le].data.length;le+=ge,X+=me,oe.length=ge,oe.dts=Math.max(oe.dts,a),S=Math.min(oe.pts,S),y=Math.max(oe.pts,y)}o=d[c-1].dts;var De,Oe=le+4*X+8;try{De=new Uint8Array(Oe)}catch(mn){return void this.observer.emit(_.ERROR,_.ERROR,{type:re.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:mn,bytes:Oe,reason:"fail allocating video mdat "+Oe})}var Ue=new DataView(De.buffer);Ue.setUint32(0,Oe),De.set(at.types.mdat,4);for(var yt=!1,rt=Number.POSITIVE_INFINITY,Ut=Number.POSITIVE_INFINITY,Ct=Number.NEGATIVE_INFINITY,Pt=Number.NEGATIVE_INFINITY,it=0;it<c;it++){for(var st=d[it],Yt=st.units,or=0,bt=0,Si=Yt.length;bt<Si;bt++){var Li=Yt[bt],pn=Li.data,Yr=Li.data.byteLength;Ue.setUint32(m,Yr),m+=4,De.set(pn,m),m+=Yr,or+=4+Yr}var Er=void 0;if(it<c-1)T=d[it+1].dts-st.dts,Er=d[it+1].pts-st.pts;else{var ki=this.config,er=it>0?st.dts-d[it-1].dts:B;if(Er=it>0?st.pts-d[it-1].pts:B,ki.stretchShortVideoTrack&&this.nextAudioPts!==null){var nl=Math.floor(ki.maxBufferHole*l),va=(i?S+i*l:this.nextAudioPts)-st.pts;va>nl?((T=va-er)<0?T=er:yt=!0,P.log("[mp4-remuxer]: It is approximately "+va/90+" ms to the next segment; using duration "+T/90+" ms for the last video frame.")):T=er}else T=er}var al=Math.round(st.pts-st.dts);rt=Math.min(rt,T),Ct=Math.max(Ct,T),Ut=Math.min(Ut,Er),Pt=Math.max(Pt,Er),u.push(new Ga(st.key,T,or,al))}if(u.length){if(dn){if(dn<70){var ys=u[0].flags;ys.dependsOn=2,ys.isNonSync=0}}else if(Wn&&Pt-Ut<Ct-rt&&B/Ct<.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 ga=a,Bt=0,Ts=u.length;Bt<Ts;Bt++){var Es=ga+u[Bt].duration,sl=ga+u[Bt].cts;if(Bt<Ts-1){var ol=Es+u[Bt+1].cts;u[Bt].duration=ol-sl}else u[Bt].duration=Bt?u[Bt-1].duration:B;u[Bt].cts=0,ga=Es}}}T=yt||!T?B:T,this.nextAvcDts=v=o+T,this.videoSampleDuration=T,this.isVideoContiguous=!0;var ll={data1:at.moof(e.sequenceNumber++,a,z({},e,{samples:u})),data2:De,startPTS:S/l,endPTS:(y+T)/l,startDTS:a/l,endDTS:v/l,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ll},n.remuxAudio=function(e,t,r,i,a){var o=e.inputTimeScale,l=o/(e.samplerate?e.samplerate:o),d=e.segmentCodec==="aac"?1024:1152,u=d*l,c=this._initPTS,f=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,v=[],m=a!==void 0,T=e.samples,S=f?0:8,y=this.nextAudioPts||-1,E=t*o,R=c.baseTime*o/c.timescale;if(this.isAudioContiguous=r=r||T.length&&y>0&&(i&&Math.abs(E-y)<9e3||Math.abs(It(T[0].pts-R,E)-y)<20*u),T.forEach(function(bt){bt.pts=It(bt.pts-R,E)}),!r||y<0){if(T=T.filter(function(bt){return bt.pts>=0}),!T.length)return;y=a===0?0:i&&!m?Math.max(0,E):T[0].pts}if(e.segmentCodec==="aac")for(var A=this.config.maxAudioFramesDrift,C=0,N=y;C<T.length;C++){var B=T[C],Y=B.pts,K=Y-N,V=Math.abs(1e3*K/o);if(K<=-A*u&&m)C===0&&(P.warn("Audio frame @ "+(Y/o).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*K/o)+" ms."),this.nextAudioPts=y=N=Y);else if(K>=A*u&&V<1e4&&m){var $=Math.round(K/u);(N=Y-$*u)<0&&($--,N+=u),C===0&&(this.nextAudioPts=y=N),P.warn("[mp4-remuxer]: Injecting "+$+" audio frame @ "+(N/o).toFixed(3)+"s due to "+Math.round(1e3*K/o)+" ms gap.");for(var X=0;X<$;X++){var le=Math.max(N,0),ye=Ua.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);ye||(P.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ye=B.unit.subarray()),T.splice(C,0,{unit:ye,pts:le}),N+=u,C++}}B.pts=N,N+=u}for(var oe,ve=null,me=null,ge=0,Le=T.length;Le--;)ge+=T[Le].unit.byteLength;for(var De=0,Oe=T.length;De<Oe;De++){var Ue=T[De],yt=Ue.unit,rt=Ue.pts;if(me!==null)v[De-1].duration=Math.round((rt-me)/l);else{if(r&&e.segmentCodec==="aac"&&(rt=y),ve=rt,!(ge>0))return;ge+=S;try{oe=new Uint8Array(ge)}catch(bt){return void this.observer.emit(_.ERROR,_.ERROR,{type:re.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:bt,bytes:ge,reason:"fail allocating audio mdat "+ge})}f||(new DataView(oe.buffer).setUint32(0,ge),oe.set(at.types.mdat,4))}oe.set(yt,S);var Ut=yt.byteLength;S+=Ut,v.push(new Ga(!0,d,Ut,0)),me=rt}var Ct=v.length;if(Ct){var Pt=v[v.length-1];this.nextAudioPts=y=me+l*Pt.duration;var it=f?new Uint8Array(0):at.moof(e.sequenceNumber++,ve/l,z({},e,{samples:v}));e.samples=[];var st=ve/o,Yt=y/o,or={data1:it,data2:oe,startPTS:st,endPTS:Yt,startDTS:st,endDTS:Yt,type:"audio",hasAudio:!0,hasVideo:!1,nb:Ct};return this.isAudioContiguous=!0,or}},n.remuxEmptyAudio=function(e,t,r,i){var a=e.inputTimeScale,o=a/(e.samplerate?e.samplerate:a),l=this.nextAudioPts,d=this._initDTS,u=9e4*d.baseTime/d.timescale,c=(l!==null?l:i.startDTS*a)+u,f=i.endDTS*a+u,v=1024*o,m=Math.ceil((f-c)/v),T=Ua.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(P.warn("[mp4-remuxer]: remux empty Audio"),T){for(var S=[],y=0;y<m;y++){var E=c+y*v;S.push({unit:T,pts:E,dts:E})}return e.samples=S,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 It(s,n){var e;if(n===null)return s;for(e=n<s?-8589934592:8589934592;Math.abs(s-n)>4294967296;)s+=e;return s}function Ba(s,n,e,t){var r=s.samples.length;if(r){for(var i=s.inputTimeScale,a=0;a<r;a++){var o=s.samples[a];o.pts=It(o.pts-9e4*e.baseTime/e.timescale,n*i)/i,o.dts=It(o.dts-9e4*t.baseTime/t.timescale,n*i)/i}var l=s.samples;return s.samples=[],{samples:l}}}function Ha(s,n,e){var t=s.samples.length;if(t){for(var r=s.inputTimeScale,i=0;i<t;i++){var a=s.samples[i];a.pts=It(a.pts-9e4*e.baseTime/e.timescale,n*r)/r}s.samples.sort(function(l,d){return l.pts-d.pts});var o=s.samples;return s.samples=[],{samples:o}}}var $t,Ga=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 ho(s)},ho=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},fo=function(){function s(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var n=s.prototype;return n.destroy=function(){},n.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},n.resetNextTimestamp=function(){this.lastEndTime=null},n.resetInitSegment=function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(a,o){if(!a||!o)return a;var l=o.keyId;return l&&o.isCommonEncryption&&xe(a,["moov","trak"]).forEach(function(d){var u=xe(d,["mdia","minf","stbl","stsd"])[0].subarray(8),c=xe(u,["enca"]),f=c.length>0;f||(c=xe(u,["encv"])),c.forEach(function(v){xe(f?v.subarray(28):v.subarray(78),["sinf"]).forEach(function(m){var T=oi(m);if(T){var S=T.subarray(8,24);S.some(function(y){return y!==0})||(P.log("[eme] Patching keyId in 'enc"+(f?"a":"v")+">sinf>>tenc' box: "+Et(S)+" -> "+Et(l)),T.set(l,8))}})})}),a}(e,i)),this.emitInitSegment=!0},n.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(e==null||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=si(e);t||(t=Ka(i.audio,Se)),r||(r=Ka(i.video,ze));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};ee(c)||(c=this.lastEndTime=a||0);var v=t.samples;if(v==null||!v.length)return f;var m={initPTS:void 0,timescale:1},T=this.initData;if((l=T)!=null&&l.length||(this.generateInitSegment(v),T=this.initData),(d=T)==null||!d.length)return P.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),f;this.emitInitSegment&&(m.tracks=this.initTracks,this.emitInitSegment=!1);var S=function(K,V){return xe(V,["moof","traf"]).reduce(function($,X){var le=xe(X,["tfdt"])[0],ye=le[0],oe=xe(X,["tfhd"]).reduce(function(ve,me){var ge=_e(me,4),Le=K[ge];if(Le){var De=_e(le,4);if(ye===1){if(De===Ar)return P.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),ve;De*=Ar+1,De+=_e(le,8)}var Oe=De/(Le.timescale||9e4);if(isFinite(Oe)&&(ve===null||Oe<ve))return Oe}return ve},null);return oe!==null&&isFinite(oe)&&($===null||oe<$)?oe:$},null)}(T,v),y=S===null?a:S;(function(K,V,$){if(K===null)return!0;var X=V-K.baseTime/K.timescale;return X<0&&Math.abs(X-$)>1}(u,y,a)||m.timescale!==u.timescale&&o)&&(m.initPTS=y-a,this.initPTS=u={baseTime:m.initPTS,timescale:1});var E=function(K,V){for(var $=0,X=0,le=0,ye=xe(K,["moof","traf"]),oe=0;oe<ye.length;oe++){var ve=ye[oe],me=xe(ve,["tfhd"])[0],ge=V[_e(me,4)];if(ge){var Le=ge.default,De=_e(me,0)|(Le==null?void 0:Le.flags),Oe=Le==null?void 0:Le.duration;8&De&&(Oe=_e(me,2&De?12:8));for(var Ue=ge.timescale||9e4,yt=xe(ve,["trun"]),rt=0;rt<yt.length;rt++)!($=Hi(yt[rt]))&&Oe&&($=Oe*_e(yt[rt],4)),ge.type===ze?X+=$/Ue:ge.type===Se&&(le+=$/Ue)}}if(X===0&&le===0){for(var Ut=0,Ct=xe(K,["sidx"]),Pt=0;Pt<Ct.length;Pt++){var it=Dn(Ct[Pt]);it!=null&&it.references&&(Ut+=it.references.reduce(function(st,Yt){return st+Yt.info.duration||0},0))}return Ut}return X||le}(v,T),R=e?y-u.baseTime/u.timescale:c,A=R+E;(function(K,V,$){xe(V,["moof","traf"]).forEach(function(X){xe(X,["tfhd"]).forEach(function(le){var ye=_e(le,4),oe=K[ye];if(oe){var ve=oe.timescale||9e4;xe(X,["tfdt"]).forEach(function(me){var ge=me[0],Le=_e(me,4);if(ge===0)Le-=$*ve,ai(me,4,Le=Math.max(Le,0));else{Le*=Math.pow(2,32),Le+=_e(me,8),Le-=$*ve,Le=Math.max(Le,0);var De=Math.floor(Le/(Ar+1)),Oe=Math.floor(Le%(Ar+1));ai(me,4,De),ai(me,8,Oe)}})}})})})(T,v,u.baseTime/u.timescale),E>0?this.lastEndTime=A:(P.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var C=!!T.audio,N=!!T.video,B="";C&&(B+="audio"),N&&(B+="video");var Y={data1:v,startPTS:R,startDTS:R,endPTS:A,endDTS:A,type:B,hasAudio:C,hasVideo:N,nb:1,dropped:0};return f.audio=Y.type==="audio"?Y:void 0,f.video=Y.type!=="audio"?Y:void 0,f.initSegment=m,f.id3=Ba(r,a,u,u),i.samples.length&&(f.text=Ha(i,a,u)),f},s}();function Ka(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===ze?"avc1.42e01e":"mp4a.40.5"}try{$t=self.performance.now.bind(self.performance)}catch{P.debug("Unable to use Performance API on this environment"),$t=typeof self!="undefined"&&self.Date.now}var zn=[{demux:eo,remux:fo},{demux:oo,remux:Yn},{demux:$s,remux:Yn},{demux:co,remux:Yn}],Xn=function(){function s(e,t,r,i,a){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=a}var n=s.prototype;return n.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},n.push=function(e,t,r,i){var a=this,o=r.transmuxing;o.executeStart=$t();var l=new Uint8Array(e),d=this.currentTransmuxState,u=this.transmuxConfig;i&&(this.currentTransmuxState=i);var c=i||d,f=c.contiguous,v=c.discontinuity,m=c.trackSwitch,T=c.accurateTimeOffset,S=c.timeOffset,y=c.initSegmentChange,E=u.audioCodec,R=u.videoCodec,A=u.defaultInitPts,C=u.duration,N=u.initSegmentData,B=function(ye,oe){var ve=null;return ye.byteLength>0&&oe!=null&&oe.key!=null&&oe.iv!==null&&oe.method!=null&&(ve=oe),ve}(l,t);if(B&&B.method==="AES-128"){var Y=this.getDecrypter();if(!Y.isSync())return this.decryptionPromise=Y.webCryptoDecrypt(l,B.key.buffer,B.iv.buffer).then(function(ye){var oe=a.push(ye,null,r);return a.decryptionPromise=null,oe}),this.decryptionPromise;var K=Y.softwareDecrypt(l,B.key.buffer,B.iv.buffer);if(r.part>-1&&(K=Y.flush()),!K)return o.executeEnd=$t(),Qn(r);l=new Uint8Array(K)}var V=this.needsProbing(v,m);if(V){var $=this.configureTransmuxer(l);if($)return P.warn("[transmuxer] "+$.message),this.observer.emit(_.ERROR,_.ERROR,{type:re.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:$,reason:$.message}),o.executeEnd=$t(),Qn(r)}(v||m||y||V)&&this.resetInitSegment(N,E,R,C,t),(v||y||V)&&this.resetInitialTimestamp(A),f||this.resetContiguity();var X=this.transmux(l,B,S,T,r),le=this.currentTransmuxState;return le.contiguous=!0,le.discontinuity=!1,le.trackSwitch=!1,o.executeEnd=$t(),X},n.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=$t();var i=this.decrypter,a=this.currentTransmuxState,o=this.decryptionPromise;if(o)return o.then(function(){return t.flush(e)});var l=[],d=a.timeOffset;if(i){var u=i.flush();u&&l.push(this.push(u,null,e))}var c=this.demuxer,f=this.remuxer;if(!c||!f)return r.executeEnd=$t(),[Qn(e)];var v=c.flush(d);return mr(v)?v.then(function(m){return t.flushRemux(l,m,e),l}):(this.flushRemux(l,v,e),l)},n.flushRemux=function(e,t,r){var i=t.audioTrack,a=t.videoTrack,o=t.id3Track,l=t.textTrack,d=this.currentTransmuxState,u=d.accurateTimeOffset,c=d.timeOffset;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=$t()},n.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},n.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},n.resetInitSegment=function(e,t,r,i,a){var o=this.demuxer,l=this.remuxer;o&&l&&(o.resetInitSegment(e,t,r,i),l.resetInitSegment(e,t,r,a))},n.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},n.transmux=function(e,t,r,i,a){return t&&t.method==="SAMPLE-AES"?this.transmuxSampleAes(e,t,r,i,a):this.transmuxUnencrypted(e,r,i,a)},n.transmuxUnencrypted=function(e,t,r,i){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),o=a.audioTrack,l=a.videoTrack,d=a.id3Track,u=a.textTrack;return{remuxResult:this.remuxer.remux(o,l,d,u,t,r,!1,this.id),chunkMeta:i}},n.transmuxSampleAes=function(e,t,r,i,a){var o=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(l){return{remuxResult:o.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,r,i,!1,o.id),chunkMeta:a}})},n.configureTransmuxer=function(e){for(var t,r=this.config,i=this.observer,a=this.typeSupported,o=this.vendor,l=0,d=zn.length;l<d;l++)if(zn[l].demux.probe(e)){t=zn[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 Je(this.config)),e},s}(),Qn=function(s){return{remuxResult:{},chunkMeta:s}};function mr(s){return"then"in s&&s.then instanceof Function}var vo=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},go=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},Jn={};(function(s){var n=Object.prototype.hasOwnProperty,e="~";function t(){}function r(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function i(l,d,u,c,f){if(typeof u!="function")throw new TypeError("The listener must be a function");var v=new r(u,c||l,f),m=e?e+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],v]:l._events[m].push(v):(l._events[m]=v,l._eventsCount++),l}function a(l,d){--l._eventsCount==0?l._events=new t:delete l._events[d]}function o(){this._events=new t,this._eventsCount=0}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1)),o.prototype.eventNames=function(){var l,d,u=[];if(this._eventsCount===0)return u;for(d in l=this._events)n.call(l,d)&&u.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(l)):u},o.prototype.listeners=function(l){var d=e?e+l:l,u=this._events[d];if(!u)return[];if(u.fn)return[u.fn];for(var c=0,f=u.length,v=new Array(f);c<f;c++)v[c]=u[c].fn;return v},o.prototype.listenerCount=function(l){var d=e?e+l:l,u=this._events[d];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,d,u,c,f,v){var m=e?e+l:l;if(!this._events[m])return!1;var T,S,y=this._events[m],E=arguments.length;if(y.fn){switch(y.once&&this.removeListener(l,y.fn,void 0,!0),E){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,u),!0;case 4:return y.fn.call(y.context,d,u,c),!0;case 5:return y.fn.call(y.context,d,u,c,f),!0;case 6:return y.fn.call(y.context,d,u,c,f,v),!0}for(S=1,T=new Array(E-1);S<E;S++)T[S-1]=arguments[S];y.fn.apply(y.context,T)}else{var R,A=y.length;for(S=0;S<A;S++)switch(y[S].once&&this.removeListener(l,y[S].fn,void 0,!0),E){case 1:y[S].fn.call(y[S].context);break;case 2:y[S].fn.call(y[S].context,d);break;case 3:y[S].fn.call(y[S].context,d,u);break;case 4:y[S].fn.call(y[S].context,d,u,c);break;default:if(!T)for(R=1,T=new Array(E-1);R<E;R++)T[R-1]=arguments[R];y[S].fn.apply(y[S].context,T)}}return!0},o.prototype.on=function(l,d,u){return i(this,l,d,u,!1)},o.prototype.once=function(l,d,u){return i(this,l,d,u,!0)},o.prototype.removeListener=function(l,d,u,c){var f=e?e+l:l;if(!this._events[f])return this;if(!d)return a(this,f),this;var v=this._events[f];if(v.fn)v.fn!==d||c&&!v.once||u&&v.context!==u||a(this,f);else{for(var m=0,T=[],S=v.length;m<S;m++)(v[m].fn!==d||c&&!v[m].once||u&&v[m].context!==u)&&T.push(v[m]);T.length?this._events[f]=T.length===1?T[0]:T:a(this,f)}return this},o.prototype.removeAllListeners=function(l){var d;return l?(d=e?e+l:l,this._events[d]&&a(this,d)):(this._events=new t,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,s.exports=o})({get exports(){return Jn},set exports(s){Jn=s}});var cn=Jn;function $n(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&&qa(t,i),a&&qa(t,a),s.postMessage({event:"transmuxComplete",data:n},t),!0}function qa(s,n){n.data1&&s.push(n.data1.buffer),n.data2&&s.push(n.data2.buffer)}function Va(s,n,e){n.reduce(function(t,r){return $n(s,r)||t},!1)||s.postMessage({event:"transmuxComplete",data:n[0]}),s.postMessage({event:"flush",data:e})}I!==void 0&&I&&function(s){var n=new cn,e=function(r,i){s.postMessage({event:r,data:i})};n.on(_.FRAG_DECRYPTED,e),n.on(_.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 Xn(n,i.typeSupported,a,i.vendor,i.id),$e(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);mr(o)?(s.transmuxer.async=!0,o.then(function(u){$n(s,u)}).catch(function(u){e(_.ERROR,{type:re.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker push error"})})):(s.transmuxer.async=!1,$n(s,o));break;case"flush":var l=i.chunkMeta,d=s.transmuxer.flush(l);mr(d)||s.transmuxer.async?(mr(d)||(d=Promise.resolve(d)),d.then(function(u){Va(s,u,l)}).catch(function(u){e(_.ERROR,{type:re.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker flush error"})})):Va(s,d,l)}})}(self);var Zn=Hn()||{isTypeSupported:function(){return!1}},ja=function(){function s(e,t,r,i){var a=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var o=e.config;this.hls=e,this.id=t,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;var l=function(S,y){(y=y||{}).frag=a.frag,y.id=a.id,S===_.ERROR&&(a.error=y.error),a.hls.trigger(S,y)};this.observer=new cn,this.observer.on(_.FRAG_DECRYPTED,l),this.observer.on(_.ERROR,l);var d,u,c,f,v={mp4:Zn.isTypeSupported("video/mp4"),mpeg:Zn.isTypeSupported("audio/mpeg"),mp3:Zn.isTypeSupported('audio/mp4; codecs="mp3"')},m=navigator.vendor;if(!this.useWorker||typeof Worker=="undefined"||(o.workerPath,0))this.transmuxer=new Xn(this.observer,v,o,m,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;("+D.toString()+")(true);"],{type:"text/javascript"}),u=self.URL.createObjectURL(d),{worker:new self.Worker(u),objectURL:u})),this.onwmsg=function(S){return a.onWorkerMessage(S)};var T=this.workerContext.worker;T.addEventListener("message",this.onwmsg),T.onerror=function(S){var y=new Error(S.message+" ("+S.filename+":"+S.lineno+")");o.enableWorker=!1,P.warn('Error in "'+t+'" Web Worker, fallback to inline'),a.hls.trigger(_.ERROR,{type:re.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:y})},T.postMessage({cmd:"init",typeSupported:v,vendor:m,id:t,config:JSON.stringify(o)})}catch(S){P.warn('Error setting up "'+t+'" Web Worker, fallback to inline',S),this.resetWorker(),this.error=null,this.transmuxer=new Xn(this.observer,v,o,m,t)}}var n=s.prototype;return n.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},n.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},n.push=function(e,t,r,i,a,o,l,d,u,c){var f,v,m=this;u.transmuxing.start=self.performance.now();var T=this.transmuxer,S=o?o.start:a.start,y=a.decryptdata,E=this.frag,R=!(E&&a.cc===E.cc),A=!(E&&u.level===E.level),C=E?u.sn-E.sn:-1,N=this.part?u.part-this.part.index:-1,B=C===0&&u.id>1&&u.id===(E==null?void 0:E.stats.chunkCount),Y=!A&&(C===1||C===0&&(N===1||B&&N<=0)),K=self.performance.now();(A||C||a.stats.parsing.start===0)&&(a.stats.parsing.start=K),!o||!N&&Y||(o.stats.parsing.start=K);var V=!(E&&((f=a.initSegment)==null?void 0:f.url)===((v=E.initSegment)==null?void 0:v.url)),$=new go(R,Y,d,A,S,V);if(!Y||R||V){P.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
|
21
|
+
discontinuity: `+R+`
|
|
22
|
+
trackSwitch: `+A+`
|
|
23
|
+
contiguous: `+Y+`
|
|
24
|
+
accurateTimeOffset: `+d+`
|
|
25
|
+
timeOffset: `+S+`
|
|
26
|
+
initSegmentChange: `+V);var X=new vo(r,i,t,l,c);this.configureTransmuxer(X)}if(this.frag=a,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:u,state:$},e instanceof ArrayBuffer?[e]:[]);else if(T){var le=T.push(e,y,u,$);mr(le)?(T.async=!0,le.then(function(ye){m.handleTransmuxComplete(ye)}).catch(function(ye){m.transmuxerError(ye,u,"transmuxer-interface push error")})):(T.async=!1,this.handleTransmuxComplete(le))}},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);mr(i)||r.async?(mr(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(_.ERROR,{type:re.MEDIA_ERROR,details:M.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}(),po=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)&&ue.getBuffered(i).length){var c=ue.bufferInfo(i,o,0),f=c.len>0,v=c.nextStart||0;if(f||v){if(l){var m=c.len>2,T=!v||t&&t.start<=o||v-o>2&&!this.fragmentTracker.getPartialFragment(o);if(m||T)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var S,y=Math.max(v,c.start||0)-o,E=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,R=!(E==null||(S=E.details)==null)&&S.live?2*E.details.targetduration:2,A=this.fragmentTracker.getPartialFragment(o);if(y>0&&(y<=R||A))return void this._trySkipBufferHole(A)}var C=self.performance.now();if(a!==null){var N=C-a;if(l||!(N>=250)||(this._reportStall(c),this.media)){var B=ue.bufferInfo(i,o,r.maxBufferHole);this._tryFixBufferStall(B,N)}}else this.stalled=C}}}else if(this.moved=!0,a!==null){if(this.stallReported){var Y=self.performance.now()-a;P.warn("playback not stuck anymore @"+o+", after "+Math.round(Y)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},n._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,a=this.media;if(a!==null){var o=a.currentTime,l=i.getPartialFragment(o);if(l&&(this._trySkipBufferHole(l)||!this.media))return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-o<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(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(_.ERROR,{type:re.MEDIA_ERROR,details:M.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=ue.bufferInfo(i,a,0),l=a<o.start?o.start:o.nextStart;if(l){var d=o.len<=t.maxBufferHole,u=o.len>0&&o.len<1&&i.readyState<3,c=l-a;if(c>0&&(d||u)){if(c>t.maxBufferHole){var f=this.fragmentTracker,v=!1;if(a===0){var m=f.getAppendedFrag(0,Me);m&&l<m.end&&(v=!0)}if(!v){var T=e||f.getAppendedFrag(a,Me);if(T){for(var S=!1,y=T.end;y<l;){var E=f.getPartialFragment(y);if(!E){S=!0;break}y+=E.duration}if(S)return 0}}}var R=Math.max(l+.05,a+.1);if(P.warn("skipping hole, adjusting currentTime from "+a+" to "+R),this.moved=!0,this.stalled=null,i.currentTime=R,e&&!e.gap){var A=new Error("fragment loaded with buffer holes, seeking from "+a+" to "+R);r.trigger(_.ERROR,{type:re.MEDIA_ERROR,details:M.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:A,reason:A.message,frag:e})}return R}}return 0},n._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(r!==null){var a=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var o=a+(i+1)*e.nudgeOffset,l=new Error("Nudging 'currentTime' from "+a+" to "+o);P.warn(l.message),r.currentTime=o,t.trigger(_.ERROR,{type:re.MEDIA_ERROR,details:M.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(_.ERROR,{type:re.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,error:d,fatal:!0})}}},s}(),mo=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[stream-controller]",Me)||this).audioCodecSwap=!1,a.gapController=null,a.level=-1,a._forceStartLoad=!1,a.altAudio=!1,a.audioOnly=!1,a.fragPlaying=null,a.onvplaying=null,a.onvseeked=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a._registerListeners(),a}ne(n,s);var e=n.prototype;return e._registerListeners=function(){var t=this.hls;t.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(_.MANIFEST_LOADING,this.onManifestLoading,this),t.on(_.MANIFEST_PARSED,this.onManifestParsed,this),t.on(_.LEVEL_LOADING,this.onLevelLoading,this),t.on(_.LEVEL_LOADED,this.onLevelLoaded,this),t.on(_.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(_.ERROR,this.onError,this),t.on(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(_.BUFFER_CREATED,this.onBufferCreated,this),t.on(_.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(_.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(_.MANIFEST_LOADING,this.onManifestLoading,this),t.off(_.MANIFEST_PARSED,this.onManifestParsed,this),t.off(_.LEVEL_LOADED,this.onLevelLoaded,this),t.off(_.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(_.ERROR,this.onError,this),t.off(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(_.BUFFER_CREATED,this.onBufferCreated,this),t.off(_.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(_.FRAG_BUFFERED,this.onFragBuffered,this)},e.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},e.startLoad=function(t){if(this.levels){var r=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var a=i.startLevel;a===-1&&(i.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=i.nextAutoLevel),this.level=i.nextLoadLevel=a,this.loadedmetadata=!1}r>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r),this.state=ce,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Ne},e.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},e.doTick=function(){switch(this.state){case qr:var t,r=this.levels,i=this.level,a=r==null||(t=r[i])==null?void 0:t.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a))break;this.state=ce;break}break;case mt:var o,l=self.performance.now(),d=this.retryDate;(!d||l>=d||(o=this.media)!=null&&o.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=ce)}this.state===ce&&this.doTickIdle(),this.onTickEnd()},e.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},e.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,i=this.levels,a=this.media,o=t.config,l=t.nextLoadLevel;if(r!==null&&(a||!this.startFragRequested&&o.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&i!=null&&i[l]){var d=i[l],u=this.getMainFwdBufferInfo();if(u!==null){var c=this.getLevelDetails();if(c&&this._streamEnded(u,c)){var f={};return this.altAudio&&(f.type="video"),this.hls.trigger(_.BUFFER_EOS,f),void(this.state=pr)}t.loadLevel!==l&&t.manualLevel===-1&&this.log("Adapting to level "+l+" from level "+this.level),this.level=t.nextLoadLevel=l;var v=d.details;if(!v||this.state===qr||v.live&&this.levelLastLoaded!==l)return this.level=l,void(this.state=qr);var m=u.len,T=this.getMaxBufferLength(d.maxBitrate);if(!(m>=T)){this.backtrackFragment&&this.backtrackFragment.start>u.end&&(this.backtrackFragment=null);var S=this.backtrackFragment?this.backtrackFragment.start:u.end,y=this.getNextFragment(S,v);if(this.couldBacktrack&&!this.fragPrevious&&y&&y.sn!=="initSegment"&&this.fragmentTracker.getState(y)!==O){var E,R=((E=this.backtrackFragment)!=null?E:y).sn-v.startSN,A=v.fragments[R-1];A&&y.cc===A.cc&&(y=A,this.fragmentTracker.removeFragment(A))}else this.backtrackFragment&&u.len&&(this.backtrackFragment=null);if(y&&this.isLoopLoading(y,S)){if(!y.gap){var C=this.audioOnly&&!this.altAudio?Se:ze,N=(C===ze?this.videoBuffer:this.mediaBuffer)||this.media;N&&this.afterBufferFlushed(N,C,Me)}y=this.getNextFragmentLoopLoading(y,v,u,Me,T)}y&&(!y.initSegment||y.initSegment.data||this.bitrateTest||(y=y.initSegment),this.loadFragment(y,d,S))}}}},e.loadFragment=function(t,r,i){var a=this.fragmentTracker.getState(t);this.fragCurrent=t,a===k?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,Me);return r&&"fragment"in r?r.fragment:r},e.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,Me)},e.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},e.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},e.nextLevelSwitch=function(){var t=this.levels,r=this.media;if(r!=null&&r.readyState){var i,a=this.getAppendedFrag(r.currentTime);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 Rt:case Dt:case mt:case gt:case Kr:this.state=ce}this.nextLoadPosition=this.getLoadPosition()},e.flushMainBuffer=function(t,r){s.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},e.onMediaAttached=function(t,r){s.prototype.onMediaAttached.call(this,t,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new po(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;ee(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(_.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=Aa())==null||(a=o.prototype)==null?void 0:a.changeType)!="function",this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},e.onLevelLoading=function(t,r){var i=this.levels;if(i&&this.state===ce){var a=i[r.level];(!a.details||a.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(a.details))&&(this.state=qr)}},e.onLevelLoaded=function(t,r){var i,a=this.levels,o=r.level,l=r.details,d=l.totalduration;if(a){this.log("Level "+o+" loaded ["+l.startSN+","+l.endSN+"], cc ["+l.startCC+", "+l.endCC+"] duration:"+d);var u=a[o],c=this.fragCurrent;!c||this.state!==Dt&&this.state!==mt||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(_.LEVEL_UPDATED,{details:l,level:o}),this.state===qr){if(this.waitForCdnTuneIn(l))return;this.state=ce}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,f),this.tick()}else this.warn("Levels were reset while loading level "+o)},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.levels;if(l){var d=l[i.level],u=d.details;if(!u)return this.warn("Dropping fragment "+i.sn+" of level "+i.level+" after level details were reset"),void this.fragmentTracker.removeFragment(i);var c=d.videoCodec,f=u.PTSKnown||!u.live,v=(r=i.initSegment)==null?void 0:r.data,m=this._getAudioCodec(d),T=this.transmuxer=this.transmuxer||new ja(this.hls,Me,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),S=a?a.index:-1,y=S!==-1,E=new Ve(i.level,i.sn,i.stats.chunkCount,o.byteLength,S,y),R=this.initPTS[i.cc];T.push(o,v,m,c,i,a,u.totalduration,f,E,R)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},e.onAudioTrackSwitching=function(t,r){var i=this.altAudio;if(!r.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;i&&(o.trigger(_.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),o.trigger(_.AUDIO_TRACK_SWITCHED,r)}},e.onAudioTrackSwitched=function(t,r){var i=r.id,a=!!this.hls.audioTracks[i].url;if(a){var o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=a,this.tick()},e.onBufferCreated=function(t,r){var i,a,o=r.tracks,l=!1;for(var d in o){var u=o[d];if(u.id==="main"){if(a=d,i=u,d==="video"){var c=o[d];c&&(this.videoBuffer=c.buffer)}}else l=!0}l&&i?(this.log("Alternate track found, use "+a+".buffered to schedule main fragment loading"),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media},e.onFragBuffered=function(t,r){var i=r.frag,a=r.part;if(!i||i.type===Me){if(this.fragContextChanged(i))return this.warn("Fragment "+i.sn+(a?" p: "+a.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Kr&&(this.state=ce));var o=a?a.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,a)}},e.onError=function(t,r){var i;if(r.fatal)this.state=ar;else switch(r.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Me,r);break;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==qr||((i=r.context)==null?void 0:i.type)!==Qt||(this.state=ce);break;case M.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.checkBuffer=function(){var t=this.media,r=this.gapController;if(t&&r&&t.readyState){if(this.loadedmetadata||!ue.getBuffered(t).length){var i=this.state!==ce?this.fragCurrent:null;r.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}},e.onFragLoadEmergencyAborted=function(){this.state=ce,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},e.onBufferFlushed=function(t,r){var i=r.type;if(i!==Se||this.audioOnly&&!this.altAudio){var a=(i===ze?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,i,Me)}},e.onLevelsUpdated=function(t,r){this.levels=r.levels},e.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},e.seekToStartPos=function(){var t=this.media;if(t){var r=t.currentTime,i=this.startPosition;if(i>=0&&r<i){if(t.seeking)return void this.log("could not seek to "+i+", already seeking at "+r);var a=ue.getBuffered(t),o=(a.length?a.start(0):0)-i;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+o+" to match buffer start"),i+=o,this.startPosition=i),this.log("seek to target start position "+i+" from current time "+r),t.currentTime=i}}},e._getAudioCodec=function(t){var r=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r=r.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),r},e._loadBitrateTestFrag=function(t,r){var i=this;t.bitrateTest=!0,this._doFragLoad(t,r).then(function(a){var o=i.hls;if(a&&!i.fragContextChanged(t)){r.fragmentError=0,i.state=ce,i.startFragRequested=!1,i.bitrateTest=!1;var l=t.stats;l.parsing.start=l.parsing.end=l.buffering.start=l.buffering.end=self.performance.now(),o.trigger(_.FRAG_LOADED,a),t.bitrateTest=!1}})},e._handleTransmuxComplete=function(t){var r,i="main",a=this.hls,o=t.remuxResult,l=t.chunkMeta,d=this.getCurrentContext(l);if(d){var u=d.frag,c=d.part,f=d.level,v=o.video,m=o.text,T=o.id3,S=o.initSegment,y=f.details,E=this.altAudio?void 0:o.audio;if(this.fragContextChanged(u))this.fragmentTracker.removeFragment(u);else{if(this.state=gt,S){S.tracks&&(this._bufferInitSegment(f,S.tracks,u,l),a.trigger(_.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:i,tracks:S.tracks}));var R=S.initPTS,A=S.timescale;ee(R)&&(this.initPTS[u.cc]={baseTime:R,timescale:A},a.trigger(_.INIT_PTS_FOUND,{frag:u,id:i,initPTS:R,timescale:A}))}if(v&&o.independent!==!1){if(y){var C=v.startPTS,N=v.endPTS,B=v.startDTS,Y=v.endDTS;if(c)c.elementaryStreams[v.type]={startPTS:C,endPTS:N,startDTS:B,endDTS:Y};else if(v.firstKeyFrame&&v.independent&&l.id===1&&(this.couldBacktrack=!0),v.dropped&&v.independent){var K=this.getMainFwdBufferInfo();if((K?K.end:this.getLoadPosition())+this.config.maxBufferHole<(v.firstKeyFramePTS?v.firstKeyFramePTS:C)-this.config.maxBufferHole)return void this.backtrack(u);u.setElementaryStreamInfo(v.type,u.start,N,u.start,Y,!0)}u.setElementaryStreamInfo(v.type,C,N,B,Y),this.backtrackFragment&&(this.backtrackFragment=u),this.bufferFragmentData(v,u,c,l)}}else if(o.independent===!1)return void this.backtrack(u);if(E){var V=E.startPTS,$=E.endPTS,X=E.startDTS,le=E.endDTS;c&&(c.elementaryStreams[Se]={startPTS:V,endPTS:$,startDTS:X,endDTS:le}),u.setElementaryStreamInfo(Se,V,$,X,le),this.bufferFragmentData(E,u,c,l)}if(y&&T!=null&&(r=T.samples)!=null&&r.length){var ye={id:i,frag:u,details:y,samples:T.samples};a.trigger(_.FRAG_PARSING_METADATA,ye)}if(y&&m){var oe={id:i,frag:u,details:y,samples:m.samples};a.trigger(_.FRAG_PARSING_USERDATA,oe)}}}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i,a){var o=this;if(this.state===gt){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(_.BUFFER_CODECS,r),Object.keys(r).forEach(function(v){var m=r[v].initSegment;m!=null&&m.byteLength&&o.hls.trigger(_.BUFFER_APPENDING,{type:v,data:m,frag:i,part:null,chunkMeta:a,parent:i.type})}),this.tick()}},e.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Me)},e.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=ce},e.checkFragmentChanged=function(){var t=this.media,r=null;if(t&&t.readyState>1&&t.seeking===!1){var i=t.currentTime;if(ue.isBuffered(t,i)?r=this.getAppendedFrag(i):ue.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(_.FRAG_CHANGED,{frag:r}),a&&a.level===o||this.hls.trigger(_.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&&ee(r)&&ee(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}(Bn),jr=function(){function s(e,t,r){t===void 0&&(t=0),r===void 0&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var n=s.prototype;return n.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},n.getTotalWeight=function(){return this.totalWeight_},n.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},s}(),yo=function(){function s(e,t,r,i){i===void 0&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new jr(e),this.fast_=new jr(t),this.defaultTTFB_=i,this.ttfb_=new jr(e)}var n=s.prototype;return n.update=function(e,t){var r=this.slow_,i=this.fast_,a=this.ttfb_;r.halfLife!==e&&(this.slow_=new jr(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new jr(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new jr(e,a.getEstimate(),a.getTotalWeight()))},n.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},n.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},n.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},n.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},n.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},n.destroy=function(){},s}(),To=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 yo(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(_.FRAG_LOADING,this.onFragLoading,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this)},n.unregisterListeners=function(){var e=this.hls;e.off(_.FRAG_LOADING,this.onFragLoading,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_.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;ee(a)&&ee(o)&&(this.lastLevelLoadSec=8*a/o),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},n._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.autoLevelEnabled,a=r.media;if(e&&a){var o=performance.now(),l=t?t.stats:e.stats,d=t?t.duration:e.duration,u=o-l.loading.start;if(l.aborted||l.loaded&&l.loaded===l.total||e.level===0)return this.clearTimer(),void(this._nextAutoLevel=-1);if(i&&!a.paused&&a.playbackRate&&a.readyState){var c=r.mainForwardBufferInfo;if(c!==null){var f=this.bwEstimator.getEstimateTTFB(),v=Math.abs(a.playbackRate);if(!(u<=Math.max(f,d/(2*v)*1e3))){var m=c.len/v;if(!(m>=2*d/v)){var T=l.loading.first?l.loading.first-l.loading.start:-1,S=l.loaded&&T>-1,y=this.bwEstimator.getEstimate(),E=r.levels,R=r.minAutoLevel,A=E[e.level],C=l.total||Math.max(l.loaded,Math.round(d*A.maxBitrate/8)),N=u-T;N<1&&S&&(N=Math.min(u,8*l.loaded/y));var B=S?1e3*l.loaded/N:0,Y=B?(C-l.loaded)/B:8*C/y+f/1e3;if(!(Y<=m)){var K,V=B?8*B:y,$=Number.POSITIVE_INFINITY;for(K=e.level-1;K>R;K--){var X=E[K].maxBitrate;if(($=this.getTimeToLoadFrag(f/1e3,V,d*X,!E[K].details))<m)break}$>=Y||$>10*d||(r.nextLoadLevel=K,S?this.bwEstimator.sample(u-Math.min(f,T),l.loaded):this.bwEstimator.sampleTTFB(u),this.clearTimer(),P.warn("[abr] Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+` is loading too slowly;
|
|
27
|
+
Time to underbuffer: `+m.toFixed(3)+` s
|
|
28
|
+
Estimated load time for current fragment: `+Y.toFixed(3)+` s
|
|
29
|
+
Estimated load time for down switch fragment: `+$.toFixed(3)+` s
|
|
30
|
+
TTFB estimate: `+T+`
|
|
31
|
+
Current BW estimate: `+(ee(y)?(y/1024).toFixed(3):"Unknown")+` Kb/s
|
|
32
|
+
New BW estimate: `+(this.bwEstimator.getEstimate()/1024).toFixed(3)+` Kb/s
|
|
33
|
+
Aborting and switching to level `+K),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),r.trigger(_.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:l}))}}}}}}},n.onFragLoaded=function(e,t){var r=t.frag,i=t.part,a=i?i.stats:r.stats;if(r.type===Me&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var o=i?i.duration:r.duration,l=this.hls.levels[r.level],d=(l.loaded?l.loaded.bytes:0)+a.loaded,u=(l.loaded?l.loaded.duration:0)+o;l.loaded={bytes:d,duration:u},l.realBitrate=Math.round(8*d/u)}if(r.bitrateTest){var c={stats:a,frag:r,part:i,id:r.type};this.onFragBuffered(_.FRAG_BUFFERED,c),r.bitrateTest=!1}}},n.onFragBuffered=function(e,t){var r=t.frag,i=t.part,a=i!=null&&i.stats.loaded?i.stats:r.stats;if(!a.aborted&&!this.ignoreFragment(r)){var o=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,a.loaded),a.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}},n.ignoreFragment=function(e){return e.type!==Me||e.sn==="initSegment"},n.clearTimer=function(){self.clearInterval(this.timer)},n.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.maxAutoLevel,a=r.config,o=r.minAutoLevel,l=r.media,d=t?t.duration:e?e.duration:0,u=l&&l.playbackRate!==0?Math.abs(l.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,f=r.mainForwardBufferInfo,v=(f?f.len:0)/u,m=this.findBestLevel(c,o,i,v,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(m>=0)return m;P.trace("[abr] "+(v?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var T=d?Math.min(d,a.maxStarvationDelay):a.maxStarvationDelay,S=a.abrBandWidthFactor,y=a.abrBandWidthUpFactor;if(!v){var E=this.bitrateTestDelay;E&&(T=(d?Math.min(d,a.maxLoadingDelay):a.maxLoadingDelay)-E,P.trace("[abr] bitrate test took "+Math.round(1e3*E)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*T)+" ms"),S=y=1)}return m=this.findBestLevel(c,o,i,v+T,S,y),Math.max(m,0)},n.findBestLevel=function(e,t,r,i,a,o){for(var l,d=this.fragCurrent,u=this.partCurrent,c=this.lastLoadedFragLevel,f=this.hls.levels,v=f[c],m=!(v==null||(l=v.details)==null||!l.live),T=v==null?void 0:v.codecSet,S=u?u.duration:d?d.duration:0,y=this.bwEstimator.getEstimateTTFB()/1e3,E=t,R=-1,A=r;A>=t;A--){var C=f[A];if(!C||T&&C.codecSet!==T)C&&(E=Math.min(A,E),R=Math.max(A,R));else{R!==-1&&P.trace("[abr] Skipped level(s) "+E+"-"+R+' with CODECS:"'+f[R].attrs.CODECS+'"; not compatible with "'+v.attrs.CODECS+'"');var N=C.details,B=(u?N==null?void 0:N.partTarget:N==null?void 0:N.averagetargetduration)||S,Y=void 0;Y=A<=c?a*e:o*e;var K=f[A].maxBitrate,V=this.getTimeToLoadFrag(y,Y,K*B,N===void 0);if(P.trace("[abr] level:"+A+" adjustedbw-bitrate:"+Math.round(Y-K)+" avgDuration:"+B.toFixed(1)+" maxFetchDuration:"+i.toFixed(1)+" fetchDuration:"+V.toFixed(1)),Y>K&&(V===0||!ee(V)||m&&!this.bitrateTestDelay||V<i))return A}}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}(),Wa=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}(),Eo=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[audio-stream-controller]",wt)||this).videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.bufferedTrack=null,a.switchingTrack=null,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a.cachedTrackLoadedData=null,a._registerListeners(),a}ne(n,s);var e=n.prototype;return e.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null},e._registerListeners=function(){var t=this.hls;t.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(_.MANIFEST_LOADING,this.onManifestLoading,this),t.on(_.LEVEL_LOADED,this.onLevelLoaded,this),t.on(_.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(_.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(_.ERROR,this.onError,this),t.on(_.BUFFER_RESET,this.onBufferReset,this),t.on(_.BUFFER_CREATED,this.onBufferCreated,this),t.on(_.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(_.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(_.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(_.MANIFEST_LOADING,this.onManifestLoading,this),t.off(_.LEVEL_LOADED,this.onLevelLoaded,this),t.off(_.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(_.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(_.ERROR,this.onError,this),t.off(_.BUFFER_RESET,this.onBufferReset,this),t.off(_.BUFFER_CREATED,this.onBufferCreated,this),t.off(_.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(_.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(_.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===_i&&this.tick()}},e.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=Ne);var r=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),r>0&&t===-1?(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r,this.state=ce):(this.loadedmetadata=!1,this.state=je),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.doTick=function(){switch(this.state){case ce:this.doTickIdle();break;case je: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=_i}break;case mt:var o,l=performance.now(),d=this.retryDate;(!d||l>=d||(o=this.media)!=null&&o.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=ce);break;case _i:var u=this.waitingData;if(u){var c=u.frag,f=u.part,v=u.cache,m=u.complete;if(this.initPTS[c.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Dt;var T={frag:c,part:f,payload:v.flush(),networkDetails:null};this._handleFragmentLoadProgress(T),m&&s.prototype._handleFragmentLoadComplete.call(this,T)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var S=this.getLoadPosition(),y=ue.bufferInfo(this.mediaBuffer,S,this.config.maxBufferHole);Ti(y.end,this.config.maxFragLookUpTolerance,c)<0&&(this.log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+y.end+" is needed"),this.clearWaitingFragment())}}else this.state=ce}this.onTickEnd()},e.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=ce)},e.resetLoadingState=function(){this.clearWaitingFragment(),s.prototype.resetLoadingState.call(this)},e.onTickEnd=function(){var t=this.media;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)},e.doTickIdle=function(){var t=this.hls,r=this.levels,i=this.media,a=this.trackId,o=t.config;if(r!=null&&r[a]&&(i||!this.startFragRequested&&o.startFragPrefetch)){var l=r[a],d=l.details;if(!d||d.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(d))this.state=je;else{var u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,Se,wt));var c=this.getFwdBufferInfo(u,wt);if(c!==null){var f=this.bufferedTrack,v=this.switchingTrack;if(!v&&this._streamEnded(c,d))return t.trigger(_.BUFFER_EOS,{type:"audio"}),void(this.state=pr);var m=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Me),T=c.len,S=this.getMaxBufferLength(m==null?void 0:m.len);if(!(T>=S)||v){var y=d.fragments[0].start,E=c.end;if(v&&i){var R=this.getLoadPosition();f&&v.attrs!==f.attrs&&(E=R),d.PTSKnown&&R<y&&(c.end>y||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=y+.05)}var A=this.getNextFragment(E,d),C=!1;if(A&&this.isLoopLoading(A,E)&&(C=!!A.gap,A=this.getNextFragmentLoopLoading(A,d,c,Me,S)),A){var N=m&&A.start>m.end+d.targetduration;if(N||(m==null||!m.len)&&c.len){var B=this.fragmentTracker.getBufferedFrag(A.start,Me);if(B===null||(C||(C=!!B.gap||!!N&&m.len===0),N&&!C||C&&c.nextStart&&c.nextStart<B.end))return}this.loadFragment(A,l,E)}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 hr(a)})},e.onAudioTrackSwitching=function(t,r){var i=!!r.url;this.trackId=r.id;var a=this.fragCurrent;a&&(a.abortRequests(),this.removeUnbufferedFrags(a.start)),this.resetLoadingState(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.switchingTrack=r,this.state=ce):(this.switchingTrack=null,this.bufferedTrack=r,this.state=Ne),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(_.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?(be(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!==je||this.waitForCdnTuneIn(o)||(this.state=ce),this.tick()}else this.warn("Audio tracks were reset while loading level "+l)}else this.cachedTrackLoadedData=r},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.config,d=this.trackId,u=this.levels;if(u){var c=u[d];if(c){var f=c.details;if(!f)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);var v=l.defaultAudioCodec||c.audioCodec||"mp4a.40.2",m=this.transmuxer;m||(m=this.transmuxer=new ja(this.hls,wt,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var T=this.initPTS[i.cc],S=(r=i.initSegment)==null?void 0:r.data;if(T!==void 0){var y=a?a.index:-1,E=y!==-1,R=new Ve(i.level,i.sn,i.stats.chunkCount,o.byteLength,y,E);m.push(o,S,v,"",i,a,f.totalduration,!1,R,T)}else this.log("Unknown video PTS for cc "+i.cc+", waiting for video PTS before demuxing audio frag "+i.sn+" of ["+f.startSN+" ,"+f.endSN+"],track "+d),(this.waitingData=this.waitingData||{frag:i,part:a,cache:new Wa,complete:!1}).cache.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=_i}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===wt)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(_.AUDIO_TRACK_SWITCHED,G({},l)))}this.fragBufferedComplete(a,o)}else this.loadedmetadata||a.type!==Me||(i=this.videoBuffer||this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)},e.onError=function(t,r){var i;if(r.fatal)this.state=ar;else switch(r.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(wt,r);break;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==je||((i=r.context)==null?void 0:i.type)!==Lt||(this.state=ce);break;case M.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 M.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.onBufferFlushed=function(t,r){r.type===Se&&(this.bufferFlushed=!0,this.state===pr&&(this.state=ce))},e._handleTransmuxComplete=function(t){var r,i="audio",a=this.hls,o=t.remuxResult,l=t.chunkMeta,d=this.getCurrentContext(l);if(d){var u=d.frag,c=d.part,f=d.level.details,v=o.audio,m=o.text,T=o.id3,S=o.initSegment;if(!this.fragContextChanged(u)&&f){if(this.state=gt,this.switchingTrack&&v&&this.completeAudioSwitch(this.switchingTrack),S!=null&&S.tracks&&(this._bufferInitSegment(S.tracks,u,l),a.trigger(_.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:i,tracks:S.tracks})),v){var y=v.startPTS,E=v.endPTS,R=v.startDTS,A=v.endDTS;c&&(c.elementaryStreams[Se]={startPTS:y,endPTS:E,startDTS:R,endDTS:A}),u.setElementaryStreamInfo(Se,y,E,R,A),this.bufferFragmentData(v,u,c,l)}if(T!=null&&(r=T.samples)!=null&&r.length){var C=z({id:i,frag:u,details:f},T);a.trigger(_.FRAG_PARSING_METADATA,C)}if(m){var N=z({id:i,frag:u,details:f},m);a.trigger(_.FRAG_PARSING_USERDATA,N)}}else this.fragmentTracker.removeFragment(u)}else this.resetWhenMissingContext(l)},e._bufferInitSegment=function(t,r,i){if(this.state===gt){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(_.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(_.BUFFER_APPENDING,l)}this.tick()}}},e.loadFragment=function(t,r,i){var a,o=this.fragmentTracker.getState(t);this.fragCurrent=t,this.switchingTrack||o===k||o===U?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=_i):(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(_.AUDIO_TRACK_SWITCHED,G({},t))},n}(Bn),_o=function(s){function n(t){var r;return(r=s.call(this,t,"[audio-track-controller]")||this).tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.currentTrack=null,r.selectDefaultTrack=!0,r.registerListeners(),r}ne(n,s);var e=n.prototype;return e.registerListeners=function(){var t=this.hls;t.on(_.MANIFEST_LOADING,this.onManifestLoading,this),t.on(_.MANIFEST_PARSED,this.onManifestParsed,this),t.on(_.LEVEL_LOADING,this.onLevelLoading,this),t.on(_.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(_.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(_.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(_.MANIFEST_LOADING,this.onManifestLoading,this),t.off(_.MANIFEST_PARSED,this.onManifestParsed,this),t.off(_.LEVEL_LOADING,this.onLevelLoading,this),t.off(_.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(_.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(_.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(_.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===Lt&&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(_.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(_.ERROR,{type:re.MEDIA_ERROR,details:M.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(_.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 Ya(s,n){if(s.length!==n.length)return!1;for(var e=0;e<s.length;e++)if(!bo(s[e].attrs,n[e].attrs))return!1;return!0}function bo(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 So=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[subtitle-stream-controller]",At)||this).levels=[],a.currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a._registerListeners(),a}ne(n,s);var e=n.prototype;return e.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},e._registerListeners=function(){var t=this.hls;t.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(_.MANIFEST_LOADING,this.onManifestLoading,this),t.on(_.LEVEL_LOADED,this.onLevelLoaded,this),t.on(_.ERROR,this.onError,this),t.on(_.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(_.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(_.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(_.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(_.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(_.MANIFEST_LOADING,this.onManifestLoading,this),t.off(_.LEVEL_LOADED,this.onLevelLoaded,this),t.off(_.ERROR,this.onError,this),t.off(_.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(_.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(_.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(_.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(_.FRAG_BUFFERED,this.onFragBuffered,this)},e.startLoad=function(t){this.stopLoad(),this.state=ce,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},e.onMediaDetaching=function(){this.tracksBuffered=[],s.prototype.onMediaDetaching.call(this)},e.onLevelLoaded=function(t,r){this.mainDetails=r.details},e.onSubtitleFragProcessed=function(t,r){var i=r.frag,a=r.success;if(this.fragPrevious=i,this.state=ce,a){var o=this.tracksBuffered[this.currentTrackId];if(o){for(var l,d=i.start,u=0;u<o.length;u++)if(d>=o[u].start&&d<=o[u].end){l=o[u];break}var c=i.start+i.duration;l?l.end=c:(l={start:d,end:c},o.push(l)),this.fragmentTracker.fragBuffered(i)}}},e.onBufferFlushing=function(t,r){var i=r.startOffset,a=r.endOffset;if(i===0&&a!==Number.POSITIVE_INFINITY){var o=this.currentTrackId,l=this.levels;if(!l.length||!l[o]||!l[o].details)return;var d=a-l[o].details.targetduration;if(d<=0)return;r.endOffsetSubtitles=Math.max(0,d),this.tracksBuffered.forEach(function(u){for(var c=0;c<u.length;)if(u[c].end<=d)u.shift();else{if(!(u[c].start<d))break;u[c].start=d,c++}}),this.fragmentTracker.removeFragmentsInRange(i,d,At)}},e.onFragBuffered=function(t,r){var i;this.loadedmetadata||r.frag.type!==Me||(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)},e.onError=function(t,r){var i=r.frag;(i==null?void 0:i.type)===At&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Ne&&(this.state=ce))},e.onSubtitleTracksUpdated=function(t,r){var i=this,a=r.subtitleTracks;Ya(this.levels,a)?this.levels=a.map(function(o){return new hr(o)}):(this.tracksBuffered=[],this.levels=a.map(function(o){var l=new hr(o);return i.tracksBuffered[l.id]=[],l}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,At),this.fragPrevious=null,this.mediaBuffer=null)},e.onSubtitleTrackSwitch=function(t,r){if(this.currentTrackId=r.id,this.levels.length&&this.currentTrackId!==-1){var i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(500)}else this.clearInterval()},e.onSubtitleTrackLoaded=function(t,r){var i,a=r.details,o=r.id,l=this.currentTrackId,d=this.levels;if(d.length){var u=d[l];if(!(o>=d.length||o!==l)&&u){this.mediaBuffer=this.mediaBufferTimeRanges;var c=0;if(a.live||(i=u.details)!=null&&i.live){var f=this.mainDetails;if(a.deltaUpdateFailed||!f)return;var v=f.fragments[0];u.details?(c=this.alignPlaylists(a,u.details))===0&&v&&mi(a,c=v.start):a.hasProgramDateTime&&f.hasProgramDateTime?(be(a,f),c=a.fragments[0].start):v&&mi(a,c=v.start)}u.details=a,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(u.details,c),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===ce&&(gr(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(_.ERROR,{type:re.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:u,reason:u.message,frag:i}),u}).then(function(u){var c=performance.now();l.trigger(_.FRAG_DECRYPTED,{frag:i,payload:u,stats:{tstart:d,tdecrypt:c}})}).catch(function(u){r.warn(u.name+": "+u.message),r.state=ce})}},e.doTick=function(){if(this.media){if(this.state===ce){var t=this.currentTrackId,r=this.levels,i=r[t];if(!r.length||!i||!i.details)return;var a=i.details,o=a.targetduration,l=this.config,d=this.getLoadPosition(),u=ue.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],d-o,l.maxBufferHole),c=u.end,f=u.len,v=this.getFwdBufferInfo(this.media,Me);if(f>this.getMaxBufferLength(v==null?void 0:v.len)+o)return;var m=a.fragments,T=m.length,S=a.edge,y=null,E=this.fragPrevious;if(c<S){var R=l.maxFragLookUpTolerance;!(y=gr(E,m,Math.max(m[0].start,c),R))&&E&&E.start<m[0].start&&(y=m[0])}else y=m[T-1];if(!y)return;y=this.mapToInitFragWhenRequired(y),this.fragmentTracker.getState(y)===k&&this.loadFragment(y,i,c)}}else this.state=ce},e.getMaxBufferLength=function(t){var r=s.prototype.getMaxBufferLength.call(this);return t?Math.max(r,t):r},e.loadFragment=function(t,r,i){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t,r):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,i))},q(n,[{key:"mediaBufferTimeRanges",get:function(){return new Lo(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(Bn),Lo=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)}}},ko=function(s){function n(t){var r;return(r=s.call(this,t,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r._subtitleDisplay=!0,r.registerListeners(),r}ne(n,s);var e=n.prototype;return e.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,s.prototype.destroy.call(this)},e.registerListeners=function(){var t=this.hls;t.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(_.MANIFEST_LOADING,this.onManifestLoading,this),t.on(_.MANIFEST_PARSED,this.onManifestParsed,this),t.on(_.LEVEL_LOADING,this.onLevelLoading,this),t.on(_.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(_.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(_.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(_.MANIFEST_LOADING,this.onManifestLoading,this),t.off(_.MANIFEST_PARSED,this.onManifestParsed,this),t.off(_.LEVEL_LOADING,this.onLevelLoading,this),t.off(_.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(_.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(_.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),ea(this.media.textTracks).forEach(function(t){ir(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(_.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===kt&&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(_.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=ea(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(_.SUBTITLE_TRACK_SWITCH,{id:l,groupId:u,name:c,type:f,url:v});var m=this.switchParams(o.url,r==null?void 0:r.details);this.loadPlaylist(m)}else this.hls.trigger(_.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=ea(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 ea(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 wo=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}(),za=Hn(),Xa=/([ha]vc.)(?:\.[^.,]+)+/,Ao=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(_.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(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.BUFFER_RESET,this.onBufferReset,this),e.on(_.BUFFER_APPENDING,this.onBufferAppending,this),e.on(_.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.BUFFER_EOS,this.onBufferEos,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_.FRAG_PARSED,this.onFragParsed,this),e.on(_.FRAG_CHANGED,this.onFragChanged,this)},n.unregisterListeners=function(){var e=this.hls;e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.BUFFER_RESET,this.onBufferReset,this),e.off(_.BUFFER_APPENDING,this.onBufferAppending,this),e.off(_.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.BUFFER_EOS,this.onBufferEos,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_.FRAG_PARSED,this.onFragParsed,this),e.off(_.FRAG_CHANGED,this.onFragChanged,this)},n._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new wo(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&&za){var i=this.mediaSource=new za;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(_.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,m=(o.levelCodec||o.codec).replace(Xa,"$1"),T=(c||u).replace(Xa,"$1");if(m!==T){var S=f+";codecs="+(c||u);r.appendChangeType(a,S),P.log("[buffer-controller]: switching codec "+m+" to "+T),r.tracks[a]={buffer:o.buffer,codec:u,container:f,levelCodec:c,metadata:v,id:d}}}}else r.pendingTracks[a]=t[a]}),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},n.appendChangeType=function(e,t){var r=this,i=this.operationQueue,a={execute:function(){var o=r.sourceBuffer[e];o&&(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],m=self.performance.now();v.start=m;var T=u.stats.buffering,S=c?c.stats.buffering:null;T.start===0&&(T.start=m),S&&S.start===0&&(S.start=m);var y=o.audio,E=!1;d==="audio"&&(y==null?void 0:y.container)==="audio/mpeg"&&(E=!this.lastMpegAudioChunk||f.id===1||this.lastMpegAudioChunk.sn!==f.sn,this.lastMpegAudioChunk=f);var R=u.start,A={execute:function(){if(v.executeStart=self.performance.now(),E){var C=r.sourceBuffer[d];if(C){var N=R-C.timestampOffset;Math.abs(N)>=.1&&(P.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+R+" (delta: "+N+") sn: "+u.sn+")"),C.timestampOffset=R)}}r.appendExecutor(l,d)},onStart:function(){},onComplete:function(){var C=self.performance.now();v.executeEnd=v.end=C,T.first===0&&(T.first=C),S&&S.first===0&&(S.first=C);var N=r.sourceBuffer,B={};for(var Y in N)B[Y]=ue.getBuffered(N[Y]);r.appendError=0,r.hls.trigger(_.BUFFER_APPENDED,{type:d,frag:u,part:c,chunkMeta:f,parent:u.type,timeRanges:B})},onError:function(C){P.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",C);var N={type:re.MEDIA_ERROR,parent:u.type,details:M.BUFFER_APPEND_ERROR,frag:u,part:c,chunkMeta:f,error:C,err:C,fatal:!1};C.code===DOMException.QUOTA_EXCEEDED_ERR?N.details=M.BUFFER_FULL_ERROR:(r.appendError++,N.details=M.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(P.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),N.fatal=!0)),i.trigger(_.ERROR,N)}};a.append(A,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(_.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[Gt]?o.push("audiovideo"):(l[Se]&&o.push("audio"),l[ze]&&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(_.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(ee(o)&&!(o<0)){var l=r.currentTime,d=t.levelTargetDuration,u=Math.max(o,d),c=Math.floor(l/d)*d-u;a.forEach(function(f){var v=i[f];if(v){var m=ue.getBuffered(v);if(m.length>0&&c>m.start(0)){if(e.trigger(_.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(_.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(v.ended&&m.end(m.length-1)-l<2*d)return void P.info("[buffer-controller]: Cannot flush "+f+" back buffer while SourceBuffer is in ended state");e.trigger(_.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=ee(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||!ee(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(_.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(_.ERROR,{type:re.MEDIA_ERROR,details:M.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(_.ERROR,{type:re.MEDIA_ERROR,details:M.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(_.ERROR,{type:re.MEDIA_ERROR,details:M.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=ee(i.duration)?i.duration:1/0,u=ee(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}(),Qa={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},Ja=function(s){var n=s;return Qa.hasOwnProperty(s)&&(n=Qa[s]),String.fromCharCode(n)},yr=15,Zt=100,Ro={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Do={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Io={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},xo={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Co=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Po=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}(),Tr=function(s){for(var n=[],e=0;e<s.length;e++)n.push(s[e].toString(16));return n},$a=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}(),Oo=function(){function s(e,t,r,i,a,o){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new $a(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}(),Mo=function(){function s(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<Zt;t++)this.chars.push(new Oo);this.logger=e,this.pos=0,this.currPenState=new $a}var n=s.prototype;return n.equals=function(e){for(var t=!0,r=0;r<Zt;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<Zt;t++)this.chars[t].copy(e.chars[t])},n.isEmpty=function(){for(var e=!0,t=0;t<Zt;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},n.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Zt&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Zt)},n.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)},n.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},n.insertChar=function(e){var t=this;e>=144&&this.backSpace();var r=Ja(e);this.pos>=Zt?this.logger.log(0,function(){return"Cannot insert "+e.toString(16)+" ("+r+") at position "+t.pos+". Skipping it!"}):(this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1))},n.clearFromPos=function(e){var t;for(t=e;t<Zt;t++)this.chars[t].reset()},n.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},n.clearToEndOfRow=function(){this.clearFromPos(this.pos)},n.getTextString=function(){for(var e=[],t=!0,r=0;r<Zt;r++){var i=this.chars[r].uchar;i!==" "&&(t=!1),e.push(i)}return t?"":e.join("")},n.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},s}(),ta=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<yr;t++)this.rows.push(new Mo(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<yr;e++)this.rows[e].clear();this.currRow=14},n.equals=function(e){for(var t=!0,r=0;r<yr;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<yr;t++)this.rows[t].copy(e.rows[t])},n.isEmpty=function(){for(var e=!0,t=0;t<yr;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<yr;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<yr;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}(),Za=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 ta(r),this.nonDisplayedMemory=new ta(r),this.lastOutputScreen=new ta(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}(),es=function(){function s(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new Po;this.channels=[null,new Za(e,t,i),new Za(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,"["+Tr([t[l],t[l+1]])+"] -> ("+Tr([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 "+Tr([i,a])+" orig: "+Tr([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(ts(e,t,r))return Wr(null,null,r),this.logger.log(3,"Repeated command ("+Tr([e,t])+") is dropped"),!0;var i=e===20||e===21||e===23?1:2,a=this.channels[i];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),Wr(e,t,r),this.currentChannel=i,!0},n.parseMidrow=function(e,t){var r=0;if((e===17||e===25)&&t>=32&&t<=47){if((r=e===17?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,"MIDROW ("+Tr([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(ts(e,t,i))return Wr(null,null,i),!0;var a=e<=23?1:2;r=t>=64&&t<=95?a===1?Ro[e]:Io[e]:a===1?Do[e]:xo[e];var o=this.channels[a];return!!o&&(o.setPAC(this.interpretPAC(r,t)),Wr(e,t,i),this.currentChannel=a,!0)},n.interpretPAC=function(e,t){var r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=(1&r)==1,r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},n.parseChars=function(e,t){var r,i,a=null,o=null;if(e>=25?(r=2,o=e-8):(r=1,o=e),o>=17&&o<=19?(i=o===17?t+80:o===18?t+112:t+144,this.logger.log(2,"Special char '"+Ja(i)+"' in channel "+r),a=[i]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var l=Tr(a);this.logger.log(3,"Char codes = "+l.join(",")),Wr(e,t,this.cmdHistory)}return a},n.parseBackgroundAttributes=function(e,t){var r;if(!((e===16||e===24)&&t>=32&&t<=47||(e===23||e===31)&&t>=45&&t<=47))return!1;var i={};e===16||e===24?(r=Math.floor((t-32)/2),i.background=Co[r],t%2==1&&(i.background=i.background+"_semi")):t===45?i.background="transparent":(i.foreground="black",t===47&&(i.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(i),Wr(e,t,this.cmdHistory),!0},n.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}},n.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}},s}();function Wr(s,n,e){e.a=s,e.b=n}function ts(s,n,e){return e.a===s&&e.b===n}var hn=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}(),ra=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var s=["","lr","rl"],n=["start","middle","end","left","right"];function e(a,o){if(typeof o!="string"||!Array.isArray(a))return!1;var l=o.toLowerCase();return!!~a.indexOf(l)&&l}function t(a){return e(n,a)}function r(a){for(var o=arguments.length,l=new Array(o>1?o-1:0),d=1;d<o;d++)l[d-1]=arguments[d];for(var u=1;u<arguments.length;u++){var c=arguments[u];for(var f in c)a[f]=c[f]}return a}function i(a,o,l){var d=this,u={enumerable:!0};d.hasBeenReset=!1;var c="",f=!1,v=a,m=o,T=l,S=null,y="",E=!0,R="auto",A="start",C=50,N="middle",B=50,Y="middle";Object.defineProperty(d,"id",r({},u,{get:function(){return c},set:function(K){c=""+K}})),Object.defineProperty(d,"pauseOnExit",r({},u,{get:function(){return f},set:function(K){f=!!K}})),Object.defineProperty(d,"startTime",r({},u,{get:function(){return v},set:function(K){if(typeof K!="number")throw new TypeError("Start time must be set to a number.");v=K,this.hasBeenReset=!0}})),Object.defineProperty(d,"endTime",r({},u,{get:function(){return m},set:function(K){if(typeof K!="number")throw new TypeError("End time must be set to a number.");m=K,this.hasBeenReset=!0}})),Object.defineProperty(d,"text",r({},u,{get:function(){return T},set:function(K){T=""+K,this.hasBeenReset=!0}})),Object.defineProperty(d,"region",r({},u,{get:function(){return S},set:function(K){S=K,this.hasBeenReset=!0}})),Object.defineProperty(d,"vertical",r({},u,{get:function(){return y},set:function(K){var V=function($){return e(s,$)}(K);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 E},set:function(K){E=!!K,this.hasBeenReset=!0}})),Object.defineProperty(d,"line",r({},u,{get:function(){return R},set:function(K){if(typeof K!="number"&&K!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");R=K,this.hasBeenReset=!0}})),Object.defineProperty(d,"lineAlign",r({},u,{get:function(){return A},set:function(K){var V=t(K);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");A=V,this.hasBeenReset=!0}})),Object.defineProperty(d,"position",r({},u,{get:function(){return C},set:function(K){if(K<0||K>100)throw new Error("Position must be between 0 and 100.");C=K,this.hasBeenReset=!0}})),Object.defineProperty(d,"positionAlign",r({},u,{get:function(){return N},set:function(K){var V=t(K);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");N=V,this.hasBeenReset=!0}})),Object.defineProperty(d,"size",r({},u,{get:function(){return B},set:function(K){if(K<0||K>100)throw new Error("Size must be between 0 and 100.");B=K,this.hasBeenReset=!0}})),Object.defineProperty(d,"align",r({},u,{get:function(){return Y},set:function(K){var V=t(K);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");Y=V,this.hasBeenReset=!0}})),d.displayState=void 0}return i.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},i}(),Fo=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 rs(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 No=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 is(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 ia=new ra(0,0,""),fn=ia.align==="middle"?"middle":"center";function Uo(s,n,e){var t=s;function r(){var a=rs(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 No;is(a,function(c,f){var v;switch(c){case"region":for(var m=e.length-1;m>=0;m--)if(e[m].id===f){l.set(c,e[m].region);break}break;case"vertical":l.alt(c,f,["rl","lr"]);break;case"line":v=f.split(","),l.integer(c,v[0]),l.percent(c,v[0])&&l.set("snapToLines",!1),l.alt(c,v[0],["auto"]),v.length===2&&l.alt("lineAlign",v[1],["start",fn,"end"]);break;case"position":v=f.split(","),l.percent(c,v[0]),v.length===2&&l.alt("positionAlign",v[1],["start",fn,"end","line-left","line-right","auto"]);break;case"size":l.percent(c,f);break;case"align":l.alt(c,f,["start",fn,"end","left","right"])}},/:/,/\s/),o.region=l.get("region",null),o.vertical=l.get("vertical","");var d=l.get("line","auto");d==="auto"&&ia.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",fn);var u=l.get("position","auto");u==="auto"&&ia.position===50&&(u=o.align==="start"||o.align==="left"?0:o.align==="end"||o.align==="right"?100:50),o.position=u}(s,n)}function ns(s){return s.replace(/<br(?: \/)?>/gi,`
|
|
35
|
+
`)}var Bo=function(){function s(){this.state="INITIAL",this.buffer="",this.decoder=new Fo,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=ns(d);u<d.length&&d[u]!=="\r"&&d[u]!==`
|
|
36
|
+
`;)++u;var c=d.slice(0,u);return d[u]==="\r"&&++u,d[u]===`
|
|
37
|
+
`&&++u,t.buffer=d.slice(u),c}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var i="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;var a=(i=r()).match(/^()?WEBVTT([ \t].*)?$/);if(a==null||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var o=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!1:i=r(),t.state){case"HEADER":/:/.test(i)?is(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 ra(0,0,""),t.state="CUE",i.indexOf("-->")===-1){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Uo(i,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var l=i.indexOf("-->")!==-1;if(!i||l&&(o=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
|
|
38
|
+
`),t.cue.text+=i;continue;case"BADCUE":i||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},n.flush=function(){var e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
|
|
25
39
|
|
|
26
|
-
`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this},
|
|
27
|
-
`:(n=t.childNodes)!==null&&n!==void 0&&n.length?Nn(t,o):o?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function vn(d,o,e){return d&&d.hasAttributeNS(o,e)?d.getAttributeNS(o,e):null}function Un(d){return new Error("Could not parse ttml timestamp "+d)}function pn(d,o){if(!d)return null;var e=_t(d);return e===null&&(jr.test(d)?e=function(t,i){var n=jr.exec(t),a=(0|n[4])+(0|n[5])/i.subFrameRate;return 3600*(0|n[1])+60*(0|n[2])+(0|n[3])+a/i.frameRate}(d,o):Ki.test(d)&&(e=function(t,i){var n=Ki.exec(t),a=Number(n[1]);switch(n[2]){case"h":return 3600*a;case"m":return 60*a;case"ms":return 1e3*a;case"f":return a/i.frameRate;case"t":return a/i.tickRate}return a}(d,o))),e}var La=function(){function d(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var t=new mt(this,"textTrack1"),i=new mt(this,"textTrack2"),n=new mt(this,"textTrack3"),a=new mt(this,"textTrack4");this.cea608Parser1=new ir(1,t,i),this.cea608Parser2=new ir(3,n,a)}e.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.Events.FRAG_LOADING,this.onFragLoading,this),e.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=d.prototype;return o.destroy=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.Events.FRAG_LOADING,this.onFragLoading,this),e.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(e,t,i,n,a){for(var r,s,l,u,c=!1,v=a.length;v--;){var m=a[v],_=(r=m[0],s=m[1],l=t,u=i,Math.min(s,u)-Math.max(r,l));if(_>=0&&(m[0]=Math.min(m[0],t),m[1]=Math.max(m[1],i),c=!0,_/(i-t)>.5))return}if(c||a.push([t,i]),this.config.renderTextTracksNatively){var S=this.captionsTracks[e];this.Cues.newCue(S,t,i,n)}else{var x=this.Cues.newCue(null,t,i,n);this.hls.trigger(p.Events.CUES_PARSED,{type:"captions",cues:x,track:e})}},o.onInitPtsFound=function(e,t){var i=this,n=t.frag,a=t.id,r=t.initPTS,s=t.timescale,l=this.unparsedVttFrags;a==="main"&&(this.initPTS[n.cc]=r,this.timescale[n.cc]=s),l.length&&(this.unparsedVttFrags=[],l.forEach(function(u){i.onFragLoaded(p.Events.FRAG_LOADED,u)}))},o.getExistingTrack=function(e){var t=this.media;if(t)for(var i=0;i<t.textTracks.length;i++){var n=t.textTracks[i];if(n[e])return n}return null},o.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},o.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,i=this.captionsTracks,n=this.media,a=t[e],r=a.label,s=a.languageCode,l=this.getExistingTrack(e);if(l)i[e]=l,ht(i[e]),rt(i[e],n);else{var u=this.createTextTrack("captions",r,s);u&&(u[e]=!0,i[e]=u)}}},o.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}},o.createTextTrack=function(e,t,i){var n=this.media;if(n)return n.addTextTrack(e,t,i)},o.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},o.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach(function(t){ht(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var i=0;i<t.length;i++)ht(t[i])}},o.onSubtitleTracksUpdated=function(e,t){var i=this;this.textTracks=[];var n=t.subtitleTracks||[],a=n.some(function(u){return u.textCodec===gr});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var r=this.tracks&&n&&this.tracks.length===n.length;if(this.tracks=n||[],this.config.renderTextTracksNatively){var s=this.media?this.media.textTracks:[];this.tracks.forEach(function(u,c){var v;if(c<s.length){for(var m=null,_=0;_<s.length;_++)if(wa(s[_],u)){m=s[_];break}m&&(v=m)}if(v)ht(v);else{var S=i._captionsOrSubtitlesFromCharacteristics(u);(v=i.createTextTrack(S,u.name,u.lang))&&(v.mode="disabled")}v&&(v.groupId=u.groupId,i.textTracks.push(v))})}else if(!r&&this.tracks&&this.tracks.length){var l=this.tracks.map(function(u){return{label:u.name,kind:u.type.toLowerCase(),default:u.default,subtitleTrack:u}});this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}},o._captionsOrSubtitlesFromCharacteristics=function(e){var t;if((t=e.attrs)!==null&&t!==void 0&&t.CHARACTERISTICS){var i=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),n=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(i&&n)return"captions"}return"subtitles"},o.onManifestLoaded=function(e,t){var i=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(function(n){var a=/(?:CC|SERVICE)([1-4])/.exec(n.instreamId);if(a){var r="textTrack"+a[1],s=i.captionsProperties[r];s&&(s.label=n.name,n.lang&&(s.languageCode=n.lang),s.media=n)}})},o.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]},o.onFragLoading=function(e,t){var i=this.cea608Parser1,n=this.cea608Parser2,a=this.lastSn,r=this.lastPartIndex;if(this.enabled&&i&&n&&t.frag.type===pe.PlaylistLevelType.MAIN){var s,l,u=t.frag.sn,c=(s=t==null||(l=t.part)===null||l===void 0?void 0:l.index)!=null?s:-1;u===a+1||u===a&&c===r+1||(i.reset(),n.reset()),this.lastSn=u,this.lastPartIndex=c}},o.onFragLoaded=function(e,t){var i=t.frag,n=t.payload,a=this.initPTS,r=this.unparsedVttFrags;if(i.type===pe.PlaylistLevelType.SUBTITLE)if(n.byteLength){if(!(0,R.isFiniteNumber)(a[i.cc]))return r.push(t),void(a.length&&this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Missing initial subtitle PTS")}));var s=i.decryptdata,l="stats"in t;if(s==null||!s.encrypted||l){var u=this.tracks[i.level],c=this.vttCCs;c[i.cc]||(c[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),u&&u.textCodec===gr?this._parseIMSC1(i,n):this._parseVTTs(i,n,c)}}else this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(e,t){var i=this,n=this.hls;Mn(t,this.initPTS[e.cc],this.timescale[e.cc],function(a){i._appendCues(a,e.level),n.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(a){k.logger.log("Failed to parse IMSC1: "+a),n.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:a})})},o._parseVTTs=function(e,t,i){var n,a=this,r=this.hls;(function(s,l,u,c,v,m,_,S){var x,I=new nr,j=(0,Dt.utf8ArrayToStr)(new Uint8Array(s)).trim().replace(ar,`
|
|
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}(),Ho=/\r\n|\n\r|\n|\r/g,na=function(s,n,e){return e===void 0&&(e=0),s.slice(e,e+n.length)===n},aa=function(s){for(var n=5381,e=s.length;e;)n=33*n^s.charCodeAt(--e);return(n>>>0).toString()};function sa(s,n,e){return aa(s.toString())+aa(n.toString())+aa(e)}function Go(s,n,e,t,r,i,a){var o,l,d,u=new Bo,c=Tt(new Uint8Array(s)).trim().replace(Ho,`
|
|
28
41
|
`).split(`
|
|
29
|
-
`),
|
|
30
|
-
`)}),I.flush()})((n=e.initSegment)!==null&&n!==void 0&&n.data?(0,W.appendUint8Array)(e.initSegment.data,new Uint8Array(t)):t,this.initPTS[e.cc],this.timescale[e.cc],i,e.cc,e.start,function(s){a._appendCues(s,e.level),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(s){a._fallbackToIMSC1(e,t),k.logger.log("Failed to parse VTT cue: "+s),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})},o._fallbackToIMSC1=function(e,t){var i=this,n=this.tracks[e.level];n.textCodec||Mn(t,this.initPTS[e.cc],this.timescale[e.cc],function(){n.textCodec=gr,i._parseIMSC1(e,t)},function(){n.textCodec="wvtt"})},o._appendCues=function(e,t){var i=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if(!n||n.mode==="disabled")return;e.forEach(function(s){return yt(n,s)})}else{var a=this.tracks[t];if(!a)return;var r=a.default?"default":"subtitles"+t;i.trigger(p.Events.CUES_PARSED,{type:"subtitles",cues:e,track:r})}},o.onFragDecrypted=function(e,t){var i=t.frag;if(i.type===pe.PlaylistLevelType.SUBTITLE){if(!(0,R.isFiniteNumber)(this.initPTS[i.cc]))return void this.unparsedVttFrags.push(t);this.onFragLoaded(p.Events.FRAG_LOADED,t)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(e,t){var i=this.cea608Parser1,n=this.cea608Parser2;if(this.enabled&&i&&n){var a=t.frag,r=t.samples;if(a.type!==pe.PlaylistLevelType.MAIN||this.closedCaptionsForLevel(a)!=="NONE")for(var s=0;s<r.length;s++){var l=r[s].bytes;if(l){var u=this.extractCea608Data(l);i.addData(r[s].pts,u[0]),n.addData(r[s].pts,u[1])}}}},o.onBufferFlushing=function(e,t){var i=t.startOffset,n=t.endOffset,a=t.endOffsetSubtitles,r=t.type,s=this.media;if(s&&!(s.currentTime<n)){if(!r||r==="video"){var l=this.captionsTracks;Object.keys(l).forEach(function(c){return It(l[c],i,n)})}if(this.config.renderTextTracksNatively&&i===0&&a!==void 0){var u=this.textTracks;Object.keys(u).forEach(function(c){return It(u[c],i,a)})}}},o.extractCea608Data=function(e){for(var t=[[],[]],i=31&e[0],n=2,a=0;a<i;a++){var r=e[n++],s=127&e[n++],l=127&e[n++];if((s!==0||l!==0)&&(4&r)!=0){var u=3&r;u!==0&&u!==1||(t[u].push(s),t[u].push(l))}}return t},d}();function wa(d,o){return d&&d.label===o.name&&!(d.textTrack1||d.textTrack2)}function Aa(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}let Da=function(){function d(i){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=i,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var o,e,t=d.prototype;return t.setStreamController=function(i){this.streamController=i},t.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},t.registerListeners=function(){var i=this.hls;i.on(p.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),i.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.on(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var i=this.hls;i.off(p.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),i.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.off(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},t.onFpsDropLevelCapping=function(i,n){d.isLevelAllowed(n.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(n.droppedLevel)},t.onMediaAttaching=function(i,n){this.media=n.media instanceof HTMLVideoElement?n.media:null,this.clientRect=null},t.onManifestParsed=function(i,n){var a=this.hls;this.restrictedLevels=[],this.firstLevel=n.firstLevel,a.config.capLevelToPlayerSize&&n.video&&this.startCapping()},t.onBufferCodecs=function(i,n){this.hls.config.capLevelToPlayerSize&&n.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping()},t.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var i=this.hls.levels;if(i.length){var n=this.hls;n.autoLevelCapping=this.getMaxLevel(i.length-1),n.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=n.autoLevelCapping}}},t.getMaxLevel=function(i){var n=this,a=this.hls.levels;if(!a.length)return-1;var r=a.filter(function(s,l){return d.isLevelAllowed(l,n.restrictedLevels)&&l<=i});return this.clientRect=null,d.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)},t.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var i=this.media,n={width:0,height:0};if(i){var a=i.getBoundingClientRect();n.width=a.width,n.height=a.height,n.width||n.height||(n.width=a.right-a.left||i.width||0,n.height=a.bottom-a.top||i.height||0)}return this.clientRect=n,n},d.isLevelAllowed=function(i,n){return n===void 0&&(n=[]),n.indexOf(i)===-1},d.getMaxLevelByMediaSize=function(i,n,a){if(!i||!i.length)return-1;for(var r,s,l=i.length-1,u=0;u<i.length;u+=1){var c=i[u];if((c.width>=n||c.height>=a)&&(r=c,!(s=i[u+1])||r.width!==s.width||r.height!==s.height)){l=u;break}}return l},o=d,(e=[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var i=1;if(!this.hls.config.ignoreDevicePixelRatio)try{i=self.devicePixelRatio}catch{}return i}}])&&Aa(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}(),Ra=function(){function d(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}var o=d.prototype;return o.setStreamController=function(e){this.streamController=e},o.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},o.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching)},o.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},o.onMediaAttaching=function(e,t){var i=this.hls.config;if(i.capLevelOnFPSDrop){var n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}},o.checkFPS=function(e,t,i){var n=performance.now();if(t){if(this.lastTime){var a=n-this.lastTime,r=i-this.lastDroppedFrames,s=t-this.lastDecodedFrames,l=1e3*r/a,u=this.hls;if(u.trigger(p.Events.FPS_DROP,{currentDropped:r,currentDecoded:s,totalDroppedFrames:i}),l>0&&r>u.config.fpsDroppedMonitoringThreshold*s){var c=u.currentLevel;k.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(u.autoLevelCapping===-1||u.autoLevelCapping>=c)&&(c-=1,u.trigger(p.Events.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:u.currentLevel}),u.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=t}},o.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},d}();var $r=N(300);function gn(d){var o=typeof Map=="function"?new Map:void 0;return gn=function(e){if(e===null||(t=e,Function.toString.call(t).indexOf("[native code]")===-1))return e;var t;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(e))return o.get(e);o.set(e,i)}function i(){return mn(e,arguments,yn(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),ki(i,e)},gn(d)}function mn(d,o,e){return mn=Ia()?Reflect.construct.bind():function(t,i,n){var a=[null];a.push.apply(a,i);var r=new(Function.bind.apply(t,a));return n&&ki(r,n.prototype),r},mn.apply(null,arguments)}function Ia(){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 ki(d,o){return ki=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ki(d,o)}function yn(d){return yn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},yn(d)}var qi="[eme]",Bn=function(){function d(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=d.CDMCleanupPromise?[d.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=k.logger.debug.bind(k.logger,qi),this.log=k.logger.log.bind(k.logger,qi),this.warn=k.logger.warn.bind(k.logger,qi),this.error=k.logger.error.bind(k.logger,qi),this.hls=e,this.config=e.config,this.registerListeners()}var o=d.prototype;return o.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null},o.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},o.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},o.getLicenseServerUrl=function(e){var t=this.config,i=t.drmSystems,n=t.widevineLicenseUrl,a=i[e];if(a)return a.licenseUrl;if(e===U.WIDEVINE&&n)return n;throw new Error('no license server URL configured for key-system "'+e+'"')},o.getServerCertificateUrl=function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},o.attemptKeySystemAccess=function(e){var t=this,i=this.hls.levels,n=function(s,l,u){return!!s&&u.indexOf(s)===l},a=i.map(function(s){return s.audioCodec}).filter(n),r=i.map(function(s){return s.videoCodec}).filter(n);return a.length+r.length===0&&r.push("avc1.42e01e"),new Promise(function(s,l){(function u(c){var v=c.shift();t.getMediaKeysPromise(v,a,r).then(function(m){return s({keySystem:v,mediaKeys:m})}).catch(function(m){c.length?u(c):l(m instanceof kr?m:new kr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:m,fatal:!0},m.message))})})(e)})},o.requestMediaKeySystemAccess=function(e,t){var i=this.config.requestMediaKeySystemAccessFunc;if(typeof i!="function"){var n="Configured requestMediaKeySystemAccess is not a function "+i;return ye===null&&self.location.protocol==="http:"&&(n="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(n))}return i(e,t)},o.getMediaKeysPromise=function(e,t,i){var n=this,a=function(u,c,v,m){var _;switch(u){case U.FAIRPLAY:_=["cenc","sinf"];break;case U.WIDEVINE:case U.PLAYREADY:_=["cenc"];break;case U.CLEARKEY:_=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+u)}return function(S,x,I,j){return[{initDataTypes:S,persistentState:j.persistentState||"not-allowed",distinctiveIdentifier:j.distinctiveIdentifier||"not-allowed",sessionTypes:j.sessionTypes||[j.sessionType||"temporary"],audioCapabilities:x.map(function(ae){return{contentType:'audio/mp4; codecs="'+ae+'"',robustness:j.audioRobustness||"",encryptionScheme:j.audioEncryptionScheme||null}}),videoCapabilities:I.map(function(ae){return{contentType:'video/mp4; codecs="'+ae+'"',robustness:j.videoRobustness||"",encryptionScheme:j.videoEncryptionScheme||null}})}]}(_,c,v,m)}(e,t,i,this.config.drmSystemOptions),r=this.keySystemAccessPromises[e],s=r==null?void 0:r.keySystemAccess;if(!s){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(a)),s=this.requestMediaKeySystemAccess(e,a);var l=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch(function(u){n.log('Failed to obtain access to key-system "'+e+'": '+u)}),s.then(function(u){n.log('Access for key-system "'+u.keySystem+'" obtained');var c=n.fetchServerCertificate(e);return n.log('Create media-keys for "'+e+'"'),l.mediaKeys=u.createMediaKeys().then(function(v){return n.log('Media-keys created for "'+e+'"'),c.then(function(m){return m?n.setMediaKeysServerCertificate(v,e,m):v})}),l.mediaKeys.catch(function(v){n.error('Failed to create media-keys for "'+e+'"}: '+v)}),l.mediaKeys})}return s.then(function(){return r.mediaKeys})},o.createMediaKeySessionContext=function(e){var t=e.decryptdata,i=e.keySystem,n=e.mediaKeys;this.log('Creating key-system session "'+i+'" keyId: '+$r.default.hexDump(t.keyId||[]));var a=n.createSession(),r={decryptdata:t,keySystem:i,mediaKeys:n,mediaKeysSession:a,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r},o.renewKeySession=function(e){var t=e.decryptdata;if(t.pssh){var i=this.createMediaKeySessionContext(e),n=this.getKeyIdString(t);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,"cenc",t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},o.getKeyIdString=function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return $r.default.hexDump(e.keyId)},o.updateKeySession=function(e,t){var i,n=e.mediaKeysSession;return this.log('Updating key-session "'+n.sessionId+'" for keyID '+$r.default.hexDump(((i=e.decryptdata)===null||i===void 0?void 0:i.keyId)||[])+`
|
|
31
|
-
} (data length: `+(t&&t.byteLength)+")"),n.update(t)},o.selectKeySystemFormat=function(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+e.sn+" "+e.type+": "+e.level+") key formats "+t.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise},o.getKeyFormatPromise=function(e){var t=this;return new Promise(function(i,n){var a=oe(t.config),r=e.map(M).filter(function(s){return!!s&&a.indexOf(s)!==-1});return t.getKeySystemSelectionPromise(r).then(function(s){var l=s.keySystem,u=L(l);u?i(u):n(new Error('Unable to find format for key-system "'+l+'"'))}).catch(n)})},o.loadKey=function(e){var t=this,i=e.keyInfo.decryptdata,n=this.getKeyIdString(i),a="(keyId: "+n+' format: "'+i.keyFormat+'" method: '+i.method+" uri: "+i.uri+")";this.log("Starting session for key "+a);var r=this.keyIdToKeySessionPromise[n];return r||(r=this.keyIdToKeySessionPromise[n]=this.getKeySystemForKeyPromise(i).then(function(s){var l=s.keySystem,u=s.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+a),t.attemptSetMediaKeys(l,u).then(function(){t.throwIfDestroyed();var c=t.createMediaKeySessionContext({keySystem:l,mediaKeys:u,decryptdata:i});return t.generateRequestWithPreferredKeySession(c,"cenc",i.pssh,"playlist-key")})})).catch(function(s){return t.handleError(s)}),r},o.throwIfDestroyed=function(e){if(e===void 0&&(e="Invalid state"),!this.hls)throw new Error("invalid state")},o.handleError=function(e){this.hls&&(this.error(e.message),e instanceof kr?this.hls.trigger(p.Events.ERROR,e.data):this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},o.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){var n=M(e.keyFormat),a=n?[n]:oe(this.config);return this.attemptKeySystemAccess(a)}return i},o.getKeySystemSelectionPromise=function(e){if(e.length||(e=oe(this.config)),e.length===0)throw new kr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},o._onMediaEncrypted=function(e){var t=this,i=e.initDataType,n=e.initData;if(this.debug('"'+e.type+'" event: init data type: "'+i+'"'),n!==null){var a,r;if(i==="sinf"&&this.config.drmSystems[U.FAIRPLAY]){var s=(0,W.bin2str)(new Uint8Array(n));try{var l=K(JSON.parse(s).sinf),u=(0,W.parseSinf)(new Uint8Array(l));if(!u)return;a=u.subarray(8,24),r=U.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var c=(0,W.parsePssh)(n);if(c===null)return;c.version===0&&c.systemId===ke.WIDEVINE&&c.data&&(a=c.data.subarray(8,24)),r=function(ae){if(ae===ke.WIDEVINE)return U.WIDEVINE}(c.systemId)}if(r&&a){for(var v=$r.default.hexDump(a),m=this.keyIdToKeySessionPromise,_=this.mediaKeySessions,S=m[v],x=function(ae){var me=_[ae],de=me.decryptdata;if(de.pssh||!de.keyId)return"continue";var _e=$r.default.hexDump(de.keyId);return v===_e||de.uri.replace(/-/g,"").indexOf(v)!==-1?(S=m[_e],delete m[_e],de.pssh=new Uint8Array(n),de.keyId=a,S=m[v]=S.then(function(){return t.generateRequestWithPreferredKeySession(me,i,n,"encrypted-event-key-match")}),"break"):void 0},I=0;I<_.length;I++){var j=x(I);if(j!=="continue"&&j==="break")break}S||(S=m[v]=this.getKeySystemSelectionPromise([r]).then(function(ae){var me,de=ae.keySystem,_e=ae.mediaKeys;t.throwIfDestroyed();var Ke=new we("ISO-23001-7",v,(me=L(de))!=null?me:"");return Ke.pssh=new Uint8Array(n),Ke.keyId=a,t.attemptSetMediaKeys(de,_e).then(function(){t.throwIfDestroyed();var ze=t.createMediaKeySessionContext({decryptdata:Ke,keySystem:de,mediaKeys:_e});return t.generateRequestWithPreferredKeySession(ze,i,n,"encrypted-event-no-match")})})),S.catch(function(ae){return t.handleError(ae)})}}},o._onWaitingForKey=function(e){this.log('"'+e.type+'" event')},o.attemptSetMediaKeys=function(e,t){var i=this,n=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var a=Promise.all(n).then(function(){if(!i.media)throw new Error("Attempted to set mediaKeys without media element attached");return i.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(a),a.then(function(){i.log('Media-keys set for "'+e+'"'),n.push(a),i.setMediaKeysQueue=i.setMediaKeysQueue.filter(function(r){return n.indexOf(r)===-1})})},o.generateRequestWithPreferredKeySession=function(e,t,i,n){var a,r,s=this,l=(a=this.config.drmSystems)===null||a===void 0||(r=a[e.keySystem])===null||r===void 0?void 0:r.generateRequest;if(l)try{var u=l.call(this.hls,t,i,e);if(!u)throw new Error("Invalid response from configured generateRequest filter");t=u.initDataType,i=e.decryptdata.pssh=u.initData?new Uint8Array(u.initData):null}catch(S){var c;if(this.warn(S.message),(c=this.hls)!==null&&c!==void 0&&c.config.debug)throw S}if(i===null)return this.log('Skipping key-session request for "'+n+'" (no initData)'),Promise.resolve(e);var v=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'+n+'": '+v+" (init data type: "+t+" length: "+(i?i.byteLength:null)+")");var m=new(Xr());e.mediaKeysSession.onmessage=function(S){var x=e.mediaKeysSession;if(x){var I=S.messageType,j=S.message;s.log('"'+I+'" message event for session "'+x.sessionId+'" message size: '+j.byteLength),I==="license-request"||I==="license-renewal"?s.renewLicense(e,j).catch(function(ae){s.handleError(ae),m.emit("error",ae)}):I==="license-release"?e.keySystem===U.FAIRPLAY&&(s.updateKeySession(e,E("acknowledged")),s.removeSession(e)):s.warn('unhandled media key message type "'+I+'"')}else m.emit("error",new Error("invalid state"))},e.mediaKeysSession.onkeystatuseschange=function(S){if(e.mediaKeysSession){s.onKeyStatusChange(e);var x=e.keyStatus;m.emit("keyStatus",x),x==="expired"&&(s.warn(e.keySystem+" expired for key "+v),s.renewKeySession(e))}else m.emit("error",new Error("invalid state"))};var _=new Promise(function(S,x){m.on("error",x),m.on("keyStatus",function(I){I.startsWith("usable")?S():I==="output-restricted"?x(new kr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):I==="internal-error"?x(new kr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+I+'"')):I==="expired"?x(new Error("key expired while generating request")):s.warn('unhandled key status change "'+I+'"')})});return e.mediaKeysSession.generateRequest(t,i).then(function(){var S;s.log('Request generated for key-session "'+((S=e.mediaKeysSession)===null||S===void 0?void 0:S.sessionId)+'" keyId: '+v)}).catch(function(S){throw new kr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_NO_SESSION,error:S,fatal:!1},"Error generating key-session request: "+S)}).then(function(){return _}).catch(function(S){throw m.removeAllListeners(),s.removeSession(e),S}).then(function(){return m.removeAllListeners(),e})},o.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach(function(i,n){t.log('key status change "'+i+'" for keyStatuses keyId: '+$r.default.hexDump("buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n))+" session keyId: "+$r.default.hexDump(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=i})},o.fetchServerCertificate=function(e){var t=this;return new Promise(function(i,n){var a=t.getServerCertificateUrl(e);if(!a)return i();t.log('Fetching serverCertificate for "'+e+'"');var r=new XMLHttpRequest;r.open("GET",a,!0),r.responseType="arraybuffer",r.onreadystatechange=function(){r.readyState===XMLHttpRequest.DONE&&(r.status===200?i(r.response):n(new kr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r},'"'+e+'" certificate request XHR failed ('+a+"). Status: "+r.status+" ("+r.statusText+")")))},r.send()})},o.setMediaKeysServerCertificate=function(e,t,i){var n=this;return new Promise(function(a,r){e.setServerCertificate(i).then(function(s){n.log("setServerCertificate "+(s?"success":"not supported by CDM")+" ("+(i==null?void 0:i.byteLength)+') on "'+t+'"'),a(e)}).catch(function(s){r(new kr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:s,fatal:!0},s.message))})})},o.renewLicense=function(e,t){var i=this;return this.requestLicense(e,new Uint8Array(t)).then(function(n){return i.updateKeySession(e,new Uint8Array(n)).catch(function(a){throw new kr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:a,fatal:!0},a.message)})})},o.setupLicenseXHR=function(e,t,i,n){var a=this,r=this.config.licenseXhrSetup;return r?Promise.resolve().then(function(){if(!i.decryptdata)throw new Error("Key removed");return r.call(a.hls,e,t,i,n)}).catch(function(s){if(!i.decryptdata)throw s;return e.open("POST",t,!0),r.call(a.hls,e,t,i,n)}).then(function(s){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:s||n}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))},o.requestLicense=function(e,t){var i=this;return new Promise(function(n,a){var r=i.getLicenseServerUrl(e.keySystem);i.log("Sending license request to URL: "+r);var s=new XMLHttpRequest;s.responseType="arraybuffer",s.onreadystatechange=function(){if(!i.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(s.readyState===4)if(s.status===200){i._requestLicenseFailureCount=0;var l=s.response;i.log("License received "+(l instanceof ArrayBuffer?l.byteLength:l));var u=i.config.licenseResponseCallback;if(u)try{l=u.call(i.hls,s,r,e)}catch(v){i.error(v)}n(l)}else if(i._requestLicenseFailureCount++,i._requestLicenseFailureCount>3||s.status>=400&&s.status<500)a(new kr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:s},"License Request XHR failed ("+r+"). Status: "+s.status+" ("+s.statusText+")"));else{var c=3-i._requestLicenseFailureCount+1;i.warn("Retrying license request, "+c+" attempts left"),i.requestLicense(e,t).then(n,a)}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=s,i.setupLicenseXHR(s,r,e,t).then(function(l){var u=l.xhr,c=l.licenseChallenge;u.send(c)})})},o.onMediaAttached=function(e,t){if(this.config.emeEnabled){var i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}},o.onMediaDetached=function(){var e=this,t=this.media,i=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},we.clearKeyUriToKeyIdMap();var n=i.length;d.CDMCleanupPromise=Promise.all(i.map(function(a){return e.removeSession(a)}).concat(t==null?void 0:t.setMediaKeys(null).catch(function(a){e.log("Could not clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))}))).then(function(){n&&(e.log("finished closing key sessions and clearing media keys"),i.length=0)}).catch(function(a){e.log("Could not close sessions and clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))})},o.onManifestLoaded=function(e,t){var i=t.sessionKeys;if(i&&this.config.emeEnabled&&!this.keyFormatPromise){var n=i.reduce(function(a,r){return a.indexOf(r.keyFormat)===-1&&a.push(r.keyFormat),a},[]);this.log("Selecting key-system from session-keys "+n.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(n)}},o.removeSession=function(e){var t=this,i=e.mediaKeysSession,n=e.licenseXhr;if(i){this.log("Remove licenses and keys and close session "+i.sessionId),i.onmessage=null,i.onkeystatuseschange=null,n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);return a>-1&&this.mediaKeySessions.splice(a,1),i.remove().catch(function(r){t.log("Could not remove session: "+r)}).then(function(){return i.close()}).catch(function(r){t.log("Could not close session: "+r)})}},d}();Bn.CDMCleanupPromise=void 0;var kr=function(d){var o,e;function t(i,n){var a;return(a=d.call(this,n)||this).data=void 0,a.data=i,i.err=i.error,a}return e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,ki(o,e),t}(gn(Error));let Pa=Bn;var or,En,Hn;function Gn(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function jn(d,o,e){return o&&Gn(d.prototype,o),e&&Gn(d,e),Object.defineProperty(d,"prototype",{writable:!1}),d}function Kn(d,o){var e=typeof Symbol!="undefined"&&d[Symbol.iterator]||d["@@iterator"];if(e)return(e=e.call(d)).next.bind(e);if(Array.isArray(d)||(e=function(i,n){if(i){if(typeof i=="string")return qn(i,n);var a=Object.prototype.toString.call(i).slice(8,-1);return a==="Object"&&i.constructor&&(a=i.constructor.name),a==="Map"||a==="Set"?Array.from(i):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?qn(i,n):void 0}}(d))||o&&d&&typeof d.length=="number"){e&&(d=e);var t=0;return function(){return t>=d.length?{done:!0}:{done:!1,value:d[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
32
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qn(d,o){(o==null||o>d.length)&&(o=d.length);for(var e=0,t=new Array(o);e<o;e++)t[e]=d[e];return t}function Vi(){return Vi=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},Vi.apply(this,arguments)}(function(d){d.MANIFEST="m",d.AUDIO="a",d.VIDEO="v",d.MUXED="av",d.INIT="i",d.CAPTION="c",d.TIMED_TEXT="tt",d.KEY="k",d.OTHER="o"})(or||(or={})),function(d){d.DASH="d",d.HLS="h",d.SMOOTH="s",d.OTHER="o"}(En||(En={})),function(d){d.VOD="v",d.LIVE="l"}(Hn||(Hn={}));var Ca=function(){function d(e){var t=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){t.initialized&&(t.starved=!0),t.buffering=!0},this.onPlaying=function(){t.initialized||(t.initialized=!0),t.buffering=!1},this.applyPlaylistData=function(a){try{t.apply(a,{ot:or.MANIFEST,su:!t.initialized})}catch(r){k.logger.warn("Could not generate manifest CMCD data.",r)}},this.applyFragmentData=function(a){try{var r=a.frag,s=t.hls.levels[r.level],l=t.getObjectType(r),u={d:1e3*r.duration,ot:l};l!==or.VIDEO&&l!==or.AUDIO&&l!=or.MUXED||(u.br=s.bitrate/1e3,u.tb=t.getTopBandwidth(l)/1e3,u.bl=t.getBufferLength(l)),t.apply(a,u)}catch(c){k.logger.warn("Could not generate segment CMCD data.",c)}},this.hls=e;var i=this.config=e.config,n=i.cmcd;n!=null&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||d.uuid(),this.cid=n.contentId,this.useHeaders=n.useHeaders===!0,this.registerListeners())}var o=d.prototype;return o.registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(p.Events.BUFFER_CREATED,this.onBufferCreated,this)},o.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(p.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},o.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},o.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},o.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},o.onBufferCreated=function(e,t){var i,n;this.audioBuffer=(i=t.tracks.audio)===null||i===void 0?void 0:i.buffer,this.videoBuffer=(n=t.tracks.video)===null||n===void 0?void 0:n.buffer},o.createData=function(){var e;return{v:1,sf:En.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},o.apply=function(e,t){t===void 0&&(t={}),Vi(t,this.createData());var i=t.ot===or.INIT||t.ot===or.VIDEO||t.ot===or.MUXED;if(this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){var n=d.toHeaders(t);if(!Object.keys(n).length)return;e.headers||(e.headers={}),Vi(e.headers,n)}else{var a=d.toQuery(t);if(!a)return;e.url=d.appendQueryToUri(e.url,a)}},o.getObjectType=function(e){var t=e.type;return t==="subtitle"?or.TIMED_TEXT:e.sn==="initSegment"?or.INIT:t==="audio"?or.AUDIO:t==="main"?this.hls.audioTracks.length?or.VIDEO:or.MUXED:void 0},o.getTopBandwidth=function(e){var t,i=0,n=this.hls;if(e===or.AUDIO)t=n.audioTracks;else{var a=n.maxAutoLevel,r=a>-1?a+1:n.levels.length;t=n.levels.slice(0,r)}for(var s,l=Kn(t);!(s=l()).done;){var u=s.value;u.bitrate>i&&(i=u.bitrate)}return i>0?i:NaN},o.getBufferLength=function(e){var t=this.hls.media,i=e===or.AUDIO?this.audioBuffer:this.videoBuffer;return i&&t?1e3*Mt.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN},o.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,i=e||this.config.loader;return function(){function n(r){this.loader=void 0,this.loader=new i(r)}var a=n.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(r,s,l){t(r),this.loader.load(r,s,l)},jn(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},o.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,i=e||this.config.loader;return function(){function n(r){this.loader=void 0,this.loader=new i(r)}var a=n.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(r,s,l){t(r),this.loader.load(r,s,l)},jn(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},d.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)},d.serialize=function(e){for(var t,i=[],n=function(S){return!Number.isNaN(S)&&S!=null&&S!==""&&S!==!1},a=function(S){return Math.round(S)},r=function(S){return 100*a(S/100)},s={br:a,d:a,bl:r,dl:r,mtp:r,nor:function(S){return encodeURIComponent(S)},rtp:r,tb:a},l=Kn(Object.keys(e||{}).sort());!(t=l()).done;){var u=t.value,c=e[u];if(n(c)&&!(u==="v"&&c===1||u=="pr"&&c===1)){var v=s[u];v&&(c=v(c));var m,_=typeof c;m=u==="ot"||u==="sf"||u==="st"?u+"="+c:_==="boolean"?u:_==="number"?u+"="+c:u+"="+JSON.stringify(c),i.push(m)}}return i.join(",")},d.toHeaders=function(e){for(var t={},i=["Object","Request","Session","Status"],n=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},r=0,s=Object.keys(e);r<s.length;r++){var l=s[r];n[a[l]!=null?a[l]:1][l]=e[l]}for(var u=0;u<n.length;u++){var c=d.serialize(n[u]);c&&(t["CMCD-"+i[u]]=c)}return t},d.toQuery=function(e){return"CMCD="+encodeURIComponent(d.serialize(e))},d.appendQueryToUri=function(e,t){if(!t)return e;var i=e.includes("?")?"&":"?";return""+e+i+t},d}(),Vn=N(408),xa=/^age:\s*[\d.]+\s*$/m;let Yn=function(){function d(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e?e.xhrSetup:null,this.stats=new Vn.LoadStats,this.retryDelay=0}var o=d.prototype;return o.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},o.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))},o.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!==null&&e!==void 0&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},o.load=function(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.retryDelay=t.retryDelay,this.loadInternal()},o.loadInternal=function(){var e=this.config,t=this.context;if(e){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0;var a=this.xhrSetup;try{if(a)try{a(i,t.url)}catch{i.open("GET",t.url,!0),a(i,t.url)}i.readyState||i.open("GET",t.url,!0);var r=this.context.headers;if(r)for(var s in r)i.setRequestHeader(s,r[s])}catch(l){return void this.callbacks.onError({code:i.status,text:l.message},t,i)}t.rangeEnd&&i.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),i.onreadystatechange=this.readystatechange.bind(this),i.onprogress=this.loadprogress.bind(this),i.responseType=t.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout),i.send()}},o.readystatechange=function(){var e=this.context,t=this.loader,i=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!i.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start)),n===4){t.onreadystatechange=null,t.onprogress=null;var r=t.status,s=t.responseType==="arraybuffer";if(r>=200&&r<300&&(s&&t.response||t.responseText!==null)){var l,u;if(i.loading.end=Math.max(self.performance.now(),i.loading.first),u=s?(l=t.response).byteLength:(l=t.responseText).length,i.loaded=i.total=u,!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(i,e,l,t),!this.callbacks)return;var v={url:t.responseURL,data:l};this.callbacks.onSuccess(v,i,e,t)}else i.retry>=a.maxRetry||r>=400&&r<499?(k.logger.error(r+" while loading "+e.url),this.callbacks.onError({code:r,text:t.statusText},e,t)):(k.logger.warn(r+" while loading "+e.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),i.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)}},o.loadtimeout=function(){k.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},o.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},o.getCacheAge=function(){var e=null;if(this.loader&&xa.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},d}();function Tn(d){var o=typeof Map=="function"?new Map:void 0;return Tn=function(e){if(e===null||(t=e,Function.toString.call(t).indexOf("[native code]")===-1))return e;var t;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(e))return o.get(e);o.set(e,i)}function i(){return bn(e,arguments,_n(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Li(i,e)},Tn(d)}function bn(d,o,e){return bn=Oa()?Reflect.construct.bind():function(t,i,n){var a=[null];a.push.apply(a,i);var r=new(Function.bind.apply(t,a));return n&&Li(r,n.prototype),r},bn.apply(null,arguments)}function Oa(){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 Li(d,o){return Li=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Li(d,o)}function _n(d){return _n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},_n(d)}function Sn(){return Sn=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},Sn.apply(this,arguments)}var Ma=function(){function d(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Fa,this.controller=new self.AbortController,this.stats=new Vn.LoadStats}var o=d.prototype;return o.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},o.abortInternal=function(){var e=this.response;e&&e.ok||(this.stats.aborted=!0,this.controller.abort())},o.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!==null&&e!==void 0&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},o.load=function(e,t,i){var n=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var r=function(c,v){var m={method:"GET",mode:"cors",credentials:"same-origin",signal:v,headers:new self.Headers(Sn({},c.headers))};return c.rangeEnd&&m.headers.set("Range","bytes="+c.rangeStart+"-"+String(c.rangeEnd-1)),m}(e,this.controller.signal),s=i.onProgress,l=e.responseType==="arraybuffer",u=l?"byteLength":"length";this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){n.abortInternal(),i.onTimeout(a,e,n.response)},t.timeout),self.fetch(this.request).then(function(c){if(n.response=n.loader=c,!c.ok){var v=c.status,m=c.statusText;throw new Na(m||"fetch, bad network response",v,c)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(c.headers.get("Content-Length")||"0"),s&&(0,R.isFiniteNumber)(t.highWaterMark)?n.loadProgressively(c,a,e,t.highWaterMark,s):l?c.arrayBuffer():c.text()}).then(function(c){var v=n.response;self.clearTimeout(n.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var m=c[u];m&&(a.loaded=a.total=m);var _={url:v.url,data:c};s&&!(0,R.isFiniteNumber)(t.highWaterMark)&&s(a,e,c,v),i.onSuccess(_,a,e,v)}).catch(function(c){if(self.clearTimeout(n.requestTimeout),!a.aborted){var v=c&&c.code||0,m=c?c.message:null;i.onError({code:v,text:m},e,c?c.details:null)}})},o.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},o.loadProgressively=function(e,t,i,n,a){n===void 0&&(n=0);var r=new Hi,s=e.body.getReader();return function l(){return s.read().then(function(u){if(u.done)return r.dataLength&&a(t,i,r.flush(),e),Promise.resolve(new ArrayBuffer(0));var c=u.value,v=c.length;return t.loaded+=v,v<n||r.dataLength?(r.push(c),r.dataLength>=n&&a(t,i,r.flush(),e)):a(t,i,c,e),l()}).catch(function(){return Promise.reject()})}()},d}();function Fa(d,o){return new self.Request(d.url,o)}var Na=function(d){var o,e;function t(i,n,a){var r;return(r=d.call(this,i)||this).code=void 0,r.details=void 0,r.code=n,r.details=a,r}return e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Li(o,e),t}(Tn(Error));let Wn=Ma;var Ua=/\s/;function kn(){return kn=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},kn.apply(this,arguments)}function Xn(d,o){var e=Object.keys(d);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(d);o&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(d,i).enumerable})),e.push.apply(e,t)}return e}function zn(d){for(var o=1;o<arguments.length;o++){var e=arguments[o]!=null?arguments[o]:{};o%2?Xn(Object(e),!0).forEach(function(t){Ba(d,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(e)):Xn(Object(e)).forEach(function(t){Object.defineProperty(d,t,Object.getOwnPropertyDescriptor(e,t))})}return d}function Ba(d,o,e){return(o=function(t){var i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t,"string");return typeof i=="symbol"?i:String(i)}(o))in d?Object.defineProperty(d,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):d[o]=e,d}var Ha=zn(zn({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Yn,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:an,bufferController:hn,capLevelController:Da,fpsController:Ra,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:ye,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},{cueHandler:{newCue:function(d,o,e,t){for(var i,n,a,r,s,l=[],u=self.VTTCue||self.TextTrackCue,c=0;c<t.rows.length;c++)if(a=!0,r=0,s="",!(i=t.rows[c]).isEmpty()){for(var v=0;v<i.chars.length;v++)Ua.test(i.chars[v].uchar)&&a?r++:(s+=i.chars[v].uchar,a=!1);i.cueStartTime=o,o===e&&(e+=1e-4),r>=16?r--:r++;var m=Kt(s.trim()),_=sr(o,e,m);d&&d.cues&&d.cues.getCueById(_)||((n=new u(o,e,m)).id=_,n.line=c+1,n.align="left",n.position=10+Math.min(80,10*Math.floor(8*r/32)),l.push(n))}return d&&l.length&&(l.sort(function(S,x){return S.line==="auto"||x.line==="auto"?0:S.line>8&&x.line>8?x.line-S.line:S.line-x.line}),l.forEach(function(S){return yt(d,S)})),l}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:ln,subtitleTrackController:cn,timelineController:La,audioStreamController:Ti,audioTrackController:sn,emeController:Pa,cmcdController:Ca});function Qn(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var Jn=function(){function d(n){n===void 0&&(n={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new gi.EventEmitter,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var a=this.config=function(Ee,Ge){if((Ge.liveSyncDurationCount||Ge.liveMaxLatencyDurationCount)&&(Ge.liveSyncDuration||Ge.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(Ge.liveMaxLatencyDurationCount!==void 0&&(Ge.liveSyncDurationCount===void 0||Ge.liveMaxLatencyDurationCount<=Ge.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(Ge.liveMaxLatencyDuration!==void 0&&(Ge.liveSyncDuration===void 0||Ge.liveMaxLatencyDuration<=Ge.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return kn({},Ee,Ge)}(d.DefaultConfig,n);this.userConfig=n,(0,k.enableLogs)(a.debug,"Hls instance"),this._autoLevelCapping=-1,a.progressive&&function(Ee){var Ge=Ee.loader;Ge!==Wn&&Ge!==Yn?(k.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),Ee.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}()&&(Ee.loader=Wn,Ee.progressive=!0,Ee.enableSoftwareAES=!0,k.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}(a);var r=a.abrController,s=a.bufferController,l=a.capLevelController,u=a.fpsController,c=this.abrController=new r(this),v=this.bufferController=new s(this),m=this.capLevelController=new l(this),_=new u(this),S=new Ye(this),x=new Rt(this),I=this.levelController=new ot(this),j=new bt(this),ae=new hr(this.config),me=this.streamController=new tn(this,j,ae);m.setStreamController(me),_.setStreamController(me);var de=[S,I,me];this.networkControllers=de;var _e=[c,v,m,_,x,j];this.audioTrackController=this.createController(a.audioTrackController,de);var Ke=a.audioStreamController;Ke&&de.push(new Ke(this,j,ae)),this.subtitleTrackController=this.createController(a.subtitleTrackController,de);var ze=a.subtitleStreamController;ze&&de.push(new ze(this,j,ae)),this.createController(a.timelineController,_e),ae.emeController=this.emeController=this.createController(a.emeController,_e),this.cmcdController=this.createController(a.cmcdController,_e),this.latencyController=this.createController(jt,_e),this.coreComponents=_e}d.isSupported=function(){return function(){var n=ni();if(!n)return!1;var a=ai(),r=n&&typeof n.isTypeSupported=="function"&&n.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),s=!a||a.prototype&&typeof a.prototype.appendBuffer=="function"&&typeof a.prototype.remove=="function";return!!r&&!!s}()};var o,e,t,i=d.prototype;return i.createController=function(n,a){if(n){var r=new n(this);return a&&a.push(r),r}return null},i.on=function(n,a,r){r===void 0&&(r=this),this._emitter.on(n,a,r)},i.once=function(n,a,r){r===void 0&&(r=this),this._emitter.once(n,a,r)},i.removeAllListeners=function(n){this._emitter.removeAllListeners(n)},i.off=function(n,a,r,s){r===void 0&&(r=this),this._emitter.off(n,a,r,s)},i.listeners=function(n){return this._emitter.listeners(n)},i.emit=function(n,a,r){return this._emitter.emit(n,a,r)},i.trigger=function(n,a){if(this.config.debug)return this.emit(n,n,a);try{return this.emit(n,n,a)}catch(r){k.logger.error("An internal error happened while handling event "+n+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(p.Events.ERROR,{type:w.ErrorTypes.OTHER_ERROR,details:w.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:n,error:r})}return!1},i.listenerCount=function(n){return this._emitter.listenerCount(n)},i.destroy=function(){k.logger.log("destroy"),this.trigger(p.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(n){return n.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(n){return n.destroy()}),this.coreComponents.length=0},i.attachMedia=function(n){k.logger.log("attachMedia"),this._media=n,this.trigger(p.Events.MEDIA_ATTACHING,{media:n})},i.detachMedia=function(){k.logger.log("detachMedia"),this.trigger(p.Events.MEDIA_DETACHING,void 0),this._media=null},i.loadSource=function(n){this.stopLoad();var a=this.media,r=this.url,s=this.url=$.buildAbsoluteURL(self.location.href,n,{alwaysNormalize:!0});k.logger.log("loadSource:"+s),a&&r&&r!==s&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(a)),this.trigger(p.Events.MANIFEST_LOADING,{url:n})},i.startLoad=function(n){n===void 0&&(n=-1),k.logger.log("startLoad("+n+")"),this.networkControllers.forEach(function(a){a.startLoad(n)})},i.stopLoad=function(){k.logger.log("stopLoad"),this.networkControllers.forEach(function(n){n.stopLoad()})},i.swapAudioCodec=function(){k.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},i.recoverMediaError=function(){k.logger.log("recoverMediaError");var n=this._media;this.detachMedia(),n&&this.attachMedia(n)},i.removeLevel=function(n,a){a===void 0&&(a=0),this.levelController.removeLevel(n,a)},o=d,t=[{key:"version",get:function(){return"1.3.1"}},{key:"Events",get:function(){return p.Events}},{key:"ErrorTypes",get:function(){return w.ErrorTypes}},{key:"ErrorDetails",get:function(){return w.ErrorDetails}},{key:"DefaultConfig",get:function(){return d.defaultConfig?d.defaultConfig:Ha},set:function(n){d.defaultConfig=n}}],(e=[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(n){k.logger.log("set currentLevel:"+n),this.loadLevel=n,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(n){k.logger.log("set nextLevel:"+n),this.levelController.manualLevel=n,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(n){k.logger.log("set loadLevel:"+n),this.levelController.manualLevel=n}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(n){this.levelController.nextLoadLevel=n}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(n){k.logger.log("set firstLevel:"+n),this.levelController.firstLevel=n}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(n){k.logger.log("set startLevel:"+n),n!==-1&&(n=Math.max(n,this.minAutoLevel)),this.levelController.startLevel=n}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(n){var a=!!n;a!==this.config.capLevelToPlayerSize&&(a?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=a)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(n){this._autoLevelCapping!==n&&(k.logger.log("set autoLevelCapping:"+n),this._autoLevelCapping=n)}},{key:"bandwidthEstimate",get:function(){var n=this.abrController.bwEstimator;return n?n.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(n){dr.indexOf(n)>-1&&(this._maxHdcpLevel=n)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var n=this.levels,a=this.config.minAutoBitrate;if(!n)return 0;for(var r=n.length,s=0;s<r;s++)if(n[s].maxBitrate>=a)return s;return 0}},{key:"maxAutoLevel",get:function(){var n,a=this.levels,r=this.autoLevelCapping,s=this.maxHdcpLevel;if(n=r===-1&&a&&a.length?a.length-1:r,s)for(var l=n;l--;){var u=a[l].attrs["HDCP-LEVEL"];if(u&&u<=s)return l}return n}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(n){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,n)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var n=this.audioTrackController;return n?n.audioTracks:[]}},{key:"audioTrack",get:function(){var n=this.audioTrackController;return n?n.audioTrack:-1},set:function(n){var a=this.audioTrackController;a&&(a.audioTrack=n)}},{key:"subtitleTracks",get:function(){var n=this.subtitleTrackController;return n?n.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var n=this.subtitleTrackController;return n?n.subtitleTrack:-1},set:function(n){var a=this.subtitleTrackController;a&&(a.subtitleTrack=n)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var n=this.subtitleTrackController;return!!n&&n.subtitleDisplay},set:function(n){var a=this.subtitleTrackController;a&&(a.subtitleDisplay=n)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(n){this.config.lowLatencyMode=n}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&Qn(o.prototype,e),t&&Qn(o,t),Object.defineProperty(o,"prototype",{writable:!1}),d}();Jn.defaultConfig=void 0},923:(fe,re,N)=>{"use strict";N.r(re),N.d(re,{BaseSegment:()=>le,ElementaryStreamTypes:()=>B,Fragment:()=>Te,Part:()=>H});var B,$=N(965),R=N(945),p=N(408);function w(ce,z){ce.prototype=Object.create(z.prototype),ce.prototype.constructor=ce,k(ce,z)}function k(ce,z){return k=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(ne,U){return ne.__proto__=U,ne},k(ce,z)}function ve(ce,z){for(var ne=0;ne<z.length;ne++){var U=z[ne];U.enumerable=U.enumerable||!1,U.configurable=!0,"value"in U&&(U.writable=!0),Object.defineProperty(ce,typeof(be=function(ke,He){if(typeof ke!="object"||ke===null)return ke;var K=ke[Symbol.toPrimitive];if(K!==void 0){var E=K.call(ke,He);if(typeof E!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(ke)}(U.key,"string"))=="symbol"?be:String(be),U)}var be}function Z(ce,z,ne){return z&&ve(ce.prototype,z),ne&&ve(ce,ne),Object.defineProperty(ce,"prototype",{writable:!1}),ce}(function(ce){ce.AUDIO="audio",ce.VIDEO="video",ce.AUDIOVIDEO="audiovideo"})(B||(B={}));var le=function(){function ce(z){var ne;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((ne={})[B.AUDIO]=null,ne[B.VIDEO]=null,ne[B.AUDIOVIDEO]=null,ne),this.baseurl=z}return ce.prototype.setByteRange=function(z,ne){var U=z.split("@",2),be=[];U.length===1?be[0]=ne?ne.byteRangeEndOffset:0:be[0]=parseInt(U[1]),be[1]=parseInt(U[0])+be[0],this._byteRange=be},Z(ce,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=(0,R.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(z){this._url=z}}]),ce}(),Te=function(ce){function z(U,be){var ke;return(ke=ce.call(this,be)||this)._decryptdata=null,ke.rawProgramDateTime=null,ke.programDateTime=null,ke.tagList=[],ke.duration=0,ke.sn=0,ke.levelkeys=void 0,ke.type=void 0,ke.loader=null,ke.keyLoader=null,ke.level=-1,ke.cc=0,ke.startPTS=void 0,ke.endPTS=void 0,ke.appendedPTS=void 0,ke.startDTS=void 0,ke.endDTS=void 0,ke.start=0,ke.deltaPTS=void 0,ke.maxStartPTS=void 0,ke.minEndPTS=void 0,ke.stats=new p.LoadStats,ke.urlId=0,ke.data=void 0,ke.bitrateTest=!1,ke.title=null,ke.initSegment=null,ke.endList=void 0,ke.type=U,ke}w(z,ce);var ne=z.prototype;return ne.setKeyFormat=function(U){if(this.levelkeys){var be=this.levelkeys[U];be&&!this._decryptdata&&(this._decryptdata=be.getDecryptData(this.sn))}},ne.abortRequests=function(){var U,be;(U=this.loader)===null||U===void 0||U.abort(),(be=this.keyLoader)===null||be===void 0||be.abort()},ne.setElementaryStreamInfo=function(U,be,ke,He,K,E){E===void 0&&(E=!1);var M=this.elementaryStreams,L=M[U];L?(L.startPTS=Math.min(L.startPTS,be),L.endPTS=Math.max(L.endPTS,ke),L.startDTS=Math.min(L.startDTS,He),L.endDTS=Math.max(L.endDTS,K)):M[U]={startPTS:be,endPTS:ke,startDTS:He,endDTS:K,partial:E}},ne.clearElementaryStreamInfo=function(){var U=this.elementaryStreams;U[B.AUDIO]=null,U[B.VIDEO]=null,U[B.AUDIOVIDEO]=null},Z(z,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var U=this.levelkeys.identity;if(U)this._decryptdata=U.getDecryptData(this.sn);else{var be=Object.keys(this.levelkeys);if(be.length===1)return this._decryptdata=this.levelkeys[be[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!(0,$.isFiniteNumber)(this.programDateTime))return null;var U=(0,$.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*U}},{key:"encrypted",get:function(){var U;if((U=this._decryptdata)!==null&&U!==void 0&&U.encrypted)return!0;if(this.levelkeys){var be=Object.keys(this.levelkeys),ke=be.length;if(ke>1||ke===1&&this.levelkeys[be[0]].encrypted)return!0}return!1}}]),z}(le),H=function(ce){function z(ne,U,be,ke,He){var K;(K=ce.call(this,be)||this).fragOffset=0,K.duration=0,K.gap=!1,K.independent=!1,K.relurl=void 0,K.fragment=void 0,K.index=void 0,K.stats=new p.LoadStats,K.duration=ne.decimalFloatingPoint("DURATION"),K.gap=ne.bool("GAP"),K.independent=ne.bool("INDEPENDENT"),K.relurl=ne.enumeratedString("URI"),K.fragment=U,K.index=ke;var E=ne.enumeratedString("BYTERANGE");return E&&K.setByteRange(E,He),He&&(K.fragOffset=He.fragOffset+He.duration),K}return w(z,ce),Z(z,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var ne=this.elementaryStreams;return!!(ne.audio||ne.video||ne.audiovideo)}}]),z}(le)},408:(fe,re,N)=>{"use strict";N.r(re),N.d(re,{LoadStats:()=>B});var B=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},965:(fe,re,N)=>{"use strict";N.r(re),N.d(re,{MAX_SAFE_INTEGER:()=>$,isFiniteNumber:()=>B});var B=Number.isFinite||function(R){return typeof R=="number"&&isFinite(R)},$=Number.MAX_SAFE_INTEGER||9007199254740991},524:(fe,re,N)=>{"use strict";N.r(re),N.d(re,{default:()=>ne,flushTextTrackMetadataCueSamples:()=>be,flushTextTrackUserdataCueSamples:()=>ke,normalizePts:()=>U});var B=N(965);let $=function(){function E(){}return E.getSilentFrame=function(M,L){if(M==="mp4a.40.2"){if(L===1)return new Uint8Array([0,200,0,128,35,128]);if(L===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(L===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(L===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(L===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(L===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(L===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(L===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(L===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},E}();var R=Math.pow(2,32)-1,p=function(){function E(){}return E.init=function(){var M;for(M in E.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},E.types)E.types.hasOwnProperty(M)&&(E.types[M]=[M.charCodeAt(0),M.charCodeAt(1),M.charCodeAt(2),M.charCodeAt(3)]);var L=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]),oe=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);E.HDLR_TYPES={video:L,audio:oe};var ye=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),W=new Uint8Array([0,0,0,0,0,0,0,0]);E.STTS=E.STSC=E.STCO=W,E.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),E.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),E.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),E.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var V=new Uint8Array([105,115,111,109]),we=new Uint8Array([97,118,99,49]),Re=new Uint8Array([0,0,0,1]);E.FTYP=E.box(E.types.ftyp,V,Re,V,we),E.DINF=E.box(E.types.dinf,E.box(E.types.dref,ye))},E.box=function(M){for(var L=8,oe=arguments.length,ye=new Array(oe>1?oe-1:0),W=1;W<oe;W++)ye[W-1]=arguments[W];for(var V=ye.length,we=V;V--;)L+=ye[V].byteLength;var Re=new Uint8Array(L);for(Re[0]=L>>24&255,Re[1]=L>>16&255,Re[2]=L>>8&255,Re[3]=255&L,Re.set(M,4),V=0,L=8;V<we;V++)Re.set(ye[V],L),L+=ye[V].byteLength;return Re},E.hdlr=function(M){return E.box(E.types.hdlr,E.HDLR_TYPES[M])},E.mdat=function(M){return E.box(E.types.mdat,M)},E.mdhd=function(M,L){L*=M;var oe=Math.floor(L/(R+1)),ye=Math.floor(L%(R+1));return E.box(E.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,M>>24&255,M>>16&255,M>>8&255,255&M,oe>>24,oe>>16&255,oe>>8&255,255&oe,ye>>24,ye>>16&255,ye>>8&255,255&ye,85,196,0,0]))},E.mdia=function(M){return E.box(E.types.mdia,E.mdhd(M.timescale,M.duration),E.hdlr(M.type),E.minf(M))},E.mfhd=function(M){return E.box(E.types.mfhd,new Uint8Array([0,0,0,0,M>>24,M>>16&255,M>>8&255,255&M]))},E.minf=function(M){return M.type==="audio"?E.box(E.types.minf,E.box(E.types.smhd,E.SMHD),E.DINF,E.stbl(M)):E.box(E.types.minf,E.box(E.types.vmhd,E.VMHD),E.DINF,E.stbl(M))},E.moof=function(M,L,oe){return E.box(E.types.moof,E.mfhd(M),E.traf(oe,L))},E.moov=function(M){for(var L=M.length,oe=[];L--;)oe[L]=E.trak(M[L]);return E.box.apply(null,[E.types.moov,E.mvhd(M[0].timescale,M[0].duration)].concat(oe).concat(E.mvex(M)))},E.mvex=function(M){for(var L=M.length,oe=[];L--;)oe[L]=E.trex(M[L]);return E.box.apply(null,[E.types.mvex].concat(oe))},E.mvhd=function(M,L){L*=M;var oe=Math.floor(L/(R+1)),ye=Math.floor(L%(R+1)),W=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,M>>24&255,M>>16&255,M>>8&255,255&M,oe>>24,oe>>16&255,oe>>8&255,255&oe,ye>>24,ye>>16&255,ye>>8&255,255&ye,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return E.box(E.types.mvhd,W)},E.sdtp=function(M){var L,oe,ye=M.samples||[],W=new Uint8Array(4+ye.length);for(L=0;L<ye.length;L++)oe=ye[L].flags,W[L+4]=oe.dependsOn<<4|oe.isDependedOn<<2|oe.hasRedundancy;return E.box(E.types.sdtp,W)},E.stbl=function(M){return E.box(E.types.stbl,E.stsd(M),E.box(E.types.stts,E.STTS),E.box(E.types.stsc,E.STSC),E.box(E.types.stsz,E.STSZ),E.box(E.types.stco,E.STCO))},E.avc1=function(M){var L,oe,ye,W=[],V=[];for(L=0;L<M.sps.length;L++)ye=(oe=M.sps[L]).byteLength,W.push(ye>>>8&255),W.push(255&ye),W=W.concat(Array.prototype.slice.call(oe));for(L=0;L<M.pps.length;L++)ye=(oe=M.pps[L]).byteLength,V.push(ye>>>8&255),V.push(255&ye),V=V.concat(Array.prototype.slice.call(oe));var we=E.box(E.types.avcC,new Uint8Array([1,W[3],W[4],W[5],255,224|M.sps.length].concat(W).concat([M.pps.length]).concat(V))),Re=M.width,Ce=M.height,ge=M.pixelRatio[0],qe=M.pixelRatio[1];return E.box(E.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,Re>>8&255,255&Re,Ce>>8&255,255&Ce,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]),we,E.box(E.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),E.box(E.types.pasp,new Uint8Array([ge>>24,ge>>16&255,ge>>8&255,255&ge,qe>>24,qe>>16&255,qe>>8&255,255&qe])))},E.esds=function(M){var L=M.config.length;return new Uint8Array([0,0,0,0,3,23+L,0,1,0,4,15+L,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([L]).concat(M.config).concat([6,1,2]))},E.mp4a=function(M){var L=M.samplerate;return E.box(E.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,M.channelCount,0,16,0,0,0,0,L>>8&255,255&L,0,0]),E.box(E.types.esds,E.esds(M)))},E.mp3=function(M){var L=M.samplerate;return E.box(E.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,M.channelCount,0,16,0,0,0,0,L>>8&255,255&L,0,0]))},E.stsd=function(M){return M.type==="audio"?M.segmentCodec==="mp3"&&M.codec==="mp3"?E.box(E.types.stsd,E.STSD,E.mp3(M)):E.box(E.types.stsd,E.STSD,E.mp4a(M)):E.box(E.types.stsd,E.STSD,E.avc1(M))},E.tkhd=function(M){var L=M.id,oe=M.duration*M.timescale,ye=M.width,W=M.height,V=Math.floor(oe/(R+1)),we=Math.floor(oe%(R+1));return E.box(E.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,L>>24&255,L>>16&255,L>>8&255,255&L,0,0,0,0,V>>24,V>>16&255,V>>8&255,255&V,we>>24,we>>16&255,we>>8&255,255&we,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,ye>>8&255,255&ye,0,0,W>>8&255,255&W,0,0]))},E.traf=function(M,L){var oe=E.sdtp(M),ye=M.id,W=Math.floor(L/(R+1)),V=Math.floor(L%(R+1));return E.box(E.types.traf,E.box(E.types.tfhd,new Uint8Array([0,0,0,0,ye>>24,ye>>16&255,ye>>8&255,255&ye])),E.box(E.types.tfdt,new Uint8Array([1,0,0,0,W>>24,W>>16&255,W>>8&255,255&W,V>>24,V>>16&255,V>>8&255,255&V])),E.trun(M,oe.length+16+20+8+16+8+8),oe)},E.trak=function(M){return M.duration=M.duration||4294967295,E.box(E.types.trak,E.tkhd(M),E.mdia(M))},E.trex=function(M){var L=M.id;return E.box(E.types.trex,new Uint8Array([0,0,0,0,L>>24,L>>16&255,L>>8&255,255&L,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},E.trun=function(M,L){var oe,ye,W,V,we,Re,Ce=M.samples||[],ge=Ce.length,qe=12+16*ge,tt=new Uint8Array(qe);for(L+=8+qe,tt.set([M.type==="video"?1:0,0,15,1,ge>>>24&255,ge>>>16&255,ge>>>8&255,255&ge,L>>>24&255,L>>>16&255,L>>>8&255,255&L],0),oe=0;oe<ge;oe++)W=(ye=Ce[oe]).duration,V=ye.size,we=ye.flags,Re=ye.cts,tt.set([W>>>24&255,W>>>16&255,W>>>8&255,255&W,V>>>24&255,V>>>16&255,V>>>8&255,255&V,we.isLeading<<2|we.dependsOn,we.isDependedOn<<6|we.hasRedundancy<<4|we.paddingValue<<1|we.isNonSync,61440&we.degradPrio,15&we.degradPrio,Re>>>24&255,Re>>>16&255,Re>>>8&255,255&Re],12+16*oe);return E.box(E.types.trun,tt)},E.initSegment=function(M){E.types||E.init();var L=E.moov(M),oe=new Uint8Array(E.FTYP.byteLength+L.byteLength);return oe.set(E.FTYP),oe.set(L,E.FTYP.byteLength),oe},E}();p.types=void 0,p.HDLR_TYPES=void 0,p.STTS=void 0,p.STSC=void 0,p.STCO=void 0,p.STSZ=void 0,p.VMHD=void 0,p.SMHD=void 0,p.STSD=void 0,p.FTYP=void 0,p.DINF=void 0;let w=p;var k=N(851),ve=N(973),Z=N(93),le=N(308),Te=N(673);function H(){return H=Object.assign?Object.assign.bind():function(E){for(var M=1;M<arguments.length;M++){var L=arguments[M];for(var oe in L)Object.prototype.hasOwnProperty.call(L,oe)&&(E[oe]=L[oe])}return E},H.apply(this,arguments)}var ce=null,z=null,ne=function(){function E(L,oe,ye,W){if(W===void 0&&(W=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=L,this.config=oe,this.typeSupported=ye,this.ISGenerated=!1,ce===null){var V=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ce=V?parseInt(V[1]):0}if(z===null){var we=navigator.userAgent.match(/Safari\/(\d+)/i);z=we?parseInt(we[1]):0}}var M=E.prototype;return M.destroy=function(){},M.resetTimeStamp=function(L){Z.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=L},M.resetNextTimestamp=function(){Z.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},M.resetInitSegment=function(){Z.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},M.getVideoStartPts=function(L){var oe=!1,ye=L.reduce(function(W,V){var we=V.pts-W;return we<-4294967296?(oe=!0,U(W,V.pts)):we>0?W:V.pts},L[0].pts);return oe&&Z.logger.debug("PTS rollover detected"),ye},M.remux=function(L,oe,ye,W,V,we,Re,Ce){var ge,qe,tt,ee,ue,ie,Oe=V,xe=V,Ne=L.pid>-1,Be=oe.pid>-1,je=oe.samples.length,pe=L.samples.length>0,Ie=Re&&je>0||je>1;if((!Ne||pe)&&(!Be||Ie)||this.ISGenerated||Re){this.ISGenerated||(tt=this.generateIS(L,oe,V));var Ye,rt=this.isVideoContiguous,yt=-1;if(Ie&&(yt=function(kt){for(var gt=0;gt<kt.length;gt++)if(kt[gt].key)return gt;return-1}(oe.samples),!rt&&this.config.forceKeyFrameOnDiscontinuity))if(ie=!0,yt>0){Z.logger.warn("[mp4-remuxer]: Dropped "+yt+" out of "+je+" video samples due to a missing keyframe");var ht=this.getVideoStartPts(oe.samples);oe.samples=oe.samples.slice(yt),oe.dropped+=yt,Ye=xe+=(oe.samples[0].pts-ht)/oe.inputTimeScale}else yt===-1&&(Z.logger.warn("[mp4-remuxer]: No keyframe found out of "+je+" video samples"),ie=!1);if(this.ISGenerated){if(pe&&Ie){var It=this.getVideoStartPts(oe.samples),Dt=(U(L.samples[0].pts,It)-It)/oe.inputTimeScale;Oe+=Math.max(0,Dt),xe+=Math.max(0,-Dt)}if(pe){if(L.samplerate||(Z.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),tt=this.generateIS(L,oe,V)),qe=this.remuxAudio(L,Oe,this.isAudioContiguous,we,Be||Ie||Ce===le.PlaylistLevelType.AUDIO?xe:void 0),Ie){var St=qe?qe.endPTS-qe.startPTS:0;oe.inputTimeScale||(Z.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),tt=this.generateIS(L,oe,V)),ge=this.remuxVideo(oe,xe,rt,St)}}else Ie&&(ge=this.remuxVideo(oe,xe,rt,0));ge&&(ge.firstKeyFrame=yt,ge.independent=yt!==-1,ge.firstKeyFramePTS=Ye)}}return this.ISGenerated&&(ye.samples.length&&(ue=be(ye,V,this._initPTS,this._initDTS)),W.samples.length&&(ee=ke(W,V,this._initPTS))),{audio:qe,video:ge,initSegment:tt,independent:ie,text:ee,id3:ue}},M.generateIS=function(L,oe,ye){var W,V,we,Re=L.samples,Ce=oe.samples,ge=this.typeSupported,qe={},tt=!(0,B.isFiniteNumber)(this._initPTS),ee="audio/mp4";if(tt&&(W=V=1/0),L.config&&Re.length&&(L.timescale=L.samplerate,L.segmentCodec==="mp3"&&(ge.mpeg?(ee="audio/mpeg",L.codec=""):ge.mp3&&(L.codec="mp3")),qe.audio={id:"audio",container:ee,codec:L.codec,initSegment:L.segmentCodec==="mp3"&&ge.mpeg?new Uint8Array(0):w.initSegment([L]),metadata:{channelCount:L.channelCount}},tt&&(we=L.inputTimeScale,W=V=Re[0].pts-Math.round(we*ye))),oe.sps&&oe.pps&&Ce.length&&(oe.timescale=oe.inputTimeScale,qe.video={id:"main",container:"video/mp4",codec:oe.codec,initSegment:w.initSegment([oe]),metadata:{width:oe.width,height:oe.height}},tt)){we=oe.inputTimeScale;var ue=this.getVideoStartPts(Ce),ie=Math.round(we*ye);V=Math.min(V,U(Ce[0].dts,ue)-ie),W=Math.min(W,ue-ie)}if(Object.keys(qe).length)return this.ISGenerated=!0,tt&&(this._initPTS=W,this._initDTS=V),{tracks:qe,initPTS:W,timescale:we}},M.remuxVideo=function(L,oe,ye,W){var V,we,Re=L.inputTimeScale,Ce=L.samples,ge=[],qe=Ce.length,tt=this._initPTS,ee=this.nextAvcDts,ue=8,ie=this.videoSampleDuration,Oe=Number.POSITIVE_INFINITY,xe=Number.NEGATIVE_INFINITY,Ne=!1;ye&&ee!==null||(ee=oe*Re-(Ce[0].pts-U(Ce[0].dts,Ce[0].pts)));for(var Be=0;Be<qe;Be++){var je=Ce[Be];je.pts=U(je.pts-tt,ee),je.dts=U(je.dts-tt,ee),je.dts<Ce[Be>0?Be-1:Be].dts&&(Ne=!0)}Ne&&Ce.sort(function(Vt,hr){var wr=Vt.dts-hr.dts,cr=Vt.pts-hr.pts;return wr||cr}),V=Ce[0].dts;var pe=Ce[Ce.length-1].dts-V,Ie=pe?Math.round(pe/(qe-1)):ie||L.inputTimeScale/30;if(ye){var Ye=V-ee,rt=Ye>Ie,yt=Ye<-1;if((rt||yt)&&(rt?Z.logger.warn("AVC: "+(0,Te.toMsFromMpegTsClock)(Ye,!0)+" ms ("+Ye+"dts) hole between fragments detected, filling it"):Z.logger.warn("AVC: "+(0,Te.toMsFromMpegTsClock)(-Ye,!0)+" ms ("+Ye+"dts) overlapping between fragments detected"),!yt||ee>Ce[0].pts)){V=ee;var ht=Ce[0].pts-Ye;Ce[0].dts=V,Ce[0].pts=ht,Z.logger.log("Video: First PTS/DTS adjusted: "+(0,Te.toMsFromMpegTsClock)(ht,!0)+"/"+(0,Te.toMsFromMpegTsClock)(V,!0)+", delta: "+(0,Te.toMsFromMpegTsClock)(Ye,!0)+" ms")}}V=Math.max(0,V);for(var It=0,Dt=0,St=0;St<qe;St++){for(var kt=Ce[St],gt=kt.units,ut=gt.length,Rt=0,Pt=0;Pt<ut;Pt++)Rt+=gt[Pt].data.length;Dt+=Rt,It+=ut,kt.length=Rt,kt.dts=Math.max(kt.dts,V),Oe=Math.min(kt.pts,Oe),xe=Math.max(kt.pts,xe)}we=Ce[qe-1].dts;var jt,zt=Dt+4*It+8;try{jt=new Uint8Array(zt)}catch{return void this.observer.emit(k.Events.ERROR,k.Events.ERROR,{type:ve.ErrorTypes.MUX_ERROR,details:ve.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:zt,reason:"fail allocating video mdat "+zt})}var Nt=new DataView(jt.buffer);Nt.setUint32(0,zt),jt.set(w.types.mdat,4);for(var dr=!1,J=Number.POSITIVE_INFINITY,O=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,P=Number.NEGATIVE_INFINITY,D=0;D<qe;D++){for(var F=Ce[D],q=F.units,Y=0,he=0,Le=q.length;he<Le;he++){var Ae=q[he],Me=Ae.data,Ve=Ae.data.byteLength;Nt.setUint32(ue,Ve),ue+=4,jt.set(Me,ue),ue+=Ve,Y+=4+Ve}var Ue=void 0;if(D<qe-1)ie=Ce[D+1].dts-F.dts,Ue=Ce[D+1].pts-F.pts;else{var Qe=this.config,ot=D>0?F.dts-Ce[D-1].dts:Ie;if(Ue=D>0?F.pts-Ce[D-1].pts:Ie,Qe.stretchShortVideoTrack&&this.nextAudioPts!==null){var bt=Math.floor(Qe.maxBufferHole*Re),We=(W?Oe+W*Re:this.nextAudioPts)-F.pts;We>bt?((ie=We-ot)<0?ie=ot:dr=!0,Z.logger.log("[mp4-remuxer]: It is approximately "+We/90+" ms to the next segment; using duration "+ie/90+" ms for the last video frame.")):ie=ot}else ie=ot}var Lt=Math.round(F.pts-F.dts);J=Math.min(J,ie),T=Math.max(T,ie),O=Math.min(O,Ue),P=Math.max(P,Ue),ge.push(new He(F.key,ie,Y,Lt))}if(ge.length){if(ce){if(ce<70){var Qt=ge[0].flags;Qt.dependsOn=2,Qt.isNonSync=0}}else if(z&&P-O<T-J&&Ie/T<.025&&ge[0].cts===0){Z.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Ot=V,xt=0,Ut=ge.length;xt<Ut;xt++){var Ze=Ot+ge[xt].duration,rr=Ot+ge[xt].cts;if(xt<Ut-1){var Er=Ze+ge[xt+1].cts;ge[xt].duration=Er-rr}else ge[xt].duration=xt?ge[xt-1].duration:Ie;ge[xt].cts=0,Ot=Ze}}}ie=dr||!ie?Ie:ie,this.nextAvcDts=ee=we+ie,this.videoSampleDuration=ie,this.isVideoContiguous=!0;var Ft={data1:w.moof(L.sequenceNumber++,V,H({},L,{samples:ge})),data2:jt,startPTS:Oe/Re,endPTS:(xe+ie)/Re,startDTS:V/Re,endDTS:ee/Re,type:"video",hasAudio:!1,hasVideo:!0,nb:ge.length,dropped:L.dropped};return L.samples=[],L.dropped=0,Ft},M.remuxAudio=function(L,oe,ye,W,V){var we=L.inputTimeScale,Re=we/(L.samplerate?L.samplerate:we),Ce=L.segmentCodec==="aac"?1024:1152,ge=Ce*Re,qe=this._initPTS,tt=L.segmentCodec==="mp3"&&this.typeSupported.mpeg,ee=[],ue=V!==void 0,ie=L.samples,Oe=tt?0:8,xe=this.nextAudioPts||-1,Ne=oe*we;if(this.isAudioContiguous=ye=ye||ie.length&&xe>0&&(W&&Math.abs(Ne-xe)<9e3||Math.abs(U(ie[0].pts-qe,Ne)-xe)<20*ge),ie.forEach(function(he){he.pts=U(he.pts-qe,Ne)}),!ye||xe<0){if(ie=ie.filter(function(he){return he.pts>=0}),!ie.length)return;xe=V===0?0:W&&!ue?Math.max(0,Ne):ie[0].pts}if(L.segmentCodec==="aac")for(var Be=this.config.maxAudioFramesDrift,je=0,pe=xe;je<ie.length;je++){var Ie=ie[je],Ye=Ie.pts,rt=Ye-pe,yt=Math.abs(1e3*rt/we);if(rt<=-Be*ge&&ue)je===0&&(Z.logger.warn("Audio frame @ "+(Ye/we).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*rt/we)+" ms."),this.nextAudioPts=xe=pe=Ye);else if(rt>=Be*ge&&yt<1e4&&ue){var ht=Math.round(rt/ge);(pe=Ye-ht*ge)<0&&(ht--,pe+=ge),je===0&&(this.nextAudioPts=xe=pe),Z.logger.warn("[mp4-remuxer]: Injecting "+ht+" audio frame @ "+(pe/we).toFixed(3)+"s due to "+Math.round(1e3*rt/we)+" ms gap.");for(var It=0;It<ht;It++){var Dt=Math.max(pe,0),St=$.getSilentFrame(L.manifestCodec||L.codec,L.channelCount);St||(Z.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),St=Ie.unit.subarray()),ie.splice(je,0,{unit:St,pts:Dt}),pe+=ge,je++}}Ie.pts=pe,pe+=ge}for(var kt,gt=null,ut=null,Rt=0,Pt=ie.length;Pt--;)Rt+=ie[Pt].unit.byteLength;for(var jt=0,zt=ie.length;jt<zt;jt++){var Nt=ie[jt],dr=Nt.unit,J=Nt.pts;if(ut!==null)ee[jt-1].duration=Math.round((J-ut)/Re);else{if(ye&&L.segmentCodec==="aac"&&(J=xe),gt=J,!(Rt>0))return;Rt+=Oe;try{kt=new Uint8Array(Rt)}catch{return void this.observer.emit(k.Events.ERROR,k.Events.ERROR,{type:ve.ErrorTypes.MUX_ERROR,details:ve.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Rt,reason:"fail allocating audio mdat "+Rt})}tt||(new DataView(kt.buffer).setUint32(0,Rt),kt.set(w.types.mdat,4))}kt.set(dr,Oe);var O=dr.byteLength;Oe+=O,ee.push(new He(!0,Ce,O,0)),ut=J}var T=ee.length;if(T){var P=ee[ee.length-1];this.nextAudioPts=xe=ut+Re*P.duration;var D=tt?new Uint8Array(0):w.moof(L.sequenceNumber++,gt/Re,H({},L,{samples:ee}));L.samples=[];var F=gt/we,q=xe/we,Y={data1:D,data2:kt,startPTS:F,endPTS:q,startDTS:F,endDTS:q,type:"audio",hasAudio:!0,hasVideo:!1,nb:T};return this.isAudioContiguous=!0,Y}},M.remuxEmptyAudio=function(L,oe,ye,W){var V=L.inputTimeScale,we=V/(L.samplerate?L.samplerate:V),Re=this.nextAudioPts,Ce=(Re!==null?Re:W.startDTS*V)+this._initDTS,ge=W.endDTS*V+this._initDTS,qe=1024*we,tt=Math.ceil((ge-Ce)/qe),ee=$.getSilentFrame(L.manifestCodec||L.codec,L.channelCount);if(Z.logger.warn("[mp4-remuxer]: remux empty Audio"),ee){for(var ue=[],ie=0;ie<tt;ie++){var Oe=Ce+ie*qe;ue.push({unit:ee,pts:Oe,dts:Oe})}return L.samples=ue,this.remuxAudio(L,oe,ye,!1)}Z.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},E}();function U(E,M){var L;if(M===null)return E;for(L=M<E?-8589934592:8589934592;Math.abs(E-M)>4294967296;)E+=L;return E}function be(E,M,L,oe){var ye=E.samples.length;if(ye){for(var W=E.inputTimeScale,V=0;V<ye;V++){var we=E.samples[V];we.pts=U(we.pts-L,M*W)/W,we.dts=U(we.dts-oe,M*W)/W}var Re=E.samples;return E.samples=[],{samples:Re}}}function ke(E,M,L){var oe=E.samples.length;if(oe){for(var ye=E.inputTimeScale,W=0;W<oe;W++){var V=E.samples[W];V.pts=U(V.pts-L,M*ye)/ye}E.samples.sort(function(Re,Ce){return Re.pts-Ce.pts});var we=E.samples;return E.samples=[],{samples:we}}}var He=function(E,M,L,oe){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=M,this.size=L,this.cts=oe,this.flags=new K(E)},K=function(E){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=E?2:1,this.isNonSync=E?0:1}},856:(fe,re,N)=>{"use strict";var B;N.r(re),N.d(re,{MetadataSchema:()=>B}),function($){$.audioId3="org.id3",$.dateRange="com.apple.quicktime.HLS",$.emsg="https://aomedia.org/emsg/ID3"}(B||(B={}))},308:(fe,re,N)=>{"use strict";var B,$;N.r(re),N.d(re,{PlaylistContextType:()=>B,PlaylistLevelType:()=>$}),function(R){R.MANIFEST="manifest",R.LEVEL="level",R.AUDIO_TRACK="audioTrack",R.SUBTITLE_TRACK="subtitleTrack"}(B||(B={})),function(R){R.MAIN="main",R.AUDIO="audio",R.SUBTITLE="subtitle"}($||($={}))},300:(fe,re,N)=>{"use strict";N.r(re),N.d(re,{default:()=>B});let B={hexDump:function($){for(var R="",p=0;p<$.length;p++){var w=$[p].toString(16);w.length<2&&(w="0"+w),R+=w}return R}}},93:(fe,re,N)=>{"use strict";N.r(re),N.d(re,{enableLogs:()=>w,logger:()=>k});var B=function(){},$={trace:B,debug:B,log:B,warn:B,info:B,error:B},R=$;function p(ve){var Z=self.console[ve];return Z?Z.bind(self.console,"["+ve+"] >"):B}function w(ve,Z){if(self.console&&ve===!0||typeof ve=="object"){(function(le){for(var Te=arguments.length,H=new Array(Te>1?Te-1:0),ce=1;ce<Te;ce++)H[ce-1]=arguments[ce];H.forEach(function(z){R[z]=le[z]?le[z].bind(le):p(z)})})(ve,"debug","log","info","warn","error");try{R.log('Debug logs enabled for "'+Z+'"')}catch{R=$}}else R=$}var k=$},63:(fe,re,N)=>{"use strict";N.r(re),N.d(re,{RemuxerTrackIdConfig:()=>Z,appendUint8Array:()=>ye,bin2str:()=>le,computeRawDurationFromSamples:()=>M,discardEPB:()=>Re,findBox:()=>ne,getDuration:()=>E,getStartDTS:()=>K,mp4Box:()=>ge,mp4pssh:()=>qe,offsetStartDTS:()=>L,parseEmsg:()=>Ce,parseInitSegment:()=>be,parsePssh:()=>tt,parseSEIMessageFromNALu:()=>we,parseSamples:()=>W,parseSegmentIndex:()=>U,parseSinf:()=>He,patchEncyptionData:()=>ke,readSint32:()=>ce,readUint16:()=>Te,readUint32:()=>H,segmentValidRange:()=>oe,writeUint32:()=>z});var B=N(923),$=N(145),R=N(181),p=N(93),w=N(300),k=Math.pow(2,32)-1,ve=[].push,Z={video:1,audio:2,id3:3,text:4};function le(ee){return String.fromCharCode.apply(null,ee)}function Te(ee,ue){var ie=ee[ue]<<8|ee[ue+1];return ie<0?65536+ie:ie}function H(ee,ue){var ie=ce(ee,ue);return ie<0?4294967296+ie:ie}function ce(ee,ue){return ee[ue]<<24|ee[ue+1]<<16|ee[ue+2]<<8|ee[ue+3]}function z(ee,ue,ie){ee[ue]=ie>>24,ee[ue+1]=ie>>16&255,ee[ue+2]=ie>>8&255,ee[ue+3]=255&ie}function ne(ee,ue){var ie=[];if(!ue.length)return ie;for(var Oe=ee.byteLength,xe=0;xe<Oe;){var Ne=H(ee,xe),Be=Ne>1?xe+Ne:Oe;if(le(ee.subarray(xe+4,xe+8))===ue[0])if(ue.length===1)ie.push(ee.subarray(xe+8,Be));else{var je=ne(ee.subarray(xe+8,Be),ue.slice(1));je.length&&ve.apply(ie,je)}xe=Be}return ie}function U(ee){var ue=[],ie=ee[0],Oe=8,xe=H(ee,Oe);Oe+=4,Oe+=ie===0?8:16,Oe+=2;var Ne=ee.length+0,Be=Te(ee,Oe);Oe+=2;for(var je=0;je<Be;je++){var pe=Oe,Ie=H(ee,pe);pe+=4;var Ye=2147483647&Ie;if((2147483648&Ie)>>>31==1)return console.warn("SIDX has hierarchical references (not supported)"),null;var rt=H(ee,pe);pe+=4,ue.push({referenceSize:Ye,subsegmentDuration:rt,info:{duration:rt/xe,start:Ne,end:Ne+Ye-1}}),Ne+=Ye,Oe=pe+=4}return{earliestPresentationTime:0,timescale:xe,version:ie,referencesCount:Be,references:ue}}function be(ee){for(var ue=[],ie=ne(ee,["moov","trak"]),Oe=0;Oe<ie.length;Oe++){var xe=ie[Oe],Ne=ne(xe,["tkhd"])[0];if(Ne){var Be=Ne[0],je=Be===0?12:20,pe=H(Ne,je),Ie=ne(xe,["mdia","mdhd"])[0];if(Ie){var Ye=H(Ie,je=(Be=Ie[0])===0?12:20),rt=ne(xe,["mdia","hdlr"])[0];if(rt){var yt=le(rt.subarray(8,12)),ht={soun:B.ElementaryStreamTypes.AUDIO,vide:B.ElementaryStreamTypes.VIDEO}[yt];if(ht){var It=ne(xe,["mdia","minf","stbl","stsd"])[0],Dt=void 0;It&&(Dt=le(It.subarray(12,16))),ue[pe]={timescale:Ye,type:ht},ue[ht]={timescale:Ye,id:pe,codec:Dt}}}}}}return ne(ee,["moov","mvex","trex"]).forEach(function(St){var kt=H(St,4),gt=ue[kt];gt&&(gt.default={duration:H(St,12),flags:H(St,20)})}),ue}function ke(ee,ue){if(!ee||!ue)return ee;var ie=ue.keyId;return ie&&ue.isCommonEncryption&&ne(ee,["moov","trak"]).forEach(function(Oe){var xe=ne(Oe,["mdia","minf","stbl","stsd"])[0].subarray(8),Ne=ne(xe,["enca"]),Be=Ne.length>0;Be||(Ne=ne(xe,["encv"])),Ne.forEach(function(je){ne(Be?je.subarray(28):je.subarray(78),["sinf"]).forEach(function(pe){var Ie=He(pe);if(Ie){var Ye=Ie.subarray(8,24);Ye.some(function(rt){return rt!==0})||(p.logger.log("[eme] Patching keyId in 'enc"+(Be?"a":"v")+">sinf>>tenc' box: "+w.default.hexDump(Ye)+" -> "+w.default.hexDump(ie)),Ie.set(ie,8))}})})}),ee}function He(ee){var ue=ne(ee,["schm"])[0];if(ue){var ie=le(ue.subarray(4,8));if(ie==="cbcs"||ie==="cenc")return ne(ee,["schi","tenc"])[0]}return p.logger.error("[eme] missing 'schm' box"),null}function K(ee,ue){return ne(ue,["moof","traf"]).reduce(function(ie,Oe){var xe=ne(Oe,["tfdt"])[0],Ne=xe[0],Be=ne(Oe,["tfhd"]).reduce(function(je,pe){var Ie=H(pe,4),Ye=ee[Ie];if(Ye){var rt=H(xe,4);Ne===1&&(rt*=Math.pow(2,32),rt+=H(xe,8));var yt=rt/(Ye.timescale||9e4);if(isFinite(yt)&&(je===null||yt<je))return yt}return je},null);return Be!==null&&isFinite(Be)&&(ie===null||Be<ie)?Be:ie},null)||0}function E(ee,ue){for(var ie=0,Oe=0,xe=0,Ne=ne(ee,["moof","traf"]),Be=0;Be<Ne.length;Be++){var je=Ne[Be],pe=ne(je,["tfhd"])[0],Ie=ue[H(pe,4)];if(Ie){var Ye=Ie.default,rt=H(pe,0)|(Ye==null?void 0:Ye.flags),yt=Ye==null?void 0:Ye.duration;8&rt&&(yt=H(pe,2&rt?12:8));for(var ht=Ie.timescale||9e4,It=ne(je,["trun"]),Dt=0;Dt<It.length;Dt++)!(ie=M(It[Dt]))&&yt&&(ie=yt*H(It[Dt],4)),Ie.type===B.ElementaryStreamTypes.VIDEO?Oe+=ie/ht:Ie.type===B.ElementaryStreamTypes.AUDIO&&(xe+=ie/ht)}}if(Oe===0&&xe===0){for(var St=0,kt=ne(ee,["sidx"]),gt=0;gt<kt.length;gt++){var ut=U(kt[gt]);ut!=null&&ut.references&&(St+=ut.references.reduce(function(Rt,Pt){return Rt+Pt.info.duration||0},0))}return St}return Oe||xe}function M(ee){var ue=H(ee,0),ie=8;1&ue&&(ie+=4),4&ue&&(ie+=4);for(var Oe=0,xe=H(ee,4),Ne=0;Ne<xe;Ne++)256&ue&&(Oe+=H(ee,ie),ie+=4),512&ue&&(ie+=4),1024&ue&&(ie+=4),2048&ue&&(ie+=4);return Oe}function L(ee,ue,ie){ne(ue,["moof","traf"]).forEach(function(Oe){ne(Oe,["tfhd"]).forEach(function(xe){var Ne=H(xe,4),Be=ee[Ne];if(Be){var je=Be.timescale||9e4;ne(Oe,["tfdt"]).forEach(function(pe){var Ie=pe[0],Ye=H(pe,4);if(Ie===0)Ye-=ie*je,z(pe,4,Ye=Math.max(Ye,0));else{Ye*=Math.pow(2,32),Ye+=H(pe,8),Ye-=ie*je,Ye=Math.max(Ye,0);var rt=Math.floor(Ye/(k+1)),yt=Math.floor(Ye%(k+1));z(pe,4,rt),z(pe,8,yt)}})}})})}function oe(ee){var ue={valid:null,remainder:null},ie=ne(ee,["moof"]);if(!ie)return ue;if(ie.length<2)return ue.remainder=ee,ue;var Oe=ie[ie.length-1];return ue.valid=(0,$.sliceUint8)(ee,0,Oe.byteOffset-8),ue.remainder=(0,$.sliceUint8)(ee,Oe.byteOffset-8),ue}function ye(ee,ue){var ie=new Uint8Array(ee.length+ue.length);return ie.set(ee),ie.set(ue,ee.length),ie}function W(ee,ue){var ie=[],Oe=ue.samples,xe=ue.timescale,Ne=ue.id,Be=!1;return ne(Oe,["moof"]).map(function(je){var pe=je.byteOffset-8;ne(je,["traf"]).map(function(Ie){var Ye=ne(Ie,["tfdt"]).map(function(rt){var yt=rt[0],ht=H(rt,4);return yt===1&&(ht*=Math.pow(2,32),ht+=H(rt,8)),ht/xe})[0];return Ye!==void 0&&(ee=Ye),ne(Ie,["tfhd"]).map(function(rt){var yt=H(rt,4),ht=16777215&H(rt,0),It=0,Dt=(16&ht)!=0,St=0,kt=(32&ht)!=0,gt=8;yt===Ne&&((1&ht)!=0&&(gt+=8),(2&ht)!=0&&(gt+=4),(8&ht)!=0&&(It=H(rt,gt),gt+=4),Dt&&(St=H(rt,gt),gt+=4),kt&&(gt+=4),ue.type==="video"&&(Be=function(ut){if(!ut)return!1;var Rt=ut.indexOf("."),Pt=Rt<0?ut:ut.substring(0,Rt);return Pt==="hvc1"||Pt==="hev1"||Pt==="dvh1"||Pt==="dvhe"}(ue.codec)),ne(Ie,["trun"]).map(function(ut){var Rt=ut[0],Pt=16777215&H(ut,0),jt=(1&Pt)!=0,zt=0,Nt=(4&Pt)!=0,dr=(256&Pt)!=0,J=0,O=(512&Pt)!=0,T=0,P=(1024&Pt)!=0,D=(2048&Pt)!=0,F=0,q=H(ut,4),Y=8;jt&&(zt=H(ut,Y),Y+=4),Nt&&(Y+=4);for(var he=zt+pe,Le=0;Le<q;Le++){if(dr?(J=H(ut,Y),Y+=4):J=It,O?(T=H(ut,Y),Y+=4):T=St,P&&(Y+=4),D&&(F=Rt===0?H(ut,Y):ce(ut,Y),Y+=4),ue.type===B.ElementaryStreamTypes.VIDEO)for(var Ae=0;Ae<T;){var Me=H(Oe,he);V(Be,Oe[he+=4])&&we(Oe.subarray(he,he+Me),Be?2:1,ee+F/xe,ie),he+=Me,Ae+=Me+4}ee+=J/xe}}))})})}),ie}function V(ee,ue){if(ee){var ie=ue>>1&63;return ie===39||ie===40}return(31&ue)==6}function we(ee,ue,ie,Oe){var xe=Re(ee),Ne=0;Ne+=ue;for(var Be=0,je=0,pe=!1,Ie=0;Ne<xe.length;){Be=0;do{if(Ne>=xe.length)break;Be+=Ie=xe[Ne++]}while(Ie===255);je=0;do{if(Ne>=xe.length)break;je+=Ie=xe[Ne++]}while(Ie===255);var Ye=xe.length-Ne;if(!pe&&Be===4&&Ne<xe.length){if(pe=!0,xe[Ne++]===181){var rt=Te(xe,Ne);if(Ne+=2,rt===49){var yt=H(xe,Ne);if(Ne+=4,yt===1195456820){var ht=xe[Ne++];if(ht===3){var It=xe[Ne++],Dt=64&It,St=Dt?2+3*(31&It):0,kt=new Uint8Array(St);if(Dt){kt[0]=It;for(var gt=1;gt<St;gt++)kt[gt]=xe[Ne++]}Oe.push({type:ht,payloadType:Be,pts:ie,bytes:kt})}}}}}else if(Be===5&&je<Ye){if(pe=!0,je>16){for(var ut=[],Rt=0;Rt<16;Rt++){var Pt=xe[Ne++].toString(16);ut.push(Pt.length==1?"0"+Pt:Pt),Rt!==3&&Rt!==5&&Rt!==7&&Rt!==9||ut.push("-")}for(var jt=je-16,zt=new Uint8Array(jt),Nt=0;Nt<jt;Nt++)zt[Nt]=xe[Ne++];Oe.push({payloadType:Be,pts:ie,uuid:ut.join(""),userData:(0,R.utf8ArrayToStr)(zt),userDataBytes:zt})}}else if(je<Ye)Ne+=je;else if(je>Ye)break}}function Re(ee){for(var ue=ee.byteLength,ie=[],Oe=1;Oe<ue-2;)ee[Oe]===0&&ee[Oe+1]===0&&ee[Oe+2]===3?(ie.push(Oe+2),Oe+=2):Oe++;if(ie.length===0)return ee;var xe=ue-ie.length,Ne=new Uint8Array(xe),Be=0;for(Oe=0;Oe<xe;Be++,Oe++)Be===ie[0]&&(Be++,ie.shift()),Ne[Oe]=ee[Be];return Ne}function Ce(ee){var ue=ee[0],ie="",Oe="",xe=0,Ne=0,Be=0,je=0,pe=0,Ie=0;if(ue===0){for(;le(ee.subarray(Ie,Ie+1))!=="\0";)ie+=le(ee.subarray(Ie,Ie+1)),Ie+=1;for(ie+=le(ee.subarray(Ie,Ie+1)),Ie+=1;le(ee.subarray(Ie,Ie+1))!=="\0";)Oe+=le(ee.subarray(Ie,Ie+1)),Ie+=1;Oe+=le(ee.subarray(Ie,Ie+1)),Ie+=1,xe=H(ee,12),Ne=H(ee,16),je=H(ee,20),pe=H(ee,24),Ie=28}else if(ue===1){xe=H(ee,Ie+=4);var Ye=H(ee,Ie+=4),rt=H(ee,Ie+=4);for(Ie+=4,Be=Math.pow(2,32)*Ye+rt,Number.isSafeInteger(Be)||(Be=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),je=H(ee,Ie),pe=H(ee,Ie+=4),Ie+=4;le(ee.subarray(Ie,Ie+1))!=="\0";)ie+=le(ee.subarray(Ie,Ie+1)),Ie+=1;for(ie+=le(ee.subarray(Ie,Ie+1)),Ie+=1;le(ee.subarray(Ie,Ie+1))!=="\0";)Oe+=le(ee.subarray(Ie,Ie+1)),Ie+=1;Oe+=le(ee.subarray(Ie,Ie+1)),Ie+=1}return{schemeIdUri:ie,value:Oe,timeScale:xe,presentationTime:Be,presentationTimeDelta:Ne,eventDuration:je,id:pe,payload:ee.subarray(Ie,ee.byteLength)}}function ge(ee){for(var ue=arguments.length,ie=new Array(ue>1?ue-1:0),Oe=1;Oe<ue;Oe++)ie[Oe-1]=arguments[Oe];for(var xe=ie.length,Ne=8,Be=xe;Be--;)Ne+=ie[Be].byteLength;var je=new Uint8Array(Ne);for(je[0]=Ne>>24&255,je[1]=Ne>>16&255,je[2]=Ne>>8&255,je[3]=255&Ne,je.set(ee,4),Be=0,Ne=8;Be<xe;Be++)je.set(ie[Be],Ne),Ne+=ie[Be].byteLength;return je}function qe(ee,ue,ie){if(ee.byteLength!==16)throw new RangeError("Invalid system id");var Oe,xe,Ne;if(ue){Oe=1,xe=new Uint8Array(16*ue.length);for(var Be=0;Be<ue.length;Be++){var je=ue[Be];if(je.byteLength!==16)throw new RangeError("Invalid key");xe.set(je,16*Be)}}else Oe=0,xe=new Uint8Array;Oe>0?(Ne=new Uint8Array(4),ue.length>0&&new DataView(Ne.buffer).setUint32(0,ue.length,!1)):Ne=new Uint8Array;var pe=new Uint8Array(4);return ie&&ie.byteLength>0&&new DataView(pe.buffer).setUint32(0,ie.byteLength,!1),ge([112,115,115,104],new Uint8Array([Oe,0,0,0]),ee,Ne,xe,pe,ie||new Uint8Array)}function tt(ee){if(!(ee instanceof ArrayBuffer)||ee.byteLength<32)return null;var ue={version:0,systemId:"",kids:null,data:null},ie=new DataView(ee),Oe=ie.getUint32(0);if(ee.byteLength!==Oe&&Oe>44||ie.getUint32(4)!==1886614376||(ue.version=ie.getUint32(8)>>>24,ue.version>1))return null;ue.systemId=w.default.hexDump(new Uint8Array(ee,12,16));var xe=ie.getUint32(28);if(ue.version===0){if(Oe-32<xe)return null;ue.data=new Uint8Array(ee,32,xe)}else if(ue.version===1){ue.kids=[];for(var Ne=0;Ne<xe;Ne++)ue.kids.push(new Uint8Array(ee,32+16*Ne,16))}return ue}},673:(fe,re,N)=>{"use strict";function B(w,k,ve,Z){ve===void 0&&(ve=1),Z===void 0&&(Z=!1);var le=w*k*ve;return Z?Math.round(le):le}function $(w,k,ve,Z){return ve===void 0&&(ve=1),Z===void 0&&(Z=!1),B(w,k,1/ve,Z)}function R(w,k){return k===void 0&&(k=!1),B(w,1e3,11111111111111112e-21,k)}function p(w,k){return k===void 0&&(k=1),B(w,9e4,1/k)}N.r(re),N.d(re,{toMpegTsClockFromTimescale:()=>p,toMsFromMpegTsClock:()=>R,toTimescaleFromBase:()=>B,toTimescaleFromScale:()=>$})},145:(fe,re,N)=>{"use strict";function B($,R,p){return Uint8Array.prototype.slice?$.slice(R,p):new Uint8Array(Array.prototype.slice.call($,R,p))}N.r(re),N.d(re,{sliceUint8:()=>B})},729:fe=>{"use strict";var re=Object.prototype.hasOwnProperty,N="~";function B(){}function $(k,ve,Z){this.fn=k,this.context=ve,this.once=Z||!1}function R(k,ve,Z,le,Te){if(typeof Z!="function")throw new TypeError("The listener must be a function");var H=new $(Z,le||k,Te),ce=N?N+ve:ve;return k._events[ce]?k._events[ce].fn?k._events[ce]=[k._events[ce],H]:k._events[ce].push(H):(k._events[ce]=H,k._eventsCount++),k}function p(k,ve){--k._eventsCount==0?k._events=new B:delete k._events[ve]}function w(){this._events=new B,this._eventsCount=0}Object.create&&(B.prototype=Object.create(null),new B().__proto__||(N=!1)),w.prototype.eventNames=function(){var k,ve,Z=[];if(this._eventsCount===0)return Z;for(ve in k=this._events)re.call(k,ve)&&Z.push(N?ve.slice(1):ve);return Object.getOwnPropertySymbols?Z.concat(Object.getOwnPropertySymbols(k)):Z},w.prototype.listeners=function(k){var ve=N?N+k:k,Z=this._events[ve];if(!Z)return[];if(Z.fn)return[Z.fn];for(var le=0,Te=Z.length,H=new Array(Te);le<Te;le++)H[le]=Z[le].fn;return H},w.prototype.listenerCount=function(k){var ve=N?N+k:k,Z=this._events[ve];return Z?Z.fn?1:Z.length:0},w.prototype.emit=function(k,ve,Z,le,Te,H){var ce=N?N+k:k;if(!this._events[ce])return!1;var z,ne,U=this._events[ce],be=arguments.length;if(U.fn){switch(U.once&&this.removeListener(k,U.fn,void 0,!0),be){case 1:return U.fn.call(U.context),!0;case 2:return U.fn.call(U.context,ve),!0;case 3:return U.fn.call(U.context,ve,Z),!0;case 4:return U.fn.call(U.context,ve,Z,le),!0;case 5:return U.fn.call(U.context,ve,Z,le,Te),!0;case 6:return U.fn.call(U.context,ve,Z,le,Te,H),!0}for(ne=1,z=new Array(be-1);ne<be;ne++)z[ne-1]=arguments[ne];U.fn.apply(U.context,z)}else{var ke,He=U.length;for(ne=0;ne<He;ne++)switch(U[ne].once&&this.removeListener(k,U[ne].fn,void 0,!0),be){case 1:U[ne].fn.call(U[ne].context);break;case 2:U[ne].fn.call(U[ne].context,ve);break;case 3:U[ne].fn.call(U[ne].context,ve,Z);break;case 4:U[ne].fn.call(U[ne].context,ve,Z,le);break;default:if(!z)for(ke=1,z=new Array(be-1);ke<be;ke++)z[ke-1]=arguments[ke];U[ne].fn.apply(U[ne].context,z)}}return!0},w.prototype.on=function(k,ve,Z){return R(this,k,ve,Z,!1)},w.prototype.once=function(k,ve,Z){return R(this,k,ve,Z,!0)},w.prototype.removeListener=function(k,ve,Z,le){var Te=N?N+k:k;if(!this._events[Te])return this;if(!ve)return p(this,Te),this;var H=this._events[Te];if(H.fn)H.fn!==ve||le&&!H.once||Z&&H.context!==Z||p(this,Te);else{for(var ce=0,z=[],ne=H.length;ce<ne;ce++)(H[ce].fn!==ve||le&&!H[ce].once||Z&&H[ce].context!==Z)&&z.push(H[ce]);z.length?this._events[Te]=z.length===1?z[0]:z:p(this,Te)}return this},w.prototype.removeAllListeners=function(k){var ve;return k?(ve=N?N+k:k,this._events[ve]&&p(this,ve)):(this._events=new B,this._eventsCount=0),this},w.prototype.off=w.prototype.removeListener,w.prototype.addListener=w.prototype.on,w.prefixed=N,w.EventEmitter=w,fe.exports=w},945:function(fe){var re,N,B,$,R;re=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,N=/^(?=([^\/?#]*))\1([^]*)$/,B=/(?:\/|^)\.(?=\/)/g,$=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,R={buildAbsoluteURL:function(p,w,k){if(k=k||{},p=p.trim(),!(w=w.trim())){if(!k.alwaysNormalize)return p;var ve=R.parseURL(p);if(!ve)throw new Error("Error trying to parse base URL.");return ve.path=R.normalizePath(ve.path),R.buildURLFromParts(ve)}var Z=R.parseURL(w);if(!Z)throw new Error("Error trying to parse relative URL.");if(Z.scheme)return k.alwaysNormalize?(Z.path=R.normalizePath(Z.path),R.buildURLFromParts(Z)):w;var le=R.parseURL(p);if(!le)throw new Error("Error trying to parse base URL.");if(!le.netLoc&&le.path&&le.path[0]!=="/"){var Te=N.exec(le.path);le.netLoc=Te[1],le.path=Te[2]}le.netLoc&&!le.path&&(le.path="/");var H={scheme:le.scheme,netLoc:Z.netLoc,path:null,params:Z.params,query:Z.query,fragment:Z.fragment};if(!Z.netLoc&&(H.netLoc=le.netLoc,Z.path[0]!=="/"))if(Z.path){var ce=le.path,z=ce.substring(0,ce.lastIndexOf("/")+1)+Z.path;H.path=R.normalizePath(z)}else H.path=le.path,Z.params||(H.params=le.params,Z.query||(H.query=le.query));return H.path===null&&(H.path=k.alwaysNormalize?R.normalizePath(Z.path):Z.path),R.buildURLFromParts(H)},parseURL:function(p){var w=re.exec(p);return w?{scheme:w[1]||"",netLoc:w[2]||"",path:w[3]||"",params:w[4]||"",query:w[5]||"",fragment:w[6]||""}:null},normalizePath:function(p){for(p=p.split("").reverse().join("").replace(B,"");p.length!==(p=p.replace($,"")).length;);return p.split("").reverse().join("")},buildURLFromParts:function(p){return p.scheme+p.netLoc+p.path+p.params+p.query+p.fragment}},fe.exports=R}},te={};function Se(fe){var re=te[fe];if(re!==void 0)return re.exports;var N=te[fe]={exports:{}};return X[fe].call(N.exports,N,N.exports,Se),N.exports}Se.m=X,Se.n=fe=>{var re=fe&&fe.__esModule?()=>fe.default:()=>fe;return Se.d(re,{a:re}),re},Se.d=(fe,re)=>{for(var N in re)Se.o(re,N)&&!Se.o(fe,N)&&Object.defineProperty(fe,N,{enumerable:!0,get:re[N]})},Se.o=(fe,re)=>Object.prototype.hasOwnProperty.call(fe,re),Se.r=fe=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(fe,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(fe,"__esModule",{value:!0})};var De=Se(76);return De.default})())});var $i=ea(ta());var ia=ea(ra()),Wa=ia.default,lr=Wa;var hi=class extends Error{constructor(Se,De=hi.MEDIA_ERR_CUSTOM,fe){var re;super(Se);this.name="MediaError",this.code=De,this.fatal=fe!=null?fe:De>=hi.MEDIA_ERR_NETWORK&&De<=hi.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(re=hi.defaultMessages[this.code])!=null?re:"")}},ur=hi;ur.MEDIA_ERR_ABORTED=1,ur.MEDIA_ERR_NETWORK=2,ur.MEDIA_ERR_DECODE=3,ur.MEDIA_ERR_SRC_NOT_SUPPORTED=4,ur.MEDIA_ERR_ENCRYPTED=5,ur.MEDIA_ERR_CUSTOM=100,ur.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 Xa=X=>X==null,Dn=(X,te)=>Xa(te)?!1:X in te,Xi={ANY:"any",MUTED:"muted"},Ii={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Rn={MSE:"mse",NATIVE:"native"},zi={HEADER:"header",QUERY:"query",NONE:"none"},vs=Object.values(zi),Vr={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Qi={HLS:Vr.M3U8},ps=Object.keys(Qi),gs=[...Object.values(Vr),"hls","HLS"];var Rr=(X,te,Se,De,fe=X)=>{fe.addEventListener(te,Se,De),X.addEventListener("teardown",()=>{fe.removeEventListener(te,Se)},{once:!0})};function na(X,te,Se){te&&Se>te&&(Se=te);for(let De=0;De<X.length;De++)if(X.start(De)<=Se&&X.end(De)>=Se)return!0;return!1}var aa=X=>{let te=X.indexOf("?");if(te<0)return[X];let Se=X.slice(0,te),De=X.slice(te);return[Se,De]},In=X=>{let te=X.type;if(te){let De=te.toUpperCase();return Dn(De,Qi)?Qi[De]:te}let{src:Se}=X;return Se?za(Se):""},za=X=>{let te="";try{te=new URL(X).pathname}catch{console.error("invalid url")}let Se=te.lastIndexOf(".");if(Se<0)return"";let fe=te.slice(Se+1).toUpperCase();return Dn(fe,Vr)?Vr[fe]:""};var Qa=Object.values(Xi),sa=X=>typeof X=="boolean"||typeof X=="string"&&Qa.includes(X),oa=({autoplay:X},te,Se)=>{let De=!1,fe=!1,re=sa(X)?X:!!X,N=()=>{De||Rr(te,"playing",()=>{De=!0},{once:!0})};if(N(),Rr(te,"loadstart",()=>{De=!1,N(),Pn(te,re)},{once:!0}),Rr(te,"loadstart",()=>{Se||(fe=!Number.isFinite(te.duration)),Pn(te,re)},{once:!0}),Se&&Se.once(lr.Events.LEVEL_LOADED,($,R)=>{var p;fe=(p=R.details.live)!=null?p:!1}),!re){let $=()=>{!fe||(Se!=null&&Se.liveSyncPosition?te.currentTime=Se.liveSyncPosition:Number.isFinite(te.seekable.end(0))&&(te.currentTime=te.seekable.end(0)))};Se&&Rr(te,"play",()=>{te.preload==="metadata"?Se.once(lr.Events.LEVEL_UPDATED,$):$()},{once:!0})}return $=>{De||(re=sa($)?$:!!$,Pn(te,re))}},Pn=(X,te)=>{if(!te)return;let Se=X.muted,De=()=>X.muted=Se;switch(te){case Xi.ANY:X.play().catch(()=>{X.muted=!0,X.play().catch(De)});break;case Xi.MUTED:X.muted=!0,X.play().catch(De);break;default:X.play().catch(()=>{});break}};var la=({preload:X,src:te},Se,De)=>{let fe=w=>{w!=null&&["","none","metadata","auto"].includes(w)?Se.setAttribute("preload",w):Se.removeAttribute("preload")};if(!De)return fe(X),fe;let re=!1,N=!1,B=De.config.maxBufferLength,$=De.config.maxBufferSize,R=w=>{fe(w);let k=w!=null?w:Se.preload;N||k==="none"||(k==="metadata"?(De.config.maxBufferLength=1,De.config.maxBufferSize=1):(De.config.maxBufferLength=B,De.config.maxBufferSize=$),p())},p=()=>{!re&&te&&(re=!0,De.loadSource(te))};return Rr(Se,"play",()=>{N=!0,De.config.maxBufferLength=B,De.config.maxBufferSize=$,p()},{once:!0}),R(X),R};function ua(X,te){te.on(lr.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(fe,{tracks:re})=>{re.forEach(N=>{var R;let B=(R=N.subtitleTrack)!=null?R:N.closedCaptions,$=te.subtitleTracks.findIndex(({lang:p,name:w,type:k})=>p==(B==null?void 0:B.lang)&&w===N.label&&k.toLowerCase()===N.kind);Cn(X,N.kind,N.label,B==null?void 0:B.lang,`${N.kind}${$}`)})});let Se=()=>{var N;if(!te.subtitleTracks.length)return;let fe=Array.from(X.textTracks).find(B=>B.id&&B.mode==="showing"&&["subtitles","captions"].includes(B.kind)),re=`${(N=te.subtitleTracks[te.subtitleTrack])==null?void 0:N.type.toLowerCase()}${te.subtitleTrack}`;if(fe&&(te.subtitleTrack<0||(fe==null?void 0:fe.id)!==re)){let B=te.subtitleTracks.findIndex(({lang:$,name:R,type:p})=>$==fe.language&&R===fe.label&&p.toLowerCase()===fe.kind);te.subtitleTrack=B}fe&&(fe==null?void 0:fe.id)===re&&fe.cues&&Array.from(fe.cues).forEach(B=>{fe.addCue(B)})};X.textTracks.addEventListener("change",Se),te.on(lr.Events.CUES_PARSED,(fe,{track:re,cues:N})=>{let B=X.textTracks.getTrackById(re);if(!B)return;let $=B.mode==="disabled";$&&(B.mode="hidden"),N.forEach(R=>{var p;(p=B.cues)!=null&&p.getCueById(R.id)||B.addCue(R)}),$&&(B.mode="disabled")}),te.once(lr.Events.DESTROYING,()=>{X.textTracks.removeEventListener("change",Se),X.querySelectorAll("track[data-removeondestroy]").forEach(re=>{re.remove()})});let De=()=>{Array.from(X.textTracks).forEach(fe=>{var re,N;if(!["subtitles","caption"].includes(fe.kind)&&fe.label==="thumbnails"){if(!((re=fe.cues)!=null&&re.length)){let B=X.querySelector('track[label="thumbnails"]'),$=(N=B==null?void 0:B.getAttribute("src"))!=null?N:"";B==null||B.removeAttribute("src"),setTimeout(()=>{B==null||B.setAttribute("src",$)},0)}fe.mode!=="hidden"&&(fe.mode="hidden")}})};te.once(lr.Events.MANIFEST_LOADED,De),te.once(lr.Events.MEDIA_ATTACHED,De)}function Cn(X,te,Se,De,fe){let re=document.createElement("track");return re.kind=te,re.label=Se,De&&(re.srclang=De),fe&&(re.id=fe),re.track.mode=["subtitles","captions"].includes(te)?"disabled":"hidden",re.setAttribute("data-removeondestroy",""),X.append(re),re.track}function Ja(X,te){let Se=Array.prototype.find.call(X.querySelectorAll("track"),De=>De.track===te);Se==null||Se.remove()}var Pi="cuepoints",xn=Object.freeze({label:Pi}),Ji=(X,{label:te=Pi}=xn)=>{var Se;return(Se=Array.from(X.querySelectorAll("track")).find(De=>De.track.label===te&&De.track.kind==="metadata"))==null?void 0:Se.track};async function da(X,te,Se=xn){let De=Ji(X,Se);if(!De){let{label:fe=Pi}=Se;De=Cn(X,"metadata",fe),De.mode="hidden",await new Promise(re=>setTimeout(()=>re(void 0),0))}return De.mode!=="hidden"&&(De.mode="hidden"),[...te].sort(({time:fe},{time:re})=>re-fe).forEach(({time:fe,value:re})=>{var w,k;let N=Array.prototype.findIndex.call(De==null?void 0:De.cues,ve=>ve.startTime>=fe),B=(w=De==null?void 0:De.cues)==null?void 0:w[N],$=B?B.startTime:Number.isFinite(X.duration)?X.duration:Number.MAX_SAFE_INTEGER,R=(k=De==null?void 0:De.cues)==null?void 0:k[N-1];R&&(R.endTime=fe);let p=new VTTCue(fe,$,JSON.stringify(re!=null?re:null));De.addCue(p)}),De}var ca=X=>({time:X.startTime,value:JSON.parse(X.text)});function $a(X,te={label:Pi}){let Se=Ji(X,te);return Se!=null&&Se.cues?Array.from(Se.cues,De=>ca(De)):[]}function ha(X,te={label:Pi}){var De;let Se=Ji(X,te);if(!!((De=Se==null?void 0:Se.activeCues)!=null&&De.length))return ca(Se.activeCues[0])}async function fa(X,te=xn){return new Promise(Se=>{Rr(X,"loadstart",async()=>{let De=await da(X,[],te);Rr(X,"cuechange",()=>{let fe=ha(X);if(fe){let re=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:fe});X.dispatchEvent(re)}},{},De),Se(De)})})}var va,pa,Za=(pa=(va=globalThis==null?void 0:globalThis.navigator)==null?void 0:va.userAgent)!=null?pa:"",es=Za.toLowerCase().indexOf("android")!==-1,fi=new WeakMap,ya="mux.com",ga,ma,Ea=(ma=(ga=lr).isSupported)==null?void 0:ma.call(ga),ts=es,Hs=()=>$i.default.utils.now(),rs=$i.default.utils.generateUUID,Gs=(X,{domain:te=ya,maxResolution:Se=""}={})=>{if(!X)return;let[De,fe=""]=aa(X),re=new URL(`https://stream.${te}/${De}.m3u8${fe}`);return Se&&re.searchParams.set("max_resolution",Se),re.toString()},is=X=>{if(!X)return;let[te]=X.split("?");return te||void 0},ns=X=>{if(!X||!X.startsWith("https://stream."))return;let[te]=new URL(X).pathname.slice(1).split(".m3u8");return te||void 0},as=X=>{var te,Se,De;return(te=X==null?void 0:X.metadata)!=null&&te.video_id?X.metadata.video_id:ba(X)&&(De=(Se=is(X.playbackId))!=null?Se:ns(X.src))!=null?De:X.src},js=X=>{var te;return(te=fi.get(X))==null?void 0:te.error},Ks=(X,te,Se)=>{ss(te,Se);let{metadata:De={}}=X,{view_session_id:fe=rs()}=De,re=as(X);De.view_session_id=fe,De.video_id=re,X.metadata=De,fi.set(te,{});let N=os(X,te);us(X,te,N),ds(X,te,N),fa(te);let B=oa(X,te,N),$=la(X,te,N);return{engine:N,setAutoplay:B,setPreload:$}},ss=(X,te)=>{let Se=te==null?void 0:te.engine;Se&&(Se.detachMedia(),Se.destroy()),(X==null?void 0:X.mux)&&!X.mux.deleted&&(X.mux.destroy(),delete X.mux),X&&(X.removeAttribute("src"),X.load(),X.removeEventListener("error",Sa),X.removeEventListener("error",On),X.removeEventListener("durationchange",_a),fi.delete(X),X.dispatchEvent(new Event("teardown")))};function Ta(X,te){var R;let Se=In(X);if(!(Se===Vr.M3U8))return!0;let fe=!Se||((R=te.canPlayType(Se))!=null?R:!0),{preferPlayback:re}=X,N=re===Rn.MSE,B=re===Rn.NATIVE;return fe&&(B||!(Ea&&(N||ts)))}var os=(X,te)=>{let{debug:Se,streamType:De,startTime:fe=-1,metadata:re,preferCmcd:N}=X,$=In(X)===Vr.M3U8,R=Ta(X,te);if($&&!R&&Ea){let p={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},w=ls(De),k=N!==zi.NONE?{useHeaders:N===zi.HEADER,sessionId:re.view_session_id,contentId:re.video_id}:void 0;return new lr({debug:Se,startPosition:fe,cmcd:k,...p,...w})}},ls=X=>[Ii.LIVE,Ii.DVR].includes(X)?{backBufferLength:8}:[Ii.LL_LIVE,Ii.LL_DVR].includes(X)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},ba=({playbackId:X,src:te,customDomain:Se})=>{if(X)return!0;if(typeof te!="string")return!1;let De=window==null?void 0:window.location.href,fe=new URL(te,De).hostname.toLocaleLowerCase();return fe.includes(ya)||!!Se&&fe.includes(Se.toLocaleLowerCase())},us=(X,te,Se)=>{var re;let{envKey:De}=X,fe=ba(X);if(De||fe){let{playerInitTime:N,playerSoftwareName:B,playerSoftwareVersion:$,beaconCollectionDomain:R,debug:p,disableCookies:w}=X,k={...X.metadata,video_title:((re=X==null?void 0:X.metadata)==null?void 0:re.video_title)||void 0},ve=Z=>typeof Z.player_error_code=="string"?!1:typeof X.errorTranslator=="function"?X.errorTranslator(Z):Z;$i.default.monitor(te,{debug:p,beaconCollectionDomain:R,hlsjs:Se,Hls:Se?lr:void 0,automaticErrorTracking:!1,errorTranslator:ve,disableCookies:w,data:{...De?{env_key:De}:{},player_software_name:B,player_software:B,player_software_version:$,player_init_time:N,...k}})}},ds=(X,te,Se)=>{var re;let De=Ta(X,te),{src:fe}=X;te&&De?(typeof fe=="string"?(te.setAttribute("src",fe),X.startTime&&(((re=fi.get(te))!=null?re:{}).startTime=X.startTime,te.addEventListener("durationchange",_a,{once:!0}))):te.removeAttribute("src"),te.addEventListener("error",Sa),te.addEventListener("error",On),te.addEventListener("emptied",()=>{te.querySelectorAll("track[data-removeondestroy]").forEach(B=>{B.remove()})},{once:!0})):Se&&fe?(Se.on(lr.Events.ERROR,(N,B)=>{let $={[lr.ErrorTypes.NETWORK_ERROR]:ur.MEDIA_ERR_NETWORK,[lr.ErrorTypes.MEDIA_ERROR]:ur.MEDIA_ERR_DECODE},R=new ur("",$[B.type]);R.fatal=B.fatal,R.data=B,te.dispatchEvent(new CustomEvent("error",{detail:R}))}),te.addEventListener("error",On),ua(te,Se),Se.attachMedia(te)):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 _a(X){var De;let te=X.target,Se=(De=fi.get(te))==null?void 0:De.startTime;if(!!Se&&na(te.seekable,te.duration,Se)){let fe=te.preload==="auto";fe&&(te.preload="none"),te.currentTime=Se,fe&&(te.preload="auto")}}async function Sa(X){if(!X.isTrusted)return;X.stopImmediatePropagation();let te=X.target;if(!(te!=null&&te.error))return;let{message:Se,code:De}=te.error,fe=new ur(Se,De);if(te.src&&(De!==ur.MEDIA_ERR_DECODE||De!==void 0))try{let{status:re}=await fetch(te.src);fe.data={response:{code:re}}}catch{}te.dispatchEvent(new CustomEvent("error",{detail:fe}))}function On(X){var De,fe;if(!(X instanceof CustomEvent)||!(X.detail instanceof ur))return;let te=X.target,Se=X.detail;!Se||!Se.fatal||(((De=fi.get(te))!=null?De:{}).error=Se,(fe=te.mux)==null||fe.emit("error",{player_error_code:Se.code,player_error_message:Se.message}))}})();
|
|
42
|
+
`),f=[],v=(o=n.baseTime,(l=n.timescale)===void 0&&(l=1),jn(o,9e4,1/l)),m="00:00.000",T=0,S=0,y=!0;u.oncue=function(E){var R=e[t],A=e.ccOffset,C=(T-v)/9e4;R!=null&&R.new&&(S!==void 0?A=e.ccOffset=R.start:function(K,V,$){var X=K[V],le=K[X.prevCC];if(!le||!le.new&&X.new)return K.ccOffset=K.presentationOffset=X.start,void(X.new=!1);for(;(ye=le)!=null&&ye.new;){var ye;K.ccOffset+=X.start-le.start,X.new=!1,le=K[(X=le).prevCC]}K.presentationOffset=$}(e,t,C)),C&&(A=C-e.presentationOffset);var N=E.endTime-E.startTime,B=It(9e4*(E.startTime+A-S),9e4*r)/9e4;E.startTime=Math.max(B,0),E.endTime=Math.max(B+N,0);var Y=E.text.trim();E.text=decodeURIComponent(encodeURIComponent(Y)),E.id||(E.id=sa(E.startTime,E.endTime,Y)),E.endTime>0&&f.push(E)},u.onparsingerror=function(E){d=E},u.onflush=function(){d?a(d):i(f)},c.forEach(function(E){if(y){if(na(E,"X-TIMESTAMP-MAP=")){y=!1,E.slice(16).split(",").forEach(function(R){na(R,"LOCAL:")?m=R.slice(6):na(R,"MPEGTS:")&&(T=parseInt(R.slice(7)))});try{S=function(R){var A=parseInt(R.slice(-3)),C=parseInt(R.slice(-6,-4)),N=parseInt(R.slice(-9,-7)),B=R.length>9?parseInt(R.substring(0,R.indexOf(":"))):0;if(!(ee(A)&&ee(C)&&ee(N)&&ee(B)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+R);return A+=1e3*C,(A+=6e4*N)+36e5*B}(m)/1e3}catch(R){d=R}return}E===""&&(y=!1)}u.parse(E+`
|
|
43
|
+
`)}),u.flush()}var oa="stpp.ttml.im1t",as=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,ss=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Ko={left:"start",center:"center",right:"end",start:"start",end:"end"};function os(s,n,e,t){var r=xe(new Uint8Array(s),["mdat"]);if(r.length!==0){var i,a,o,l,d=r.map(function(c){return Tt(c)}),u=(i=n.baseTime,a=1,(o=n.timescale)===void 0&&(o=1),l===void 0&&(l=!1),jn(i,a,1/o,l));try{d.forEach(function(c){return e(function(f,v){var m=new DOMParser().parseFromString(f,"text/xml").getElementsByTagName("tt")[0];if(!m)throw new Error("Invalid ttml");var T={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(T).reduce(function(C,N){return C[N]=m.getAttribute("ttp:"+N)||T[N],C},{}),y=m.getAttribute("xml:space")!=="preserve",E=ls(la(m,"styling","style")),R=ls(la(m,"layout","region")),A=la(m,"body","[begin]");return[].map.call(A,function(C){var N=us(C,y);if(!N||!C.hasAttribute("begin"))return null;var B=da(C.getAttribute("begin"),S),Y=da(C.getAttribute("dur"),S),K=da(C.getAttribute("end"),S);if(B===null)throw ds(C);if(K===null){if(Y===null)throw ds(C);K=B+Y}var V=new ra(B-v,K-v,N);V.id=sa(V.startTime,V.endTime,V.text);var $=function(ye,oe,ve){var me="http://www.w3.org/ns/ttml#styling",ge=null,Le=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],De=ye!=null&&ye.hasAttribute("style")?ye.getAttribute("style"):null;return De&&ve.hasOwnProperty(De)&&(ge=ve[De]),Le.reduce(function(Oe,Ue){var yt=ua(oe,me,Ue)||ua(ye,me,Ue)||ua(ge,me,Ue);return yt&&(Oe[Ue]=yt),Oe},{})}(R[C.getAttribute("region")],E[C.getAttribute("style")],E),X=$.textAlign;if(X){var le=Ko[X];le&&(V.lineAlign=le),V.align=X}return z(V,$),V}).filter(function(C){return C!==null})}(c,u))})}catch(c){t(c)}}else t(new Error("Could not parse IMSC1 mdat"))}function la(s,n,e){var t=s.getElementsByTagName(n)[0];return t?[].slice.call(t.querySelectorAll(e)):[]}function ls(s){return s.reduce(function(n,e){var t=e.getAttribute("xml:id");return t&&(n[t]=e),n},{})}function us(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?us(t,n):n?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function ua(s,n,e){return s&&s.hasAttributeNS(n,e)?s.getAttributeNS(n,e):null}function ds(s){return new Error("Could not parse ttml timestamp "+s)}function da(s,n){if(!s)return null;var e=rs(s);return e===null&&(as.test(s)?e=function(t,r){var i=as.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):ss.test(s)&&(e=function(t,r){var i=ss.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 qo=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 hn(this,"textTrack1"),r=new hn(this,"textTrack2"),i=new hn(this,"textTrack3"),a=new hn(this,"textTrack4");this.cea608Parser1=new es(1,t,r),this.cea608Parser2=new es(3,i,a)}e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(_.FRAG_LOADING,this.onFragLoading,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this),e.on(_.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(_.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(_.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(_.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this)}var n=s.prototype;return n.destroy=function(){var e=this.hls;e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(_.FRAG_LOADING,this.onFragLoading,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this),e.off(_.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(_.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(_.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(_.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},n.addCues=function(e,t,r,i,a){for(var o,l,d,u,c=!1,f=a.length;f--;){var v=a[f],m=(o=v[0],l=v[1],d=t,u=r,Math.min(l,u)-Math.max(o,d));if(m>=0&&(v[0]=Math.min(v[0],t),v[1]=Math.max(v[1],r),c=!0,m/(r-t)>.5))return}if(c||a.push([t,r]),this.config.renderTextTracksNatively){var T=this.captionsTracks[e];this.Cues.newCue(T,t,r,i)}else{var S=this.Cues.newCue(null,t,r,i);this.hls.trigger(_.CUES_PARSED,{type:"captions",cues:S,track:e})}},n.onInitPtsFound=function(e,t){var r=this,i=t.frag,a=t.id,o=t.initPTS,l=t.timescale,d=this.unparsedVttFrags;a==="main"&&(this.initPTS[i.cc]={baseTime:o,timescale:l}),d.length&&(this.unparsedVttFrags=[],d.forEach(function(u){r.onFragLoaded(_.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,ir(r[e]),Or(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(_.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){ir(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++)ir(t[r])}},n.onSubtitleTracksUpdated=function(e,t){var r=this,i=t.subtitleTracks||[],a=i.some(function(d){return d.textCodec===oa});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){if(Ya(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(Vo(o[v],d)){f=o[v];break}f&&(c=f)}if(c)ir(c);else{var m=r._captionsOrSubtitlesFromCharacteristics(d);(c=r.createTextTrack(m,d.name,d.lang))&&(c.mode="disabled")}c&&(c.groupId=d.groupId,r.textTracks.push(c))})}else if(this.tracks.length){var l=this.tracks.map(function(d){return{label:d.name,kind:d.type.toLowerCase(),default:d.default,subtitleTrack:d}});this.hls.trigger(_.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}},n._captionsOrSubtitlesFromCharacteristics=function(e){if(e.attrs.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),r=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&r)return"captions"}return"subtitles"},n.onManifestLoaded=function(e,t){var r=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(function(i){var a=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(a){var o="textTrack"+a[1],l=r.captionsProperties[o];l&&(l.label=i.name,i.lang&&(l.languageCode=i.lang),l.media=i)}})},n.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]},n.onFragLoading=function(e,t){var r=this.cea608Parser1,i=this.cea608Parser2,a=this.lastSn,o=this.lastPartIndex;if(this.enabled&&r&&i&&t.frag.type===Me){var l,d,u=t.frag.sn,c=(l=t==null||(d=t.part)==null?void 0:d.index)!=null?l:-1;u===a+1||u===a&&c===o+1||(r.reset(),i.reset()),this.lastSn=u,this.lastPartIndex=c}},n.onFragLoaded=function(e,t){var r=t.frag,i=t.payload,a=this.initPTS,o=this.unparsedVttFrags;if(r.type===At)if(i.byteLength){if(!a[r.cc])return o.push(t),void(a.length&&this.hls.trigger(_.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===oa?this._parseIMSC1(r,i):this._parseVTTs(r,i,c)}}else this.hls.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},n._parseIMSC1=function(e,t){var r=this,i=this.hls;os(t,this.initPTS[e.cc],function(a){r._appendCues(a,e.level),i.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(a){P.log("Failed to parse IMSC1: "+a),i.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:a})})},n._parseVTTs=function(e,t,r){var i,a=this,o=this.hls;Go((i=e.initSegment)!=null&&i.data?Kt(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(_.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(l){a._fallbackToIMSC1(e,t),P.log("Failed to parse VTT cue: "+l),o.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:l})})},n._fallbackToIMSC1=function(e,t){var r=this,i=this.tracks[e.level];i.textCodec||os(t,this.initPTS[e.cc],function(){i.textCodec=oa,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 Zi(i,l)})}else{var a=this.tracks[t];if(!a)return;var o=a.default?"default":"subtitles"+t;r.trigger(_.CUES_PARSED,{type:"subtitles",cues:e,track:o})}},n.onFragDecrypted=function(e,t){var r=t.frag;if(r.type===At){if(!this.initPTS[r.cc])return void this.unparsedVttFrags.push(t);this.onFragLoaded(_.FRAG_LOADED,t)}},n.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},n.onFragParsingUserdata=function(e,t){var r=this.cea608Parser1,i=this.cea608Parser2;if(this.enabled&&r&&i){var a=t.frag,o=t.samples;if(a.type!==Me||this.closedCaptionsForLevel(a)!=="NONE")for(var l=0;l<o.length;l++){var d=o[l].bytes;if(d){var u=this.extractCea608Data(d);r.addData(o[l].pts,u[0]),i.addData(o[l].pts,u[1])}}}},n.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.endOffsetSubtitles,o=t.type,l=this.media;if(l&&!(l.currentTime<i)){if(!o||o==="video"){var d=this.captionsTracks;Object.keys(d).forEach(function(c){return Xe(d[c],r,i)})}if(this.config.renderTextTracksNatively&&r===0&&a!==void 0){var u=this.textTracks;Object.keys(u).forEach(function(c){return Xe(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 Vo(s,n){return!!s&&s.label===n.name&&!(s.textTrack1||s.textTrack2)}var jo=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(_.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this)},n.unregisterListener=function(){var e=this.hls;e.off(_.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.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}(),Wo=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(_.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.unregisterListeners=function(){this.hls.off(_.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(_.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(_.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]",cs=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(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(_.MANIFEST_LOADED,this.onManifestLoaded,this)},n.unregisterListeners=function(){this.hls.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(_.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(_.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===qe.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:re.KEY_SYSTEM_ERROR,details:M.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 ti===null&&self.location.protocol==="http:"&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(i))}return r(e,t)},n.getMediaKeysPromise=function(e,t,r){var i=this,a=function(u,c,f,v){var m;switch(u){case qe.FAIRPLAY:m=["cenc","sinf"];break;case qe.WIDEVINE:case qe.PLAYREADY:m=["cenc"];break;case qe.CLEARKEY:m=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+u)}return function(T,S,y,E){return[{initDataTypes:T,persistentState:E.persistentState||"not-allowed",distinctiveIdentifier:E.distinctiveIdentifier||"not-allowed",sessionTypes:E.sessionTypes||[E.sessionType||"temporary"],audioCapabilities:S.map(function(R){return{contentType:'audio/mp4; codecs="'+R+'"',robustness:E.audioRobustness||"",encryptionScheme:E.audioEncryptionScheme||null}}),videoCapabilities:y.map(function(R){return{contentType:'video/mp4; codecs="'+R+'"',robustness:E.videoRobustness||"",encryptionScheme:E.videoEncryptionScheme||null}})}]}(m,c,f,v)}(e,t,r,this.config.drmSystemOptions),o=this.keySystemAccessPromises[e],l=o==null?void 0:o.keySystemAccess;if(!l){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(a)),l=this.requestMediaKeySystemAccess(e,a);var d=this.keySystemAccessPromises[e]={keySystemAccess:l};return l.catch(function(u){i.log('Failed to obtain access to key-system "'+e+'": '+u)}),l.then(function(u){i.log('Access for key-system "'+u.keySystem+'" obtained');var c=i.fetchServerCertificate(e);return i.log('Create media-keys for "'+e+'"'),d.mediaKeys=u.createMediaKeys().then(function(f){return i.log('Media-keys created for "'+e+'"'),c.then(function(v){return v?i.setMediaKeysServerCertificate(f,e,v):f})}),d.mediaKeys.catch(function(f){i.error('Failed to create media-keys for "'+e+'"}: '+f)}),d.mediaKeys})}return l.then(function(){return o.mediaKeys})},n.createMediaKeySessionContext=function(e){var t=e.decryptdata,r=e.keySystem,i=e.mediaKeys;this.log('Creating key-system session "'+r+'" keyId: '+Et(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 Et(e.keyId)},n.updateKeySession=function(e,t){var r,i=e.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+Et(((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=ei(t.config),o=e.map($r).filter(function(l){return!!l&&a.indexOf(l)!==-1});return t.getKeySystemSelectionPromise(o).then(function(l){var d=l.keySystem,u=Zr(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(_.ERROR,e.data):this.hls.trigger(_.ERROR,{type:re.KEY_SYSTEM_ERROR,details:M.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=$r(e.keyFormat),a=i?[i]:ei(this.config);return this.attemptKeySystemAccess(a)}return r},n.getKeySystemSelectionPromise=function(e){if(e.length||(e=ei(this.config)),e.length===0)throw new xt({type:re.KEY_SYSTEM_ERROR,details:M.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[qe.FAIRPLAY]){var l=et(new Uint8Array(i));try{var d=Xr(JSON.parse(l).sinf),u=oi(new Uint8Array(d));if(!u)return;a=u.subarray(8,24),o=qe.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var c=function(R){if(!(R instanceof ArrayBuffer)||R.byteLength<32)return null;var A={version:0,systemId:"",kids:null,data:null},C=new DataView(R),N=C.getUint32(0);if(R.byteLength!==N&&N>44||C.getUint32(4)!==1886614376||(A.version=C.getUint32(8)>>>24,A.version>1))return null;A.systemId=Et(new Uint8Array(R,12,16));var B=C.getUint32(28);if(A.version===0){if(N-32<B)return null;A.data=new Uint8Array(R,32,B)}else if(A.version===1){A.kids=[];for(var Y=0;Y<B;Y++)A.kids.push(new Uint8Array(R,32+16*Y,16))}return A}(i);if(c===null)return;c.version===0&&c.systemId===Ii&&c.data&&(a=c.data.subarray(8,24)),o=function(R){if(R===Ii)return qe.WIDEVINE}(c.systemId)}if(o&&a){for(var f=Et(a),v=this.keyIdToKeySessionPromise,m=this.mediaKeySessions,T=v[f],S=function(){var R=m[y],A=R.decryptdata;if(A.pssh||!A.keyId)return"continue";var C=Et(A.keyId);return f===C||A.uri.replace(/-/g,"").indexOf(f)!==-1?(T=v[C],delete v[C],A.pssh=new Uint8Array(i),A.keyId=a,T=v[f]=T.then(function(){return t.generateRequestWithPreferredKeySession(R,r,i,"encrypted-event-key-match")}),"break"):void 0},y=0;y<m.length;y++){var E=S();if(E!=="continue"&&E==="break")break}T||(T=v[f]=this.getKeySystemSelectionPromise([o]).then(function(R){var A,C=R.keySystem,N=R.mediaKeys;t.throwIfDestroyed();var B=new Dr("ISO-23001-7",f,(A=Zr(C))!=null?A:"");return B.pssh=new Uint8Array(i),B.keyId=a,t.attemptSetMediaKeys(C,N).then(function(){t.throwIfDestroyed();var Y=t.createMediaKeySessionContext({decryptdata:B,keySystem:C,mediaKeys:N});return t.generateRequestWithPreferredKeySession(Y,r,i,"encrypted-event-no-match")})})),T.catch(function(R){return t.handleError(R)})}}},n._onWaitingForKey=function(e){this.log('"'+e.type+'" event')},n.attemptSetMediaKeys=function(e,t){var r=this,i=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var a=Promise.all(i).then(function(){if(!r.media)throw new Error("Attempted to set mediaKeys without media element attached");return r.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(a),a.then(function(){r.log('Media-keys set for "'+e+'"'),i.push(a),r.setMediaKeysQueue=r.setMediaKeysQueue.filter(function(o){return i.indexOf(o)===-1})})},n.generateRequestWithPreferredKeySession=function(e,t,r,i){var a,o,l=this,d=(a=this.config.drmSystems)==null||(o=a[e.keySystem])==null?void 0:o.generateRequest;if(d)try{var u=d.call(this.hls,t,r,e);if(!u)throw new Error("Invalid response from configured generateRequest filter");t=u.initDataType,r=e.decryptdata.pssh=u.initData?new Uint8Array(u.initData):null}catch(T){var c;if(this.warn(T.message),(c=this.hls)!=null&&c.config.debug)throw T}if(r===null)return this.log('Skipping key-session request for "'+i+'" (no initData)'),Promise.resolve(e);var f=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'+i+'": '+f+" (init data type: "+t+" length: "+(r?r.byteLength:null)+")");var v=new cn;e.mediaKeysSession.onmessage=function(T){var S=e.mediaKeysSession;if(S){var y=T.messageType,E=T.message;l.log('"'+y+'" message event for session "'+S.sessionId+'" message size: '+E.byteLength),y==="license-request"||y==="license-renewal"?l.renewLicense(e,E).catch(function(R){l.handleError(R),v.emit("error",R)}):y==="license-release"?e.keySystem===qe.FAIRPLAY&&(l.updateKeySession(e,Di("acknowledged")),l.removeSession(e)):l.warn('unhandled media key message type "'+y+'"')}else v.emit("error",new Error("invalid state"))},e.mediaKeysSession.onkeystatuseschange=function(T){if(e.mediaKeysSession){l.onKeyStatusChange(e);var S=e.keyStatus;v.emit("keyStatus",S),S==="expired"&&(l.warn(e.keySystem+" expired for key "+f),l.renewKeySession(e))}else v.emit("error",new Error("invalid state"))};var m=new Promise(function(T,S){v.on("error",S),v.on("keyStatus",function(y){y.startsWith("usable")?T():y==="output-restricted"?S(new xt({type:re.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):y==="internal-error"?S(new xt({type:re.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+y+'"')):y==="expired"?S(new Error("key expired while generating request")):l.warn('unhandled key status change "'+y+'"')})});return e.mediaKeysSession.generateRequest(t,r).then(function(){var T;l.log('Request generated for key-session "'+((T=e.mediaKeysSession)==null?void 0:T.sessionId)+'" keyId: '+f)}).catch(function(T){throw new xt({type:re.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_SESSION,error:T,fatal:!1},"Error generating key-session request: "+T)}).then(function(){return m}).catch(function(T){throw v.removeAllListeners(),l.removeSession(e),T}).then(function(){return v.removeAllListeners(),e})},n.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach(function(r,i){t.log('key status change "'+r+'" for keyStatuses keyId: '+Et("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))+" session keyId: "+Et(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=r})},n.fetchServerCertificate=function(e){var t=this.config,r=new t.loader(t),i=this.getServerCertificateUrl(e);return i?(this.log('Fetching serverCertificate for "'+e+'"'),new Promise(function(a,o){var l={responseType:"arraybuffer",url:i},d=t.certLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:function(f,v,m,T){a(f.data)},onError:function(f,v,m,T){o(new xt({type:re.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:G({url:l.url,data:void 0},f)},'"'+e+'" certificate request failed ('+i+"). Status: "+f.code+" ("+f.text+")"))},onTimeout:function(f,v,m){o(new xt({type:re.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},'"'+e+'" certificate request timed out ('+i+")"))},onAbort:function(f,v,m){o(new Error("aborted"))}};r.load(l,u,c)})):Promise.resolve()},n.setMediaKeysServerCertificate=function(e,t,r){var i=this;return new Promise(function(a,o){e.setServerCertificate(r).then(function(l){i.log("setServerCertificate "+(l?"success":"not supported by CDM")+" ("+(r==null?void 0:r.byteLength)+') on "'+t+'"'),a(e)}).catch(function(l){o(new xt({type:re.KEY_SYSTEM_ERROR,details:M.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:re.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:a,fatal:!0},a.message)})})},n.setupLicenseXHR=function(e,t,r,i){var a=this,o=this.config.licenseXhrSetup;return o?Promise.resolve().then(function(){if(!r.decryptdata)throw new Error("Key removed");return o.call(a.hls,e,t,r,i)}).catch(function(l){if(!r.decryptdata)throw l;return e.open("POST",t,!0),o.call(a.hls,e,t,r,i)}).then(function(l){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:l||i}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))},n.requestLicense=function(e,t){var r=this,i=this.config.keyLoadPolicy.default;return new Promise(function(a,o){var l=r.getLicenseServerUrl(e.keySystem);r.log("Sending license request to URL: "+l);var d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=function(){if(!r.hls||!e.mediaKeysSession)return o(new Error("invalid state"));if(d.readyState===4)if(d.status===200){r._requestLicenseFailureCount=0;var u=d.response;r.log("License received "+(u instanceof ArrayBuffer?u.byteLength:u));var c=r.config.licenseResponseCallback;if(c)try{u=c.call(r.hls,d,l,e)}catch(T){r.error(T)}a(u)}else{var f=i.errorRetry,v=f?f.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>v||d.status>=400&&d.status<500)o(new xt({type:re.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:l,data:void 0,code:d.status,text:d.statusText}},"License Request XHR failed ("+l+"). Status: "+d.status+" ("+d.statusText+")"));else{var m=v-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+m+" attempts left"),r.requestLicense(e,t).then(a,o)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=d,r.setupLicenseXHR(d,l,e,t).then(function(u){var c=u.xhr,f=u.licenseChallenge;c.send(f)})})},n.onMediaAttached=function(e,t){if(this.config.emeEnabled){var r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}},n.onMediaDetached=function(){var e=this,t=this.media,r=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Dr.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}();cs.CDMCleanupPromise=void 0;var xt=function(s){function n(e,t){var r;return(r=s.call(this,t)||this).data=void 0,e.error||(e.error=new Error(t)),r.data=e,e.err=e.error,r}return ne(n,s),n}(Ie(Error)),Yo="m",gn="a",ca="v",ha="av",hs="i",zo="tt",Xo=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:Yo,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!==ca&&d!==gn&&d!=ha||(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(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHED,this.onMediaDetached,this),e.on(_.BUFFER_CREATED,this.onBufferCreated,this)},n.unregisterListeners=function(){var e=this.hls;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHED,this.onMediaDetached,this),e.off(_.BUFFER_CREATED,this.onBufferCreated,this)},n.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},n.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},n.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},n.onBufferCreated=function(e,t){var r,i;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(i=t.tracks.video)==null?void 0:i.buffer},n.createData=function(){var e;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},n.apply=function(e,t){t===void 0&&(t={}),z(t,this.createData());var r=t.ot===hs||t.ot===ca||t.ot===ha;if(this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){var i=s.toHeaders(t);if(!Object.keys(i).length)return;e.headers||(e.headers={}),z(e.headers,i)}else{var a=s.toQuery(t);if(!a)return;e.url=s.appendQueryToUri(e.url,a)}},n.getObjectType=function(e){var t=e.type;return t==="subtitle"?zo:e.sn==="initSegment"?hs:t==="audio"?gn:t==="main"?this.hls.audioTracks.length?ca:ha:void 0},n.getTopBandwidth=function(e){var t,r=0,i=this.hls;if(e===gn)t=i.audioTracks;else{var a=i.maxAutoLevel,o=a>-1?a+1:i.levels.length;t=i.levels.slice(0,o)}for(var l,d=ke(t);!(l=d()).done;){var u=l.value;u.bitrate>r&&(r=u.bitrate)}return r>0?r:NaN},n.getBufferLength=function(e){var t=this.hls.media,r=e===gn?this.audioBuffer:this.videoBuffer;return r&&t?1e3*ue.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(T){return!Number.isNaN(T)&&T!=null&&T!==""&&T!==!1},a=function(T){return Math.round(T)},o=function(T){return 100*a(T/100)},l={br:a,d:a,bl:o,dl:o,mtp:o,nor:function(T){return encodeURIComponent(T)},rtp:o,tb:a},d=ke(Object.keys(e||{}).sort());!(t=d()).done;){var u=t.value,c=e[u];if(i(c)&&!(u==="v"&&c===1||u=="pr"&&c===1)){var f=l[u];f&&(c=f(c));var v=typeof c,m=void 0;m=u==="ot"||u==="sf"||u==="st"?u+"="+c:v==="boolean"?u:v==="number"?u+"="+c:u+"="+JSON.stringify(c),r.push(m)}}return r.join(",")},s.toHeaders=function(e){for(var t={},r=["Object","Request","Session","Status"],i=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},o=0,l=Object.keys(e);o<l.length;o++){var d=l[o];i[a[d]!=null?a[d]:1][d]=e[d]}for(var u=0;u<i.length;u++){var c=s.serialize(i[u]);c&&(t["CMCD-"+r[u]]=c)}return t},s.toQuery=function(e){return"CMCD="+encodeURIComponent(s.serialize(e))},s.appendQueryToUri=function(e,t){if(!t)return e;var r=e.includes("?")?"&":"?";return""+e+r+t},s}(),Qo=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(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.ERROR,this.onError,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.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)===Ze&&r.flags===Gr){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(_.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[l];d&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==d.bitrate&&this.log("Unstable Pathways change from bitrate "+d.bitrate+" to "+u.bitrate),this.hls.nextLoadLevel=l);break}}}},n.clonePathways=function(e){var t=this,r=this.levels;if(r){var i={},a={};e.forEach(function(o){var l=o.ID,d=o["BASE-ID"],u=o["URI-REPLACEMENT"];if(!r.some(function(f){return f.pathwayId===l})){var c=t.getLevelsForPathway(d).map(function(f){var v=z({},f);v.details=void 0,v.url=vs(f.uri,f.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",u);var m=new Be(f.attrs);m["PATHWAY-ID"]=l;var T=m.AUDIO&&m.AUDIO+"_clone_"+l,S=m.SUBTITLES&&m.SUBTITLES+"_clone_"+l;T&&(i[m.AUDIO]=T,m.AUDIO=T),S&&(a[m.SUBTITLES]=S,m.SUBTITLES=S),v.attrs=m;var y=new hr(v);return L(y,"audio",T),L(y,"text",S),y});r.push.apply(r,c),fs(t.audioTracks,i,u,l),fs(t.subtitleTracks,a,u,l)}})}},n.loadSteeringManifest=function(e){var t,r=this,i=this.hls.config,a=i.loader;this.loader&&this.loader.destroy(),this.loader=new a(i);try{t=new self.URL(e)}catch{return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if(t.protocol!=="data:"){var o=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+o)}var l={responseType:"json",url:t.href},d=i.steeringManifestLoadPolicy.default,u=d.errorRetry||d.timeoutRetry||{},c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},f={onSuccess:function(v,m,T,S){r.log('Loaded steering manifest: "'+t+'"');var y=v.data;if(y.VERSION===1){r.updated=performance.now(),r.timeToLoad=y.TTL;var E=y["RELOAD-URI"],R=y["PATHWAY-CLONES"],A=y["PATHWAY-PRIORITY"];if(E)try{r.uri=new self.URL(E,t).href}catch{return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+E)}r.scheduleRefresh(r.uri||T.url),R&&r.clonePathways(R),A&&r.updatePathwayPriority(A)}else r.log("Steering VERSION "+y.VERSION+" not supported!")},onError:function(v,m,T,S){if(r.log("Error loading steering manifest: "+v.code+" "+v.text+" ("+m.url+")"),r.stopLoad(),v.code===410)return r.enabled=!1,void r.log("Steering manifest "+m.url+" no longer available");var y=1e3*r.timeToLoad;if(v.code!==429)r.scheduleRefresh(r.uri||m.url,y);else{var E=r.loader;if(typeof(E==null?void 0:E.getResponseHeader)=="function"){var R=E.getResponseHeader("Retry-After");R&&(y=1e3*parseFloat(R))}r.log("Steering manifest "+m.url+" rate limited")}},onTimeout:function(v,m,T){r.log("Timeout loading steering manifest ("+m.url+")"),r.scheduleRefresh(r.uri||m.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(l,c,f)},n.scheduleRefresh=function(e,t){var r=this;t===void 0&&(t=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(function(){r.loadSteeringManifest(e)},t)},s}();function fs(s,n,e,t){s&&Object.keys(n).forEach(function(r){var i=s.filter(function(a){return a.groupId===r}).map(function(a){var o=z({},a);return o.details=void 0,o.attrs=new Be(o.attrs),o.url=o.attrs.URI=vs(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 vs(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 Jo=/^age:\s*[\d.]+\s*$/im,gs=function(){function s(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Mt,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&&ee(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;Br(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(Br(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=yi(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&&Jo.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}(),$o=/(\d+)-(\d+)\/(\d+)/,ps=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||Zo,this.controller=new self.AbortController,this.stats=new Mt}var n=s.prototype;return n.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},n.abortInternal=function(){var e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},n.load=function(e,t,r){var i=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var o=function(m,T){var S={method:"GET",mode:"cors",credentials:"same-origin",signal:T,headers:new self.Headers(z({},m.headers))};return m.rangeEnd&&S.headers.set("Range","bytes="+m.rangeStart+"-"+String(m.rangeEnd-1)),S}(e,this.controller.signal),l=r.onProgress,d=e.responseType==="arraybuffer",u=d?"byteLength":"length",c=t.loadPolicy,f=c.maxTimeToFirstByteMs,v=c.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,o),self.clearTimeout(this.requestTimeout),t.timeout=f&&ee(f)?f:v,this.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(a,e,i.response)},t.timeout),self.fetch(this.request).then(function(m){i.response=i.loader=m;var T=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=v,i.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(a,e,i.response)},v-(T-a.loading.start)),!m.ok){var S=m.status,y=m.statusText;throw new el(y||"fetch, bad network response",S,m)}return a.loading.first=T,a.total=function(E){var R=E.get("Content-Range");if(R){var A=function(N){var B=$o.exec(N);if(B)return parseInt(B[2])-parseInt(B[1])+1}(R);if(ee(A))return A}var C=E.get("Content-Length");if(C)return parseInt(C)}(m.headers)||a.total,l&&ee(t.highWaterMark)?i.loadProgressively(m,a,e,t.highWaterMark,l):d?m.arrayBuffer():e.responseType==="json"?m.json():m.text()}).then(function(m){var T=i.response;self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var S=m[u];S&&(a.loaded=a.total=S);var y={url:T.url,data:m,code:T.status};l&&!ee(t.highWaterMark)&&l(a,e,m,T),r.onSuccess(y,a,e,T)}).catch(function(m){if(self.clearTimeout(i.requestTimeout),!a.aborted){var T=m&&m.code||0,S=m?m.message:null;r.onError({code:T,text:S},e,m?m.details:null,a)}})},n.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},n.loadProgressively=function(e,t,r,i,a){i===void 0&&(i=0);var o=new Wa,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 Zo(s,n){return new self.Request(s.url,n)}var el=function(s){function n(e,t,r){var i;return(i=s.call(this,e)||this).code=void 0,i.details=void 0,i.code=t,i.details=r,i}return ne(n,s),n}(Ie(Error)),tl=/\s/,rl=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:gs,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:To,bufferController:Ao,capLevelController:jo,errorController:h,fpsController:Wo,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:ti,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++)tl.test(r.chars[v].uchar)&&a?o++:(l+=r.chars[v].uchar,a=!1);r.cueStartTime=n,n===e&&(e+=1e-4),o>=16?o--:o++;var m=ns(l.trim()),T=sa(n,e,m);s!=null&&(f=s.cues)!=null&&f.getCueById(T)||((i=new u(n,e,m)).id=T,i.line=c+1,i.align="left",i.position=10+Math.min(80,10*Math.floor(8*o/32)),d.push(i))}return s&&d.length&&(d.sort(function(S,y){return S.line==="auto"||y.line==="auto"?0:S.line>8&&y.line>8?y.line-S.line:S.line-y.line}),d.forEach(function(S){return Zi(s,S)})),d}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:So,subtitleTrackController:ko,timelineController:qo,audioStreamController:Eo,audioTrackController:_o,emeController:cs,cmcdController:Xo,contentSteeringController:Qo});function fa(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(fa):Object.keys(s).reduce(function(n,e){return n[e]=fa(s[e]),n},{}):s}function il(s){var n=s.loader;n!==ps&&n!==gs?(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=ps,s.progressive=!0,s.enableSoftwareAES=!0,P.log("[config]: Progressive streaming enabled, using FetchLoader"))}var ms=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 cn,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,$e(e.debug||!1,"Hls instance");var t=this.config=function($,X){if((X.liveSyncDurationCount||X.liveMaxLatencyDurationCount)&&(X.liveSyncDuration||X.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(X.liveMaxLatencyDurationCount!==void 0&&(X.liveSyncDurationCount===void 0||X.liveMaxLatencyDurationCount<=X.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(X.liveMaxLatencyDuration!==void 0&&(X.liveSyncDuration===void 0||X.liveMaxLatencyDuration<=X.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var le=fa($),ye=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(oe){var ve=(oe==="level"?"playlist":oe)+"LoadPolicy",me=X[ve]===void 0,ge=[];ye.forEach(function(Le){var De=oe+"Loading"+Le,Oe=X[De];if(Oe!==void 0&&me){ge.push(De);var Ue=le[ve].default;switch(X[ve]={default:Ue},Le){case"TimeOut":Ue.maxLoadTimeMs=Oe,Ue.maxTimeToFirstByteMs=Oe;break;case"MaxRetry":Ue.errorRetry.maxNumRetry=Oe,Ue.timeoutRetry.maxNumRetry=Oe;break;case"RetryDelay":Ue.errorRetry.retryDelayMs=Oe,Ue.timeoutRetry.retryDelayMs=Oe;break;case"MaxRetryTimeout":Ue.errorRetry.maxRetryDelayMs=Oe,Ue.timeoutRetry.maxRetryDelayMs=Oe}}}),ge.length&&P.warn('hls.js config: "'+ge.join('", "')+'" setting(s) are deprecated, use "'+ve+'": '+JSON.stringify(X[ve]))}),G(G({},le),X)}(s.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&il(t);var r=t.abrController,i=t.bufferController,a=t.capLevelController,o=t.errorController,l=t.fpsController,d=new o(this),u=this.abrController=new r(this),c=this.bufferController=new i(this),f=this.capLevelController=new a(this),v=new l(this),m=new $i(this),T=new gi(this),S=t.contentSteeringController,y=S?new S(this):null,E=this.levelController=new b(this,y),R=new W(this),A=new tt(this.config),C=this.streamController=new mo(this,R,A);f.setStreamController(C),v.setStreamController(C);var N=[m,E,C];y&&N.splice(1,0,y),this.networkControllers=N;var B=[u,c,f,v,T,R];this.audioTrackController=this.createController(t.audioTrackController,N);var Y=t.audioStreamController;Y&&N.push(new Y(this,R,A)),this.subtitleTrackController=this.createController(t.subtitleTrackController,N);var K=t.subtitleStreamController;K&&N.push(new K(this,R,A)),this.createController(t.timelineController,B),A.emeController=this.emeController=this.createController(t.emeController,B),this.cmcdController=this.createController(t.cmcdController,B),this.latencyController=this.createController(en,B),this.coreComponents=B,N.push(d);var V=d.onErrorOut;typeof V=="function"&&this.on(_.ERROR,V,d)}s.isSupported=function(){return function(){var e=Hn();if(!e)return!1;var t=Aa(),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(_.ERROR,{type:re.OTHER_ERROR,details:M.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(_.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(_.MEDIA_ATTACHING,{media:e})},n.detachMedia=function(){P.log("detachMedia"),this.trigger(_.MEDIA_DETACHING,void 0),this._media=null},n.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=Fe.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(_.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){Fr.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 _}},{key:"ErrorTypes",get:function(){return re}},{key:"ErrorDetails",get:function(){return M}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:rl},set:function(e){s.defaultConfig=e}}]),s}();return ms.defaultConfig=void 0,ms},typeof ws=="object"&&typeof ma!="undefined"?ma.exports=H():typeof define=="function"&&define.amd?define(H):(F=typeof globalThis!="undefined"?globalThis:F||self).Hls=H()})(!1)});var Sn=Ls(ks());var Rs=Ls(As()),ml=Rs.default,ot=ml;var zr=class extends Error{constructor(F,H=zr.MEDIA_ERR_CUSTOM,j,G){var Q;super(F);this.name="MediaError",this.code=H,this.context=G,this.fatal=j!=null?j:H>=zr.MEDIA_ERR_NETWORK&&H<=zr.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(Q=zr.defaultMessages[this.code])!=null?Q:"")}},vt=zr;vt.MEDIA_ERR_ABORTED=1,vt.MEDIA_ERR_NETWORK=2,vt.MEDIA_ERR_DECODE=3,vt.MEDIA_ERR_SRC_NOT_SUPPORTED=4,vt.MEDIA_ERR_ENCRYPTED=5,vt.MEDIA_ERR_CUSTOM=100,vt.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 yl=D=>D==null,ya=(D,I)=>yl(I)?!1:D in I,Tn={ANY:"any",MUTED:"muted"},tr={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},Ta={MSE:"mse",NATIVE:"native"},En={HEADER:"header",QUERY:"query",NONE:"none"},jl=Object.values(En),lr={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},_n={HLS:lr.M3U8},Wl=Object.keys(_n),Yl=[...Object.values(lr),"hls","HLS"];var Ot=(D,I,F,H,j=D)=>{j.addEventListener(I,F,H),D.addEventListener("teardown",()=>{j.removeEventListener(I,F)},{once:!0})};function Ds(D,I,F){I&&F>I&&(F=I);for(let H=0;H<D.length;H++)if(D.start(H)<=F&&D.end(H)>=F)return!0;return!1}var Is=D=>{let I=D.indexOf("?");if(I<0)return[D];let F=D.slice(0,I),H=D.slice(I);return[F,H]},Ea=D=>{let I=D.type;if(I){let H=I.toUpperCase();return ya(H,_n)?_n[H]:I}let{src:F}=D;return F?Tl(F):""},_a=D=>D==="VOD"?tr.ON_DEMAND:tr.LIVE,ba=D=>D==="EVENT"?Number.POSITIVE_INFINITY:D==="VOD"?Number.NaN:0,Tl=D=>{let I="";try{I=new URL(D).pathname}catch{console.error("invalid url")}let F=I.lastIndexOf(".");if(F<0)return"";let j=I.slice(F+1).toUpperCase();return ya(j,lr)?lr[j]:""};var El=Object.values(Tn),xs=D=>typeof D=="boolean"||typeof D=="string"&&El.includes(D),Cs=({autoplay:D},I,F)=>{let H=!1,j=!1,G=xs(D)?D:!!D,Q=()=>{H||Ot(I,"playing",()=>{H=!0},{once:!0})};if(Q(),Ot(I,"loadstart",()=>{H=!1,Q(),Sa(I,G)},{once:!0}),Ot(I,"loadstart",()=>{F||(j=!Number.isFinite(I.duration)),Sa(I,G)},{once:!0}),F&&F.once(ot.Events.LEVEL_LOADED,(te,z)=>{var ne;j=(ne=z.details.live)!=null?ne:!1}),!G){let te=()=>{!j||(F!=null&&F.liveSyncPosition?I.currentTime=F.liveSyncPosition:Number.isFinite(I.seekable.end(0))&&(I.currentTime=I.seekable.end(0)))};F&&Ot(I,"play",()=>{I.preload==="metadata"?F.once(ot.Events.LEVEL_UPDATED,te):te()},{once:!0})}return te=>{H||(G=xs(te)?te:!!te,Sa(I,G))}},Sa=(D,I)=>{if(!I)return;let F=D.muted,H=()=>D.muted=F;switch(I){case Tn.ANY:D.play().catch(()=>{D.muted=!0,D.play().catch(H)});break;case Tn.MUTED:D.muted=!0,D.play().catch(H);break;default:D.play().catch(()=>{});break}};var Ps=({preload:D,src:I},F,H)=>{let j=Te=>{Te!=null&&["","none","metadata","auto"].includes(Te)?F.setAttribute("preload",Te):F.removeAttribute("preload")};if(!H)return j(D),j;let G=!1,Q=!1,q=H.config.maxBufferLength,te=H.config.maxBufferSize,z=Te=>{j(Te);let ae=Te!=null?Te:F.preload;Q||ae==="none"||(ae==="metadata"?(H.config.maxBufferLength=1,H.config.maxBufferSize=1):(H.config.maxBufferLength=q,H.config.maxBufferSize=te),ne())},ne=()=>{!G&&I&&(G=!0,H.loadSource(I))};return Ot(F,"play",()=>{Q=!0,H.config.maxBufferLength=q,H.config.maxBufferSize=te,ne()},{once:!0}),z(D),z};function Os(D,I){I.on(ot.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(j,{tracks:G})=>{G.forEach(Q=>{var z;let q=(z=Q.subtitleTrack)!=null?z:Q.closedCaptions,te=I.subtitleTracks.findIndex(({lang:ne,name:Te,type:ae})=>ne==(q==null?void 0:q.lang)&&Te===Q.label&&ae.toLowerCase()===Q.kind);La(D,Q.kind,Q.label,q==null?void 0:q.lang,`${Q.kind}${te}`)})});let F=()=>{var Q;if(!I.subtitleTracks.length)return;let j=Array.from(D.textTracks).find(q=>q.id&&q.mode==="showing"&&["subtitles","captions"].includes(q.kind)),G=`${(Q=I.subtitleTracks[I.subtitleTrack])==null?void 0:Q.type.toLowerCase()}${I.subtitleTrack}`;if(j&&(I.subtitleTrack<0||(j==null?void 0:j.id)!==G)){let q=I.subtitleTracks.findIndex(({lang:te,name:z,type:ne})=>te==j.language&&z===j.label&&ne.toLowerCase()===j.kind);I.subtitleTrack=q}j&&(j==null?void 0:j.id)===G&&j.cues&&Array.from(j.cues).forEach(q=>{j.addCue(q)})};D.textTracks.addEventListener("change",F),I.on(ot.Events.CUES_PARSED,(j,{track:G,cues:Q})=>{let q=D.textTracks.getTrackById(G);if(!q)return;let te=q.mode==="disabled";te&&(q.mode="hidden"),Q.forEach(z=>{var ne;(ne=q.cues)!=null&&ne.getCueById(z.id)||q.addCue(z)}),te&&(q.mode="disabled")}),I.once(ot.Events.DESTROYING,()=>{D.textTracks.removeEventListener("change",F),D.querySelectorAll("track[data-removeondestroy]").forEach(G=>{G.remove()})});let H=()=>{Array.from(D.textTracks).forEach(j=>{var G,Q;if(!["subtitles","caption"].includes(j.kind)&&j.label==="thumbnails"){if(!((G=j.cues)!=null&&G.length)){let q=D.querySelector('track[label="thumbnails"]'),te=(Q=q==null?void 0:q.getAttribute("src"))!=null?Q:"";q==null||q.removeAttribute("src"),setTimeout(()=>{q==null||q.setAttribute("src",te)},0)}j.mode!=="hidden"&&(j.mode="hidden")}})};I.once(ot.Events.MANIFEST_LOADED,H),I.once(ot.Events.MEDIA_ATTACHED,H)}function La(D,I,F,H,j){let G=document.createElement("track");return G.kind=I,G.label=F,H&&(G.srclang=H),j&&(G.id=j),G.track.mode=["subtitles","captions"].includes(I)?"disabled":"hidden",G.setAttribute("data-removeondestroy",""),D.append(G),G.track}function _l(D,I){let F=Array.prototype.find.call(D.querySelectorAll("track"),H=>H.track===I);F==null||F.remove()}var wi="cuepoints",ka=Object.freeze({label:wi}),bn=(D,{label:I=wi}=ka)=>{var F;return(F=Array.from(D.querySelectorAll("track")).find(H=>H.track.label===I&&H.track.kind==="metadata"))==null?void 0:F.track};async function Ms(D,I,F=ka){let H=bn(D,F);if(!H){let{label:j=wi}=F;H=La(D,"metadata",j),H.mode="hidden",await new Promise(G=>setTimeout(()=>G(void 0),0))}return H.mode!=="hidden"&&(H.mode="hidden"),[...I].sort(({time:j},{time:G})=>G-j).forEach(({time:j,value:G})=>{var Te,ae;let Q=Array.prototype.findIndex.call(H==null?void 0:H.cues,Ee=>Ee.startTime>=j),q=(Te=H==null?void 0:H.cues)==null?void 0:Te[Q],te=q?q.startTime:Number.isFinite(D.duration)?D.duration:Number.MAX_SAFE_INTEGER,z=(ae=H==null?void 0:H.cues)==null?void 0:ae[Q-1];z&&(z.endTime=j);let ne=new VTTCue(j,te,JSON.stringify(G!=null?G:null));H.addCue(ne)}),H}var Fs=D=>({time:D.startTime,value:JSON.parse(D.text)});function bl(D,I={label:wi}){let F=bn(D,I);return F!=null&&F.cues?Array.from(F.cues,H=>Fs(H)):[]}function Ns(D,I={label:wi}){var G,Q;let F=bn(D,I);if(!((G=F==null?void 0:F.activeCues)!=null&&G.length))return;let{currentTime:H}=D,j=Array.prototype.find.call((Q=F.activeCues)!=null?Q:[],({startTime:q,endTime:te})=>q<=H&&te>H);return Fs(j)}async function Us(D,I=ka){return new Promise(F=>{Ot(D,"loadstart",async()=>{let H=await Ms(D,[],I);Ot(D,"cuechange",()=>{let j=Ns(D);if(j){let G=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:j});D.dispatchEvent(G)}},{},H),F(H)})})}function Sl(D,I){if(I){let F=I.playingDate;if(F!=null)return new Date(F.getTime()-D.currentTime*1e3)}return typeof D.getStartDate=="function"?D.getStartDate():new Date(NaN)}function Ll(D,I){if(I&&I.playingDate)return I.playingDate;if(typeof D.getStartDate=="function"){let F=D.getStartDate();return new Date(F.getTime()+D.currentTime*1e3)}return new Date(NaN)}var kl=async D=>fetch(D).then(I=>I.text()).then(I=>{let F=I.split(`
|
|
46
|
+
`).find((H,j,G)=>j&&G[j-1].startsWith("#EXT-X-STREAM-INF"));return fetch(F).then(H=>H.text()).then(H=>H.split(`
|
|
47
|
+
`))}),wl=D=>{var Q,q;let F=(q=((Q=D.find(te=>te.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?Q:"").split(":")[1])==null?void 0:q.trim(),H=_a(F),j=ba(F),G;if(H===tr.LIVE){let te=D.find(ne=>ne.startsWith("#EXT-X-PART-INF"));!!te?G=+te.split(":")[1].split("=")[1]*2:G=+D.find(ae=>ae.startsWith("#EXT-X-TARGETDURATION")).split(":")[1]*3}return{streamType:H,targetLiveWindow:j,liveEdgeStartOffset:G}},Bs=async(D,I)=>{var Q,q,te;let F=await kl(D),{streamType:H,targetLiveWindow:j,liveEdgeStartOffset:G}=wl(F);((Q=lt.get(I))!=null?Q:{}).liveEdgeStartOffset=G,((q=lt.get(I))!=null?q:{}).targetLiveWindow=j,I.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((te=lt.get(I))!=null?te:{}).streamType=H,I.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Al=D=>{var Q;let I=D.type,F=_a(I),H=ba(I),j,G=!!((Q=D.partList)!=null&&Q.length);return F===tr.LIVE&&(j=G?D.partTarget*2:D.targetduration*3),{streamType:F,targetLiveWindow:H,liveEdgeStartOffset:j,lowLatency:G}},Rl=(D,I,F)=>{var q,te,z,ne,Te,ae,Ee,Ae;let{streamType:H,targetLiveWindow:j,liveEdgeStartOffset:G,lowLatency:Q}=Al(D);if(H===tr.LIVE){Q?(F.config.backBufferLength=(q=F.userConfig.backBufferLength)!=null?q:4,F.config.maxFragLookUpTolerance=(te=F.userConfig.maxFragLookUpTolerance)!=null?te:.001,F.config.abrBandWidthUpFactor=(z=F.userConfig.abrBandWidthUpFactor)!=null?z:F.config.abrBandWidthFactor):F.config.backBufferLength=(ne=F.userConfig.backBufferLength)!=null?ne:8;let Ie=Object.freeze({get length(){return I.seekable.length},start(Ye){return I.seekable.start(Ye)},end(Ye){var ke;return Ye>this.length?I.seekable.end(Ye):(ke=F.liveSyncPosition)!=null?ke:I.seekable.end(Ye)}});((Te=lt.get(I))!=null?Te:{}).seekable=Ie}((ae=lt.get(I))!=null?ae:{}).liveEdgeStartOffset=G,((Ee=lt.get(I))!=null?Ee:{}).targetLiveWindow=j,I.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((Ae=lt.get(I))!=null?Ae:{}).streamType=H,I.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Hs,Gs,Dl=(Gs=(Hs=globalThis==null?void 0:globalThis.navigator)==null?void 0:Hs.userAgent)!=null?Gs:"",Il=Dl.toLowerCase().indexOf("android")!==-1,lt=new WeakMap,Vs="mux.com",Ks,qs,js=(qs=(Ks=ot).isSupported)==null?void 0:qs.call(Ks),xl=Il,Eu=()=>Sn.default.utils.now(),Cl=Sn.default.utils.generateUUID,_u=(D,{domain:I=Vs,maxResolution:F=""}={})=>{if(!D)return;let[H,j=""]=Is(D),G=new URL(`https://stream.${I}/${H}.m3u8${j}`);return F&&G.searchParams.set("max_resolution",F),G.toString()},Pl=D=>{if(!D)return;let[I]=D.split("?");return I||void 0},Ol=D=>{if(!D||!D.startsWith("https://stream."))return;let[I]=new URL(D).pathname.slice(1).split(".m3u8");return I||void 0},Ml=D=>{var I,F,H;return(I=D==null?void 0:D.metadata)!=null&&I.video_id?D.metadata.video_id:Ys(D)&&(H=(F=Pl(D.playbackId))!=null?F:Ol(D.src))!=null?H:D.src},bu=D=>{var I;return(I=lt.get(D))==null?void 0:I.error},Su=D=>{var I,F;return(F=(I=lt.get(D))==null?void 0:I.streamType)!=null?F:tr.UNKNOWN},Lu=D=>{var I,F;return(F=(I=lt.get(D))==null?void 0:I.targetLiveWindow)!=null?F:Number.NaN},Fl=D=>{var I,F;return(F=(I=lt.get(D))==null?void 0:I.seekable)!=null?F:D.seekable},ku=D=>{var H;let I=(H=lt.get(D))==null?void 0:H.liveEdgeStartOffset;if(typeof I!="number")return Number.NaN;let F=Fl(D);return F.length?F.end(F.length-1)-I:Number.NaN},wu=(D,I,F)=>{Nl(I,F);let{metadata:H={}}=D,{view_session_id:j=Cl()}=H,G=Ml(D);H.view_session_id=j,H.video_id=G,D.metadata=H,lt.set(I,{});let Q=Ul(D,I);Hl(D,I,Q),Gl(D,I,Q),Us(I);let q=Cs(D,I,Q),te=Ps(D,I,Q);return{engine:Q,setAutoplay:q,setPreload:te}},Nl=(D,I)=>{let F=I==null?void 0:I.engine;F&&(F.detachMedia(),F.destroy()),(D==null?void 0:D.mux)&&!D.mux.deleted&&(D.mux.destroy(),delete D.mux),D&&(D.removeAttribute("src"),D.load(),D.removeEventListener("error",Xs),D.removeEventListener("error",wa),D.removeEventListener("durationchange",zs),lt.delete(D),D.dispatchEvent(new Event("teardown")))};function Ws(D,I){var z;let F=Ea(D);if(!(F===lr.M3U8))return!0;let j=!F||((z=I.canPlayType(F))!=null?z:!0),{preferPlayback:G}=D,Q=G===Ta.MSE,q=G===Ta.NATIVE;return j&&(q||!(js&&(Q||xl)))}var Ul=(D,I)=>{let{debug:F,streamType:H,startTime:j=-1,metadata:G,preferCmcd:Q}=D,te=Ea(D)===lr.M3U8,z=Ws(D,I);if(te&&!z&&js){let ne={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},Te=Bl(H),ae=Q!==En.NONE?{useHeaders:Q===En.HEADER,sessionId:G==null?void 0:G.view_session_id,contentId:G==null?void 0:G.video_id}:void 0;return new ot({debug:F,startPosition:j,cmcd:ae,...ne,...Te})}},Bl=D=>D===tr.LIVE?{backBufferLength:8}:{},Ys=({playbackId:D,src:I,customDomain:F})=>{if(D)return!0;if(typeof I!="string")return!1;let H=window==null?void 0:window.location.href,j=new URL(I,H).hostname.toLocaleLowerCase();return j.includes(Vs)||!!F&&j.includes(F.toLocaleLowerCase())},Hl=(D,I,F)=>{var G;let{envKey:H}=D,j=Ys(D);if(H||j){let{playerInitTime:Q,playerSoftwareName:q,playerSoftwareVersion:te,beaconCollectionDomain:z,debug:ne,disableCookies:Te}=D,ae={...D.metadata,video_title:((G=D==null?void 0:D.metadata)==null?void 0:G.video_title)||void 0},Ee=Ae=>typeof Ae.player_error_code=="string"?!1:typeof D.errorTranslator=="function"?D.errorTranslator(Ae):Ae;Sn.default.monitor(I,{debug:ne,beaconCollectionDomain:z,hlsjs:F,Hls:F?ot:void 0,automaticErrorTracking:!1,errorTranslator:Ee,disableCookies:Te,data:{...H?{env_key:H}:{},player_software_name:q,player_software:q,player_software_version:te,player_init_time:Q,...ae}})}},Gl=(D,I,F)=>{var G;let H=Ws(D,I),{src:j}=D;I&&H?(typeof j=="string"?(I.preload==="none"?Ot(I,"loadstart",()=>Bs(j,I)):Bs(j,I),I.setAttribute("src",j),D.startTime&&(((G=lt.get(I))!=null?G:{}).startTime=D.startTime,I.addEventListener("durationchange",zs,{once:!0}))):I.removeAttribute("src"),I.addEventListener("error",Xs),I.addEventListener("error",wa),I.addEventListener("emptied",()=>{I.querySelectorAll("track[data-removeondestroy]").forEach(q=>{q.remove()})},{once:!0})):F&&j?(F.once(ot.Events.LEVEL_LOADED,(Q,q)=>{Rl(q.details,I,F)}),F.on(ot.Events.ERROR,(Q,q)=>{let te={[ot.ErrorTypes.NETWORK_ERROR]:vt.MEDIA_ERR_NETWORK,[ot.ErrorTypes.MEDIA_ERROR]:vt.MEDIA_ERR_DECODE},z=new vt("",te[q.type]);z.fatal=q.fatal,z.data=q,I.dispatchEvent(new CustomEvent("error",{detail:z}))}),I.addEventListener("error",wa),Os(I,F),F.attachMedia(I)):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 zs(D){var H;let I=D.target,F=(H=lt.get(I))==null?void 0:H.startTime;if(!!F&&Ds(I.seekable,I.duration,F)){let j=I.preload==="auto";j&&(I.preload="none"),I.currentTime=F,j&&(I.preload="auto")}}async function Xs(D){if(!D.isTrusted)return;D.stopImmediatePropagation();let I=D.target;if(!(I!=null&&I.error))return;let{message:F,code:H}=I.error,j=new vt(F,H);if(I.src&&(H!==vt.MEDIA_ERR_DECODE||H!==void 0))try{let{status:G}=await fetch(I.src);j.data={response:{code:G}}}catch{}I.dispatchEvent(new CustomEvent("error",{detail:j}))}function wa(D){var H,j;if(!(D instanceof CustomEvent)||!(D.detail instanceof vt))return;let I=D.target,F=D.detail;!F||!F.fatal||(((H=lt.get(I))!=null?H:{}).error=F,(j=I.mux)==null||j.emit("error",{player_error_code:F.code,player_error_message:F.message,player_error_context:F.context}))}})();
|
|
33
48
|
/*!
|
|
34
49
|
* JavaScript Cookie v2.1.3
|
|
35
50
|
* https://github.com/js-cookie/js-cookie
|
|
@@ -39,7 +54,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
39
54
|
*/
|
|
40
55
|
/*!
|
|
41
56
|
* mux-embed
|
|
42
|
-
* @version 4.
|
|
43
|
-
* @copyright
|
|
57
|
+
* @version 4.24.0
|
|
58
|
+
* @copyright 2023 Mux, Inc
|
|
44
59
|
*/
|
|
45
60
|
//# sourceMappingURL=playback-core.js.map
|