@mux/mux-player 2.3.2 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- "use strict";(()=>{var rT=Object.create;var yp=Object.defineProperty;var sT=Object.getOwnPropertyDescriptor;var nT=Object.getOwnPropertyNames;var aT=Object.getPrototypeOf,oT=Object.prototype.hasOwnProperty;var lT=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var dT=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of nT(e))!oT.call(i,s)&&s!==t&&yp(i,s,{get:()=>e[s],enumerable:!(r=sT(e,s))||r.enumerable});return i};var cT=(i,e,t)=>(t=i!=null?rT(aT(i)):{},dT(e||!i||!i.__esModule?yp(t,"default",{value:i,enumerable:!0}):t,i));var lc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var Pe=(i,e,t)=>(lc(i,e,"read from private field"),t?t.call(i):e.get(i)),dt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Jt=(i,e,t,r)=>(lc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t);var ct=(i,e,t)=>(lc(i,e,"access private method"),t);var I0=lT((Dl,Qu)=>{(function(){var i,e;i=this,e=function(){return function(){var t={80:function(n,a,o){n.exports=o(728).default},728:function(n,a,o){"use strict";o.d(a,{default:function(){return Zy}});var l=o(48),d=o.n(l),c=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(v){var m=16*Math.random()|0;return(v==="x"?m:3&m|8).toString(16)})},u=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},h=function(v){var m,p;if(v&&v.nodeName!==void 0)return v.muxId||(v.muxId=u()),v.muxId;try{p=document.querySelector(v)}catch{}return p&&!p.muxId&&(p.muxId=v),((m=p)===null||m===void 0?void 0:m.muxId)||v},f=function(v){var m;v&&v.nodeName!==void 0?v=h(m=v):m=document.querySelector(v);var p=m&&m.nodeName?m.nodeName.toLowerCase():"";return[m,v,p]},g=o(640),E=o.n(g),T=E().methodFactory;E().methodFactory=function(v,m,p){var y=T(v,m,p);return function(){for(var _=["[mux]"],I=0;I<arguments.length;I++)_.push(arguments[I]);y.apply(void 0,_)}},E().setLevel(E().getLevel());var A=E();function k(){return(d().doNotTrack||d().navigator&&d().navigator.doNotTrack)==="1"}var L={now:function(){var v=d().performance,m=v&&v.timing,p=m&&m.navigationStart,y=typeof p=="number"&&typeof v.now=="function"?p+v.now():Date.now();return Math.round(y)}},F=function(v){return R(v)[0]},R=function(v){if(typeof v!="string"||v==="")return["localhost"];var m,p=(v.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return p&&(m=(p.match(/[^\.]+\.[^\.]+$/)||[])[0]),[p,m]},B={exists:function(){var v=d().performance;return(v&&v.timing)!==void 0},domContentLoadedEventEnd:function(){var v=d().performance,m=v&&v.timing;return m&&m.domContentLoadedEventEnd},navigationStart:function(){var v=d().performance,m=v&&v.timing;return m&&m.navigationStart}};function P(v,m,p){p=p===void 0?1:p,v[m]=v[m]||0,v[m]+=p}var G=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],K=["x-cdn","content-type"].concat(G);function N(v){var m={};return(v=v||"").trim().split(/[\r\n]+/).forEach(function(p){if(p){var y=p.split(": "),_=y.shift();_&&(K.indexOf(_.toLowerCase())>=0||_.toLowerCase().indexOf("x-litix-")===0)&&(m[_]=y.join(": "))}}),m}function j(v){if(v){var m=G.find(function(p){return v[p]!==void 0});return m?v[m]:void 0}}var Y=function(v){var m={};for(var p in v){var y=v[p];y["DATA-ID"].search("io.litix.data.")!==-1&&(m[y["DATA-ID"].replace("io.litix.data.","")]=y.VALUE)}return m};function Ee(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);m&&(y=y.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,y)}return p}function ge(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?Ee(Object(p),!0).forEach(function(y){ye(v,y,p[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Ee(Object(p)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(p,y))})}return v}function ye(v,m,p){return m in v?Object.defineProperty(v,m,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[m]=p,v}var we=function(v){if(!v)return{};var m=B.navigationStart(),p=v.loading,y=p?p.start:v.trequest,_=p?p.first:v.tfirst,I=p?p.end:v.tload;return{bytesLoaded:v.total,requestStart:Math.round(m+y),responseStart:Math.round(m+_),responseEnd:Math.round(m+I)}},Ie=function(v){if(v&&typeof v.getAllResponseHeaders=="function")return N(v.getAllResponseHeaders())};function Z(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);m&&(y=y.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,y)}return p}function te(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?Z(Object(p),!0).forEach(function(y){re(v,y,p[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Z(Object(p)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(p,y))})}return v}function re(v,m,p){return m in v?Object.defineProperty(v,m,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[m]=p,v}var Le=function(v,m){if(!v||!v.requestEndDate)return{};var p,y=F(v.url),_=v.url,I=v.bytesLoaded,x=new Date(v.requestStartDate).getTime(),w=new Date(v.firstByteDate).getTime(),U=new Date(v.requestEndDate).getTime(),H=isNaN(v.duration)?0:v.duration,C=typeof m.getMetricsFor=="function"?m.getMetricsFor(v.mediaType).HttpList:m.getDashMetrics().getHttpRequests(v.mediaType);return C.length>0&&(p=N(C[C.length-1]._responseHeaders||"")),{requestStart:x,requestResponseStart:w,requestResponseEnd:U,requestBytesLoaded:I,requestResponseHeaders:p,requestMediaDuration:H,requestHostname:y,requestUrl:_,requestId:p?j(p):void 0}},Re=function(v,m){var p=m.getQualityFor(v),y=m.getCurrentTrackFor(v).bitrateList;return y?{currentLevel:p,renditionWidth:y[p].width||null,renditionHeight:y[p].height||null,renditionBitrate:y[p].bandwidth}:{}},Qe=function(v){var m;return(m=v.match(/.*codecs\*?="(.*)"/))===null||m===void 0?void 0:m[1]},Ot=function(v){try{var m,p;return(m=v.getVersion)===null||m===void 0||(p=m.call(v))===null||p===void 0?void 0:p.split(".").map(function(y){return parseInt(y)})[0]}catch{return!1}};function Nt(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var kt=0,Wi=function(){function v(){(function(_,I){if(!(_ instanceof I))throw new TypeError("Cannot call a class as a function")})(this,v)}var m,p,y;return m=v,p=[{key:"on",value:function(_,I,x){return I._eventEmitterGuid=I._eventEmitterGuid||++kt,this._listeners=this._listeners||{},this._listeners[_]=this._listeners[_]||[],x&&(I=I.bind(x)),this._listeners[_].push(I),I}},{key:"off",value:function(_,I){var x=this._listeners&&this._listeners[_];x&&x.forEach(function(w,U){w._eventEmitterGuid===I._eventEmitterGuid&&x.splice(U,1)})}},{key:"one",value:function(_,I,x){var w=this;I._eventEmitterGuid=I._eventEmitterGuid||++kt;var U=function H(){w.off(_,H),I.apply(x||this,arguments)};U._eventEmitterGuid=I._eventEmitterGuid,this.on(_,U)}},{key:"emit",value:function(_,I){var x=this;if(this._listeners){I=I||{};var w=this._listeners["before*"]||[],U=this._listeners[_]||[],H=this._listeners["after"+_]||[],C=function(be,ne){(be=be.slice()).forEach(function(ce){ce.call(x,{type:_},ne)})};C(w,I),C(U,I),C(H,I)}}}],p&&Nt(m.prototype,p),y&&Nt(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}(),yn=Wi;function Nm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Fb=function(){function v(_){var I=this;(function(x,w){if(!(x instanceof w))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,_.on("playing",function(){I._playheadShouldBeProgressing=!0}),_.on("play",this._startPlaybackHeartbeatInterval.bind(this)),_.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),_.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),_.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),_.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("seeked",function(){_.data.player_is_paused?I._stopPlaybackHeartbeatInterval():I._startPlaybackHeartbeatInterval()}),_.on("timeupdate",function(){I._playbackHeartbeatInterval!==null&&_.emit("playbackheartbeat")}),_.on("devicesleep",function(x,w){I._playbackHeartbeatInterval!==null&&(d().clearInterval(I._playbackHeartbeatInterval),_.emit("playbackheartbeatend",{viewer_time:w.viewer_time}),I._playbackHeartbeatInterval=null)})}var m,p,y;return m=v,(p=[{key:"_startPlaybackHeartbeatInterval",value:function(){var _=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=d().setInterval(function(){_.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(d().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Nm(m.prototype,p),y&&Nm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Um(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Bb(v,m,p){return m&&Um(v.prototype,m),p&&Um(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var $b=Bb(function v(m){var p=this;(function(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("viewinit",function(){p.viewErrored=!1}),m.on("error",function(y,_){try{var I=m.errorTranslator({player_error_code:_.player_error_code,player_error_message:_.player_error_message,player_error_context:_.player_error_context});I?(m.data.player_error_code=I.player_error_code||_.player_error_code,m.data.player_error_message=I.player_error_message||_.player_error_message,m.data.player_error_context=I.player_error_context||_.player_error_context,p.viewErrored=!0):(delete m.data.player_error_code,delete m.data.player_error_message,delete m.data.player_error_context)}catch(x){m.mux.log.warn("Exception in error translator callback.",x),p.viewErrored=!0}})});function Fm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Gb=function(){function v(_){(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._watchTimeTrackerLastCheckedTime=null,_.on("playbackheartbeat",this._updateWatchTime.bind(this)),_.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var m,p,y;return m=v,(p=[{key:"_updateWatchTime",value:function(_,I){var x=I.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=x),P(this.pm.data,"view_watch_time",x-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=x}},{key:"_clearWatchTimeState",value:function(_,I){this._updateWatchTime(_,I),this._watchTimeTrackerLastCheckedTime=null}}])&&Fm(m.prototype,p),y&&Fm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Bm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Hb=function(){function v(_){var I=this;(function(U,H){if(!(U instanceof H))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=L.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var x=this._startPlaybackTimeTracking.bind(this);_.on("playing",x),_.on("adplaying",x),_.on("seeked",x);var w=this._stopPlaybackTimeTracking.bind(this);_.on("playbackheartbeatend",w),_.on("seeking",w),_.on("adplaying",function(){I._isAdPlaying=!0}),_.on("adended",function(){I._isAdPlaying=!1}),_.on("adpause",function(){I._isAdPlaying=!1}),_.on("adbreakstart",function(){I._isAdPlaying=!1}),_.on("adbreakend",function(){I._isAdPlaying=!1}),_.on("adplay",function(){I._isAdPlaying=!1}),_.on("viewinit",function(){I._playbackTimeTrackerLastPlayheadPosition=-1,I._lastTime=L.now(),I._isAdPlaying=!1,I._callbackUpdatePlaybackTime=null})}var m,p,y;return m=v,(p=[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var _=this.pm.data.player_playhead_time,I=L.now(),x=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&_>this._playbackTimeTrackerLastPlayheadPosition?x=_-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(x=I-this._lastTime),x>0&&x<=1e3&&P(this.pm.data,"view_content_playback_time",x),this._playbackTimeTrackerLastPlayheadPosition=_,this._lastTime=I}}])&&Bm(m.prototype,p),y&&Bm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function $m(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Vb=function(){function v(_){(function(x,w){if(!(x instanceof w))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_;var I=this._updatePlayheadTime.bind(this);_.on("playbackheartbeat",I),_.on("playbackheartbeatend",I),_.on("timeupdate",I),_.on("destroy",function(){_.off("timeupdate",I)})}var m,p,y;return m=v,(p=[{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(_,I){var x=this,w=function(){x.pm.currentFragmentPDT&&x.pm.currentFragmentStart&&(x.pm.data.player_program_time=x.pm.currentFragmentPDT+x.pm.data.player_playhead_time-x.pm.currentFragmentStart)};if(I&&I.player_playhead_time)this.pm.data.player_playhead_time=I.player_playhead_time,w(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var U=this.pm.getPlayheadTime();U!==void 0&&(this.pm.data.player_playhead_time=U,w(),this._updateMaxPlayheadPosition())}}}])&&$m(m.prototype,p),y&&$m(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Gm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Wb(v,m,p){return m&&Gm(v.prototype,m),p&&Gm(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Hm=3e5,Kb=Wb(function v(m){if(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")}(this,v),!m.disableRebufferTracking){var p,y=function(I,x){_(x),p=void 0},_=function(I){if(p){var x=I.viewer_time-p;P(m.data,"view_rebuffer_duration",x),p=I.viewer_time,m.data.view_rebuffer_duration>Hm&&(m.emit("viewend"),m.send("viewend"),m.mux.log.warn("Ending view after rebuffering for longer than ".concat(Hm,"ms, future events will be ignored unless a programchange or videochange occurs.")))}m.data.view_watch_time>=0&&m.data.view_rebuffer_count>0&&(m.data.view_rebuffer_frequency=m.data.view_rebuffer_count/m.data.view_watch_time,m.data.view_rebuffer_percentage=m.data.view_rebuffer_duration/m.data.view_watch_time)};m.on("playbackheartbeat",function(I,x){return _(x)}),m.on("rebufferstart",function(I,x){p||(P(m.data,"view_rebuffer_count",1),p=x.viewer_time,m.one("rebufferend",y))}),m.on("viewinit",function(){p=void 0,m.off("rebufferend",y)})}});function Vm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var qb=function(){function v(_){var I=this;(function(x,w){if(!(x instanceof w))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.disableRebufferTracking||_.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,_.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),_.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),_.on("seeking",function(){I._cleanupRebufferTracker(null,{viewer_time:L.now()})}))}var m,p,y;return m=v,p=[{key:"_checkIfRebuffering",value:function(_,I){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(_,I);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var x=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&x>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=I.viewer_time}else this._cleanupRebufferTracker(_,I,!0);else this._prepareRebufferTrackerState(I.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(_){this._lastCheckedTime=_,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=_}},{key:"_cleanupRebufferTracker",value:function(_,I){var x=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:I.viewer_time});else{if(this._lastCheckedTime===null)return;var w=this.pm.data.player_playhead_time-this._lastPlayheadTime,U=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&w>0&&U-w>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+U-w}))}x?this._prepareRebufferTrackerState(I.viewer_time):this._clearRebufferTrackerState()}}],p&&Vm(m.prototype,p),y&&Vm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}(),Yb=qb;function Wm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var jb=function(){function v(_){var I=this;(function(x,w){if(!(x instanceof w))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){var x=_.data,w=x.view_id;if(!x.view_program_changed){var U=function(H,C){var be=C.viewer_time;H.type==="playing"&&_.data.view_time_to_first_frame===void 0?I.calculateTimeToFirstFrame(be||L.now(),w):H.type!=="adplaying"||_.data.view_time_to_first_frame!==void 0&&!I._inPrerollPosition()||I.calculateTimeToFirstFrame(be||L.now(),w)};_.one("playing",U),_.one("adplaying",U),_.one("viewend",function(){_.off("playing",U),_.off("adplaying",U)})}})}var m,p,y;return m=v,(p=[{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(_,I){I===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:_}),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))}}])&&Wm(m.prototype,p),y&&Wm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Km(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function zb(v,m,p){return m&&Km(v.prototype,m),p&&Km(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Xb=zb(function v(m){var p=this;(function(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("viewinit",function(){p._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(y){m.on(y,function(){if(p._lastPlayheadPosition>=0&&m.data.player_playhead_time>=0&&p._lastPlayerWidth>=0&&p._lastSourceWidth>0&&p._lastPlayerHeight>=0&&p._lastSourceHeight>0){var _=m.data.player_playhead_time-p._lastPlayheadPosition;if(_<0)return void(p._lastPlayheadPosition=-1);var I=Math.min(p._lastPlayerWidth/p._lastSourceWidth,p._lastPlayerHeight/p._lastSourceHeight),x=Math.max(0,I-1),w=Math.max(0,1-I);m.data.view_max_upscale_percentage=Math.max(m.data.view_max_upscale_percentage||0,x),m.data.view_max_downscale_percentage=Math.max(m.data.view_max_downscale_percentage||0,w),P(m.data,"view_total_content_playback_time",_),P(m.data,"view_total_upscaling",x*_),P(m.data,"view_total_downscaling",w*_)}p._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(y){m.on(y,function(){p._lastPlayheadPosition=m.data.player_playhead_time,p._lastPlayerWidth=m.data.player_width,p._lastPlayerHeight=m.data.player_height,p._lastSourceWidth=m.data.video_source_width,p._lastSourceHeight=m.data.video_source_height})})});function qm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Qb(v,m,p){return m&&qm(v.prototype,m),p&&qm(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Zb=Qb(function v(m){var p=this;(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v),this.isSeeking=!1;var y=-1,_=function(){var I=L.now(),x=(m.data.viewer_time||I)-(y||I);P(m.data,"view_seek_duration",x),m.data.view_max_seek_time=Math.max(m.data.view_max_seek_time||0,x),p.isSeeking=!1,y=-1};m.on("seeking",function(I,x){Object.assign(m.data,x),p.isSeeking&&x.viewer_time-y<=2e3?y=x.viewer_time:(p.isSeeking&&_(),p.isSeeking=!0,y=x.viewer_time,P(m.data,"view_seek_count",1),m.send("seeking"))}),m.on("seeked",function(){_()}),m.on("viewend",function(){p.isSeeking&&(_(),m.send("seeked")),p.isSeeking=!1,y=-1})});function Ym(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,w=[],U=!0,H=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(w.push(I.value),!y||w.length!==y);U=!0);}catch(C){H=!0,x=C}finally{try{U||_.return==null||_.return()}finally{if(H)throw x}}return w}}(v,m)||function(p,y){if(p){if(typeof p=="string")return jm(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?jm(p,y):void 0}}(v,m)||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 jm(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}function zm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Xm=function(v,m){v.push(m),v.sort(function(p,y){return p.viewer_time-y.viewer_time})},Jb=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],ey=function(){function v(_){var I=this;(function(w,U){if(!(w instanceof U))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){I.isAdBreak=!1,I._currentAdRequestNumber=0,I._currentAdResponseNumber=0,I._adRequests=[],I._adResponses=[],I._adHasPlayed=!1,I._wouldBeNewAdPlay=!0,I._prerollPlayTime=void 0}),Jb.forEach(function(w){return _.on(w,I._updateAdData.bind(I))});var x=function(){I.isAdBreak=!1};_.on("adbreakstart",function(){I.isAdBreak=!0}),_.on("play",x),_.on("playing",x),_.on("viewend",x),_.on("adrequest",function(w,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdRequestNumber++},U),Xm(I._adRequests,U),P(_.data,"view_ad_request_count"),I.inPrerollPosition()&&(_.data.view_preroll_requested=!0,I._adHasPlayed||P(_.data,"view_preroll_request_count"))}),_.on("adresponse",function(w,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdResponseNumber++},U),Xm(I._adResponses,U);var H=I.findAdRequest(U.ad_request_id);H&&P(_.data,"view_ad_request_time",Math.max(0,U.viewer_time-H.viewer_time))}),_.on("adplay",function(w,U){I._adHasPlayed=!0,I._wouldBeNewAdPlay&&(I._wouldBeNewAdPlay=!1,P(_.data,"view_ad_played_count")),I.inPrerollPosition()&&!_.data.view_preroll_played&&(_.data.view_preroll_played=!0,I._adRequests.length>0&&(_.data.view_preroll_request_time=Math.max(0,U.viewer_time-I._adRequests[0].viewer_time)),_.data.view_start&&(_.data.view_startup_preroll_request_time=Math.max(0,U.viewer_time-_.data.view_start)),I._prerollPlayTime=U.viewer_time)}),_.on("adplaying",function(w,U){I.inPrerollPosition()&&_.data.view_preroll_load_time===void 0&&I._prerollPlayTime!==void 0&&(_.data.view_preroll_load_time=U.viewer_time-I._prerollPlayTime,_.data.view_startup_preroll_load_time=U.viewer_time-I._prerollPlayTime)}),_.on("adclicked",function(w,U){I._wouldBeNewAdPlay||P(_.data,"view_ad_clicked_count")}),_.on("adskipped",function(w,U){I._wouldBeNewAdPlay||P(_.data,"view_ad_skipped_count")}),_.on("adended",function(){I._wouldBeNewAdPlay=!0}),_.on("aderror",function(){I._wouldBeNewAdPlay=!0})}var m,p,y;return m=v,(p=[{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(_){for(var I=0;I<this._adRequests.length;I++)if(this._adRequests[I].ad_request_id===_)return this._adRequests[I]}},{key:"_updateAdData",value:function(_,I){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&I.ad_tag_url){var x=Ym(R(I.ad_tag_url),2),w=x[0],U=x[1];this.pm.data.view_preroll_ad_tag_domain=U,this.pm.data.view_preroll_ad_tag_hostname=w}if(!this.pm.data.view_preroll_ad_asset_hostname&&I.ad_asset_url){var H=Ym(R(I.ad_asset_url),2),C=H[0],be=H[1];this.pm.data.view_preroll_ad_asset_domain=be,this.pm.data.view_preroll_ad_asset_hostname=C}}this.pm.data.ad_asset_url=I==null?void 0:I.ad_asset_url,this.pm.data.ad_tag_url=I==null?void 0:I.ad_tag_url,this.pm.data.ad_creative_id=I==null?void 0:I.ad_creative_id,this.pm.data.ad_id=I==null?void 0:I.ad_id,this.pm.data.ad_universal_id=I==null?void 0:I.ad_universal_id}}])&&zm(m.prototype,p),y&&zm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Qm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function ty(v,m,p){return m&&Qm(v.prototype,m),p&&Qm(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var iy=ty(function v(m){var p,y;(function(w,U){if(!(w instanceof U))throw new TypeError("Cannot call a class as a function")})(this,v);var _=function(){m.disableRebufferTracking||p&&(P(m.data,"view_waiting_rebuffer_duration",L.now()-p),p=!1,d().clearInterval(y))},I=!1,x=function(){I=!1,_()};m.on("waiting",function(){I&&(m.disableRebufferTracking||(P(m.data,"view_waiting_rebuffer_count",1),p=L.now(),y=d().setInterval(function(){if(p){var w=L.now();P(m.data,"view_waiting_rebuffer_duration",w-p),p=w}},250)))}),m.on("playing",function(){_(),I=!0}),m.on("pause",x),m.on("seeking",x)});function Zm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function ry(v,m,p){return m&&Zm(v.prototype,m),p&&Zm(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var sy=ry(function v(m){var p=this;(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v);var y=function(){p.lastWallClockTime=L.now(),m.on("before*",_)},_=function(I){var x=L.now(),w=p.lastWallClockTime;p.lastWallClockTime=x,x-w>3e4&&(m.emit("devicesleep",{viewer_time:w}),Object.assign(m.data,{viewer_time:w}),m.send("devicesleep"),m.emit("devicewake",{viewer_time:x}),Object.assign(m.data,{viewer_time:x}),m.send("devicewake"))};m.one("playbackheartbeat",y),m.on("playbackheartbeatend",function(){m.off("before*",_),m.one("playbackheartbeat",y)})}),Jm=o(375),ny=o(655),ep=o.n(ny),tp="muxData",ip=function(){var v;try{v=Jm.parse(ep().get(tp)||"")}catch{v={}}return v},rp=function(v){try{ep().set(tp,Jm.stringify(v),{expires:365})}catch{}},ay=function(){var v=ip();return v.mux_viewer_id=v.mux_viewer_id||c(),v.msn=v.msn||Math.random(),rp(v),{mux_viewer_id:v.mux_viewer_id,mux_sample_number:v.msn}};function oy(v,m){var p=m.beaconCollectionDomain,y=m.beaconDomain;if(p)return"https://"+p;var _=y||"litix.io";return(v=v||"inferred").match(/^[a-z0-9]+$/)?"https://"+v+"."+_:"https://img.litix.io/a.gif"}var sp=function(){var v;switch(np()){case"cellular":v="cellular";break;case"ethernet":v="wired";break;case"wifi":v="wifi";break;case void 0:break;default:v="other"}return v},np=function(){var v=d().navigator,m=v&&(v.connection||v.mozConnection||v.webkitConnection);return m&&m.type};sp.getConnectionFromAPI=np;var ly=sp,dy=op({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"}),ap=op({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",ck:"clicked",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",sd:"skipped",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 op(v){var m={};for(var p in v)v.hasOwnProperty(p)&&(m[v[p]]=p);return m}function ec(v){var m={},p={};return Object.keys(v).forEach(function(y){var _=!1;if(v.hasOwnProperty(y)&&v[y]!==void 0){var I=y.split("_"),x=I[0],w=dy[x];w||(A.info("Data key word `"+I[0]+"` not expected in "+y),w=x+"_"),I.splice(1).forEach(function(U){U==="url"&&(_=!0),ap[U]?w+=ap[U]:Number(U)&&Math.floor(Number(U))===Number(U)?w+=U:(A.info("Data key word `"+U+"` not expected in "+y),w+="_"+U+"_")}),_?p[w]=v[y]:m[w]=v[y]}}),Object.assign(m,p)}var cy={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},uy=["hb","requestcompleted","requestfailed","requestcanceled"],hy="https://img.litix.io",Ki=function(v){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=v||hy,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},cy,m)};Ki.prototype.queueEvent=function(v,m){var p=Object.assign({},m);return(this._eventQueue.length<=this._options.maxQueueLength||v==="eventrateexceeded")&&(this._eventQueue.push(p),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},Ki.prototype.flushEvents=function(){var v=arguments.length>0&&arguments[0]!==void 0&&arguments[0];v&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},Ki.prototype.destroy=function(){var v=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,v?this._clearBeaconQueue():this.flushEvents(),d().clearTimeout(this._sendTimeout)},Ki.prototype._clearBeaconQueue=function(){var v=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,m=this._eventQueue.slice(v);v>0&&Object.assign(m[m.length-1],ec({mux_view_message:"event queue truncated"}));var p=this._createPayload(m);lp(this._beaconUrl,p,!0,function(){})},Ki.prototype._sendBeaconQueue=function(){var v=this;if(!this._postInFlight){var m=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var p=this._createPayload(m),y=L.now();lp(this._beaconUrl,p,!1,function(_,I){I?(v._eventQueue=m.concat(v._eventQueue),v._failureCount+=1,A.info("Error sending beacon: "+I)):v._failureCount=0,v._roundTripTime=L.now()-y,v._postInFlight=!1})}},Ki.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var v=Math.pow(2,this._failureCount-1);return(1+(v*=Math.random()))*this._options.baseTimeBetweenBeacons},Ki.prototype._startBeaconSending=function(){var v=this;d().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=d().setTimeout(function(){v._eventQueue.length&&v._sendBeaconQueue(),v._startBeaconSending()},this._getNextBeaconTime()))},Ki.prototype._createPayload=function(v){var m,p,y,_=this,I={transmission_timestamp:Math.round(L.now())};this._roundTripTime&&(I.rtt_ms=Math.round(this._roundTripTime));var x=function(){m=JSON.stringify({metadata:I,events:p||v}),y=m.length/1024},w=function(){return y<=_._options.maxPayloadKBSize};return x(),w()||(A.info("Payload size is too big ("+y+" kb). Removing unnecessary events."),p=v.filter(function(U){return uy.indexOf(U.e)===-1}),x()),w()||(A.info("Payload size still too big ("+y+" kb). Cropping fields.."),p.forEach(function(U){for(var H in U){var C=U[H];typeof C=="string"&&C.length>51200&&(U[H]=C.substring(0,51200))}}),x()),m};var fy=function(v){return v.length<=57344},lp=function(v,m,p,y){if(p&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(v,m))y();else if(d().fetch)d().fetch(v,{method:"POST",body:m,headers:{"Content-Type":"text/plain"},keepalive:fy(m)}).then(function(I){return y(null,I.ok?null:"Error")}).catch(function(I){return y(null,I)});else{if(d().XMLHttpRequest){var _=new(d()).XMLHttpRequest;return _.onreadystatechange=function(){if(_.readyState===4)return y(null,_.status!==200?"error":void 0)},_.open("POST",v),_.setRequestHeader("Content-Type","text/plain"),void _.send(m)}y()}},my=Ki;function py(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,w=[],U=!0,H=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(w.push(I.value),!y||w.length!==y);U=!0);}catch(C){H=!0,x=C}finally{try{U||_.return==null||_.return()}finally{if(H)throw x}}return w}}(v,m)||function(p,y){if(p){if(typeof p=="string")return dp(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?dp(p,y):void 0}}(v,m)||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 dp(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}function cp(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);m&&(y=y.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,y)}return p}function xs(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?cp(Object(p),!0).forEach(function(y){Va(v,y,p[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):cp(Object(p)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(p,y))})}return v}function Tn(v){return Tn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},Tn(v)}function gy(v,m){if(!(v instanceof m))throw new TypeError("Cannot call a class as a function")}function up(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Va(v,m,p){return m in v?Object.defineProperty(v,m,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[m]=p,v}var vy=["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"],Ey=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],by=["ad_id","ad_creative_id","ad_universal_id"],yy=["viewstart","error","ended","viewend"],Ty=function(){function v(_,I){var x,w,U,H,C,be,ne,ce,_e,le,Te,ot,At,wt,je,sr=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};gy(this,v),Va(this,"previousBeaconData",null),Va(this,"lastEventTime",0),Va(this,"rateLimited",!1),this.mux=_,this.envKey=I,this.options=sr,this.eventQueue=new my(oy(this.envKey,this.options)),this.sampleRate=(x=this.options.sampleRate)!==null&&x!==void 0?x:1,this.disableCookies=(w=this.options.disableCookies)!==null&&w!==void 0&&w,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:(H=this.options.platform)===null||H===void 0?void 0:H.name,viewer_application_version:(C=this.options.platform)===null||C===void 0?void 0:C.version,viewer_application_engine:(be=this.options.platform)===null||be===void 0?void 0:be.layout,viewer_device_name:(ne=this.options.platform)===null||ne===void 0?void 0:ne.product,viewer_device_category:"",viewer_device_manufacturer:(ce=this.options.platform)===null||ce===void 0?void 0:ce.manufacturer,viewer_os_family:(_e=this.options.platform)===null||_e===void 0||(le=_e.os)===null||le===void 0?void 0:le.family,viewer_os_architecture:(Te=this.options.platform)===null||Te===void 0||(ot=Te.os)===null||ot===void 0?void 0:ot.architecture,viewer_os_version:(At=this.options.platform)===null||At===void 0||(wt=At.os)===null||wt===void 0?void 0:wt.version,viewer_connection_type:ly(),page_url:d()===null||d()===void 0||(je=d().location)===null||je===void 0?void 0:je.href},this.viewerData=this.disableCookies?{}:ay()}var m,p,y;return m=v,(p=[{key:"send",value:function(_,I){var x;if(_&&I!=null&&I.view_id){if(this.respectDoNotTrack&&k())return A.info("Not sending `"+_+"` because Do Not Track is enabled");if(!I||Tn(I)!=="object")return A.error("A data object was expected in send() but was not provided");var w,U,H=this.disableCookies?{}:(w=ip(),U=L.now(),w.session_start&&(w.sst=w.session_start,delete w.session_start),w.session_id&&(w.sid=w.session_id,delete w.session_id),w.session_expires&&(w.sex=w.session_expires,delete w.session_expires),(!w.sex||w.sex<U)&&(w.sid=c(),w.sst=U),w.sex=U+15e5,rp(w),{session_id:w.sid,session_start:w.sst,session_expires:w.sex}),C=xs(xs(xs(xs(xs({},this.pageLevelData),I),H),this.viewerData),{},{event:_,env_key:this.envKey});C.user_id&&(C.viewer_user_id=C.user_id,delete C.user_id);var be=((x=C.mux_sample_number)!==null&&x!==void 0?x:0)>=this.sampleRate,ne=ec(this._deduplicateBeaconData(_,C));if(this.lastEventTime=this.mux.utils.now(),be)return A.info("Not sending event due to sample rate restriction",_,C,ne);if(this.envKey||A.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",_,C,ne),!this.rateLimited){if(A.info("Sending event",_,C,ne),this.rateLimited=!this.eventQueue.queueEvent(_,ne),this.mux.WINDOW_UNLOADING&&_==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&_==="hb"?this.eventQueue.flushEvents(!0):yy.indexOf(_)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return C.event="eventrateexceeded",ne=ec(C),this.eventQueue.queueEvent(C.event,ne),A.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(_,I){var x=this,w={},U=I.view_id;if(U==="-1"||_==="viewstart"||_==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)w=xs({},I),U&&(this.previousBeaconData=w),U&&_==="viewend"&&(this.previousBeaconData=null);else{var H=_.indexOf("request")===0;Object.entries(I).forEach(function(C){var be=py(C,2),ne=be[0],ce=be[1];x.previousBeaconData&&(ce!==x.previousBeaconData[ne]||vy.indexOf(ne)>-1||x.objectHasChanged(H,ne,ce,x.previousBeaconData[ne])||x.eventRequiresKey(_,ne))&&(w[ne]=ce,x.previousBeaconData[ne]=ce)})}return w}},{key:"objectHasChanged",value:function(_,I,x,w){return!(!_||I.indexOf("request_")!==0||I!=="request_response_headers"&&Tn(x)==="object"&&Tn(w)==="object"&&Object.keys(x||{}).length===Object.keys(w||{}).length)}},{key:"eventRequiresKey",value:function(_,I){return _==="renditionchange"&&I.indexOf("video_source_")===0||!(!by.includes(I)||!Ey.includes(_))}}])&&up(m.prototype,p),y&&up(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function hp(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function _y(v,m,p){return m&&hp(v.prototype,m),p&&hp(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Ay=_y(function v(m){(function(H,C){if(!(H instanceof C))throw new TypeError("Cannot call a class as a function")})(this,v);var p=0,y=0,_=0,I=0,x=0,w=0,U=0;m.on("requestcompleted",function(H,C){var be,ne,ce=C.request_start,_e=C.request_response_start,le=C.request_response_end,Te=C.request_bytes_loaded;if(I++,_e?(be=_e-(ce!=null?ce:0),ne=(le!=null?le:0)-_e):ne=(le!=null?le:0)-(ce!=null?ce:0),ne>0&&Te&&Te>0){var ot=Te/ne*8e3;x++,y+=Te,_+=ne,m.data.view_min_request_throughput=Math.min(m.data.view_min_request_throughput||1/0,ot),m.data.view_average_request_throughput=y/_*8e3,m.data.view_request_count=I,be>0&&(p+=be,m.data.view_max_request_latency=Math.max(m.data.view_max_request_latency||0,be),m.data.view_average_request_latency=p/x)}}),m.on("requestfailed",function(H,C){I++,w++,m.data.view_request_count=I,m.data.view_request_failed_count=w}),m.on("requestcanceled",function(H,C){I++,U++,m.data.view_request_count=I,m.data.view_request_canceled_count=U})});function fp(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Sy(v,m,p){return m&&fp(v.prototype,m),p&&fp(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var xy=Sy(function v(m){var p=this;(function(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("before*",function(y,_){var I=_.viewer_time,x=L.now(),w=p._lastEventTime;if(p._lastEventTime=x,w&&x-w>36e5){var U=Object.keys(m.data).reduce(function(H,C){return C.indexOf("video_")===0?Object.assign(H,function(be,ne,ce){return ne in be?Object.defineProperty(be,ne,{value:ce,enumerable:!0,configurable:!0,writable:!0}):be[ne]=ce,be}({},C,m.data[C])):H},{});m.mux.log.info("Received event after at least an hour inactivity, creating a new view"),m.emit("viewinit",Object.assign({viewer_time:I},U)),m.playbackHeartbeat._playheadShouldBeProgressing&&y.type!=="play"&&y.type!=="adbreakstart"&&(m.emit("play",{viewer_time:I}),y.type!=="playing"&&m.emit("playing",{viewer_time:I}))}})});function tc(v){return tc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},tc(v)}function Iy(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,w=[],U=!0,H=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(w.push(I.value),!y||w.length!==y);U=!0);}catch(C){H=!0,x=C}finally{try{U||_.return==null||_.return()}finally{if(H)throw x}}return w}}(v,m)||function(p,y){if(p){if(typeof p=="string")return mp(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?mp(p,y):void 0}}(v,m)||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 mp(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}function pp(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function ic(v,m){return ic=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,y){return p.__proto__=y,p},ic(v,m)}function Ly(v){var m=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 p,y=Wa(v);if(m){var _=Wa(this).constructor;p=Reflect.construct(y,arguments,_)}else p=y.apply(this,arguments);return Ry(this,p)}}function Ry(v,m){if(m&&(tc(m)==="object"||typeof m=="function"))return m;if(m!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return mt(v)}function mt(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function Wa(v){return Wa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(m){return m.__proto__||Object.getPrototypeOf(m)},Wa(v)}var ky=["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"],wy=function(v){(function(x,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function");x.prototype=Object.create(w&&w.prototype,{constructor:{value:x,writable:!0,configurable:!0}}),Object.defineProperty(x,"prototype",{writable:!1}),w&&ic(x,w)})(I,v);var m,p,y,_=Ly(I);function I(x,w,U){var H,C;(function(le,Te){if(!(le instanceof Te))throw new TypeError("Cannot call a class as a function")})(this,I),(C=_.call(this)).DOM_CONTENT_LOADED_EVENT_END=B.domContentLoadedEventEnd(),C.NAVIGATION_START=B.navigationStart(),C.mux=x,C.id=w,(H=U)!==null&&H!==void 0&&H.beaconDomain&&C.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),(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(le){return le}},U)).data=U.data||{},U.data.property_key&&(U.data.env_key=U.data.property_key,delete U.data.property_key),A.setLevel(U.debug?"debug":"warn"),C.getPlayheadTime=U.getPlayheadTime,C.getStateData=U.getStateData||function(){return{}},C.getAdData=U.getAdData||function(){},C.minimumRebufferDuration=U.minimumRebufferDuration,C.sustainedRebufferThreshold=U.sustainedRebufferThreshold,C.playbackHeartbeatTime=U.playbackHeartbeatTime,C.disableRebufferTracking=U.disableRebufferTracking,C.disableRebufferTracking&&C.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."),C.disablePlayheadRebufferTracking=U.disablePlayheadRebufferTracking,C.errorTranslator=U.errorTranslator,C.playbackEventDispatcher=new Ty(x,U.data.env_key,U),C.data={player_instance_id:c(),mux_sample_rate:U.sampleRate,beacon_domain:U.beaconCollectionDomain||U.beaconDomain},C.data.view_sequence_number=1,C.data.player_sequence_number=1,C.oldEmit=C.emit,C.emit=function(le,Te){Te=Object.assign({viewer_time:this.mux.utils.now()},Te),this.oldEmit(le,Te)};var be=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(mt(C));C.on("viewinit",function(le,Te){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,Te),this._initializeViewData(),this.one("play",be),this.one("adbreakstart",be)});var ne=function(le){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",le)}.bind(mt(C));if(C.on("videochange",function(le,Te){ne(Te)}),C.on("programchange",function(le,Te){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),ne(Object.assign(Te,{view_program_changed:!0})),be(),this.emit("play"),this.emit("playing")}),C.on("fragmentchange",function(le,Te){this.currentFragmentPDT=Te.currentFragmentPDT,this.currentFragmentStart=Te.currentFragmentStart}),C.on("destroy",C.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ce=function(){var le=C.data.view_start!==void 0;C.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",le&&C.mux.WINDOW_HIDDEN&&(C.data.player_is_paused||C.emit("hb"))};window.addEventListener("visibilitychange",ce,!1);var _e=function(le){le.persisted||C.destroy()};window.addEventListener("pagehide",_e,!1),C.on("destroy",function(){window.removeEventListener("visibilitychange",ce),window.removeEventListener("pagehide",_e)})}return C.on("playerready",function(le,Te){Object.assign(this.data,Te)}),ky.forEach(function(le){C.on(le,function(Te,ot){le.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,ot),this._sanitizeData()}),C.on("after"+le,function(){(le!=="error"||this.errorTracker.viewErrored)&&this.send(le)})}),C.on("viewend",function(le,Te){Object.assign(C.data,Te)}),C.one("playerready",function(le){var Te=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=Te-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),C.longResumeTracker=new xy(mt(C)),C.errorTracker=new $b(mt(C)),new sy(mt(C)),C.seekingTracker=new Zb(mt(C)),C.playheadTime=new Vb(mt(C)),C.playbackHeartbeat=new Fb(mt(C)),new Xb(mt(C)),C.watchTimeTracker=new Gb(mt(C)),new Hb(mt(C)),C.adTracker=new ey(mt(C)),new Yb(mt(C)),new Kb(mt(C)),new jb(mt(C)),new iy(mt(C)),new Ay(mt(C)),U.hlsjs&&C.addHLSJS(U),U.dashjs&&C.addDashJS(U),C.emit("viewinit",U.data),C}return m=I,p=[{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(x){if(this.data.view_id){var w=Object.assign({},this.data);if(w.video_source_is_live===void 0&&(w.player_source_duration===1/0||w.video_source_duration===1/0?w.video_source_is_live=!0:(w.player_source_duration>0||w.video_source_duration>0)&&(w.video_source_is_live=!1)),w.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(be){w[be]=void 0}),w.video_source_url=w.video_source_url||w.player_source_url,w.video_source_url){var U=Iy(R(w.video_source_url),2),H=U[0],C=U[1];w.video_source_domain=C,w.video_source_hostname=H}delete w.ad_request_id,this.playbackEventDispatcher.send(x,w),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),x==="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 x=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(w){var U=parseInt(x.data[w],10);x.data[w]=isNaN(U)?void 0:U}),["player_source_url","video_source_url"].forEach(function(w){if(x.data[w]){var U=x.data[w].toLowerCase();U.indexOf("data:")!==0&&U.indexOf("blob:")!==0||(x.data[w]="MSE style URL")}})}},{key:"_resetVideoData",value:function(x,w){var U=this;Object.keys(this.data).forEach(function(H){H.indexOf("video_")===0&&delete U.data[H]})}},{key:"_resetViewData",value:function(){var x=this;Object.keys(this.data).forEach(function(w){w.indexOf("view_")===0&&delete x.data[w]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(x,w){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var x=this,w=this.data.view_id=c(),U=function(){w===x.data.view_id&&P(x.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",U):U()}},{key:"_restartHeartBeat",value:function(){var x=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){x.data.player_is_paused||x.emit("hb")},1e4))}},{key:"addHLSJS",value:function(x){x.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=x.hlsjs,function(w,U,H){var C=arguments.length>4?arguments[4]:void 0,be=w.log,ne=w.utils.secondsToMs,ce=function(it){var ae,Q=parseInt(C.version);return Q===1&&it.programDateTime!==null&&(ae=it.programDateTime),Q===0&&it.pdt!==null&&(ae=it.pdt),ae};if(B.exists()){var _e=function(it,ae){return w.emit(U,it,ae)},le=function(it,ae){var Q=ae.levels,X=ae.audioTracks,fe=ae.url,ve=ae.stats,Ae=ae.networkDetails,Oe=ae.sessionData,rt={},Ze={};Q.forEach(function(Zt,Cr){rt[Cr]={width:Zt.width,height:Zt.height,bitrate:Zt.bitrate,attrs:Zt.attrs}}),X.forEach(function(Zt,Cr){Ze[Cr]={name:Zt.name,language:Zt.lang,bitrate:Zt.bitrate}});var De=we(ve),pt=De.bytesLoaded,nr=De.requestStart,xn=De.responseStart,In=De.responseEnd;_e("requestcompleted",ge(ge({},Y(Oe)),{},{request_event_type:it,request_bytes_loaded:pt,request_start:nr,request_response_start:xn,request_response_end:In,request_type:"manifest",request_hostname:F(fe),request_response_headers:Ie(Ae),request_rendition_lists:{media:rt,audio:Ze,video:{}}}))};H.on(C.Events.MANIFEST_LOADED,le);var Te=function(it,ae){var Q=ae.details,X=ae.level,fe=ae.networkDetails,ve=ae.stats,Ae=we(ve),Oe=Ae.bytesLoaded,rt=Ae.requestStart,Ze=Ae.responseStart,De=Ae.responseEnd,pt=Q.fragments[Q.fragments.length-1],nr=ce(pt)+ne(pt.duration);_e("requestcompleted",{request_event_type:it,request_bytes_loaded:Oe,request_start:rt,request_response_start:Ze,request_response_end:De,request_current_level:X,request_type:"manifest",request_hostname:F(Q.url),request_response_headers:Ie(fe),video_holdback:Q.holdBack&&ne(Q.holdBack),video_part_holdback:Q.partHoldBack&&ne(Q.partHoldBack),video_part_target_duration:Q.partTarget&&ne(Q.partTarget),video_target_duration:Q.targetduration&&ne(Q.targetduration),video_source_is_live:Q.live,player_manifest_newest_program_time:isNaN(nr)?void 0:nr})};H.on(C.Events.LEVEL_LOADED,Te);var ot=function(it,ae){var Q=ae.details,X=ae.networkDetails,fe=ae.stats,ve=we(fe),Ae=ve.bytesLoaded,Oe=ve.requestStart,rt=ve.responseStart,Ze=ve.responseEnd;_e("requestcompleted",{request_event_type:it,request_bytes_loaded:Ae,request_start:Oe,request_response_start:rt,request_response_end:Ze,request_type:"manifest",request_hostname:F(Q.url),request_response_headers:Ie(X)})};H.on(C.Events.AUDIO_TRACK_LOADED,ot);var At=function(it,ae){var Q=ae.stats,X=ae.networkDetails,fe=ae.frag;Q=Q||fe.stats;var ve=we(Q),Ae=ve.bytesLoaded,Oe=ve.requestStart,rt=ve.responseStart,Ze=ve.responseEnd,De=X?Ie(X):void 0,pt={request_event_type:it,request_bytes_loaded:Ae,request_start:Oe,request_response_start:rt,request_response_end:Ze,request_hostname:X?F(X.responseURL):void 0,request_id:De?j(De):void 0,request_response_headers:De,request_media_duration:fe.duration,request_url:X==null?void 0:X.responseURL};fe.type==="main"?(pt.request_type="media",pt.request_current_level=fe.level,pt.request_video_width=(H.levels[fe.level]||{}).width,pt.request_video_height=(H.levels[fe.level]||{}).height,pt.request_labeled_bitrate=(H.levels[fe.level]||{}).bitrate):pt.request_type=fe.type,_e("requestcompleted",pt)};H.on(C.Events.FRAG_LOADED,At);var wt=function(it,ae){var Q=ae.frag,X=Q.start,fe={currentFragmentPDT:ce(Q),currentFragmentStart:ne(X)};_e("fragmentchange",fe)};H.on(C.Events.FRAG_CHANGED,wt);var je=function(it,ae){var Q=ae.type,X=ae.details,fe=ae.response,ve=ae.fatal,Ae=ae.frag,Oe=ae.networkDetails,rt=(Ae==null?void 0:Ae.url)||ae.url||"",Ze=Oe?Ie(Oe):void 0;if(X!==C.ErrorDetails.MANIFEST_LOAD_ERROR&&X!==C.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&X!==C.ErrorDetails.FRAG_LOAD_ERROR&&X!==C.ErrorDetails.FRAG_LOAD_TIMEOUT&&X!==C.ErrorDetails.LEVEL_LOAD_ERROR&&X!==C.ErrorDetails.LEVEL_LOAD_TIMEOUT&&X!==C.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&X!==C.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&X!==C.ErrorDetails.SUBTITLE_LOAD_ERROR&&X!==C.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&X!==C.ErrorDetails.KEY_LOAD_ERROR&&X!==C.ErrorDetails.KEY_LOAD_TIMEOUT||_e("requestfailed",{request_error:X,request_url:rt,request_hostname:F(rt),request_id:Ze?j(Ze):void 0,request_type:X===C.ErrorDetails.FRAG_LOAD_ERROR||X===C.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":X===C.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||X===C.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":X===C.ErrorDetails.SUBTITLE_LOAD_ERROR||X===C.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":X===C.ErrorDetails.KEY_LOAD_ERROR||X===C.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:fe==null?void 0:fe.code,request_error_text:fe==null?void 0:fe.text}),ve){var De,pt="".concat(rt?"url: ".concat(rt,`
1
+ "use strict";(()=>{var vT=Object.create;var kp=Object.defineProperty;var ET=Object.getOwnPropertyDescriptor;var bT=Object.getOwnPropertyNames;var yT=Object.getPrototypeOf,TT=Object.prototype.hasOwnProperty;var _T=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var AT=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of bT(e))!TT.call(i,s)&&s!==t&&kp(i,s,{get:()=>e[s],enumerable:!(r=ET(e,s))||r.enumerable});return i};var ST=(i,e,t)=>(t=i!=null?vT(yT(i)):{},AT(e||!i||!i.__esModule?kp(t,"default",{value:i,enumerable:!0}):t,i));var pc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var Pe=(i,e,t)=>(pc(i,e,"read from private field"),t?t.call(i):e.get(i)),ct=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ei=(i,e,t,r)=>(pc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t);var ut=(i,e,t)=>(pc(i,e,"access private method"),t);var B0=_T((Fl,nh)=>{(function(){var i,e;i=this,e=function(){return function(){var t={80:function(n,a,o){n.exports=o(728).default},728:function(n,a,o){"use strict";o.d(a,{default:function(){return hT}});var l=o(48),d=o.n(l),c=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(v){var m=16*Math.random()|0;return(v==="x"?m:3&m|8).toString(16)})},u=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},h=function(v){var m,p;if(v&&v.nodeName!==void 0)return v.muxId||(v.muxId=u()),v.muxId;try{p=document.querySelector(v)}catch{}return p&&!p.muxId&&(p.muxId=v),((m=p)===null||m===void 0?void 0:m.muxId)||v},f=function(v){var m;v&&v.nodeName!==void 0?v=h(m=v):m=document.querySelector(v);var p=m&&m.nodeName?m.nodeName.toLowerCase():"";return[m,v,p]},g=o(640),E=o.n(g),T=E().methodFactory;E().methodFactory=function(v,m,p){var y=T(v,m,p);return function(){for(var _=["[mux]"],I=0;I<arguments.length;I++)_.push(arguments[I]);y.apply(void 0,_)}},E().setLevel(E().getLevel());var S=E();function k(){return(d().doNotTrack||d().navigator&&d().navigator.doNotTrack)==="1"}var L={now:function(){var v=d().performance,m=v&&v.timing,p=m&&m.navigationStart,y=typeof p=="number"&&typeof v.now=="function"?p+v.now():Date.now();return Math.round(y)}},F=function(v){return R(v)[0]},R=function(v){if(typeof v!="string"||v==="")return["localhost"];var m,p=(v.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return p&&(m=(p.match(/[^\.]+\.[^\.]+$/)||[])[0]),[p,m]},B={exists:function(){var v=d().performance;return(v&&v.timing)!==void 0},domContentLoadedEventEnd:function(){var v=d().performance,m=v&&v.timing;return m&&m.domContentLoadedEventEnd},navigationStart:function(){var v=d().performance,m=v&&v.timing;return m&&m.navigationStart}};function P(v,m,p){p=p===void 0?1:p,v[m]=v[m]||0,v[m]+=p}var H=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],V=["x-cdn","content-type"].concat(H);function N(v){var m={};return(v=v||"").trim().split(/[\r\n]+/).forEach(function(p){if(p){var y=p.split(": "),_=y.shift();_&&(V.indexOf(_.toLowerCase())>=0||_.toLowerCase().indexOf("x-litix-")===0)&&(m[_]=y.join(": "))}}),m}function j(v){if(v){var m=H.find(function(p){return v[p]!==void 0});return m?v[m]:void 0}}var Y=function(v){var m={};for(var p in v){var y=v[p];y["DATA-ID"].search("io.litix.data.")!==-1&&(m[y["DATA-ID"].replace("io.litix.data.","")]=y.VALUE)}return m};function Ee(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);m&&(y=y.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,y)}return p}function ge(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?Ee(Object(p),!0).forEach(function(y){ye(v,y,p[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Ee(Object(p)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(p,y))})}return v}function ye(v,m,p){return m in v?Object.defineProperty(v,m,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[m]=p,v}var we=function(v){if(!v)return{};var m=B.navigationStart(),p=v.loading,y=p?p.start:v.trequest,_=p?p.first:v.tfirst,I=p?p.end:v.tload;return{bytesLoaded:v.total,requestStart:Math.round(m+y),responseStart:Math.round(m+_),responseEnd:Math.round(m+I)}},Ie=function(v){if(v&&typeof v.getAllResponseHeaders=="function")return N(v.getAllResponseHeaders())};function Z(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);m&&(y=y.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,y)}return p}function te(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?Z(Object(p),!0).forEach(function(y){re(v,y,p[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Z(Object(p)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(p,y))})}return v}function re(v,m,p){return m in v?Object.defineProperty(v,m,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[m]=p,v}var Le=function(v,m){if(!v||!v.requestEndDate)return{};var p,y=F(v.url),_=v.url,I=v.bytesLoaded,x=new Date(v.requestStartDate).getTime(),D=new Date(v.firstByteDate).getTime(),U=new Date(v.requestEndDate).getTime(),G=isNaN(v.duration)?0:v.duration,C=typeof m.getMetricsFor=="function"?m.getMetricsFor(v.mediaType).HttpList:m.getDashMetrics().getHttpRequests(v.mediaType);return C.length>0&&(p=N(C[C.length-1]._responseHeaders||"")),{requestStart:x,requestResponseStart:D,requestResponseEnd:U,requestBytesLoaded:I,requestResponseHeaders:p,requestMediaDuration:G,requestHostname:y,requestUrl:_,requestId:p?j(p):void 0}},Re=function(v,m){var p=m.getQualityFor(v),y=m.getCurrentTrackFor(v).bitrateList;return y?{currentLevel:p,renditionWidth:y[p].width||null,renditionHeight:y[p].height||null,renditionBitrate:y[p].bandwidth}:{}},Qe=function(v){var m;return(m=v.match(/.*codecs\*?="(.*)"/))===null||m===void 0?void 0:m[1]},Bt=function(v){try{var m,p;return(m=v.getVersion)===null||m===void 0||(p=m.call(v))===null||p===void 0?void 0:p.split(".").map(function(y){return parseInt(y)})[0]}catch{return!1}};function $t(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Mt=0,ji=function(){function v(){(function(_,I){if(!(_ instanceof I))throw new TypeError("Cannot call a class as a function")})(this,v)}var m,p,y;return m=v,p=[{key:"on",value:function(_,I,x){return I._eventEmitterGuid=I._eventEmitterGuid||++Mt,this._listeners=this._listeners||{},this._listeners[_]=this._listeners[_]||[],x&&(I=I.bind(x)),this._listeners[_].push(I),I}},{key:"off",value:function(_,I){var x=this._listeners&&this._listeners[_];x&&x.forEach(function(D,U){D._eventEmitterGuid===I._eventEmitterGuid&&x.splice(U,1)})}},{key:"one",value:function(_,I,x){var D=this;I._eventEmitterGuid=I._eventEmitterGuid||++Mt;var U=function G(){D.off(_,G),I.apply(x||this,arguments)};U._eventEmitterGuid=I._eventEmitterGuid,this.on(_,U)}},{key:"emit",value:function(_,I){var x=this;if(this._listeners){I=I||{};var D=this._listeners["before*"]||[],U=this._listeners[_]||[],G=this._listeners["after"+_]||[],C=function(be,ne){(be=be.slice()).forEach(function(ce){ce.call(x,{type:_},ne)})};C(D,I),C(U,I),C(G,I)}}}],p&&$t(m.prototype,p),y&&$t(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}(),Tn=ji;function Km(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Zb=function(){function v(_){var I=this;(function(x,D){if(!(x instanceof D))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,_.on("playing",function(){I._playheadShouldBeProgressing=!0}),_.on("play",this._startPlaybackHeartbeatInterval.bind(this)),_.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),_.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),_.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),_.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("seeked",function(){_.data.player_is_paused?I._stopPlaybackHeartbeatInterval():I._startPlaybackHeartbeatInterval()}),_.on("timeupdate",function(){I._playbackHeartbeatInterval!==null&&_.emit("playbackheartbeat")}),_.on("devicesleep",function(x,D){I._playbackHeartbeatInterval!==null&&(d().clearInterval(I._playbackHeartbeatInterval),_.emit("playbackheartbeatend",{viewer_time:D.viewer_time}),I._playbackHeartbeatInterval=null)})}var m,p,y;return m=v,(p=[{key:"_startPlaybackHeartbeatInterval",value:function(){var _=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=d().setInterval(function(){_.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(d().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Km(m.prototype,p),y&&Km(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function qm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Jb(v,m,p){return m&&qm(v.prototype,m),p&&qm(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var ey=Jb(function v(m){var p=this;(function(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("viewinit",function(){p.viewErrored=!1}),m.on("error",function(y,_){try{var I=m.errorTranslator({player_error_code:_.player_error_code,player_error_message:_.player_error_message,player_error_context:_.player_error_context});I?(m.data.player_error_code=I.player_error_code||_.player_error_code,m.data.player_error_message=I.player_error_message||_.player_error_message,m.data.player_error_context=I.player_error_context||_.player_error_context,p.viewErrored=!0):(delete m.data.player_error_code,delete m.data.player_error_message,delete m.data.player_error_context)}catch(x){m.mux.log.warn("Exception in error translator callback.",x),p.viewErrored=!0}})});function Ym(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var ty=function(){function v(_){(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._watchTimeTrackerLastCheckedTime=null,_.on("playbackheartbeat",this._updateWatchTime.bind(this)),_.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var m,p,y;return m=v,(p=[{key:"_updateWatchTime",value:function(_,I){var x=I.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=x),P(this.pm.data,"view_watch_time",x-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=x}},{key:"_clearWatchTimeState",value:function(_,I){this._updateWatchTime(_,I),this._watchTimeTrackerLastCheckedTime=null}}])&&Ym(m.prototype,p),y&&Ym(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function jm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var iy=function(){function v(_){var I=this;(function(U,G){if(!(U instanceof G))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=L.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var x=this._startPlaybackTimeTracking.bind(this);_.on("playing",x),_.on("adplaying",x),_.on("seeked",x);var D=this._stopPlaybackTimeTracking.bind(this);_.on("playbackheartbeatend",D),_.on("seeking",D),_.on("adplaying",function(){I._isAdPlaying=!0}),_.on("adended",function(){I._isAdPlaying=!1}),_.on("adpause",function(){I._isAdPlaying=!1}),_.on("adbreakstart",function(){I._isAdPlaying=!1}),_.on("adbreakend",function(){I._isAdPlaying=!1}),_.on("adplay",function(){I._isAdPlaying=!1}),_.on("viewinit",function(){I._playbackTimeTrackerLastPlayheadPosition=-1,I._lastTime=L.now(),I._isAdPlaying=!1,I._callbackUpdatePlaybackTime=null})}var m,p,y;return m=v,(p=[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var _=this.pm.data.player_playhead_time,I=L.now(),x=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&_>this._playbackTimeTrackerLastPlayheadPosition?x=_-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(x=I-this._lastTime),x>0&&x<=1e3&&P(this.pm.data,"view_content_playback_time",x),this._playbackTimeTrackerLastPlayheadPosition=_,this._lastTime=I}}])&&jm(m.prototype,p),y&&jm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function zm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var ry=function(){function v(_){(function(x,D){if(!(x instanceof D))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_;var I=this._updatePlayheadTime.bind(this);_.on("playbackheartbeat",I),_.on("playbackheartbeatend",I),_.on("timeupdate",I),_.on("destroy",function(){_.off("timeupdate",I)})}var m,p,y;return m=v,(p=[{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(_,I){var x=this,D=function(){x.pm.currentFragmentPDT&&x.pm.currentFragmentStart&&(x.pm.data.player_program_time=x.pm.currentFragmentPDT+x.pm.data.player_playhead_time-x.pm.currentFragmentStart)};if(I&&I.player_playhead_time)this.pm.data.player_playhead_time=I.player_playhead_time,D(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var U=this.pm.getPlayheadTime();U!==void 0&&(this.pm.data.player_playhead_time=U,D(),this._updateMaxPlayheadPosition())}}}])&&zm(m.prototype,p),y&&zm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Xm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function sy(v,m,p){return m&&Xm(v.prototype,m),p&&Xm(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Qm=3e5,ny=sy(function v(m){if(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")}(this,v),!m.disableRebufferTracking){var p,y=function(I,x){_(x),p=void 0},_=function(I){if(p){var x=I.viewer_time-p;P(m.data,"view_rebuffer_duration",x),p=I.viewer_time,m.data.view_rebuffer_duration>Qm&&(m.emit("viewend"),m.send("viewend"),m.mux.log.warn("Ending view after rebuffering for longer than ".concat(Qm,"ms, future events will be ignored unless a programchange or videochange occurs.")))}m.data.view_watch_time>=0&&m.data.view_rebuffer_count>0&&(m.data.view_rebuffer_frequency=m.data.view_rebuffer_count/m.data.view_watch_time,m.data.view_rebuffer_percentage=m.data.view_rebuffer_duration/m.data.view_watch_time)};m.on("playbackheartbeat",function(I,x){return _(x)}),m.on("rebufferstart",function(I,x){p||(P(m.data,"view_rebuffer_count",1),p=x.viewer_time,m.one("rebufferend",y))}),m.on("viewinit",function(){p=void 0,m.off("rebufferend",y)})}});function Zm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var ay=function(){function v(_){var I=this;(function(x,D){if(!(x instanceof D))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.disableRebufferTracking||_.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,_.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),_.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),_.on("seeking",function(){I._cleanupRebufferTracker(null,{viewer_time:L.now()})}))}var m,p,y;return m=v,p=[{key:"_checkIfRebuffering",value:function(_,I){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(_,I);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var x=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&x>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=I.viewer_time}else this._cleanupRebufferTracker(_,I,!0);else this._prepareRebufferTrackerState(I.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(_){this._lastCheckedTime=_,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=_}},{key:"_cleanupRebufferTracker",value:function(_,I){var x=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:I.viewer_time});else{if(this._lastCheckedTime===null)return;var D=this.pm.data.player_playhead_time-this._lastPlayheadTime,U=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&D>0&&U-D>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+U-D}))}x?this._prepareRebufferTrackerState(I.viewer_time):this._clearRebufferTrackerState()}}],p&&Zm(m.prototype,p),y&&Zm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}(),oy=ay;function Jm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var ly=function(){function v(_){var I=this;(function(x,D){if(!(x instanceof D))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){var x=_.data,D=x.view_id;if(!x.view_program_changed){var U=function(G,C){var be=C.viewer_time;G.type==="playing"&&_.data.view_time_to_first_frame===void 0?I.calculateTimeToFirstFrame(be||L.now(),D):G.type!=="adplaying"||_.data.view_time_to_first_frame!==void 0&&!I._inPrerollPosition()||I.calculateTimeToFirstFrame(be||L.now(),D)};_.one("playing",U),_.one("adplaying",U),_.one("viewend",function(){_.off("playing",U),_.off("adplaying",U)})}})}var m,p,y;return m=v,(p=[{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(_,I){I===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:_}),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))}}])&&Jm(m.prototype,p),y&&Jm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function ep(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function dy(v,m,p){return m&&ep(v.prototype,m),p&&ep(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var cy=dy(function v(m){var p=this;(function(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("viewinit",function(){p._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(y){m.on(y,function(){if(p._lastPlayheadPosition>=0&&m.data.player_playhead_time>=0&&p._lastPlayerWidth>=0&&p._lastSourceWidth>0&&p._lastPlayerHeight>=0&&p._lastSourceHeight>0){var _=m.data.player_playhead_time-p._lastPlayheadPosition;if(_<0)return void(p._lastPlayheadPosition=-1);var I=Math.min(p._lastPlayerWidth/p._lastSourceWidth,p._lastPlayerHeight/p._lastSourceHeight),x=Math.max(0,I-1),D=Math.max(0,1-I);m.data.view_max_upscale_percentage=Math.max(m.data.view_max_upscale_percentage||0,x),m.data.view_max_downscale_percentage=Math.max(m.data.view_max_downscale_percentage||0,D),P(m.data,"view_total_content_playback_time",_),P(m.data,"view_total_upscaling",x*_),P(m.data,"view_total_downscaling",D*_)}p._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(y){m.on(y,function(){p._lastPlayheadPosition=m.data.player_playhead_time,p._lastPlayerWidth=m.data.player_width,p._lastPlayerHeight=m.data.player_height,p._lastSourceWidth=m.data.video_source_width,p._lastSourceHeight=m.data.video_source_height})})});function tp(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function uy(v,m,p){return m&&tp(v.prototype,m),p&&tp(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var hy=uy(function v(m){var p=this;(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v),this.isSeeking=!1;var y=-1,_=function(){var I=L.now(),x=(m.data.viewer_time||I)-(y||I);P(m.data,"view_seek_duration",x),m.data.view_max_seek_time=Math.max(m.data.view_max_seek_time||0,x),p.isSeeking=!1,y=-1};m.on("seeking",function(I,x){Object.assign(m.data,x),p.isSeeking&&x.viewer_time-y<=2e3?y=x.viewer_time:(p.isSeeking&&_(),p.isSeeking=!0,y=x.viewer_time,P(m.data,"view_seek_count",1),m.send("seeking"))}),m.on("seeked",function(){_()}),m.on("viewend",function(){p.isSeeking&&(_(),m.send("seeked")),p.isSeeking=!1,y=-1})});function ip(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,D=[],U=!0,G=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(D.push(I.value),!y||D.length!==y);U=!0);}catch(C){G=!0,x=C}finally{try{U||_.return==null||_.return()}finally{if(G)throw x}}return D}}(v,m)||function(p,y){if(p){if(typeof p=="string")return rp(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?rp(p,y):void 0}}(v,m)||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 rp(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}function sp(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var np=function(v,m){v.push(m),v.sort(function(p,y){return p.viewer_time-y.viewer_time})},fy=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],my=function(){function v(_){var I=this;(function(D,U){if(!(D instanceof U))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){I.isAdBreak=!1,I._currentAdRequestNumber=0,I._currentAdResponseNumber=0,I._adRequests=[],I._adResponses=[],I._adHasPlayed=!1,I._wouldBeNewAdPlay=!0,I._prerollPlayTime=void 0}),fy.forEach(function(D){return _.on(D,I._updateAdData.bind(I))});var x=function(){I.isAdBreak=!1};_.on("adbreakstart",function(){I.isAdBreak=!0}),_.on("play",x),_.on("playing",x),_.on("viewend",x),_.on("adrequest",function(D,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdRequestNumber++},U),np(I._adRequests,U),P(_.data,"view_ad_request_count"),I.inPrerollPosition()&&(_.data.view_preroll_requested=!0,I._adHasPlayed||P(_.data,"view_preroll_request_count"))}),_.on("adresponse",function(D,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdResponseNumber++},U),np(I._adResponses,U);var G=I.findAdRequest(U.ad_request_id);G&&P(_.data,"view_ad_request_time",Math.max(0,U.viewer_time-G.viewer_time))}),_.on("adplay",function(D,U){I._adHasPlayed=!0,I._wouldBeNewAdPlay&&(I._wouldBeNewAdPlay=!1,P(_.data,"view_ad_played_count")),I.inPrerollPosition()&&!_.data.view_preroll_played&&(_.data.view_preroll_played=!0,I._adRequests.length>0&&(_.data.view_preroll_request_time=Math.max(0,U.viewer_time-I._adRequests[0].viewer_time)),_.data.view_start&&(_.data.view_startup_preroll_request_time=Math.max(0,U.viewer_time-_.data.view_start)),I._prerollPlayTime=U.viewer_time)}),_.on("adplaying",function(D,U){I.inPrerollPosition()&&_.data.view_preroll_load_time===void 0&&I._prerollPlayTime!==void 0&&(_.data.view_preroll_load_time=U.viewer_time-I._prerollPlayTime,_.data.view_startup_preroll_load_time=U.viewer_time-I._prerollPlayTime)}),_.on("adclicked",function(D,U){I._wouldBeNewAdPlay||P(_.data,"view_ad_clicked_count")}),_.on("adskipped",function(D,U){I._wouldBeNewAdPlay||P(_.data,"view_ad_skipped_count")}),_.on("adended",function(){I._wouldBeNewAdPlay=!0}),_.on("aderror",function(){I._wouldBeNewAdPlay=!0})}var m,p,y;return m=v,(p=[{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(_){for(var I=0;I<this._adRequests.length;I++)if(this._adRequests[I].ad_request_id===_)return this._adRequests[I]}},{key:"_updateAdData",value:function(_,I){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&I.ad_tag_url){var x=ip(R(I.ad_tag_url),2),D=x[0],U=x[1];this.pm.data.view_preroll_ad_tag_domain=U,this.pm.data.view_preroll_ad_tag_hostname=D}if(!this.pm.data.view_preroll_ad_asset_hostname&&I.ad_asset_url){var G=ip(R(I.ad_asset_url),2),C=G[0],be=G[1];this.pm.data.view_preroll_ad_asset_domain=be,this.pm.data.view_preroll_ad_asset_hostname=C}}this.pm.data.ad_asset_url=I==null?void 0:I.ad_asset_url,this.pm.data.ad_tag_url=I==null?void 0:I.ad_tag_url,this.pm.data.ad_creative_id=I==null?void 0:I.ad_creative_id,this.pm.data.ad_id=I==null?void 0:I.ad_id,this.pm.data.ad_universal_id=I==null?void 0:I.ad_universal_id}}])&&sp(m.prototype,p),y&&sp(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function ap(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function py(v,m,p){return m&&ap(v.prototype,m),p&&ap(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var gy=py(function v(m){var p,y;(function(D,U){if(!(D instanceof U))throw new TypeError("Cannot call a class as a function")})(this,v);var _=function(){m.disableRebufferTracking||p&&(P(m.data,"view_waiting_rebuffer_duration",L.now()-p),p=!1,d().clearInterval(y))},I=!1,x=function(){I=!1,_()};m.on("waiting",function(){I&&(m.disableRebufferTracking||(P(m.data,"view_waiting_rebuffer_count",1),p=L.now(),y=d().setInterval(function(){if(p){var D=L.now();P(m.data,"view_waiting_rebuffer_duration",D-p),p=D}},250)))}),m.on("playing",function(){_(),I=!0}),m.on("pause",x),m.on("seeking",x)});function op(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function vy(v,m,p){return m&&op(v.prototype,m),p&&op(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Ey=vy(function v(m){var p=this;(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v);var y=function(){p.lastWallClockTime=L.now(),m.on("before*",_)},_=function(I){var x=L.now(),D=p.lastWallClockTime;p.lastWallClockTime=x,x-D>3e4&&(m.emit("devicesleep",{viewer_time:D}),Object.assign(m.data,{viewer_time:D}),m.send("devicesleep"),m.emit("devicewake",{viewer_time:x}),Object.assign(m.data,{viewer_time:x}),m.send("devicewake"))};m.one("playbackheartbeat",y),m.on("playbackheartbeatend",function(){m.off("before*",_),m.one("playbackheartbeat",y)})}),lp=o(375),by=o(655),dp=o.n(by),cp="muxData",up=function(){var v;try{v=lp.parse(dp().get(cp)||"")}catch{v={}}return v},hp=function(v){try{dp().set(cp,lp.stringify(v),{expires:365})}catch{}},yy=function(){var v=up();return v.mux_viewer_id=v.mux_viewer_id||c(),v.msn=v.msn||Math.random(),hp(v),{mux_viewer_id:v.mux_viewer_id,mux_sample_number:v.msn}};function Ty(v,m){var p=m.beaconCollectionDomain,y=m.beaconDomain;if(p)return"https://"+p;var _=y||"litix.io";return(v=v||"inferred").match(/^[a-z0-9]+$/)?"https://"+v+"."+_:"https://img.litix.io/a.gif"}var fp=function(){var v;switch(mp()){case"cellular":v="cellular";break;case"ethernet":v="wired";break;case"wifi":v="wifi";break;case void 0:break;default:v="other"}return v},mp=function(){var v=d().navigator,m=v&&(v.connection||v.mozConnection||v.webkitConnection);return m&&m.type};fp.getConnectionFromAPI=mp;var _y=fp,Ay=gp({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"}),pp=gp({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",ck:"clicked",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",sd:"skipped",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 gp(v){var m={};for(var p in v)v.hasOwnProperty(p)&&(m[v[p]]=p);return m}function oc(v){var m={},p={};return Object.keys(v).forEach(function(y){var _=!1;if(v.hasOwnProperty(y)&&v[y]!==void 0){var I=y.split("_"),x=I[0],D=Ay[x];D||(S.info("Data key word `"+I[0]+"` not expected in "+y),D=x+"_"),I.splice(1).forEach(function(U){U==="url"&&(_=!0),pp[U]?D+=pp[U]:Number(U)&&Math.floor(Number(U))===Number(U)?D+=U:(S.info("Data key word `"+U+"` not expected in "+y),D+="_"+U+"_")}),_?p[D]=v[y]:m[D]=v[y]}}),Object.assign(m,p)}var Sy={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},xy=["hb","requestcompleted","requestfailed","requestcanceled"],Iy="https://img.litix.io",zi=function(v){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=v||Iy,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},Sy,m)};zi.prototype.queueEvent=function(v,m){var p=Object.assign({},m);return(this._eventQueue.length<=this._options.maxQueueLength||v==="eventrateexceeded")&&(this._eventQueue.push(p),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},zi.prototype.flushEvents=function(){var v=arguments.length>0&&arguments[0]!==void 0&&arguments[0];v&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},zi.prototype.destroy=function(){var v=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,v?this._clearBeaconQueue():this.flushEvents(),d().clearTimeout(this._sendTimeout)},zi.prototype._clearBeaconQueue=function(){var v=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,m=this._eventQueue.slice(v);v>0&&Object.assign(m[m.length-1],oc({mux_view_message:"event queue truncated"}));var p=this._createPayload(m);vp(this._beaconUrl,p,!0,function(){})},zi.prototype._sendBeaconQueue=function(){var v=this;if(!this._postInFlight){var m=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var p=this._createPayload(m),y=L.now();vp(this._beaconUrl,p,!1,function(_,I){I?(v._eventQueue=m.concat(v._eventQueue),v._failureCount+=1,S.info("Error sending beacon: "+I)):v._failureCount=0,v._roundTripTime=L.now()-y,v._postInFlight=!1})}},zi.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var v=Math.pow(2,this._failureCount-1);return(1+(v*=Math.random()))*this._options.baseTimeBetweenBeacons},zi.prototype._startBeaconSending=function(){var v=this;d().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=d().setTimeout(function(){v._eventQueue.length&&v._sendBeaconQueue(),v._startBeaconSending()},this._getNextBeaconTime()))},zi.prototype._createPayload=function(v){var m,p,y,_=this,I={transmission_timestamp:Math.round(L.now())};this._roundTripTime&&(I.rtt_ms=Math.round(this._roundTripTime));var x=function(){m=JSON.stringify({metadata:I,events:p||v}),y=m.length/1024},D=function(){return y<=_._options.maxPayloadKBSize};return x(),D()||(S.info("Payload size is too big ("+y+" kb). Removing unnecessary events."),p=v.filter(function(U){return xy.indexOf(U.e)===-1}),x()),D()||(S.info("Payload size still too big ("+y+" kb). Cropping fields.."),p.forEach(function(U){for(var G in U){var C=U[G];typeof C=="string"&&C.length>51200&&(U[G]=C.substring(0,51200))}}),x()),m};var Ly=function(v){return v.length<=57344},vp=function(v,m,p,y){if(p&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(v,m))y();else if(d().fetch)d().fetch(v,{method:"POST",body:m,headers:{"Content-Type":"text/plain"},keepalive:Ly(m)}).then(function(I){return y(null,I.ok?null:"Error")}).catch(function(I){return y(null,I)});else{if(d().XMLHttpRequest){var _=new(d()).XMLHttpRequest;return _.onreadystatechange=function(){if(_.readyState===4)return y(null,_.status!==200?"error":void 0)},_.open("POST",v),_.setRequestHeader("Content-Type","text/plain"),void _.send(m)}y()}},Ry=zi;function ky(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,D=[],U=!0,G=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(D.push(I.value),!y||D.length!==y);U=!0);}catch(C){G=!0,x=C}finally{try{U||_.return==null||_.return()}finally{if(G)throw x}}return D}}(v,m)||function(p,y){if(p){if(typeof p=="string")return Ep(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?Ep(p,y):void 0}}(v,m)||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 Ep(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}function bp(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);m&&(y=y.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,y)}return p}function Is(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?bp(Object(p),!0).forEach(function(y){ja(v,y,p[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):bp(Object(p)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(p,y))})}return v}function _n(v){return _n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},_n(v)}function wy(v,m){if(!(v instanceof m))throw new TypeError("Cannot call a class as a function")}function yp(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function ja(v,m,p){return m in v?Object.defineProperty(v,m,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[m]=p,v}var Dy=["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"],Cy=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],My=["ad_id","ad_creative_id","ad_universal_id"],Py=["viewstart","error","ended","viewend"],Oy=function(){function v(_,I){var x,D,U,G,C,be,ne,ce,_e,le,Te,lt,It,Pt,ze,ar=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};wy(this,v),ja(this,"previousBeaconData",null),ja(this,"lastEventTime",0),ja(this,"rateLimited",!1),this.mux=_,this.envKey=I,this.options=ar,this.eventQueue=new Ry(Ty(this.envKey,this.options)),this.sampleRate=(x=this.options.sampleRate)!==null&&x!==void 0?x:1,this.disableCookies=(D=this.options.disableCookies)!==null&&D!==void 0&&D,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:(G=this.options.platform)===null||G===void 0?void 0:G.name,viewer_application_version:(C=this.options.platform)===null||C===void 0?void 0:C.version,viewer_application_engine:(be=this.options.platform)===null||be===void 0?void 0:be.layout,viewer_device_name:(ne=this.options.platform)===null||ne===void 0?void 0:ne.product,viewer_device_category:"",viewer_device_manufacturer:(ce=this.options.platform)===null||ce===void 0?void 0:ce.manufacturer,viewer_os_family:(_e=this.options.platform)===null||_e===void 0||(le=_e.os)===null||le===void 0?void 0:le.family,viewer_os_architecture:(Te=this.options.platform)===null||Te===void 0||(lt=Te.os)===null||lt===void 0?void 0:lt.architecture,viewer_os_version:(It=this.options.platform)===null||It===void 0||(Pt=It.os)===null||Pt===void 0?void 0:Pt.version,viewer_connection_type:_y(),page_url:d()===null||d()===void 0||(ze=d().location)===null||ze===void 0?void 0:ze.href},this.viewerData=this.disableCookies?{}:yy()}var m,p,y;return m=v,(p=[{key:"send",value:function(_,I){var x;if(_&&I!=null&&I.view_id){if(this.respectDoNotTrack&&k())return S.info("Not sending `"+_+"` because Do Not Track is enabled");if(!I||_n(I)!=="object")return S.error("A data object was expected in send() but was not provided");var D,U,G=this.disableCookies?{}:(D=up(),U=L.now(),D.session_start&&(D.sst=D.session_start,delete D.session_start),D.session_id&&(D.sid=D.session_id,delete D.session_id),D.session_expires&&(D.sex=D.session_expires,delete D.session_expires),(!D.sex||D.sex<U)&&(D.sid=c(),D.sst=U),D.sex=U+15e5,hp(D),{session_id:D.sid,session_start:D.sst,session_expires:D.sex}),C=Is(Is(Is(Is(Is({},this.pageLevelData),I),G),this.viewerData),{},{event:_,env_key:this.envKey});C.user_id&&(C.viewer_user_id=C.user_id,delete C.user_id);var be=((x=C.mux_sample_number)!==null&&x!==void 0?x:0)>=this.sampleRate,ne=oc(this._deduplicateBeaconData(_,C));if(this.lastEventTime=this.mux.utils.now(),be)return S.info("Not sending event due to sample rate restriction",_,C,ne);if(this.envKey||S.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",_,C,ne),!this.rateLimited){if(S.info("Sending event",_,C,ne),this.rateLimited=!this.eventQueue.queueEvent(_,ne),this.mux.WINDOW_UNLOADING&&_==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&_==="hb"?this.eventQueue.flushEvents(!0):Py.indexOf(_)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return C.event="eventrateexceeded",ne=oc(C),this.eventQueue.queueEvent(C.event,ne),S.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(_,I){var x=this,D={},U=I.view_id;if(U==="-1"||_==="viewstart"||_==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)D=Is({},I),U&&(this.previousBeaconData=D),U&&_==="viewend"&&(this.previousBeaconData=null);else{var G=_.indexOf("request")===0;Object.entries(I).forEach(function(C){var be=ky(C,2),ne=be[0],ce=be[1];x.previousBeaconData&&(ce!==x.previousBeaconData[ne]||Dy.indexOf(ne)>-1||x.objectHasChanged(G,ne,ce,x.previousBeaconData[ne])||x.eventRequiresKey(_,ne))&&(D[ne]=ce,x.previousBeaconData[ne]=ce)})}return D}},{key:"objectHasChanged",value:function(_,I,x,D){return!(!_||I.indexOf("request_")!==0||I!=="request_response_headers"&&_n(x)==="object"&&_n(D)==="object"&&Object.keys(x||{}).length===Object.keys(D||{}).length)}},{key:"eventRequiresKey",value:function(_,I){return _==="renditionchange"&&I.indexOf("video_source_")===0||!(!My.includes(I)||!Cy.includes(_))}}])&&yp(m.prototype,p),y&&yp(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Tp(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Ny(v,m,p){return m&&Tp(v.prototype,m),p&&Tp(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Uy=Ny(function v(m){(function(G,C){if(!(G instanceof C))throw new TypeError("Cannot call a class as a function")})(this,v);var p=0,y=0,_=0,I=0,x=0,D=0,U=0;m.on("requestcompleted",function(G,C){var be,ne,ce=C.request_start,_e=C.request_response_start,le=C.request_response_end,Te=C.request_bytes_loaded;if(I++,_e?(be=_e-(ce!=null?ce:0),ne=(le!=null?le:0)-_e):ne=(le!=null?le:0)-(ce!=null?ce:0),ne>0&&Te&&Te>0){var lt=Te/ne*8e3;x++,y+=Te,_+=ne,m.data.view_min_request_throughput=Math.min(m.data.view_min_request_throughput||1/0,lt),m.data.view_average_request_throughput=y/_*8e3,m.data.view_request_count=I,be>0&&(p+=be,m.data.view_max_request_latency=Math.max(m.data.view_max_request_latency||0,be),m.data.view_average_request_latency=p/x)}}),m.on("requestfailed",function(G,C){I++,D++,m.data.view_request_count=I,m.data.view_request_failed_count=D}),m.on("requestcanceled",function(G,C){I++,U++,m.data.view_request_count=I,m.data.view_request_canceled_count=U})});function _p(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Fy(v,m,p){return m&&_p(v.prototype,m),p&&_p(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var By=Fy(function v(m){var p=this;(function(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("before*",function(y,_){var I=_.viewer_time,x=L.now(),D=p._lastEventTime;if(p._lastEventTime=x,D&&x-D>36e5){var U=Object.keys(m.data).reduce(function(G,C){return C.indexOf("video_")===0?Object.assign(G,function(be,ne,ce){return ne in be?Object.defineProperty(be,ne,{value:ce,enumerable:!0,configurable:!0,writable:!0}):be[ne]=ce,be}({},C,m.data[C])):G},{});m.mux.log.info("Received event after at least an hour inactivity, creating a new view"),m.emit("viewinit",Object.assign({viewer_time:I},U)),m.playbackHeartbeat._playheadShouldBeProgressing&&y.type!=="play"&&y.type!=="adbreakstart"&&(m.emit("play",{viewer_time:I}),y.type!=="playing"&&m.emit("playing",{viewer_time:I}))}})});function lc(v){return lc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},lc(v)}function $y(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,D=[],U=!0,G=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(D.push(I.value),!y||D.length!==y);U=!0);}catch(C){G=!0,x=C}finally{try{U||_.return==null||_.return()}finally{if(G)throw x}}return D}}(v,m)||function(p,y){if(p){if(typeof p=="string")return Ap(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?Ap(p,y):void 0}}(v,m)||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 Ap(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}function Sp(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function dc(v,m){return dc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,y){return p.__proto__=y,p},dc(v,m)}function Hy(v){var m=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 p,y=za(v);if(m){var _=za(this).constructor;p=Reflect.construct(y,arguments,_)}else p=y.apply(this,arguments);return Gy(this,p)}}function Gy(v,m){if(m&&(lc(m)==="object"||typeof m=="function"))return m;if(m!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return pt(v)}function pt(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function za(v){return za=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(m){return m.__proto__||Object.getPrototypeOf(m)},za(v)}var Vy=["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"],Wy=function(v){(function(x,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function");x.prototype=Object.create(D&&D.prototype,{constructor:{value:x,writable:!0,configurable:!0}}),Object.defineProperty(x,"prototype",{writable:!1}),D&&dc(x,D)})(I,v);var m,p,y,_=Hy(I);function I(x,D,U){var G,C;(function(le,Te){if(!(le instanceof Te))throw new TypeError("Cannot call a class as a function")})(this,I),(C=_.call(this)).DOM_CONTENT_LOADED_EVENT_END=B.domContentLoadedEventEnd(),C.NAVIGATION_START=B.navigationStart(),C.mux=x,C.id=D,(G=U)!==null&&G!==void 0&&G.beaconDomain&&C.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),(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(le){return le}},U)).data=U.data||{},U.data.property_key&&(U.data.env_key=U.data.property_key,delete U.data.property_key),S.setLevel(U.debug?"debug":"warn"),C.getPlayheadTime=U.getPlayheadTime,C.getStateData=U.getStateData||function(){return{}},C.getAdData=U.getAdData||function(){},C.minimumRebufferDuration=U.minimumRebufferDuration,C.sustainedRebufferThreshold=U.sustainedRebufferThreshold,C.playbackHeartbeatTime=U.playbackHeartbeatTime,C.disableRebufferTracking=U.disableRebufferTracking,C.disableRebufferTracking&&C.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."),C.disablePlayheadRebufferTracking=U.disablePlayheadRebufferTracking,C.errorTranslator=U.errorTranslator,C.playbackEventDispatcher=new Oy(x,U.data.env_key,U),C.data={player_instance_id:c(),mux_sample_rate:U.sampleRate,beacon_domain:U.beaconCollectionDomain||U.beaconDomain},C.data.view_sequence_number=1,C.data.player_sequence_number=1,C.oldEmit=C.emit,C.emit=function(le,Te){Te=Object.assign({viewer_time:this.mux.utils.now()},Te),this.oldEmit(le,Te)};var be=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(pt(C));C.on("viewinit",function(le,Te){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,Te),this._initializeViewData(),this.one("play",be),this.one("adbreakstart",be)});var ne=function(le){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",le)}.bind(pt(C));if(C.on("videochange",function(le,Te){ne(Te)}),C.on("programchange",function(le,Te){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),ne(Object.assign(Te,{view_program_changed:!0})),be(),this.emit("play"),this.emit("playing")}),C.on("fragmentchange",function(le,Te){this.currentFragmentPDT=Te.currentFragmentPDT,this.currentFragmentStart=Te.currentFragmentStart}),C.on("destroy",C.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ce=function(){var le=C.data.view_start!==void 0;C.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",le&&C.mux.WINDOW_HIDDEN&&(C.data.player_is_paused||C.emit("hb"))};window.addEventListener("visibilitychange",ce,!1);var _e=function(le){le.persisted||C.destroy()};window.addEventListener("pagehide",_e,!1),C.on("destroy",function(){window.removeEventListener("visibilitychange",ce),window.removeEventListener("pagehide",_e)})}return C.on("playerready",function(le,Te){Object.assign(this.data,Te)}),Vy.forEach(function(le){C.on(le,function(Te,lt){le.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,lt),this._sanitizeData()}),C.on("after"+le,function(){(le!=="error"||this.errorTracker.viewErrored)&&this.send(le)})}),C.on("viewend",function(le,Te){Object.assign(C.data,Te)}),C.one("playerready",function(le){var Te=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=Te-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),C.longResumeTracker=new By(pt(C)),C.errorTracker=new ey(pt(C)),new Ey(pt(C)),C.seekingTracker=new hy(pt(C)),C.playheadTime=new ry(pt(C)),C.playbackHeartbeat=new Zb(pt(C)),new cy(pt(C)),C.watchTimeTracker=new ty(pt(C)),new iy(pt(C)),C.adTracker=new my(pt(C)),new oy(pt(C)),new ny(pt(C)),new ly(pt(C)),new gy(pt(C)),new Uy(pt(C)),U.hlsjs&&C.addHLSJS(U),U.dashjs&&C.addDashJS(U),C.emit("viewinit",U.data),C}return m=I,p=[{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(x){if(this.data.view_id){var D=Object.assign({},this.data);if(D.video_source_is_live===void 0&&(D.player_source_duration===1/0||D.video_source_duration===1/0?D.video_source_is_live=!0:(D.player_source_duration>0||D.video_source_duration>0)&&(D.video_source_is_live=!1)),D.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(be){D[be]=void 0}),D.video_source_url=D.video_source_url||D.player_source_url,D.video_source_url){var U=$y(R(D.video_source_url),2),G=U[0],C=U[1];D.video_source_domain=C,D.video_source_hostname=G}delete D.ad_request_id,this.playbackEventDispatcher.send(x,D),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),x==="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 x=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(D){var U=parseInt(x.data[D],10);x.data[D]=isNaN(U)?void 0:U}),["player_source_url","video_source_url"].forEach(function(D){if(x.data[D]){var U=x.data[D].toLowerCase();U.indexOf("data:")!==0&&U.indexOf("blob:")!==0||(x.data[D]="MSE style URL")}})}},{key:"_resetVideoData",value:function(x,D){var U=this;Object.keys(this.data).forEach(function(G){G.indexOf("video_")===0&&delete U.data[G]})}},{key:"_resetViewData",value:function(){var x=this;Object.keys(this.data).forEach(function(D){D.indexOf("view_")===0&&delete x.data[D]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(x,D){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var x=this,D=this.data.view_id=c(),U=function(){D===x.data.view_id&&P(x.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",U):U()}},{key:"_restartHeartBeat",value:function(){var x=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){x.data.player_is_paused||x.emit("hb")},1e4))}},{key:"addHLSJS",value:function(x){x.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=x.hlsjs,function(D,U,G){var C=arguments.length>4?arguments[4]:void 0,be=D.log,ne=D.utils.secondsToMs,ce=function(rt){var ae,Q=parseInt(C.version);return Q===1&&rt.programDateTime!==null&&(ae=rt.programDateTime),Q===0&&rt.pdt!==null&&(ae=rt.pdt),ae};if(B.exists()){var _e=function(rt,ae){return D.emit(U,rt,ae)},le=function(rt,ae){var Q=ae.levels,X=ae.audioTracks,fe=ae.url,ve=ae.stats,Ae=ae.networkDetails,Ne=ae.sessionData,st={},Ze={};Q.forEach(function(Jt,Mr){st[Mr]={width:Jt.width,height:Jt.height,bitrate:Jt.bitrate,attrs:Jt.attrs}}),X.forEach(function(Jt,Mr){Ze[Mr]={name:Jt.name,language:Jt.lang,bitrate:Jt.bitrate}});var De=we(ve),gt=De.bytesLoaded,or=De.requestStart,In=De.responseStart,Ln=De.responseEnd;_e("requestcompleted",ge(ge({},Y(Ne)),{},{request_event_type:rt,request_bytes_loaded:gt,request_start:or,request_response_start:In,request_response_end:Ln,request_type:"manifest",request_hostname:F(fe),request_response_headers:Ie(Ae),request_rendition_lists:{media:st,audio:Ze,video:{}}}))};G.on(C.Events.MANIFEST_LOADED,le);var Te=function(rt,ae){var Q=ae.details,X=ae.level,fe=ae.networkDetails,ve=ae.stats,Ae=we(ve),Ne=Ae.bytesLoaded,st=Ae.requestStart,Ze=Ae.responseStart,De=Ae.responseEnd,gt=Q.fragments[Q.fragments.length-1],or=ce(gt)+ne(gt.duration);_e("requestcompleted",{request_event_type:rt,request_bytes_loaded:Ne,request_start:st,request_response_start:Ze,request_response_end:De,request_current_level:X,request_type:"manifest",request_hostname:F(Q.url),request_response_headers:Ie(fe),video_holdback:Q.holdBack&&ne(Q.holdBack),video_part_holdback:Q.partHoldBack&&ne(Q.partHoldBack),video_part_target_duration:Q.partTarget&&ne(Q.partTarget),video_target_duration:Q.targetduration&&ne(Q.targetduration),video_source_is_live:Q.live,player_manifest_newest_program_time:isNaN(or)?void 0:or})};G.on(C.Events.LEVEL_LOADED,Te);var lt=function(rt,ae){var Q=ae.details,X=ae.networkDetails,fe=ae.stats,ve=we(fe),Ae=ve.bytesLoaded,Ne=ve.requestStart,st=ve.responseStart,Ze=ve.responseEnd;_e("requestcompleted",{request_event_type:rt,request_bytes_loaded:Ae,request_start:Ne,request_response_start:st,request_response_end:Ze,request_type:"manifest",request_hostname:F(Q.url),request_response_headers:Ie(X)})};G.on(C.Events.AUDIO_TRACK_LOADED,lt);var It=function(rt,ae){var Q=ae.stats,X=ae.networkDetails,fe=ae.frag;Q=Q||fe.stats;var ve=we(Q),Ae=ve.bytesLoaded,Ne=ve.requestStart,st=ve.responseStart,Ze=ve.responseEnd,De=X?Ie(X):void 0,gt={request_event_type:rt,request_bytes_loaded:Ae,request_start:Ne,request_response_start:st,request_response_end:Ze,request_hostname:X?F(X.responseURL):void 0,request_id:De?j(De):void 0,request_response_headers:De,request_media_duration:fe.duration,request_url:X==null?void 0:X.responseURL};fe.type==="main"?(gt.request_type="media",gt.request_current_level=fe.level,gt.request_video_width=(G.levels[fe.level]||{}).width,gt.request_video_height=(G.levels[fe.level]||{}).height,gt.request_labeled_bitrate=(G.levels[fe.level]||{}).bitrate):gt.request_type=fe.type,_e("requestcompleted",gt)};G.on(C.Events.FRAG_LOADED,It);var Pt=function(rt,ae){var Q=ae.frag,X=Q.start,fe={currentFragmentPDT:ce(Q),currentFragmentStart:ne(X)};_e("fragmentchange",fe)};G.on(C.Events.FRAG_CHANGED,Pt);var ze=function(rt,ae){var Q=ae.type,X=ae.details,fe=ae.response,ve=ae.fatal,Ae=ae.frag,Ne=ae.networkDetails,st=(Ae==null?void 0:Ae.url)||ae.url||"",Ze=Ne?Ie(Ne):void 0;if(X!==C.ErrorDetails.MANIFEST_LOAD_ERROR&&X!==C.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&X!==C.ErrorDetails.FRAG_LOAD_ERROR&&X!==C.ErrorDetails.FRAG_LOAD_TIMEOUT&&X!==C.ErrorDetails.LEVEL_LOAD_ERROR&&X!==C.ErrorDetails.LEVEL_LOAD_TIMEOUT&&X!==C.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&X!==C.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&X!==C.ErrorDetails.SUBTITLE_LOAD_ERROR&&X!==C.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&X!==C.ErrorDetails.KEY_LOAD_ERROR&&X!==C.ErrorDetails.KEY_LOAD_TIMEOUT||_e("requestfailed",{request_error:X,request_url:st,request_hostname:F(st),request_id:Ze?j(Ze):void 0,request_type:X===C.ErrorDetails.FRAG_LOAD_ERROR||X===C.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":X===C.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||X===C.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":X===C.ErrorDetails.SUBTITLE_LOAD_ERROR||X===C.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":X===C.ErrorDetails.KEY_LOAD_ERROR||X===C.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:fe==null?void 0:fe.code,request_error_text:fe==null?void 0:fe.text}),ve){var De,gt="".concat(st?"url: ".concat(st,`
5
5
  `):"")+"".concat(fe&&(fe.code||fe.text)?"response: ".concat(fe.code,", ").concat(fe.text,`
6
6
  `):"")+"".concat(ae.reason?"failure reason: ".concat(ae.reason,`
7
7
  `):"")+"".concat(ae.level?"level: ".concat(ae.level,`
@@ -10,13 +10,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
10
10
  `):"")+"".concat(ae.error?"error: ".concat(ae.error,`
11
11
  `):"")+"".concat(ae.event?"event: ".concat(ae.event,`
12
12
  `):"")+"".concat(ae.err?"error message: ".concat((De=ae.err)===null||De===void 0?void 0:De.message,`
13
- `):"");_e("error",{player_error_code:Q,player_error_message:X,player_error_context:pt})}};H.on(C.Events.ERROR,je);var sr=function(it,ae){var Q=ae.frag,X=Q&&Q._url||"";_e("requestcanceled",{request_event_type:it,request_url:X,request_type:"media",request_hostname:F(X)})};H.on(C.Events.FRAG_LOAD_EMERGENCY_ABORTED,sr);var Sn=function(it,ae){var Q=ae.level,X=H.levels[Q];if(X&&X.attrs&&X.attrs.BANDWIDTH){var fe,ve=X.attrs.BANDWIDTH,Ae=parseFloat(X.attrs["FRAME-RATE"]);isNaN(Ae)||(fe=Ae),ve?_e("renditionchange",{video_source_fps:fe,video_source_bitrate:ve,video_source_width:X.width,video_source_height:X.height,video_source_rendition_name:X.name,video_source_codec:X==null?void 0:X.videoCodec}):be.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};H.on(C.Events.LEVEL_SWITCHED,Sn),H._stopMuxMonitor=function(){H.off(C.Events.MANIFEST_LOADED,le),H.off(C.Events.LEVEL_LOADED,Te),H.off(C.Events.AUDIO_TRACK_LOADED,ot),H.off(C.Events.FRAG_LOADED,At),H.off(C.Events.FRAG_CHANGED,wt),H.off(C.Events.ERROR,je),H.off(C.Events.FRAG_LOAD_EMERGENCY_ABORTED,sr),H.off(C.Events.LEVEL_SWITCHED,Sn),H.off(C.Events.DESTROYING,H._stopMuxMonitor),delete H._stopMuxMonitor},H.on(C.Events.DESTROYING,H._stopMuxMonitor)}else be.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,x.hlsjs,{},x.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var x;this.hlsjs&&((x=this.hlsjs)&&typeof x._stopMuxMonitor=="function"&&x._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(x){x.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=x.dashjs,function(w,U,H){var C=w.log;if(H&&H.on){var be=Ot(H),ne=function(Q,X){return w.emit(U,Q,X)},ce=function(Q){var X=Q.type,fe=(Q.data||{}).url;ne("requestcompleted",{request_event_type:X,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:F(fe),request_url:fe})};H.on("manifestLoaded",ce);var _e={},le=function(Q){if(typeof Q.getRequests!="function")return null;var X=Q.getRequests({state:"executed"});return X.length===0?null:X[X.length-1]},Te=function(Q){var X=Q.type,fe=Q.fragmentModel,ve=Q.chunk,Ae=le(fe);ot({type:X,request:Ae,chunk:ve})},ot=function(Q){var X=Q.type,fe=Q.chunk,ve=Q.request,Ae=(fe||{}).mediaInfo||{},Oe=Ae.type,rt=Ae.bitrateList,Ze={};(rt=rt||[]).forEach(function(Ln,_i){Ze[_i]={},Ze[_i].width=Ln.width,Ze[_i].height=Ln.height,Ze[_i].bitrate=Ln.bandwidth,Ze[_i].attrs={}}),Oe==="video"?_e.video=Ze:Oe==="audio"?_e.audio=Ze:_e.media=Ze;var De=Le(ve,H),pt=De.requestStart,nr=De.requestResponseStart,xn=De.requestResponseEnd,In=De.requestResponseHeaders,Zt=De.requestMediaDuration,Cr=De.requestHostname,ac=De.requestUrl,oc=De.requestId;ne("requestcompleted",{request_event_type:X,request_start:pt,request_response_start:nr,request_response_end:xn,request_bytes_loaded:-1,request_type:Oe+"_init",request_response_headers:In,request_hostname:Cr,request_id:oc,request_url:ac,request_media_duration:Zt,request_rendition_lists:_e})};be>=4?H.on("initFragmentLoaded",ot):H.on("initFragmentLoaded",Te);var At=function(Q){var X=Q.type,fe=Q.fragmentModel,ve=Q.chunk,Ae=le(fe);wt({type:X,request:Ae,chunk:ve})},wt=function(Q){var X=Q.type,fe=Q.chunk,ve=Q.request,Ae=fe||{},Oe=Ae.mediaInfo,rt=Ae.start,Ze=(Oe||{}).type,De=Le(ve,H),pt=De.requestStart,nr=De.requestResponseStart,xn=De.requestResponseEnd,In=De.requestBytesLoaded,Zt=De.requestResponseHeaders,Cr=De.requestMediaDuration,ac=De.requestHostname,oc=De.requestUrl,Ln=De.requestId,_i=Re(Ze,H),Jy=_i.currentLevel,eT=_i.renditionWidth,tT=_i.renditionHeight,iT=_i.renditionBitrate;ne("requestcompleted",{request_event_type:X,request_start:pt,request_response_start:nr,request_response_end:xn,request_bytes_loaded:In,request_type:Ze,request_response_headers:Zt,request_hostname:ac,request_id:Ln,request_url:oc,request_media_start_time:rt,request_media_duration:Cr,request_current_level:Jy,request_labeled_bitrate:iT,request_video_width:eT,request_video_height:tT})};be>=4?H.on("mediaFragmentLoaded",wt):H.on("mediaFragmentLoaded",At);var je={video:void 0,audio:void 0,totalBitrate:void 0},sr=function(){if(je.video&&typeof je.video.bitrate=="number"){if(je.video.width&&je.video.height){var Q=je.video.bitrate;return je.audio&&typeof je.audio.bitrate=="number"&&(Q+=je.audio.bitrate),Q!==je.totalBitrate?(je.totalBitrate=Q,{video_source_bitrate:Q,video_source_height:je.video.height,video_source_width:je.video.width,video_source_codec:Qe(je.video.codec)}):void 0}C.warn("have bitrate info for video but missing width/height")}},Sn=function(Q,X,fe){if(typeof Q.newQuality=="number"){var ve=Q.mediaType;if(ve==="audio"||ve==="video"){var Ae=H.getBitrateInfoListFor(ve).find(function(rt){return rt.qualityIndex===Q.newQuality});if(Ae&&typeof Ae.bitrate=="number"){je[ve]=te(te({},Ae),{},{codec:H.getCurrentTrackFor(ve).codec});var Oe=sr();Oe&&ne("renditionchange",Oe)}else C.warn("missing bitrate info for ".concat(ve))}}else C.warn("missing evt.newQuality in qualityChangeRendered event",Q)};H.on("qualityChangeRendered",Sn);var it=function(Q){var X=Q.request,fe=Q.mediaType;ne("requestcanceled",{request_event_type:(X=X||{}).type+"_"+X.action,request_url:X.url,request_type:fe,request_hostname:F(X.url)})};H.on("fragmentLoadingAbandoned",it);var ae=function(Q){var X,fe,ve=Q.error,Ae=(ve==null||(X=ve.data)===null||X===void 0?void 0:X.request)||{},Oe=(ve==null||(fe=ve.data)===null||fe===void 0?void 0:fe.response)||{};(ve==null?void 0:ve.code)===27&&ne("requestfailed",{request_error:Ae.type+"_"+Ae.action,request_url:Ae.url,request_hostname:F(Ae.url),request_type:Ae.mediaType,request_error_code:Oe.status,request_error_text:Oe.statusText});var rt="".concat(Ae!=null&&Ae.url?"url: ".concat(Ae.url,`
14
- `):"")+"".concat(Oe!=null&&Oe.status||Oe!=null&&Oe.statusText?"response: ".concat(Oe==null?void 0:Oe.status,", ").concat(Oe==null?void 0:Oe.statusText,`
15
- `):"");ne("error",{player_error_code:ve==null?void 0:ve.code,player_error_message:ve==null?void 0:ve.message,player_error_context:rt})};H.on("error",ae),H._stopMuxMonitor=function(){H.off("manifestLoaded",ce),H.off("initFragmentLoaded",ot),H.off("mediaFragmentLoaded",wt),H.off("qualityChangeRendered",Sn),H.off("error",ae),H.off("fragmentLoadingAbandoned",it),delete H._stopMuxMonitor}}else C.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,x.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var x;this.dashjs&&((x=this.dashjs)&&typeof x._stopMuxMonitor=="function"&&x._stopMuxMonitor(),this.dashjs=void 0)}}],p&&pp(m.prototype,p),y&&pp(m,y),Object.defineProperty(m,"prototype",{writable:!1}),I}(yn),Dy=wy,Cy=o(153),_n=o.n(Cy);function rc(v){return rc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},rc(v)}function gp(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,w=[],U=!0,H=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(w.push(I.value),!y||w.length!==y);U=!0);}catch(C){H=!0,x=C}finally{try{U||_.return==null||_.return()}finally{if(H)throw x}}return w}}(v,m)||function(p,y){if(p){if(typeof p=="string")return vp(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?vp(p,y):void 0}}(v,m)||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 vp(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}var Is,My=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Py={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};d()&&d().WeakMap&&(Is=new WeakMap);var Oy="#EXT-X-TARGETDURATION",Ny="#EXT-X-PART-INF",Uy="#EXT-X-SERVER-CONTROL",Fy="#EXTINF",By="#EXT-X-PROGRAM-DATE-TIME",$y="#EXT-X-VERSION",Gy="#EXT-X-SESSION-DATA",Ka=function(v){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(v),this.manifest};Ka.prototype.process=function(v){var m;for(this.buffer+=v,m=this.buffer.indexOf(`
13
+ `):"");_e("error",{player_error_code:Q,player_error_message:X,player_error_context:gt})}};G.on(C.Events.ERROR,ze);var ar=function(rt,ae){var Q=ae.frag,X=Q&&Q._url||"";_e("requestcanceled",{request_event_type:rt,request_url:X,request_type:"media",request_hostname:F(X)})};G.on(C.Events.FRAG_LOAD_EMERGENCY_ABORTED,ar);var xn=function(rt,ae){var Q=ae.level,X=G.levels[Q];if(X&&X.attrs&&X.attrs.BANDWIDTH){var fe,ve=X.attrs.BANDWIDTH,Ae=parseFloat(X.attrs["FRAME-RATE"]);isNaN(Ae)||(fe=Ae),ve?_e("renditionchange",{video_source_fps:fe,video_source_bitrate:ve,video_source_width:X.width,video_source_height:X.height,video_source_rendition_name:X.name,video_source_codec:X==null?void 0:X.videoCodec}):be.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};G.on(C.Events.LEVEL_SWITCHED,xn),G._stopMuxMonitor=function(){G.off(C.Events.MANIFEST_LOADED,le),G.off(C.Events.LEVEL_LOADED,Te),G.off(C.Events.AUDIO_TRACK_LOADED,lt),G.off(C.Events.FRAG_LOADED,It),G.off(C.Events.FRAG_CHANGED,Pt),G.off(C.Events.ERROR,ze),G.off(C.Events.FRAG_LOAD_EMERGENCY_ABORTED,ar),G.off(C.Events.LEVEL_SWITCHED,xn),G.off(C.Events.DESTROYING,G._stopMuxMonitor),delete G._stopMuxMonitor},G.on(C.Events.DESTROYING,G._stopMuxMonitor)}else be.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,x.hlsjs,{},x.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var x;this.hlsjs&&((x=this.hlsjs)&&typeof x._stopMuxMonitor=="function"&&x._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(x){x.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=x.dashjs,function(D,U,G){var C=D.log;if(G&&G.on){var be=Bt(G),ne=function(Q,X){return D.emit(U,Q,X)},ce=function(Q){var X=Q.type,fe=(Q.data||{}).url;ne("requestcompleted",{request_event_type:X,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:F(fe),request_url:fe})};G.on("manifestLoaded",ce);var _e={},le=function(Q){if(typeof Q.getRequests!="function")return null;var X=Q.getRequests({state:"executed"});return X.length===0?null:X[X.length-1]},Te=function(Q){var X=Q.type,fe=Q.fragmentModel,ve=Q.chunk,Ae=le(fe);lt({type:X,request:Ae,chunk:ve})},lt=function(Q){var X=Q.type,fe=Q.chunk,ve=Q.request,Ae=(fe||{}).mediaInfo||{},Ne=Ae.type,st=Ae.bitrateList,Ze={};(st=st||[]).forEach(function(Rn,Si){Ze[Si]={},Ze[Si].width=Rn.width,Ze[Si].height=Rn.height,Ze[Si].bitrate=Rn.bandwidth,Ze[Si].attrs={}}),Ne==="video"?_e.video=Ze:Ne==="audio"?_e.audio=Ze:_e.media=Ze;var De=Le(ve,G),gt=De.requestStart,or=De.requestResponseStart,In=De.requestResponseEnd,Ln=De.requestResponseHeaders,Jt=De.requestMediaDuration,Mr=De.requestHostname,fc=De.requestUrl,mc=De.requestId;ne("requestcompleted",{request_event_type:X,request_start:gt,request_response_start:or,request_response_end:In,request_bytes_loaded:-1,request_type:Ne+"_init",request_response_headers:Ln,request_hostname:Mr,request_id:mc,request_url:fc,request_media_duration:Jt,request_rendition_lists:_e})};be>=4?G.on("initFragmentLoaded",lt):G.on("initFragmentLoaded",Te);var It=function(Q){var X=Q.type,fe=Q.fragmentModel,ve=Q.chunk,Ae=le(fe);Pt({type:X,request:Ae,chunk:ve})},Pt=function(Q){var X=Q.type,fe=Q.chunk,ve=Q.request,Ae=fe||{},Ne=Ae.mediaInfo,st=Ae.start,Ze=(Ne||{}).type,De=Le(ve,G),gt=De.requestStart,or=De.requestResponseStart,In=De.requestResponseEnd,Ln=De.requestBytesLoaded,Jt=De.requestResponseHeaders,Mr=De.requestMediaDuration,fc=De.requestHostname,mc=De.requestUrl,Rn=De.requestId,Si=Re(Ze,G),fT=Si.currentLevel,mT=Si.renditionWidth,pT=Si.renditionHeight,gT=Si.renditionBitrate;ne("requestcompleted",{request_event_type:X,request_start:gt,request_response_start:or,request_response_end:In,request_bytes_loaded:Ln,request_type:Ze,request_response_headers:Jt,request_hostname:fc,request_id:Rn,request_url:mc,request_media_start_time:st,request_media_duration:Mr,request_current_level:fT,request_labeled_bitrate:gT,request_video_width:mT,request_video_height:pT})};be>=4?G.on("mediaFragmentLoaded",Pt):G.on("mediaFragmentLoaded",It);var ze={video:void 0,audio:void 0,totalBitrate:void 0},ar=function(){if(ze.video&&typeof ze.video.bitrate=="number"){if(ze.video.width&&ze.video.height){var Q=ze.video.bitrate;return ze.audio&&typeof ze.audio.bitrate=="number"&&(Q+=ze.audio.bitrate),Q!==ze.totalBitrate?(ze.totalBitrate=Q,{video_source_bitrate:Q,video_source_height:ze.video.height,video_source_width:ze.video.width,video_source_codec:Qe(ze.video.codec)}):void 0}C.warn("have bitrate info for video but missing width/height")}},xn=function(Q,X,fe){if(typeof Q.newQuality=="number"){var ve=Q.mediaType;if(ve==="audio"||ve==="video"){var Ae=G.getBitrateInfoListFor(ve).find(function(st){return st.qualityIndex===Q.newQuality});if(Ae&&typeof Ae.bitrate=="number"){ze[ve]=te(te({},Ae),{},{codec:G.getCurrentTrackFor(ve).codec});var Ne=ar();Ne&&ne("renditionchange",Ne)}else C.warn("missing bitrate info for ".concat(ve))}}else C.warn("missing evt.newQuality in qualityChangeRendered event",Q)};G.on("qualityChangeRendered",xn);var rt=function(Q){var X=Q.request,fe=Q.mediaType;ne("requestcanceled",{request_event_type:(X=X||{}).type+"_"+X.action,request_url:X.url,request_type:fe,request_hostname:F(X.url)})};G.on("fragmentLoadingAbandoned",rt);var ae=function(Q){var X,fe,ve=Q.error,Ae=(ve==null||(X=ve.data)===null||X===void 0?void 0:X.request)||{},Ne=(ve==null||(fe=ve.data)===null||fe===void 0?void 0:fe.response)||{};(ve==null?void 0:ve.code)===27&&ne("requestfailed",{request_error:Ae.type+"_"+Ae.action,request_url:Ae.url,request_hostname:F(Ae.url),request_type:Ae.mediaType,request_error_code:Ne.status,request_error_text:Ne.statusText});var st="".concat(Ae!=null&&Ae.url?"url: ".concat(Ae.url,`
14
+ `):"")+"".concat(Ne!=null&&Ne.status||Ne!=null&&Ne.statusText?"response: ".concat(Ne==null?void 0:Ne.status,", ").concat(Ne==null?void 0:Ne.statusText,`
15
+ `):"");ne("error",{player_error_code:ve==null?void 0:ve.code,player_error_message:ve==null?void 0:ve.message,player_error_context:st})};G.on("error",ae),G._stopMuxMonitor=function(){G.off("manifestLoaded",ce),G.off("initFragmentLoaded",lt),G.off("mediaFragmentLoaded",Pt),G.off("qualityChangeRendered",xn),G.off("error",ae),G.off("fragmentLoadingAbandoned",rt),delete G._stopMuxMonitor}}else C.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,x.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var x;this.dashjs&&((x=this.dashjs)&&typeof x._stopMuxMonitor=="function"&&x._stopMuxMonitor(),this.dashjs=void 0)}}],p&&Sp(m.prototype,p),y&&Sp(m,y),Object.defineProperty(m,"prototype",{writable:!1}),I}(Tn),Ky=Wy,qy=o(153),An=o.n(qy);function cc(v){return cc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},cc(v)}function xp(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,D=[],U=!0,G=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(D.push(I.value),!y||D.length!==y);U=!0);}catch(C){G=!0,x=C}finally{try{U||_.return==null||_.return()}finally{if(G)throw x}}return D}}(v,m)||function(p,y){if(p){if(typeof p=="string")return Ip(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?Ip(p,y):void 0}}(v,m)||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 Ip(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}var Ls,Yy=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],jy={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};d()&&d().WeakMap&&(Ls=new WeakMap);var zy="#EXT-X-TARGETDURATION",Xy="#EXT-X-PART-INF",Qy="#EXT-X-SERVER-CONTROL",Zy="#EXTINF",Jy="#EXT-X-PROGRAM-DATE-TIME",eT="#EXT-X-VERSION",tT="#EXT-X-SESSION-DATA",Xa=function(v){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(v),this.manifest};Xa.prototype.process=function(v){var m;for(this.buffer+=v,m=this.buffer.indexOf(`
17
17
  `);m>-1;m=this.buffer.indexOf(`
18
- `))this.processLine(this.buffer.substring(0,m)),this.buffer=this.buffer.substring(m+1)},Ka.prototype.processLine=function(v){var m=v.indexOf(":"),p=Ky(v,m),y=p[0],_=p.length===2?nc(p[1]):void 0;if(y[0]!=="#")this.currentUri.uri=y,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(y){case Oy:if(!isFinite(_)||_<0)return;this.manifest.targetDuration=_,this.setHoldBack();break;case Ny:sc(this.manifest,p),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Uy:sc(this.manifest,p),this.setHoldBack();break;case Fy:_===0?this.currentUri.duration=.01:_>0&&(this.currentUri.duration=_);break;case By:var I=_,x=new Date(I);this.manifest.dateTimeString||(this.manifest.dateTimeString=I,this.manifest.dateTimeObject=x),this.currentUri.dateTimeString=I,this.currentUri.dateTimeObject=x;break;case $y:sc(this.manifest,p);break;case Gy:var w=qy(p[1]),U=Y(w);Object.assign(this.manifest.sessionData,U)}},Ka.prototype.setHoldBack=function(){var v=this.manifest,m=v.serverControl,p=v.targetDuration,y=v.partTargetDuration;if(m){var _="holdBack",I="partHoldBack",x=p&&3*p,w=y&&2*y;p&&!m.hasOwnProperty(_)&&(m[_]=x),x&&m[_]<x&&(m[_]=x),y&&!m.hasOwnProperty(I)&&(m[I]=3*y),y&&m[I]<w&&(m[I]=w)}};var sc=function(v,m){var p,y=Ep(m[0].replace("#EXT-X-",""));Wy(m[1])?(p={},p=Object.assign(Vy(m[1]),p)):p=nc(m[1]),v[y]=p},Ep=function(v){return v.toLowerCase().replace(/-(\w)/g,function(m){return m[1].toUpperCase()})},nc=function(v){if(v.toLowerCase()==="yes"||v.toLowerCase()==="no")return v.toLowerCase()==="yes";var m=v.indexOf(":")!==-1?v:parseFloat(v);return isNaN(m)?v:m},Hy=function(v){var m={},p=v.split("=");return p.length>1&&(m[Ep(p[0])]=nc(p[1])),m},Vy=function(v){for(var m=v.split(","),p={},y=0;m.length>y;y++){var _=m[y],I=Hy(_);p=Object.assign(I,p)}return p},Wy=function(v){return v.indexOf("=")>-1},Ky=function(v,m){return m===-1?[v]:[v.substring(0,m),v.substring(m+1)]},qy=function(v){var m={};if(v){var p=v.search(",");return[v.slice(0,p),v.slice(p+1)].forEach(function(y,_){for(var I=y.replace(/['"]+/g,"").split("="),x=0;x<I.length;x++)I[x]==="DATA-ID"&&(m["DATA-ID"]=I[1-x]),I[x]==="VALUE"&&(m.VALUE=I[1-x])}),{data:m}}},Yy=Ka,jy={safeCall:function(v,m,p,y){var _=y;if(v&&typeof v[m]=="function")try{_=v[m].apply(v,p)}catch(I){A.info("safeCall error",I)}return _},safeIncrement:P,getComputedStyle:function(v,m){var p;if(v&&m&&d()&&typeof d().getComputedStyle=="function")return Is&&Is.has(v)&&(p=Is.get(v)),p||(p=d().getComputedStyle(v,null),Is&&Is.set(v,p)),p.getPropertyValue(m)},secondsToMs:function(v){return Math.floor(1e3*v)},assign:Object.assign,headersStringToObject:N,cdnHeadersToRequestId:j,extractHostnameAndDomain:R,extractHostname:F,manifestParser:Yy,generateShortID:u,generateUUID:c,now:L.now},zy={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 Xy(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,w=[],U=!0,H=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(w.push(I.value),!y||w.length!==y);U=!0);}catch(C){H=!0,x=C}finally{try{U||_.return==null||_.return()}finally{if(H)throw x}}return w}}(v,m)||function(p,y){if(p){if(typeof p=="string")return bp(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?bp(p,y):void 0}}(v,m)||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 bp(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}var Qt={},An=function v(m){var p=arguments;typeof m=="string"?v.hasOwnProperty(m)?d().setTimeout(function(){p=Array.prototype.splice.call(p,1),v[m].apply(null,p)},0):A.warn("`"+m+"` is an unknown task"):typeof m=="function"?d().setTimeout(function(){m(v)},0):A.warn("`"+m+"` is invalid.")},Qy={loaded:L.now(),NAME:"mux-embed",VERSION:"4.30.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(v,m){return function(p,y,_){var I=gp(f(y),3),x=I[0],w=I[1],U=I[2],H=p.log,C=p.utils.getComputedStyle,be=p.utils.secondsToMs;if(!x)return H.error("No element was found with the `"+w+"` query selector.");if(U!=="video"&&U!=="audio")return H.error("The element of `"+w+"` was not a media element.");x.mux&&(x.mux.destroy(),delete x.mux,H.warn("Already monitoring this video element, replacing existing event listeners")),(_=Object.assign({automaticErrorTracking:!0},_)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:p.VERSION},_.data),_.getPlayheadTime=function(){return be(x.currentTime)},_.getStateData=function(){var ce,_e,le=this.hlsjs&&this.hlsjs.url,Te=this.dashjs&&rc(this.dashjs.getSource==="function")&&this.dashjs.getSource(),ot={player_is_paused:x.paused,player_playhead_time:be(x.currentTime),player_width:parseInt(C(x,"width")),player_height:parseInt(C(x,"height")),player_autoplay_on:x.autoplay,player_preload_on:x.preload,player_language_code:x.lang,player_is_fullscreen:_n()&&!!(_n().fullscreenElement||_n().webkitFullscreenElement||_n().mozFullScreenElement||_n().msFullscreenElement),video_poster_url:x.poster,video_source_url:le||Te||x.currentSrc,video_source_duration:be(x.duration),video_source_height:x.videoHeight,video_source_width:x.videoWidth,view_dropped_frame_count:(ce=x)===null||ce===void 0||(_e=ce.getVideoPlaybackQuality)===null||_e===void 0?void 0:_e.call(ce).droppedVideoFrames},At=_.getPlayheadTime();if(x.getStartDate&&At>0){var wt=x.getStartDate();if(wt&&typeof wt.getTime=="function"&&wt.getTime()){var je=wt.getTime();if(ot.player_program_time=je+At,x.seekable.length>0){var sr=je+x.seekable.end(x.seekable.length-1);ot.player_live_edge_program_time=sr}}}return ot},x.mux=x.mux||{},x.mux.deleted=!1,x.mux.emit=function(ce,_e){p.emit(w,ce,_e)};var ne=function(){H.error("The monitor for this video element has already been destroyed.")};x.mux.destroy=function(){Object.keys(x.mux.listeners).forEach(function(ce){x.removeEventListener(ce,x.mux.listeners[ce],!1)}),delete x.mux.listeners,x.mux.destroy=ne,x.mux.swapElement=ne,x.mux.emit=ne,x.mux.addHLSJS=ne,x.mux.addDashJS=ne,x.mux.removeHLSJS=ne,x.mux.removeDashJS=ne,x.mux.deleted=!0,p.emit(w,"destroy")},x.mux.swapElement=function(ce){var _e=gp(f(ce),3),le=_e[0],Te=_e[1],ot=_e[2];return le?ot!=="video"&&ot!=="audio"?p.log.error("The element of `"+Te+"` was not a media element."):(le.muxId=x.muxId,delete x.muxId,le.mux=le.mux||{},le.mux.listeners=Object.assign({},x.mux.listeners),delete x.mux.listeners,Object.keys(le.mux.listeners).forEach(function(At){x.removeEventListener(At,le.mux.listeners[At],!1),le.addEventListener(At,le.mux.listeners[At],!1)}),le.mux.swapElement=x.mux.swapElement,le.mux.destroy=x.mux.destroy,delete x.mux,void(x=le)):p.log.error("No element was found with the `"+Te+"` query selector.")},x.mux.addHLSJS=function(ce){p.addHLSJS(w,ce)},x.mux.addDashJS=function(ce){p.addDashJS(w,ce)},x.mux.removeHLSJS=function(){p.removeHLSJS(w)},x.mux.removeDashJS=function(){p.removeDashJS(w)},p.init(w,_),p.emit(w,"playerready"),x.paused||(p.emit(w,"play"),x.readyState>2&&p.emit(w,"playing")),x.mux.listeners={},My.forEach(function(ce){(ce!=="error"||_.automaticErrorTracking)&&(x.mux.listeners[ce]=function(){var _e={};if(ce==="error"){if(!x.error||x.error.code===1)return;_e.player_error_code=x.error.code,_e.player_error_message=Py[x.error.code]||x.error.message}p.emit(w,ce,_e)},x.addEventListener(ce,x.mux.listeners[ce],!1))})}(An,v,m)},destroyMonitor:function(v){var m=Xy(f(v),1)[0];m&&m.mux&&typeof m.mux.destroy=="function"?m.mux.destroy():A.error("A video element monitor for `"+v+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(v,m){var p=h(v);Qt[p]?Qt[p].addHLSJS(m):A.error("A monitor for `"+p+"` has not been initialized.")},addDashJS:function(v,m){var p=h(v);Qt[p]?Qt[p].addDashJS(m):A.error("A monitor for `"+p+"` has not been initialized.")},removeHLSJS:function(v){var m=h(v);Qt[m]?Qt[m].removeHLSJS():A.error("A monitor for `"+m+"` has not been initialized.")},removeDashJS:function(v){var m=h(v);Qt[m]?Qt[m].removeDashJS():A.error("A monitor for `"+m+"` has not been initialized.")},init:function(v,m){k()&&m&&m.respectDoNotTrack&&A.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var p=h(v);Qt[p]=new Dy(An,p,m)},emit:function(v,m,p){var y=h(v);Qt[y]?(Qt[y].emit(m,p),m==="destroy"&&delete Qt[y]):A.error("A monitor for `"+y+"` has not been initialized.")},checkDoNotTrack:k,log:A,utils:jy,events:zy,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(An,Qy),d()!==void 0&&typeof d().addEventListener=="function"&&d().addEventListener("pagehide",function(v){v.persisted||(An.WINDOW_UNLOADING=!0)},!1);var Zy=An},655:function(n,a,o){var l,d;function c(u){return c=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},c(u);}(function(u){var h=!1;if((d=typeof(l=u)=="function"?l.call(a,o,a,n):l)===void 0||(n.exports=d),h=!0,c(a)==="object"&&(n.exports=u(),h=!0),!h){var f=window.Cookies,g=window.Cookies=u();g.noConflict=function(){return window.Cookies=f,g}}})(function(){var u=function(){for(var h=0,f={};h<arguments.length;h++){var g=arguments[h];for(var E in g)f[E]=g[E]}return f};return function h(f){function g(E,T,A){var k;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(A=u({path:"/"},g.defaults,A)).expires=="number"){var L=new Date;L.setMilliseconds(L.getMilliseconds()+864e5*A.expires),A.expires=L}try{k=JSON.stringify(T),/^[\{\[]/.test(k)&&(T=k)}catch{}return T=f.write?f.write(T,E):encodeURIComponent(String(T)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),E=(E=(E=encodeURIComponent(String(E))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[E,"=",T,A.expires?"; expires="+A.expires.toUTCString():"",A.path?"; path="+A.path:"",A.domain?"; domain="+A.domain:"",A.secure?"; secure":""].join("")}E||(k={});for(var F=document.cookie?document.cookie.split("; "):[],R=/(%[0-9A-Z]{2})+/g,B=0;B<F.length;B++){var P=F[B].split("="),G=P.slice(1).join("=");G.charAt(0)==='"'&&(G=G.slice(1,-1));try{var K=P[0].replace(R,decodeURIComponent);if(G=f.read?f.read(G,K):f(G,K)||G.replace(R,decodeURIComponent),this.json)try{G=JSON.parse(G)}catch{}if(E===K){k=G;break}E||(k[K]=G)}catch{}}return k}}return g.set=g,g.get=function(E){return g.call(g,E)},g.getJSON=function(){return g.apply({json:!0},[].slice.call(arguments))},g.defaults={},g.remove=function(E,T){g(E,"",u(T,{expires:-1}))},g.withConverter=h,g}(function(){})})},153:function(n,a,o){var l,d=o.g!==void 0?o.g:typeof window!="undefined"?window:{},c=o(558);typeof document!="undefined"?l=document:(l=d["__GLOBAL_DOCUMENT_CACHE@4"])||(l=d["__GLOBAL_DOCUMENT_CACHE@4"]=c),n.exports=l},48:function(n,a,o){var l;l=typeof window!="undefined"?window:o.g!==void 0?o.g:typeof self!="undefined"?self:{},n.exports=l},640:function(n,a,o){var l,d;(function(c,u){"use strict";l=function(){var h=function(){},f="undefined",g=typeof window!==f&&typeof window.navigator!==f&&/Trident\/|MSIE /.test(window.navigator.userAgent),E=["trace","debug","info","warn","error"];function T(N,j){var Y=N[j];if(typeof Y.bind=="function")return Y.bind(N);try{return Function.prototype.bind.call(Y,N)}catch{return function(){return Function.prototype.apply.apply(Y,[N,arguments])}}}function A(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function k(N){return N==="debug"&&(N="log"),typeof console!==f&&(N==="trace"&&g?A:console[N]!==void 0?T(console,N):console.log!==void 0?T(console,"log"):h)}function L(N,j){for(var Y=0;Y<E.length;Y++){var Ee=E[Y];this[Ee]=Y<N?h:this.methodFactory(Ee,N,j)}this.log=this.debug}function F(N,j,Y){return function(){typeof console!==f&&(L.call(this,j,Y),this[N].apply(this,arguments))}}function R(N,j,Y){return k(N)||F.apply(this,arguments)}function B(N,j,Y){var Ee,ge=this;j=j==null?"WARN":j;var ye="loglevel";function we(re){var Le=(E[re]||"silent").toUpperCase();if(typeof window!==f&&ye){try{return void(window.localStorage[ye]=Le)}catch{}try{window.document.cookie=encodeURIComponent(ye)+"="+Le+";"}catch{}}}function Ie(){var re;if(typeof window!==f&&ye){try{re=window.localStorage[ye]}catch{}if(typeof re===f)try{var Le=window.document.cookie,Re=Le.indexOf(encodeURIComponent(ye)+"=");Re!==-1&&(re=/^([^;]+)/.exec(Le.slice(Re))[1])}catch{}return ge.levels[re]===void 0&&(re=void 0),re}}function Z(){if(typeof window!==f&&ye){try{return void window.localStorage.removeItem(ye)}catch{}try{window.document.cookie=encodeURIComponent(ye)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof N=="string"?ye+=":"+N:typeof N=="symbol"&&(ye=void 0),ge.name=N,ge.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},ge.methodFactory=Y||R,ge.getLevel=function(){return Ee},ge.setLevel=function(re,Le){if(typeof re=="string"&&ge.levels[re.toUpperCase()]!==void 0&&(re=ge.levels[re.toUpperCase()]),!(typeof re=="number"&&re>=0&&re<=ge.levels.SILENT))throw"log.setLevel() called with invalid level: "+re;if(Ee=re,Le!==!1&&we(re),L.call(ge,re,N),typeof console===f&&re<ge.levels.SILENT)return"No console available for logging"},ge.setDefaultLevel=function(re){j=re,Ie()||ge.setLevel(re,!1)},ge.resetLevel=function(){ge.setLevel(j,!1),Z()},ge.enableAll=function(re){ge.setLevel(ge.levels.TRACE,re)},ge.disableAll=function(re){ge.setLevel(ge.levels.SILENT,re)};var te=Ie();te==null&&(te=j),ge.setLevel(te,!1)}var P=new B,G={};P.getLogger=function(N){if(typeof N!="symbol"&&typeof N!="string"||N==="")throw new TypeError("You must supply a name when creating a logger.");var j=G[N];return j||(j=G[N]=new B(N,P.getLevel(),P.methodFactory)),j};var K=typeof window!==f?window.log:void 0;return P.noConflict=function(){return typeof window!==f&&window.log===P&&(window.log=K),P},P.getLoggers=function(){return G},P.default=P,P},(d=typeof l=="function"?l.call(a,o,a,n):l)===void 0||(n.exports=d)})()},375:function(n,a){"use strict";var o=Object.prototype.hasOwnProperty;function l(c){try{return decodeURIComponent(c.replace(/\+/g," "))}catch{return null}}function d(c){try{return encodeURIComponent(c)}catch{return null}}a.stringify=function(c,u){u=u||"";var h,f,g=[];for(f in typeof u!="string"&&(u="?"),c)if(o.call(c,f)){if((h=c[f])||h!=null&&!isNaN(h)||(h=""),f=d(f),h=d(h),f===null||h===null)continue;g.push(f+"="+h)}return g.length?u+g.join("&"):""},a.parse=function(c){for(var u,h=/([^=?#&]+)=?([^&]*)/g,f={};u=h.exec(c);){var g=l(u[1]),E=l(u[2]);g===null||E===null||g in f||(f[g]=E)}return f}},558:function(){}},r={};function s(n){var a=r[n];if(a!==void 0)return a.exports;var o=r[n]={exports:{}};return t[n].call(o.exports,o,o.exports,s),o.exports}return s.n=function(n){var a=n&&n.__esModule?function(){return n.default}:function(){return n};return s.d(a,{a}),a},s.d=function(n,a){for(var o in a)s.o(a,o)&&!s.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:a[o]})},s.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),s.o=function(n,a){return Object.prototype.hasOwnProperty.call(n,a)},s(80)}()},typeof Dl=="object"&&typeof Qu=="object"?Qu.exports=e():typeof Dl=="object"?Dl.mux=e():i.mux=e()})()});var Ls=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends Ls{}globalThis.DocumentFragment=i}var Rn=class extends Ls{},dc=class extends Ls{},uT={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(Rn)}},kn,cc=class{constructor(e,t={}){dt(this,kn,void 0);Jt(this,kn,t==null?void 0:t.detail)}get detail(){return Pe(this,kn)}initCustomEvent(){}};kn=new WeakMap;function hT(i,e){return new Rn}var Tp={document:{createElement:hT},DocumentFragment,customElements:uT,CustomEvent:cc,EventTarget:Ls,HTMLElement:Rn,HTMLVideoElement:dc},_p=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Je=_p?Tp:globalThis,Kt=_p?Tp.document:globalThis.document;var ee={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},me={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},Mr={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_PAUSED:"mediaPaused",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_ENDED:"mediaEnded",MEDIA_MUTED:"mediaMuted",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_IS_PIP:"mediaIsPip",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_LOADING:"mediaLoading",MEDIA_BUFFERED:"mediaBuffered",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled"},Ap=Object.entries(Mr),S=Ap.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{}),qi=Ap.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"}),MI=Object.entries(qi).reduce((i,[e,t])=>{let r=S[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),Sp=Object.entries(S).reduce((i,[e,t])=>{let r=qi[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),ar={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},Pr={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var uc={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},qt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},di={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var St={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:i=1}={})=>`current playback rate ${i}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading"},We={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",ENTER_AIRPLAY:()=>"start airplay",EXIT_AIRPLAY:()=>"stop airplay",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:i=30}={})=>`seek forward ${i} seconds`,SEEK_BACK_N_SECS:({seekOffset:i=30}={})=>`seek back ${i} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"},mT={...St,...We};function xp(i){return i==null?void 0:i.map(pT).join(" ")}function Ip(i){return i==null?void 0:i.split(/\s+/).map(gT)}function pT(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function gT(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:t,height:r}}}function Lp(i){return i==null?void 0:i.map(vT).join(" ")}function Rp(i){return i==null?void 0:i.split(/\s+/).map(ET)}function vT(i){if(i){let{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function ET(i){if(i){let[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function qa(i,e=!1){return i.split("_").map(function(t,r){return(r||e?t[0].toUpperCase():t[0].toLowerCase())+t.slice(1).toLowerCase()}).join("")}function kp(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function wp(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function Ya(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}var ja=i=>new Promise(e=>setTimeout(e,i));var Dp=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],bT=(i,e)=>{let t=i===1?Dp[e].singular:Dp[e].plural;return`${i} ${t}`},Or=i=>{if(!wp(i))return"";let e=Math.abs(i),t=e!==i,r=new Date(0,0,0,0,0,e,0);return`${[r.getHours(),r.getMinutes(),r.getSeconds()].map((o,l)=>o&&bT(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Ai(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let r=Math.floor(i%60),s=Math.floor(i/60%60),n=Math.floor(i/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=s=r="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",r=r<10?"0"+r:r,(t?"-":"")+n+s+r}var UI=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}});var za=(i,e,t=".value")=>{let r=i.querySelector(t);r&&(r.textContent=e)},TT=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},Xa=(i,e)=>TT(i,e)[0],or=(i,e)=>!i||!e?!1:i.contains(e)?!0:or(i,e.getRootNode().host),lr=(i,e)=>{if(!i)return null;let t=i.closest(e);return t||lr(i.getRootNode().host,e)};function fc(i=document){var e;let t=i==null?void 0:i.activeElement;return t?(e=fc(t.shadowRoot))!=null?e:t:null}function Cp(i){var e;let t=(e=i==null?void 0:i.getRootNode)==null?void 0:e.call(i);return t instanceof ShadowRoot||t instanceof Document?t:null}function Mp(i,e=3){if(i.checkVisibility)return i.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});let t=i;for(;t&&e>0;){let r=getComputedStyle(t);if(r.opacity==="0"||r.visibility==="hidden"||r.display==="none")return!1;t=t.parentElement,e--}return!0}function Pp(i,e,t,r){let s=hc(t,r),n=hc(t,{x:i,y:e}),a=hc(r,{x:i,y:e});return n>s||a>s?n>a?1:0:n/s}function hc(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function ze(i,e){var t;let r;for(r of i.querySelectorAll("style")){let s;try{s=(t=r.sheet)==null?void 0:t.cssRules}catch{continue}for(let n of s!=null?s:[])if(n.selectorText===e)return n}return r!=null&&r.sheet?(r.sheet.insertRule(`${e}{}`,r.sheet.cssRules.length),r.sheet.cssRules[r.sheet.cssRules.length-1]):{style:{setProperty:()=>{},removeProperty:()=>{},getPropertyValue:()=>""}}}function Fe(i,e,t=Number.NaN){let r=i.getAttribute(e);return r!=null?+r:t}function Ke(i,e,t){let r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}Fe(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function Be(i,e){return i.hasAttribute(e)}function Ne(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}Be(i,e)!=t&&i.toggleAttribute(e,t)}function He(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function $e(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}let r=`${t}`;He(i,e,void 0)!==r&&i.setAttribute(e,r)}var Qa=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},mc=class{observe(){}unobserve(){}disconnect(){}},Op={createElement:function(){return new pc.HTMLElement},addEventListener(){},removeEventListener(){}},pc={ResizeObserver:mc,document:Op,HTMLElement:class extends Qa{},DocumentFragment:class extends Qa{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[]}},Np=typeof window=="undefined"||typeof window.customElements=="undefined",Up=Object.keys(pc).every(i=>i in globalThis),D=Np&&!Up?pc:globalThis,q=Np&&!Up?Op:globalThis.document;var _T=Object.defineProperty,AT=(i,e,t)=>e in i?_T(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ST=(i,e,t)=>(AT(i,typeof e!="symbol"?e+"":e,t),t),Fp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ei=(i,e,t)=>(Fp(i,e,"read from private field"),t?t.call(i):e.get(i)),Za=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ja=(i,e,t,r)=>(Fp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Si,eo,Rs,to,Bp=q.createElement("template");Bp.innerHTML=`
18
+ `))this.processLine(this.buffer.substring(0,m)),this.buffer=this.buffer.substring(m+1)},Xa.prototype.processLine=function(v){var m=v.indexOf(":"),p=nT(v,m),y=p[0],_=p.length===2?hc(p[1]):void 0;if(y[0]!=="#")this.currentUri.uri=y,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(y){case zy:if(!isFinite(_)||_<0)return;this.manifest.targetDuration=_,this.setHoldBack();break;case Xy:uc(this.manifest,p),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Qy:uc(this.manifest,p),this.setHoldBack();break;case Zy:_===0?this.currentUri.duration=.01:_>0&&(this.currentUri.duration=_);break;case Jy:var I=_,x=new Date(I);this.manifest.dateTimeString||(this.manifest.dateTimeString=I,this.manifest.dateTimeObject=x),this.currentUri.dateTimeString=I,this.currentUri.dateTimeObject=x;break;case eT:uc(this.manifest,p);break;case tT:var D=aT(p[1]),U=Y(D);Object.assign(this.manifest.sessionData,U)}},Xa.prototype.setHoldBack=function(){var v=this.manifest,m=v.serverControl,p=v.targetDuration,y=v.partTargetDuration;if(m){var _="holdBack",I="partHoldBack",x=p&&3*p,D=y&&2*y;p&&!m.hasOwnProperty(_)&&(m[_]=x),x&&m[_]<x&&(m[_]=x),y&&!m.hasOwnProperty(I)&&(m[I]=3*y),y&&m[I]<D&&(m[I]=D)}};var uc=function(v,m){var p,y=Lp(m[0].replace("#EXT-X-",""));sT(m[1])?(p={},p=Object.assign(rT(m[1]),p)):p=hc(m[1]),v[y]=p},Lp=function(v){return v.toLowerCase().replace(/-(\w)/g,function(m){return m[1].toUpperCase()})},hc=function(v){if(v.toLowerCase()==="yes"||v.toLowerCase()==="no")return v.toLowerCase()==="yes";var m=v.indexOf(":")!==-1?v:parseFloat(v);return isNaN(m)?v:m},iT=function(v){var m={},p=v.split("=");return p.length>1&&(m[Lp(p[0])]=hc(p[1])),m},rT=function(v){for(var m=v.split(","),p={},y=0;m.length>y;y++){var _=m[y],I=iT(_);p=Object.assign(I,p)}return p},sT=function(v){return v.indexOf("=")>-1},nT=function(v,m){return m===-1?[v]:[v.substring(0,m),v.substring(m+1)]},aT=function(v){var m={};if(v){var p=v.search(",");return[v.slice(0,p),v.slice(p+1)].forEach(function(y,_){for(var I=y.replace(/['"]+/g,"").split("="),x=0;x<I.length;x++)I[x]==="DATA-ID"&&(m["DATA-ID"]=I[1-x]),I[x]==="VALUE"&&(m.VALUE=I[1-x])}),{data:m}}},oT=Xa,lT={safeCall:function(v,m,p,y){var _=y;if(v&&typeof v[m]=="function")try{_=v[m].apply(v,p)}catch(I){S.info("safeCall error",I)}return _},safeIncrement:P,getComputedStyle:function(v,m){var p;if(v&&m&&d()&&typeof d().getComputedStyle=="function")return Ls&&Ls.has(v)&&(p=Ls.get(v)),p||(p=d().getComputedStyle(v,null),Ls&&Ls.set(v,p)),p.getPropertyValue(m)},secondsToMs:function(v){return Math.floor(1e3*v)},assign:Object.assign,headersStringToObject:N,cdnHeadersToRequestId:j,extractHostnameAndDomain:R,extractHostname:F,manifestParser:oT,generateShortID:u,generateUUID:c,now:L.now},dT={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 cT(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,D=[],U=!0,G=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(D.push(I.value),!y||D.length!==y);U=!0);}catch(C){G=!0,x=C}finally{try{U||_.return==null||_.return()}finally{if(G)throw x}}return D}}(v,m)||function(p,y){if(p){if(typeof p=="string")return Rp(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?Rp(p,y):void 0}}(v,m)||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 Rp(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}var Zt={},Sn=function v(m){var p=arguments;typeof m=="string"?v.hasOwnProperty(m)?d().setTimeout(function(){p=Array.prototype.splice.call(p,1),v[m].apply(null,p)},0):S.warn("`"+m+"` is an unknown task"):typeof m=="function"?d().setTimeout(function(){m(v)},0):S.warn("`"+m+"` is invalid.")},uT={loaded:L.now(),NAME:"mux-embed",VERSION:"4.30.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(v,m){return function(p,y,_){var I=xp(f(y),3),x=I[0],D=I[1],U=I[2],G=p.log,C=p.utils.getComputedStyle,be=p.utils.secondsToMs;if(!x)return G.error("No element was found with the `"+D+"` query selector.");if(U!=="video"&&U!=="audio")return G.error("The element of `"+D+"` was not a media element.");x.mux&&(x.mux.destroy(),delete x.mux,G.warn("Already monitoring this video element, replacing existing event listeners")),(_=Object.assign({automaticErrorTracking:!0},_)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:p.VERSION},_.data),_.getPlayheadTime=function(){return be(x.currentTime)},_.getStateData=function(){var ce,_e,le=this.hlsjs&&this.hlsjs.url,Te=this.dashjs&&cc(this.dashjs.getSource==="function")&&this.dashjs.getSource(),lt={player_is_paused:x.paused,player_playhead_time:be(x.currentTime),player_width:parseInt(C(x,"width")),player_height:parseInt(C(x,"height")),player_autoplay_on:x.autoplay,player_preload_on:x.preload,player_language_code:x.lang,player_is_fullscreen:An()&&!!(An().fullscreenElement||An().webkitFullscreenElement||An().mozFullScreenElement||An().msFullscreenElement),video_poster_url:x.poster,video_source_url:le||Te||x.currentSrc,video_source_duration:be(x.duration),video_source_height:x.videoHeight,video_source_width:x.videoWidth,view_dropped_frame_count:(ce=x)===null||ce===void 0||(_e=ce.getVideoPlaybackQuality)===null||_e===void 0?void 0:_e.call(ce).droppedVideoFrames},It=_.getPlayheadTime();if(x.getStartDate&&It>0){var Pt=x.getStartDate();if(Pt&&typeof Pt.getTime=="function"&&Pt.getTime()){var ze=Pt.getTime();if(lt.player_program_time=ze+It,x.seekable.length>0){var ar=ze+x.seekable.end(x.seekable.length-1);lt.player_live_edge_program_time=ar}}}return lt},x.mux=x.mux||{},x.mux.deleted=!1,x.mux.emit=function(ce,_e){p.emit(D,ce,_e)};var ne=function(){G.error("The monitor for this video element has already been destroyed.")};x.mux.destroy=function(){Object.keys(x.mux.listeners).forEach(function(ce){x.removeEventListener(ce,x.mux.listeners[ce],!1)}),delete x.mux.listeners,x.mux.destroy=ne,x.mux.swapElement=ne,x.mux.emit=ne,x.mux.addHLSJS=ne,x.mux.addDashJS=ne,x.mux.removeHLSJS=ne,x.mux.removeDashJS=ne,x.mux.deleted=!0,p.emit(D,"destroy")},x.mux.swapElement=function(ce){var _e=xp(f(ce),3),le=_e[0],Te=_e[1],lt=_e[2];return le?lt!=="video"&&lt!=="audio"?p.log.error("The element of `"+Te+"` was not a media element."):(le.muxId=x.muxId,delete x.muxId,le.mux=le.mux||{},le.mux.listeners=Object.assign({},x.mux.listeners),delete x.mux.listeners,Object.keys(le.mux.listeners).forEach(function(It){x.removeEventListener(It,le.mux.listeners[It],!1),le.addEventListener(It,le.mux.listeners[It],!1)}),le.mux.swapElement=x.mux.swapElement,le.mux.destroy=x.mux.destroy,delete x.mux,void(x=le)):p.log.error("No element was found with the `"+Te+"` query selector.")},x.mux.addHLSJS=function(ce){p.addHLSJS(D,ce)},x.mux.addDashJS=function(ce){p.addDashJS(D,ce)},x.mux.removeHLSJS=function(){p.removeHLSJS(D)},x.mux.removeDashJS=function(){p.removeDashJS(D)},p.init(D,_),p.emit(D,"playerready"),x.paused||(p.emit(D,"play"),x.readyState>2&&p.emit(D,"playing")),x.mux.listeners={},Yy.forEach(function(ce){(ce!=="error"||_.automaticErrorTracking)&&(x.mux.listeners[ce]=function(){var _e={};if(ce==="error"){if(!x.error||x.error.code===1)return;_e.player_error_code=x.error.code,_e.player_error_message=jy[x.error.code]||x.error.message}p.emit(D,ce,_e)},x.addEventListener(ce,x.mux.listeners[ce],!1))})}(Sn,v,m)},destroyMonitor:function(v){var m=cT(f(v),1)[0];m&&m.mux&&typeof m.mux.destroy=="function"?m.mux.destroy():S.error("A video element monitor for `"+v+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(v,m){var p=h(v);Zt[p]?Zt[p].addHLSJS(m):S.error("A monitor for `"+p+"` has not been initialized.")},addDashJS:function(v,m){var p=h(v);Zt[p]?Zt[p].addDashJS(m):S.error("A monitor for `"+p+"` has not been initialized.")},removeHLSJS:function(v){var m=h(v);Zt[m]?Zt[m].removeHLSJS():S.error("A monitor for `"+m+"` has not been initialized.")},removeDashJS:function(v){var m=h(v);Zt[m]?Zt[m].removeDashJS():S.error("A monitor for `"+m+"` has not been initialized.")},init:function(v,m){k()&&m&&m.respectDoNotTrack&&S.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var p=h(v);Zt[p]=new Ky(Sn,p,m)},emit:function(v,m,p){var y=h(v);Zt[y]?(Zt[y].emit(m,p),m==="destroy"&&delete Zt[y]):S.error("A monitor for `"+y+"` has not been initialized.")},checkDoNotTrack:k,log:S,utils:lT,events:dT,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Sn,uT),d()!==void 0&&typeof d().addEventListener=="function"&&d().addEventListener("pagehide",function(v){v.persisted||(Sn.WINDOW_UNLOADING=!0)},!1);var hT=Sn},655:function(n,a,o){var l,d;function c(u){return c=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},c(u);}(function(u){var h=!1;if((d=typeof(l=u)=="function"?l.call(a,o,a,n):l)===void 0||(n.exports=d),h=!0,c(a)==="object"&&(n.exports=u(),h=!0),!h){var f=window.Cookies,g=window.Cookies=u();g.noConflict=function(){return window.Cookies=f,g}}})(function(){var u=function(){for(var h=0,f={};h<arguments.length;h++){var g=arguments[h];for(var E in g)f[E]=g[E]}return f};return function h(f){function g(E,T,S){var k;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(S=u({path:"/"},g.defaults,S)).expires=="number"){var L=new Date;L.setMilliseconds(L.getMilliseconds()+864e5*S.expires),S.expires=L}try{k=JSON.stringify(T),/^[\{\[]/.test(k)&&(T=k)}catch{}return T=f.write?f.write(T,E):encodeURIComponent(String(T)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),E=(E=(E=encodeURIComponent(String(E))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[E,"=",T,S.expires?"; expires="+S.expires.toUTCString():"",S.path?"; path="+S.path:"",S.domain?"; domain="+S.domain:"",S.secure?"; secure":""].join("")}E||(k={});for(var F=document.cookie?document.cookie.split("; "):[],R=/(%[0-9A-Z]{2})+/g,B=0;B<F.length;B++){var P=F[B].split("="),H=P.slice(1).join("=");H.charAt(0)==='"'&&(H=H.slice(1,-1));try{var V=P[0].replace(R,decodeURIComponent);if(H=f.read?f.read(H,V):f(H,V)||H.replace(R,decodeURIComponent),this.json)try{H=JSON.parse(H)}catch{}if(E===V){k=H;break}E||(k[V]=H)}catch{}}return k}}return g.set=g,g.get=function(E){return g.call(g,E)},g.getJSON=function(){return g.apply({json:!0},[].slice.call(arguments))},g.defaults={},g.remove=function(E,T){g(E,"",u(T,{expires:-1}))},g.withConverter=h,g}(function(){})})},153:function(n,a,o){var l,d=o.g!==void 0?o.g:typeof window!="undefined"?window:{},c=o(558);typeof document!="undefined"?l=document:(l=d["__GLOBAL_DOCUMENT_CACHE@4"])||(l=d["__GLOBAL_DOCUMENT_CACHE@4"]=c),n.exports=l},48:function(n,a,o){var l;l=typeof window!="undefined"?window:o.g!==void 0?o.g:typeof self!="undefined"?self:{},n.exports=l},640:function(n,a,o){var l,d;(function(c,u){"use strict";l=function(){var h=function(){},f="undefined",g=typeof window!==f&&typeof window.navigator!==f&&/Trident\/|MSIE /.test(window.navigator.userAgent),E=["trace","debug","info","warn","error"];function T(N,j){var Y=N[j];if(typeof Y.bind=="function")return Y.bind(N);try{return Function.prototype.bind.call(Y,N)}catch{return function(){return Function.prototype.apply.apply(Y,[N,arguments])}}}function S(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function k(N){return N==="debug"&&(N="log"),typeof console!==f&&(N==="trace"&&g?S:console[N]!==void 0?T(console,N):console.log!==void 0?T(console,"log"):h)}function L(N,j){for(var Y=0;Y<E.length;Y++){var Ee=E[Y];this[Ee]=Y<N?h:this.methodFactory(Ee,N,j)}this.log=this.debug}function F(N,j,Y){return function(){typeof console!==f&&(L.call(this,j,Y),this[N].apply(this,arguments))}}function R(N,j,Y){return k(N)||F.apply(this,arguments)}function B(N,j,Y){var Ee,ge=this;j=j==null?"WARN":j;var ye="loglevel";function we(re){var Le=(E[re]||"silent").toUpperCase();if(typeof window!==f&&ye){try{return void(window.localStorage[ye]=Le)}catch{}try{window.document.cookie=encodeURIComponent(ye)+"="+Le+";"}catch{}}}function Ie(){var re;if(typeof window!==f&&ye){try{re=window.localStorage[ye]}catch{}if(typeof re===f)try{var Le=window.document.cookie,Re=Le.indexOf(encodeURIComponent(ye)+"=");Re!==-1&&(re=/^([^;]+)/.exec(Le.slice(Re))[1])}catch{}return ge.levels[re]===void 0&&(re=void 0),re}}function Z(){if(typeof window!==f&&ye){try{return void window.localStorage.removeItem(ye)}catch{}try{window.document.cookie=encodeURIComponent(ye)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof N=="string"?ye+=":"+N:typeof N=="symbol"&&(ye=void 0),ge.name=N,ge.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},ge.methodFactory=Y||R,ge.getLevel=function(){return Ee},ge.setLevel=function(re,Le){if(typeof re=="string"&&ge.levels[re.toUpperCase()]!==void 0&&(re=ge.levels[re.toUpperCase()]),!(typeof re=="number"&&re>=0&&re<=ge.levels.SILENT))throw"log.setLevel() called with invalid level: "+re;if(Ee=re,Le!==!1&&we(re),L.call(ge,re,N),typeof console===f&&re<ge.levels.SILENT)return"No console available for logging"},ge.setDefaultLevel=function(re){j=re,Ie()||ge.setLevel(re,!1)},ge.resetLevel=function(){ge.setLevel(j,!1),Z()},ge.enableAll=function(re){ge.setLevel(ge.levels.TRACE,re)},ge.disableAll=function(re){ge.setLevel(ge.levels.SILENT,re)};var te=Ie();te==null&&(te=j),ge.setLevel(te,!1)}var P=new B,H={};P.getLogger=function(N){if(typeof N!="symbol"&&typeof N!="string"||N==="")throw new TypeError("You must supply a name when creating a logger.");var j=H[N];return j||(j=H[N]=new B(N,P.getLevel(),P.methodFactory)),j};var V=typeof window!==f?window.log:void 0;return P.noConflict=function(){return typeof window!==f&&window.log===P&&(window.log=V),P},P.getLoggers=function(){return H},P.default=P,P},(d=typeof l=="function"?l.call(a,o,a,n):l)===void 0||(n.exports=d)})()},375:function(n,a){"use strict";var o=Object.prototype.hasOwnProperty;function l(c){try{return decodeURIComponent(c.replace(/\+/g," "))}catch{return null}}function d(c){try{return encodeURIComponent(c)}catch{return null}}a.stringify=function(c,u){u=u||"";var h,f,g=[];for(f in typeof u!="string"&&(u="?"),c)if(o.call(c,f)){if((h=c[f])||h!=null&&!isNaN(h)||(h=""),f=d(f),h=d(h),f===null||h===null)continue;g.push(f+"="+h)}return g.length?u+g.join("&"):""},a.parse=function(c){for(var u,h=/([^=?#&]+)=?([^&]*)/g,f={};u=h.exec(c);){var g=l(u[1]),E=l(u[2]);g===null||E===null||g in f||(f[g]=E)}return f}},558:function(){}},r={};function s(n){var a=r[n];if(a!==void 0)return a.exports;var o=r[n]={exports:{}};return t[n].call(o.exports,o,o.exports,s),o.exports}return s.n=function(n){var a=n&&n.__esModule?function(){return n.default}:function(){return n};return s.d(a,{a}),a},s.d=function(n,a){for(var o in a)s.o(a,o)&&!s.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:a[o]})},s.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),s.o=function(n,a){return Object.prototype.hasOwnProperty.call(n,a)},s(80)}()},typeof Fl=="object"&&typeof nh=="object"?nh.exports=e():typeof Fl=="object"?Fl.mux=e():i.mux=e()})()});var Rs=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends Rs{}globalThis.DocumentFragment=i}var kn=class extends Rs{},gc=class extends Rs{},xT={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(kn)}},wn,vc=class{constructor(e,t={}){ct(this,wn,void 0);ei(this,wn,t==null?void 0:t.detail)}get detail(){return Pe(this,wn)}initCustomEvent(){}};wn=new WeakMap;function IT(i,e){return new kn}var wp={document:{createElement:IT},DocumentFragment,customElements:xT,CustomEvent:vc,EventTarget:Rs,HTMLElement:kn,HTMLVideoElement:gc},Dp=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Je=Dp?wp:globalThis,jt=Dp?wp.document:globalThis.document;var ee={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},me={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},Pr={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_PAUSED:"mediaPaused",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_ENDED:"mediaEnded",MEDIA_MUTED:"mediaMuted",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_IS_PIP:"mediaIsPip",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_LOADING:"mediaLoading",MEDIA_BUFFERED:"mediaBuffered",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_CHAPTERS_CUES:"mediaChaptersCues"},Cp=Object.entries(Pr),A=Cp.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{}),Xi=Cp.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"}),QI=Object.entries(Xi).reduce((i,[e,t])=>{let r=A[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),Mp=Object.entries(A).reduce((i,[e,t])=>{let r=Xi[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),xi={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},Or={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var Ec={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},zt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},ui={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var Lt={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:i=1}={})=>`current playback rate ${i}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading",SETTINGS:()=>"settings",AUDIO_TRACKS:()=>"audio tracks",QUALITY:()=>"quality"},We={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",ENTER_AIRPLAY:()=>"start airplay",EXIT_AIRPLAY:()=>"stop airplay",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:i=30}={})=>`seek forward ${i} seconds`,SEEK_BACK_N_SECS:({seekOffset:i=30}={})=>`seek back ${i} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"},RT={...Lt,...We};function Pp(i){return i==null?void 0:i.map(kT).join(" ")}function Op(i){return i==null?void 0:i.split(/\s+/).map(wT)}function kT(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function wT(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:t,height:r}}}function Np(i){return i==null?void 0:i.map(DT).join(" ")}function Up(i){return i==null?void 0:i.split(/\s+/).map(CT)}function DT(i){if(i){let{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function CT(i){if(i){let[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function Qa(i,e=!1){return i.split("_").map(function(t,r){return(r||e?t[0].toUpperCase():t[0].toLowerCase())+t.slice(1).toLowerCase()}).join("")}function Fp(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Bp(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function Za(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}var Ja=i=>new Promise(e=>setTimeout(e,i));var $p=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],MT=(i,e)=>{let t=i===1?$p[e].singular:$p[e].plural;return`${i} ${t}`},Nr=i=>{if(!Bp(i))return"";let e=Math.abs(i),t=e!==i,r=new Date(0,0,0,0,0,e,0);return`${[r.getHours(),r.getMinutes(),r.getSeconds()].map((o,l)=>o&&MT(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Ii(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let r=Math.floor(i%60),s=Math.floor(i/60%60),n=Math.floor(i/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=s=r="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",r=r<10?"0"+r:r,(t?"-":"")+n+s+r}var tL=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}});var eo=(i,e,t=".value")=>{let r=i.querySelector(t);r&&(r.textContent=e)},OT=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},to=(i,e)=>OT(i,e)[0],lr=(i,e)=>!i||!e?!1:i.contains(e)?!0:lr(i,e.getRootNode().host),dr=(i,e)=>{if(!i)return null;let t=i.closest(e);return t||dr(i.getRootNode().host,e)};function yc(i=document){var e;let t=i==null?void 0:i.activeElement;return t?(e=yc(t.shadowRoot))!=null?e:t:null}function Hp(i){var e;let t=(e=i==null?void 0:i.getRootNode)==null?void 0:e.call(i);return t instanceof ShadowRoot||t instanceof Document?t:null}function Gp(i,e=3){if(i.checkVisibility)return i.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});let t=i;for(;t&&e>0;){let r=getComputedStyle(t);if(r.opacity==="0"||r.visibility==="hidden"||r.display==="none")return!1;t=t.parentElement,e--}return!0}function Vp(i,e,t,r){let s=bc(t,r),n=bc(t,{x:i,y:e}),a=bc(r,{x:i,y:e});return n>s||a>s?n>a?1:0:n/s}function bc(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function Ye(i,e){let t=NT(i,r=>r===e);return t||Tc(i,e)}function NT(i,e){var t;let r;for(r of i.querySelectorAll("style")){let s;try{s=(t=r.sheet)==null?void 0:t.cssRules}catch{continue}for(let n of s!=null?s:[])if(e(n.selectorText))return n}}function Tc(i,e){var t,r;let s=(t=i.querySelectorAll("style"))!=null?t:[],n=s==null?void 0:s[s.length-1];return n!=null&&n.sheet?(n==null||n.sheet.insertRule(`${e}{}`,n.sheet.cssRules.length),(r=n.sheet.cssRules)==null?void 0:r[n.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",i),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function $e(i,e,t=Number.NaN){let r=i.getAttribute(e);return r!=null?+r:t}function Ke(i,e,t){let r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}$e(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function He(i,e){return i.hasAttribute(e)}function Ue(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}He(i,e)!=t&&i.toggleAttribute(e,t)}function Fe(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function Oe(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}let r=`${t}`;Fe(i,e,void 0)!==r&&i.setAttribute(e,r)}var io=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},_c=class{observe(){}unobserve(){}disconnect(){}},Wp={createElement:function(){return new ro.HTMLElement},createElementNS:function(){return new ro.HTMLElement},addEventListener(){},removeEventListener(){}},ro={ResizeObserver:_c,document:Wp,HTMLElement:class extends io{},DocumentFragment:class extends io{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia(i){return{matches:!1,media:i}}},Kp=typeof window=="undefined"||typeof window.customElements=="undefined",qp=Object.keys(ro).every(i=>i in globalThis),w=Kp&&!qp?ro:globalThis,q=Kp&&!qp?Wp:globalThis.document;var UT=Object.defineProperty,FT=(i,e,t)=>e in i?UT(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,BT=(i,e,t)=>(FT(i,typeof e!="symbol"?e+"":e,t),t),Yp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ti=(i,e,t)=>(Yp(i,e,"read from private field"),t?t.call(i):e.get(i)),so=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},no=(i,e,t,r)=>(Yp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Li,ao,ks,oo,jp=q.createElement("template");jp.innerHTML=`
20
20
  <style>
21
21
  :host {
22
22
  font: var(--media-font,
@@ -65,52 +65,52 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
65
65
  min-width: 100%;
66
66
  }
67
67
  </style>
68
- `;var Ge=class extends D.HTMLElement{constructor(e={}){if(super(),Za(this,Si,void 0),ST(this,"preventClick",!1),Za(this,eo,r=>{this.preventClick||this.handleClick(r)}),Za(this,Rs,r=>{let{key:s}=r;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",ei(this,Rs));return}this.preventClick||this.handleClick(r)}),Za(this,to,r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",ei(this,Rs));return}this.addEventListener("keyup",ei(this,Rs),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});let r=Bp.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=q.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),this.shadowRoot.appendChild(r)}let{style:t}=ze(this.shadowRoot,":host");t.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`)}static get observedAttributes(){return["disabled",me.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",ei(this,eo)),this.addEventListener("keydown",ei(this,to)),this.tabIndex=0}disable(){this.removeEventListener("click",ei(this,eo)),this.removeEventListener("keydown",ei(this,to)),this.removeEventListener("keyup",ei(this,Rs)),this.tabIndex=-1}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER?(t&&((n=(s=ei(this,Si))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ja(this,Si,null)),r&&this.isConnected&&(Ja(this,Si,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ei(this,Si))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(Ja(this,Si,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ei(this,Si))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=ei(this,Si))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ja(this,Si,null)}get keysUsed(){return["Enter"," "]}handleClick(e){}};Si=new WeakMap;eo=new WeakMap;Rs=new WeakMap;to=new WeakMap;D.customElements.get("media-chrome-button")||D.customElements.define("media-chrome-button",Ge);var $p=`<svg aria-hidden="true" viewBox="0 0 26 24">
68
+ `;var Ge=class extends w.HTMLElement{constructor(e={}){if(super(),so(this,Li,void 0),BT(this,"preventClick",!1),so(this,ao,t=>{this.preventClick||this.handleClick(t)}),so(this,ks,t=>{let{key:r}=t;if(!this.keysUsed.includes(r)){this.removeEventListener("keyup",ti(this,ks));return}this.preventClick||this.handleClick(t)}),so(this,oo,t=>{let{metaKey:r,altKey:s,key:n}=t;if(r||s||!this.keysUsed.includes(n)){this.removeEventListener("keyup",ti(this,ks));return}this.addEventListener("keyup",ti(this,ks),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});let t=jp.content.cloneNode(!0);this.nativeEl=t;let r=e.slotTemplate;r||(r=q.createElement("template"),r.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(r.content.cloneNode(!0)),this.shadowRoot.appendChild(t)}}static get observedAttributes(){return["disabled",me.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",ti(this,ao)),this.addEventListener("keydown",ti(this,oo)),this.tabIndex=0}disable(){this.removeEventListener("click",ti(this,ao)),this.removeEventListener("keydown",ti(this,oo)),this.removeEventListener("keyup",ti(this,ks)),this.tabIndex=-1}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER?(t&&((n=(s=ti(this,Li))==null?void 0:s.unassociateElement)==null||n.call(s,this),no(this,Li,null)),r&&this.isConnected&&(no(this,Li,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ti(this,Li))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;let{style:s}=Ye(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");let n=this.getAttribute(me.MEDIA_CONTROLLER);n&&(no(this,Li,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=ti(this,Li))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=ti(this,Li))==null?void 0:e.unassociateElement)==null||t.call(e,this),no(this,Li,null)}get keysUsed(){return["Enter"," "]}handleClick(e){}};Li=new WeakMap;ao=new WeakMap;ks=new WeakMap;oo=new WeakMap;w.customElements.get("media-chrome-button")||w.customElements.define("media-chrome-button",Ge);var zp=`<svg aria-hidden="true" viewBox="0 0 26 24">
69
69
  <path d="M22.13 3H3.87a.87.87 0 0 0-.87.87v13.26a.87.87 0 0 0 .87.87h3.4L9 16H5V5h16v11h-4l1.72 2h3.4a.87.87 0 0 0 .87-.87V3.87a.87.87 0 0 0-.86-.87Zm-8.75 11.44a.5.5 0 0 0-.76 0l-4.91 5.73a.5.5 0 0 0 .38.83h9.82a.501.501 0 0 0 .38-.83l-4.91-5.73Z"/>
70
70
  </svg>
71
- `,Hp=q.createElement("template");Hp.innerHTML=`
71
+ `,Qp=q.createElement("template");Qp.innerHTML=`
72
72
  <style>
73
- :host([${S.MEDIA_IS_AIRPLAYING}]) slot:not([name=exit]):not([name=icon]) {
73
+ :host([${A.MEDIA_IS_AIRPLAYING}]) slot:not([name=exit]):not([name=icon]) {
74
74
  display: none !important;
75
75
  }
76
76
 
77
77
 
78
- :host(:not([${S.MEDIA_IS_AIRPLAYING}])) slot:not([name=enter]):not([name=icon]) {
78
+ :host(:not([${A.MEDIA_IS_AIRPLAYING}])) slot:not([name=enter]):not([name=icon]) {
79
79
  display: none !important;
80
80
  }
81
81
  </style>
82
82
 
83
83
  <slot name="icon">
84
- <slot name="enter">${$p}</slot>
85
- <slot name="exit">${$p}</slot>
84
+ <slot name="enter">${zp}</slot>
85
+ <slot name="exit">${zp}</slot>
86
86
  </slot>
87
- `;var Gp=i=>{let e=i.mediaIsAirplaying?We.EXIT_AIRPLAY():We.ENTER_AIRPLAY();i.setAttribute("aria-label",e)},gc=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_AIRPLAYING,S.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Hp,...e})}connectedCallback(){super.connectedCallback(),Gp(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_IS_AIRPLAYING&&Gp(this)}get mediaIsAirplaying(){return Be(this,S.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){Ne(this,S.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return He(this,S.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){$e(this,S.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new D.CustomEvent(ee.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};D.customElements.get("media-airplay-button")||D.customElements.define("media-airplay-button",gc);var xT='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',IT='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',Wp=q.createElement("template");Wp.innerHTML=`
87
+ `;var Xp=i=>{let e=i.mediaIsAirplaying?We.EXIT_AIRPLAY():We.ENTER_AIRPLAY();i.setAttribute("aria-label",e)},Ac=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_IS_AIRPLAYING,A.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Qp,...e})}connectedCallback(){super.connectedCallback(),Xp(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===A.MEDIA_IS_AIRPLAYING&&Xp(this)}get mediaIsAirplaying(){return He(this,A.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){Ue(this,A.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return Fe(this,A.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){Oe(this,A.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new w.CustomEvent(ee.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};w.customElements.get("media-airplay-button")||w.customElements.define("media-airplay-button",Ac);var $T='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',HT='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',Jp=q.createElement("template");Jp.innerHTML=`
88
88
  <style>
89
- :host([${S.MEDIA_IS_CASTING}]) slot:not([name=exit]):not([name=icon]) {
89
+ :host([${A.MEDIA_IS_CASTING}]) slot:not([name=exit]):not([name=icon]) {
90
90
  display: none !important;
91
91
  }
92
92
 
93
93
 
94
- :host(:not([${S.MEDIA_IS_CASTING}])) slot:not([name=enter]):not([name=icon]) {
94
+ :host(:not([${A.MEDIA_IS_CASTING}])) slot:not([name=enter]):not([name=icon]) {
95
95
  display: none !important;
96
96
  }
97
97
  </style>
98
98
 
99
99
  <slot name="icon">
100
- <slot name="enter">${xT}</slot>
101
- <slot name="exit">${IT}</slot>
100
+ <slot name="enter">${$T}</slot>
101
+ <slot name="exit">${HT}</slot>
102
102
  </slot>
103
- `;var Vp=i=>{let e=i.mediaIsCasting?We.EXIT_CAST():We.ENTER_CAST();i.setAttribute("aria-label",e)},vc=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_CASTING,S.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Wp,...e})}connectedCallback(){super.connectedCallback(),Vp(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_IS_CASTING&&Vp(this)}get mediaIsCasting(){return Be(this,S.MEDIA_IS_CASTING)}set mediaIsCasting(e){Ne(this,S.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return He(this,S.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){$e(this,S.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?ee.MEDIA_EXIT_CAST_REQUEST:ee.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new D.CustomEvent(e,{composed:!0,bubbles:!0}))}};D.customElements.get("media-cast-button")||D.customElements.define("media-cast-button",vc);var Kp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},dr=(i,e,t)=>(Kp(i,e,"read from private field"),t?t.call(i):e.get(i)),LT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},io=(i,e,t,r)=>(Kp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ut,qp=q.createElement("template");qp.innerHTML=`
103
+ `;var Zp=i=>{let e=i.mediaIsCasting?We.EXIT_CAST():We.ENTER_CAST();i.setAttribute("aria-label",e)},Sc=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_IS_CASTING,A.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Jp,...e})}connectedCallback(){super.connectedCallback(),Zp(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===A.MEDIA_IS_CASTING&&Zp(this)}get mediaIsCasting(){return He(this,A.MEDIA_IS_CASTING)}set mediaIsCasting(e){Ue(this,A.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return Fe(this,A.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){Oe(this,A.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?ee.MEDIA_EXIT_CAST_REQUEST:ee.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-cast-button")||w.customElements.define("media-cast-button",Sc);var eg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},cr=(i,e,t)=>(eg(i,e,"read from private field"),t?t.call(i):e.get(i)),GT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},lo=(i,e,t,r)=>(eg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ht,tg=q.createElement("template");tg.innerHTML=`
104
104
  <style>
105
105
  :host {
106
106
  display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
107
107
  box-sizing: border-box;
108
108
  }
109
109
  </style>
110
- `;var Ec=class extends D.HTMLElement{constructor(e={}){if(super(),LT(this,Ut,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),r=qp.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=q.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(r)}}static get observedAttributes(){return[me.MEDIA_CONTROLLER,S.MEDIA_PAUSED]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER&&(t&&((n=(s=dr(this,Ut))==null?void 0:s.unassociateElement)==null||n.call(s,this),io(this,Ut,null)),r&&this.isConnected&&(io(this,Ut,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=dr(this,Ut))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),io(this,Ut,RT(this)),this.getAttribute(me.MEDIA_CONTROLLER)&&((t=(e=dr(this,Ut))==null?void 0:e.associateElement)==null||t.call(e,this)),(r=dr(this,Ut))==null||r.addEventListener("pointerdown",this),(s=dr(this,Ut))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,r,s;this.getAttribute(me.MEDIA_CONTROLLER)&&((t=(e=dr(this,Ut))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(r=dr(this,Ut))==null||r.removeEventListener("pointerdown",this),(s=dr(this,Ut))==null||s.removeEventListener("click",this),io(this,Ut,null)}handleEvent(e){var t;let r=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(r==null?void 0:r.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:c}=this.getBoundingClientRect(),u=n-o,h=a-l;if(u<0||h<0||u>d||h>c||d===0&&c===0)return;let{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===uc.TOUCH){this.handleTap(e);return}else if(f===uc.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return Be(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ne(this,S.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?ee.MEDIA_PLAY_REQUEST:ee.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new D.CustomEvent(t,{composed:!0,bubbles:!0}))}};Ut=new WeakMap;function RT(i){var e;let t=i.getAttribute(me.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):lr(i,"media-controller")}D.customElements.get("media-gesture-receiver")||D.customElements.define("media-gesture-receiver",Ec);var Yp=new WeakMap,bc=i=>{let e=Yp.get(i);return e||Yp.set(i,e=new Set),e},jp=new D.ResizeObserver(i=>{for(let e of i)for(let t of bc(e.target))t(e)});function wn(i,e){bc(i).add(e),jp.observe(i)}function yc(i,e){let t=bc(i);t.delete(e),t.size||jp.unobserve(i)}var kT=Object.defineProperty,wT=(i,e,t)=>e in i?kT(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,DT=(i,e,t)=>(wT(i,typeof e!="symbol"?e+"":e,t),t),Sc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ks=(i,e,t)=>(Sc(i,e,"read from private field"),t?t.call(i):e.get(i)),Nr=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Tc=(i,e,t,r)=>(Sc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ci=(i,e,t)=>(Sc(i,e,"access private method"),t),ro,Yi,_c,zp,Ac,Xp,Dn,no,ao,xc,ws,Cn,ke={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},Qp=q.createElement("template");Qp.innerHTML=`
110
+ `;var xc=class extends w.HTMLElement{constructor(e={}){if(super(),GT(this,Ht,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),r=tg.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=q.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(r)}}static get observedAttributes(){return[me.MEDIA_CONTROLLER,A.MEDIA_PAUSED]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER&&(t&&((n=(s=cr(this,Ht))==null?void 0:s.unassociateElement)==null||n.call(s,this),lo(this,Ht,null)),r&&this.isConnected&&(lo(this,Ht,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=cr(this,Ht))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),lo(this,Ht,VT(this)),this.getAttribute(me.MEDIA_CONTROLLER)&&((t=(e=cr(this,Ht))==null?void 0:e.associateElement)==null||t.call(e,this)),(r=cr(this,Ht))==null||r.addEventListener("pointerdown",this),(s=cr(this,Ht))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,r,s;this.getAttribute(me.MEDIA_CONTROLLER)&&((t=(e=cr(this,Ht))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(r=cr(this,Ht))==null||r.removeEventListener("pointerdown",this),(s=cr(this,Ht))==null||s.removeEventListener("click",this),lo(this,Ht,null)}handleEvent(e){var t;let r=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(r==null?void 0:r.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:c}=this.getBoundingClientRect(),u=n-o,h=a-l;if(u<0||h<0||u>d||h>c||d===0&&c===0)return;let{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===Ec.TOUCH){this.handleTap(e);return}else if(f===Ec.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return He(this,A.MEDIA_PAUSED)}set mediaPaused(e){Ue(this,A.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?ee.MEDIA_PLAY_REQUEST:ee.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new w.CustomEvent(t,{composed:!0,bubbles:!0}))}};Ht=new WeakMap;function VT(i){var e;let t=i.getAttribute(me.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):dr(i,"media-controller")}w.customElements.get("media-gesture-receiver")||w.customElements.define("media-gesture-receiver",xc);var ig=new WeakMap,Ic=i=>{let e=ig.get(i);return e||ig.set(i,e=new Set),e},rg=new w.ResizeObserver(i=>{for(let e of i)for(let t of Ic(e.target))t(e)});function Ur(i,e){Ic(i).add(e),rg.observe(i)}function Dn(i,e){let t=Ic(i);t.delete(e),t.size||rg.unobserve(i)}var WT=Object.defineProperty,KT=(i,e,t)=>e in i?WT(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,qT=(i,e,t)=>(KT(i,typeof e!="symbol"?e+"":e,t),t),Dc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Rc=(i,e,t)=>(Dc(i,e,"read from private field"),t?t.call(i):e.get(i)),Fr=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Lc=(i,e,t,r)=>(Dc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),hi=(i,e,t)=>(Dc(i,e,"access private method"),t),co,ws,kc,sg,wc,ng,Cn,ho,fo,Cc,Ds,Mn,ke={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},ag=q.createElement("template");ag.innerHTML=`
111
111
  <style>
112
112
 
113
- :host([${S.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
113
+ :host([${A.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
114
114
  outline: none;
115
115
  }
116
116
 
@@ -157,7 +157,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
157
157
  }
158
158
 
159
159
 
160
- ::slotted(:not([slot=media]):not([slot=poster]):not(media-loading-indicator)) {
160
+ ::slotted(:not([slot=media]):not([slot=poster]):not(media-loading-indicator):not([hidden])) {
161
161
  pointer-events: auto;
162
162
  }
163
163
 
@@ -199,18 +199,18 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
199
199
  }
200
200
 
201
201
 
202
- ::slotted(:not([slot=media]):not([${ke.NO_AUTOHIDE}]):not([hidden])) {
202
+ ::slotted(:not([slot=media]):not([slot=poster]):not([${ke.NO_AUTOHIDE}]):not([hidden])) {
203
203
  opacity: 1;
204
204
  transition: opacity 0.25s;
205
205
  }
206
206
 
207
207
 
208
- :host([${ke.USER_INACTIVE}]:not([${S.MEDIA_PAUSED}]):not([${S.MEDIA_IS_AIRPLAYING}]):not([${S.MEDIA_IS_CASTING}]):not([${ke.AUDIO}])) ::slotted(:not([slot=media]):not([${ke.NO_AUTOHIDE}])) {
208
+ :host([${ke.USER_INACTIVE}]:not([${A.MEDIA_PAUSED}]):not([${A.MEDIA_IS_AIRPLAYING}]):not([${A.MEDIA_IS_CASTING}]):not([${ke.AUDIO}])) ::slotted(:not([slot=media]):not([slot=poster]):not([${ke.NO_AUTOHIDE}])) {
209
209
  opacity: 0;
210
210
  transition: opacity 1s;
211
211
  }
212
212
 
213
- :host([${ke.USER_INACTIVE}]:not([${S.MEDIA_PAUSED}]):not([${S.MEDIA_IS_CASTING}]):not([${ke.AUDIO}])) ::slotted([slot=media]) {
213
+ :host([${ke.USER_INACTIVE}]:not([${A.MEDIA_PAUSED}]):not([${A.MEDIA_IS_CASTING}]):not([${ke.AUDIO}])) ::slotted([slot=media]) {
214
214
  cursor: none;
215
215
  }
216
216
 
@@ -219,13 +219,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
219
219
  }
220
220
 
221
221
 
222
- :host(:not([${ke.AUDIO}])[${S.MEDIA_HAS_PLAYED}]) slot[name=poster] {
222
+ :host(:not([${ke.AUDIO}])[${A.MEDIA_HAS_PLAYED}]) slot[name=poster] {
223
223
  display: none;
224
224
  }
225
225
 
226
- ::slotted([role=menu]) {
226
+ ::slotted([role="menu"]) {
227
227
  align-self: end;
228
228
  }
229
+
230
+ ::slotted([role="dialog"]) {
231
+ align-self: center;
232
+ }
229
233
  </style>
230
234
 
231
235
  <slot name="media" part="layer media-layer"></slot>
@@ -240,7 +244,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
240
244
 
241
245
  <slot part="bottom chrome"></slot>
242
246
  </span>
243
- `;var CT=Object.values(S),MT="sm:384 md:576 lg:768 xl:960";function PT(i){OT(i.target,i.contentRect.width)}function OT(i,e){var t;if(!i.isConnected)return;let r=(t=i.getAttribute(ke.BREAKPOINTS))!=null?t:MT,s=NT(r),n=UT(s,e),a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){let o=new CustomEvent(qi.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}}function NT(i){let e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function UT(i,e){return Object.keys(i).filter(t=>e>=i[t])}var so=class extends D.HTMLElement{constructor(){super(),Nr(this,_c),Nr(this,Ac),Nr(this,Dn),Nr(this,ao),Nr(this,ws),Nr(this,ro,0),Nr(this,Yi,void 0),DT(this,"breakpointsComputed",!1),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Qp.content.cloneNode(!0)));let e=a=>{let o=this.media;for(let l of a)l.type==="childList"&&(l.removedNodes.forEach(d=>{if(d.slot=="media"&&l.target==this){let c=l.previousSibling&&l.previousSibling.previousElementSibling;if(!c||!o)this.mediaUnsetCallback(d);else{let u=c.slot!=="media";for(;(c=c.previousSibling)!==null;)c.slot=="media"&&(u=!1);u&&this.mediaUnsetCallback(d)}}}),o&&l.addedNodes.forEach(d=>{d===o&&o!==ks(this,Yi)&&this.handleMediaUpdated(o).then(c=>this.mediaSetCallback(c))}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let r=!1;wn(this,a=>{r||(setTimeout(()=>{PT(a),r=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(qi.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),r=!0)});let n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:!0}).length){ks(this,Yi)&&this.mediaUnsetCallback(ks(this,Yi));return}this.media&&this.media!==ks(this,Yi)&&this.handleMediaUpdated(this.media).then(o=>this.mediaSetCallback(o))})}static get observedAttributes(){return[ke.AUTOHIDE,ke.GESTURES_DISABLED].concat(CT).filter(e=>![S.MEDIA_RENDITION_LIST,S.MEDIA_AUDIO_TRACK_LIST].includes(e))}attributeChangedCallback(e,t,r){e.toLowerCase()==ke.AUTOHIDE&&(this.autohide=r)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){Tc(this,Yi,e);let t=r=>(Tc(this,Yi,null),console.error('Media Chrome: Media element set with slot="media" does not appear to be compatible.',r),Promise.reject(r));return e?(e.localName.includes("-")&&await D.customElements.whenDefined(e.localName),e):t(e)}connectedCallback(){var e;let r=this.getAttribute(ke.AUDIO)!=null?St.AUDIO_PLAYER():St.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",r),this.media&&this.media!==ks(this,Yi)&&this.handleMediaUpdated(this.media).then(s=>this.mediaSetCallback(s)),this.setAttribute(ke.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=D.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=D.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){}handleEvent(e){switch(e.type){case"pointerdown":Tc(this,ro,e.timeStamp);break;case"pointermove":ci(this,_c,zp).call(this,e);break;case"pointerup":ci(this,Ac,Xp).call(this,e);break;case"mouseleave":ci(this,Dn,no).call(this);break;case"mouseup":this.removeAttribute(ke.KEYBOARD_CONTROL);break;case"keyup":ci(this,ws,Cn).call(this),this.setAttribute(ke.KEYBOARD_CONTROL,"");break}}set autohide(e){e=Number(e),this._autohide=isNaN(e)?0:e}get autohide(){return this._autohide===void 0?2:this._autohide}};ro=new WeakMap;Yi=new WeakMap;_c=new WeakSet;zp=function(i){i.pointerType!=="mouse"&&i.timeStamp-ks(this,ro)<250||(ci(this,ao,xc).call(this),clearTimeout(this._inactiveTimeout),[this,this.media].includes(i.target)&&ci(this,ws,Cn).call(this))};Ac=new WeakSet;Xp=function(i){if(i.pointerType==="touch"){let e=!this.hasAttribute(ke.USER_INACTIVE);[this,this.media].includes(i.target)&&e?ci(this,Dn,no).call(this):ci(this,ws,Cn).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&ci(this,ws,Cn).call(this)};Dn=new WeakSet;no=function(){if(this.autohide<0||this.hasAttribute(ke.USER_INACTIVE))return;this.setAttribute(ke.USER_INACTIVE,"");let i=new D.CustomEvent(qi.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};ao=new WeakSet;xc=function(){if(!this.hasAttribute(ke.USER_INACTIVE))return;this.removeAttribute(ke.USER_INACTIVE);let i=new D.CustomEvent(qi.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};ws=new WeakSet;Cn=function(){ci(this,ao,xc).call(this),clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=setTimeout(()=>{ci(this,Dn,no).call(this)},this.autohide*1e3))};var Zp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},gt=(i,e,t)=>(Zp(i,e,"read from private field"),t?t.call(i):e.get(i)),Mn=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},oo=(i,e,t,r)=>(Zp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ds,Cs,lo,Ur,ji,cr,ur=class{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){Mn(this,ji),Mn(this,Ds,void 0),Mn(this,Cs,void 0),Mn(this,lo,void 0),Mn(this,Ur,new Set),oo(this,Ds,e),oo(this,Cs,t),oo(this,lo,new Set(r))}[Symbol.iterator](){return gt(this,ji,cr).values()}get length(){return gt(this,ji,cr).size}get value(){var e;return(e=[...gt(this,ji,cr)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(oo(this,Ur,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...gt(this,ji,cr)][e]}values(){return gt(this,ji,cr).values()}forEach(e){gt(this,ji,cr).forEach(e)}add(...e){var t,r;e.forEach(s=>gt(this,Ur).add(s)),!(this.value===""&&!((t=gt(this,Ds))!=null&&t.hasAttribute(`${gt(this,Cs)}`)))&&((r=gt(this,Ds))==null||r.setAttribute(`${gt(this,Cs)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>gt(this,Ur).delete(r)),(t=gt(this,Ds))==null||t.setAttribute(`${gt(this,Cs)}`,`${this.value}`)}contains(e){return gt(this,ji,cr).has(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}};Ds=new WeakMap;Cs=new WeakMap;lo=new WeakMap;Ur=new WeakMap;ji=new WeakSet;cr=function(){return gt(this,Ur).size?gt(this,Ur):gt(this,lo)};var FT=(i="")=>i.split(/\s+/),Jp=(i="")=>{let[e,t,r]=i.split(":"),s=r?decodeURIComponent(r):void 0;return e=e==="cc"?"captions":"subtitles",{kind:e,language:t,label:s}},Pn=(i="",e={})=>FT(i).map(t=>{let r=Jp(t);return{...e,...r}}),Ic=i=>Array.isArray(i)?i.map(e=>typeof e=="string"?Jp(e):e):typeof i=="string"?Pn(i):[i],co=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,Fr=(i=[])=>Array.prototype.map.call(i,co).join(" "),BT=(i,e)=>t=>t[i]===e,eg=i=>{let e=Object.entries(i).map(([t,r])=>BT(t,r));return t=>e.every(r=>r(t))},Ms=(i,e=[],t=[])=>{let r=Ic(t).map(eg),s=n=>r.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=i})},uo=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];let t=typeof e=="function"?e:eg(e);return Array.from(i.textTracks).filter(t)},tg=i=>!!i.getAttribute(S.MEDIA_SUBTITLES_SHOWING);var st={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};q.fullscreenElement===void 0&&(st.enter="webkitRequestFullScreen",st.exit=q.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",st.rootEvents=["webkitfullscreenchange"],st.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],st.element="webkitFullscreenElement",st.error="webkitfullscreenerror",st.enabled="webkitFullscreenEnabled");var ho,Lc=()=>{var i,e;return ho||(ho=(e=(i=q)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),ho)},ig=async(i=Lc())=>{if(!i)return!1;let e=i.volume;return i.volume=e/2+.1,await ja(0),i.volume!==e},$T=(i=Lc())=>typeof(i==null?void 0:i.requestPictureInPicture)=="function",GT=(i=Lc())=>{let e=q[st.enabled];return!e&&i&&(e="webkitSupportsFullscreen"in i),e},Rc=GT(),rg=$T(),sg=!!D.WebKitPlaybackTargetAvailabilityEvent,ng=!!D.chrome;var mo,ag=ig().then(i=>(mo=i,mo)),HT=Object.values(di),fo=i=>uo(i.media,e=>[ar.SUBTITLES,ar.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),og=i=>uo(i.media,e=>e.mode===Pr.SHOWING&&[ar.SUBTITLES,ar.CAPTIONS].includes(e.kind)),Ft={MEDIA_PAUSED:{get:function(i){let{media:e}=i;return e?e.paused:!0},mediaEvents:["play","playing","pause","emptied"]},MEDIA_HAS_PLAYED:{get:function(i){let{media:e}=i;return e?!e.paused:!1},mediaEvents:["playing","emptied"]},MEDIA_ENDED:{get:function(i){let{media:e}=i;return e?e.ended:!1},mediaEvents:["seeked","ended","emptied"]},MEDIA_PLAYBACK_RATE:{get:function(i){let{media:e}=i;return!e||typeof e.playbackRate=="undefined"?1:e.playbackRate},mediaEvents:["ratechange","loadstart"]},MEDIA_MUTED:{get:function(i){let{media:e}=i;return!e||typeof e.muted=="undefined"?!1:e.muted},mediaEvents:["volumechange"]},MEDIA_VOLUME:{get:function(i){let{media:e}=i;return!e||typeof e.volume=="undefined"?1:Number(e.volume)},mediaEvents:["volumechange"]},MEDIA_VOLUME_LEVEL:{get:function(i){let{media:e}=i,t="high";if(!e||typeof e.volume=="undefined")return t;let{muted:r,volume:s}=e;return s===0||r?t="off":s<.5?t="low":s<.75&&(t="medium"),t},mediaEvents:["volumechange"]},MEDIA_CURRENT_TIME:{get:function(i){let{media:e}=i;return!e||typeof e.currentTime=="undefined"?0:e.currentTime},mediaEvents:["playing","pause","timeupdate","loadedmetadata"]},MEDIA_DURATION:{get:function(i){let{media:e}=i;return i.hasAttribute("defaultduration")&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?+i.getAttribute("defaultduration"):!e||!Number.isFinite(e.duration)?Number.NaN:e.duration},mediaEvents:["durationchange","loadedmetadata","emptied"]},MEDIA_SEEKABLE:{get:function(i){var e;let{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;let r=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!r&&!s))return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress"]},MEDIA_LOADING:{get:function(i){var e;return((e=i.media)==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},MEDIA_BUFFERED:{get:function(i){var e,t,r;let s=(e=i.media)==null?void 0:e.buffered;return Array.from((r=(t=i.media)==null?void 0:t.buffered)!=null?r:[]).map((n,a)=>[Number(s.start(a)).toFixed(3),Number(s.end(a)).toFixed(3)])},mediaEvents:["progress","emptied"]},MEDIA_STREAM_TYPE:{get:function(i){let{media:e}=i;if(!e)return;let{streamType:t}=e;if(HT.includes(t)){if(t===di.UNKNOWN){let s=i.getAttribute("defaultstreamtype");return[di.LIVE,di.ON_DEMAND].includes(s)?s:void 0}return t}let r=e.duration;if(r===1/0)return di.LIVE;if(Number.isFinite(r))return di.ON_DEMAND;{let s=i.getAttribute("defaultstreamtype");if([di.LIVE,di.ON_DEMAND].includes(s))return s}},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},MEDIA_TARGET_LIVE_WINDOW:{get:function(i){let{media:e}=i;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,r=Ft.MEDIA_STREAM_TYPE.get(i);return(t==null||Number.isNaN(t))&&r===di.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},MEDIA_TIME_IS_LIVE:{get:function(i){let{media:e}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(Ft.MEDIA_STREAM_TYPE.get(i)==="live"))return!1;let r=e.seekable;if(!r)return!0;if(!r.length)return!1;let s=i.hasAttribute("liveedgeoffset")?Number(i.getAttribute("liveedgeoffset")):10,n=r.end(r.length-1)-s;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},MEDIA_IS_FULLSCREEN:{get:function(i,e){var t,r;let s=i.media;if(s&&q[st.element]===void 0&&"webkitDisplayingFullscreen"in s)return s.webkitDisplayingFullscreen&&s.webkitPresentationMode==="fullscreen";let n;return e?n=q[st.element]?e.target:null:n=(r=(t=Cp(i))==null?void 0:t.fullscreenElement)!=null?r:q[st.element],or(i.fullscreenElement,n)},rootEvents:st.rootEvents,mediaEvents:st.mediaEvents},MEDIA_IS_PIP:{get:function(i,e){var t;let r=i.media;if(!r)return!1;if(e)return e.type=="enterpictureinpicture";{let s=(t=i.getRootNode().pictureInPictureElement)!=null?t:q.pictureInPictureElement;return or(r,s)}},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},MEDIA_IS_AIRPLAYING:{get:function(i){var e;let{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:t.remote.state},remoteEvents:["playing","connect","connecting","disconnect"]},MEDIA_IS_CASTING:{get:function(i){var e;let{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:t.remote.state},remoteEvents:["connect","connecting","disconnect"]},MEDIA_AIRPLAY_UNAVAILABLE:{get:function(i,{availability:e=!1}={}){if(!sg)return qt.UNSUPPORTED;if(!(e==null||e===!0))return qt.UNAVAILABLE},mediaSetCallback(i,e){var t;(t=i.remote)==null||t.watchAvailability(r=>e({availability:r}))},mediaUnsetCallback(i){var e;(e=i.remote)==null||e.cancelWatchAvailability()}},MEDIA_CAST_UNAVAILABLE:{get:function(i,{availability:e=!1}={}){var t;let{media:r}=i;if(!ng||!((t=r==null?void 0:r.remote)!=null&&t.state))return qt.UNSUPPORTED;if(!(e==null||e===!0))return qt.UNAVAILABLE},mediaSetCallback(i,e){var t;(t=i.remote)==null||t.watchAvailability(r=>e({availability:r}))},mediaUnsetCallback(i){var e;(e=i.remote)==null||e.cancelWatchAvailability()}},MEDIA_FULLSCREEN_UNAVAILABLE:{get:function(){return Rc?void 0:qt.UNAVAILABLE}},MEDIA_PIP_UNAVAILABLE:{get:function(){return rg?void 0:qt.UNSUPPORTED}},MEDIA_RENDITION_UNAVAILABLE:{get:function(i){var e;let{media:t}=i;if(!(t!=null&&t.videoRenditions))return qt.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return qt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_AUDIO_TRACK_UNAVAILABLE:{get:function(i){var e,t;let{media:r}=i;if(!(r!=null&&r.audioTracks))return qt.UNSUPPORTED;if(((t=(e=r.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return qt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},MEDIA_VOLUME_UNAVAILABLE:{get:function(i){if(mo!==void 0&&!mo)return qt.UNSUPPORTED;let{media:e}=i;if(e&&typeof e.volume=="undefined")return qt.UNAVAILABLE},mediaEvents:["loadstart"]},MEDIA_SUBTITLES_LIST:{get:function(i){return fo(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},MEDIA_SUBTITLES_SHOWING:{get:function(i,e){var t;return i.hasAttribute("defaultsubtitles")&&["addtrack","removetrack"].includes(e==null?void 0:e.type)&&[ar.CAPTIONS,ar.SUBTITLES].includes((t=e==null?void 0:e.track)==null?void 0:t.kind)&&On.MEDIA_TOGGLE_SUBTITLES_REQUEST(void 0,{detail:!0},i),og(i).map(({kind:r,label:s,language:n})=>({kind:r,label:s,language:n}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"]},MEDIA_RENDITION_LIST:{get:function(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]]},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_RENDITION_SELECTED:{get:function(i){var e,t,r;let{media:s}=i;return(r=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:r.id},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},MEDIA_AUDIO_TRACK_LIST:{get:function(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},MEDIA_AUDIO_TRACK_ENABLED:{get:function(i){var e,t;let{media:r}=i;return(t=[...(e=r==null?void 0:r.audioTracks)!=null?e:[]].find(s=>s.enabled))==null?void 0:t.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]}},On={MEDIA_PLAY_REQUEST:(i,e,t)=>{var r;let s=Ft.MEDIA_STREAM_TYPE.get(t),n=t.getAttribute("noautoseektolive")===null;s==di.LIVE&&n&&On.MEDIA_SEEK_TO_LIVE_REQUEST(i),(r=i.play())==null||r.catch(()=>{})},MEDIA_PAUSE_REQUEST:i=>i.pause(),MEDIA_MUTE_REQUEST:i=>i.muted=!0,MEDIA_UNMUTE_REQUEST:i=>{i.muted=!1,i.volume===0&&(i.volume=.25)},MEDIA_VOLUME_REQUEST:(i,e,t)=>{let r=e.detail;if(i.volume=r,r>0&&i.muted&&(i.muted=!1),!t.hasAttribute("novolumepref"))try{D.localStorage.setItem("media-chrome-pref-volume",r.toString())}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:(i,e,t)=>{if(!Rc){console.warn("MediaChrome: Fullscreen support is unavailable; not entering fullscreen");return}q.pictureInPictureElement&&q.exitPictureInPicture(),t[st.enter]?t.fullscreenElement[st.enter]():i.webkitEnterFullscreen?i.webkitEnterFullscreen():i.requestFullscreen?i.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported")},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{q[st.exit]()},MEDIA_ENTER_PIP_REQUEST:i=>{if(!q.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!i.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}q[st.element]&&q[st.exit]();let e=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};i.requestPictureInPicture().catch(t=>{if(t.code===11)if(i.readyState===0&&i.preload==="none"){let r=()=>{i.removeEventListener("loadedmetadata",s),i.preload="none"},s=()=>{i.requestPictureInPicture().catch(e),r()};i.addEventListener("loadedmetadata",s),i.preload="metadata",setTimeout(()=>{i.readyState===0&&e(),r()},1e3)}else throw t;else throw t})},MEDIA_EXIT_PIP_REQUEST:()=>{q.pictureInPictureElement&&q.exitPictureInPicture()},MEDIA_ENTER_CAST_REQUEST:async i=>{var e;if(((e=i.remote)==null?void 0:e.state)==="disconnected"){if(q[st.element]&&q[st.exit](),!i.remote.prompt){console.warn("MediaChrome: Casting is not supported in this environment");return}try{await i.remote.prompt()}catch{}}},MEDIA_EXIT_CAST_REQUEST:i=>{var e;((e=i.remote)==null?void 0:e.state)==="connected"&&i.remote.prompt()},MEDIA_SEEK_REQUEST:(i,e)=>{let t=e.detail;(i.readyState>0||i.readyState===void 0)&&(i.currentTime=t)},MEDIA_PLAYBACK_RATE_REQUEST:(i,e)=>{i.playbackRate=e.detail},MEDIA_PREVIEW_REQUEST:(i,e,t)=>{var r;if(!i)return;let s=e.detail;s===null&&t.propagateMediaState(S.MEDIA_PREVIEW_TIME,void 0),t.propagateMediaState(S.MEDIA_PREVIEW_TIME,s);let[n]=uo(i,{kind:ar.METADATA,label:"thumbnails"});if(!(n&&n.cues))return;if(s===null){t.propagateMediaState(S.MEDIA_PREVIEW_IMAGE,void 0),t.propagateMediaState(S.MEDIA_PREVIEW_COORDS,void 0);return}let a=Array.prototype.find.call(n.cues,c=>c.startTime>=s);if(!a)return;let o=/'^(?:[a-z]+:)?\/\//i.test(a.text)||(r=i.querySelector('track[label="thumbnails"]'))==null?void 0:r.src,l=new URL(a.text,o),d=new URLSearchParams(l.hash).get("#xywh");t.propagateMediaState(S.MEDIA_PREVIEW_IMAGE,l.href),t.propagateMediaState(S.MEDIA_PREVIEW_COORDS,d.split(","))},MEDIA_SHOW_SUBTITLES_REQUEST:(i,e,t)=>{var r;let s=fo(t),{detail:n=[]}=e,a=Ic(n),o=(r=a[0])==null?void 0:r.language;o&&!(t!=null&&t.hasAttribute("nosubtitleslangpref"))&&D.localStorage.setItem("media-chrome-pref-subtitles-lang",o),Ms(Pr.SHOWING,s,a)},MEDIA_DISABLE_SUBTITLES_REQUEST:(i,e,t)=>{let r=fo(t),{detail:s=[]}=e;Ms(Pr.DISABLED,r,s)},MEDIA_TOGGLE_SUBTITLES_REQUEST:(i,e,t)=>{let{detail:r}=e!=null?e:{},s=fo(t),n=og(t),a=!!n.length;if(s.length){if(r===!1||a&&r!==!0)Ms(Pr.DISABLED,s,n);else if(r===!0||!a&&r!==!1){let o=s[0];if(!(t!=null&&t.hasAttribute("nosubtitleslangpref"))){let u=D.localStorage.getItem("media-chrome-pref-subtitles-lang"),h=u?[u,...D.navigator.languages]:D.navigator.languages,f=s.filter(g=>h.some(E=>g.language.toLowerCase().startsWith(E.split("-")[0]))).sort((g,E)=>{let T=h.findIndex(k=>g.language.toLowerCase().startsWith(k.split("-")[0])),A=h.findIndex(k=>E.language.toLowerCase().startsWith(k.split("-")[0]));return T-A});f[0]&&(o=f[0])}let{language:l,label:d,kind:c}=o;Ms(Pr.DISABLED,s,n),Ms(Pr.SHOWING,s,[{language:l,label:d,kind:c}])}}},MEDIA_AIRPLAY_REQUEST:async i=>{if(i!=null&&i.remote){if(!i.remote.prompt){console.warn("MediaChrome: AirPlay is not supported in this environment");return}try{await i.remote.prompt()}catch{}}},MEDIA_SEEK_TO_LIVE_REQUEST:i=>{let e=i.seekable;if(!e){console.warn("MediaChrome: Media element does not support seeking to live.");return}if(!e.length){console.warn("MediaChrome: Media is unable to seek to live.");return}i.currentTime=e.end(e.length-1)},MEDIA_RENDITION_REQUEST:(i,e)=>{if(!(i!=null&&i.videoRenditions)){console.warn("MediaChrome: Rendition selection not supported by this media.");return}let t=e.detail,r=[...i.videoRenditions].findIndex(s=>s.id==t);i.videoRenditions.selectedIndex!=r&&(i.videoRenditions.selectedIndex=r)},MEDIA_AUDIO_TRACK_REQUEST:(i,e)=>{if(!(i!=null&&i.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let t=e.detail;for(let r of i.audioTracks)r.enabled=t==r.id}};var Cc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},xi=(i,e,t)=>(Cc(i,e,"read from private field"),t?t.call(i):e.get(i)),Nn=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},kc=(i,e,t,r)=>(Cc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Os=(i,e,t)=>(Cc(i,e,"access private method"),t),hr,Un,Ps,Ns,Fn,po,wc,fg=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],VT=10,lg=0,Dt={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys"},go=class extends so{constructor(){super(),Nn(this,Ns),Nn(this,po),Nn(this,hr,new ur(this,Dt.HOTKEYS)),Nn(this,Un,void 0),Nn(this,Ps,void 0),Ft.MEDIA_VOLUME_UNAVAILABLE.get(this)===void 0&&ag.then(()=>{this.propagateMediaState(S.MEDIA_VOLUME_UNAVAILABLE,Ft.MEDIA_VOLUME_UNAVAILABLE.get(this))}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this),Object.keys(On).forEach(e=>{let t=`_handle${qa(e,!0)}`;this[t]=r=>{if(r.stopPropagation(),!this.media){console.warn("MediaController: No media available.");return}On[e](this.media,r,this)},this.addEventListener(ee[e],this[t])}),this._mediaStatePropagators={},Object.keys(Ft).forEach(e=>{this._mediaStatePropagators[e]=t=>{this.propagateMediaState(Mr[e],Ft[e].get(this,t))}})}static get observedAttributes(){return super.observedAttributes.concat(Dt.NO_HOTKEYS,Dt.HOTKEYS,Dt.DEFAULT_STREAM_TYPE,Dt.DEFAULT_SUBTITLES,Dt.DEFAULT_DURATION)}get fullscreenElement(){var e;return(e=xi(this,Un))!=null?e:this}set fullscreenElement(e){this.hasAttribute(Dt.FULLSCREEN_ELEMENT)&&this.removeAttribute(Dt.FULLSCREEN_ELEMENT),kc(this,Un,e)}attributeChangedCallback(e,t,r){var s;if(super.attributeChangedCallback(e,t,r),e===Dt.NO_HOTKEYS)r!==t&&r===""?(this.hasAttribute(Dt.HOTKEYS)&&console.warn("Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):r!==t&&r===null&&this.enableHotkeys();else if(e===Dt.HOTKEYS)xi(this,hr).value=r;else if(e===Dt.DEFAULT_SUBTITLES&&r!==t&&r==="")this.dispatchEvent(new D.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:!0}));else if(e===Dt.DEFAULT_STREAM_TYPE)this.propagateMediaState(Mr.MEDIA_STREAM_TYPE);else if(e===Dt.FULLSCREEN_ELEMENT){let n=r?(s=xi(this,Ps))==null?void 0:s.getElementById(r):void 0;kc(this,Un,n)}}connectedCallback(){super.connectedCallback(),kc(this,Ps,this.getRootNode()),this.enableHotkeys()}disconnectedCallback(){super.disconnectedCallback(),this.disableHotkeys(),this.dispatchEvent(new D.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:!1}))}mediaSetCallback(e){if(super.mediaSetCallback(e),e.hasAttribute("tabindex")||(e.tabIndex=-1),Object.keys(Ft).forEach(t=>{let{mediaSetCallback:r,mediaEvents:s,rootEvents:n,textTracksEvents:a,videoRenditionsEvents:o,audioTracksEvents:l,remoteEvents:d}=Ft[t],c=this._mediaStatePropagators[t];r&&(r(e,c),c()),s==null||s.forEach(u=>{e.addEventListener(u,c),c()}),n==null||n.forEach(u=>{var h;(h=xi(this,Ps))==null||h.addEventListener(u,c),c()}),a==null||a.forEach(u=>{var h;(h=e.textTracks)==null||h.addEventListener(u,c),c()}),o==null||o.forEach(u=>{var h;(h=e.videoRenditions)==null||h.addEventListener(u,c),c()}),l==null||l.forEach(u=>{var h;(h=e.audioTracks)==null||h.addEventListener(u,c),c()}),d==null||d.forEach(u=>{var h;(h=e.remote)==null||h.addEventListener(u,c),c()})}),!this.hasAttribute("novolumepref"))try{let t=D.localStorage.getItem("media-chrome-pref-volume");t!==null&&(e.volume=t)}catch(t){console.debug("Error getting volume pref",t)}}mediaUnsetCallback(e){super.mediaUnsetCallback(e),Object.keys(Ft).forEach(t=>{let{mediaUnsetCallback:r,mediaEvents:s,rootEvents:n,textTracksEvents:a,videoRenditionsEvents:o,audioTracksEvents:l,remoteEvents:d}=Ft[t],c=this._mediaStatePropagators[t];s==null||s.forEach(u=>{e.removeEventListener(u,c)}),n==null||n.forEach(u=>{var h;(h=xi(this,Ps))==null||h.removeEventListener(u,c)}),a==null||a.forEach(u=>{var h;(h=e.textTracks)==null||h.removeEventListener(u,c)}),o==null||o.forEach(u=>{var h;(h=e.videoRenditions)==null||h.removeEventListener(u,c),c()}),l==null||l.forEach(u=>{var h;(h=e.audioTracks)==null||h.removeEventListener(u,c),c()}),d==null||d.forEach(u=>{var h;(h=e.remote)==null||h.removeEventListener(u,c),c()}),r&&(r(e,c),c())}),this.propagateMediaState(Mr.MEDIA_PAUSED,!0)}propagateMediaState(e,t){let r=hg(this.mediaStateReceivers,e);if(ug(this.mediaStateReceivers,e,t),r===hg(this.mediaStateReceivers,e))return;let s=e.toLowerCase(),n=new D.CustomEvent(Sp[s],{composed:!0,bubbles:!0,detail:t});this.dispatchEvent(n)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let r=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=zT(e,r,s);Object.keys(ee).forEach(a=>{e.addEventListener(ee[a],this[`_handle${qa(a,!0)}`])}),t.set(e,n)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.keys(ee).forEach(s=>{e.removeEventListener(ee[s],this[`_handle${qa(s,!0)}`])})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),Object.keys(Ft).forEach(s=>{let n=Ft[s];ug([e],Mr[s],n.get(this))}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,r=t.indexOf(e);r<0||t.splice(r,1)}enableHotkeys(){this.addEventListener("keydown",Os(this,po,wc))}disableHotkeys(){this.removeEventListener("keydown",Os(this,po,wc)),this.removeEventListener("keyup",Os(this,Ns,Fn))}get hotkeys(){return xi(this,hr)}keyboardShortcutHandler(e){var t,r,s,n;if(((n=(s=(t=e.target.getAttribute(Dt.KEYS_USED))==null?void 0:t.split(" "))!=null?s:(r=e.target)==null?void 0:r.keysUsed)!=null?n:[]).map(f=>f==="Space"?" ":f).filter(Boolean).includes(e.key))return;let o,l,d,c,u,h=VT;if(!xi(this,hr).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&xi(this,hr).contains("nospace")))switch(e.key){case" ":case"k":o=this.getAttribute(S.MEDIA_PAUSED)!=null?ee.MEDIA_PLAY_REQUEST:ee.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new D.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"m":o=this.getAttribute(S.MEDIA_VOLUME_LEVEL)==="off"?ee.MEDIA_UNMUTE_REQUEST:ee.MEDIA_MUTE_REQUEST,this.dispatchEvent(new D.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"f":o=this.getAttribute(S.MEDIA_IS_FULLSCREEN)!=null?ee.MEDIA_EXIT_FULLSCREEN_REQUEST:ee.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new D.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new D.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":l=this.getAttribute(S.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:lg,c=Math.max(d-h,0),u=new D.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break;case"ArrowRight":l=this.getAttribute(S.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:lg,c=Math.max(d+h,0),u=new D.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break;default:break}}};hr=new WeakMap;Un=new WeakMap;Ps=new WeakMap;Ns=new WeakSet;Fn=function(i){let{key:e}=i;if(!fg.includes(e)){this.removeEventListener("keyup",Os(this,Ns,Fn));return}this.keyboardShortcutHandler(i)};po=new WeakSet;wc=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!fg.includes(r)){this.removeEventListener("keyup",Os(this,Ns,Fn));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(xi(this,hr).contains(`no${r.toLowerCase()}`)||r===" "&&xi(this,hr).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",Os(this,Ns,Fn),{once:!0})};var WT=Object.values(S),KT=Object.values(Mr),Mc=i=>{var e,t,r,s;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(D.customElements.upgrade(i),{observedAttributes:n}=i.constructor);let a=(s=(r=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,me.MEDIA_CHROME_ATTRIBUTES))==null?void 0:r.split)==null?void 0:s.call(r,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>WT.includes(o)):[]},qT=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&D.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof D.customElements.get(i.nodeName.toLowerCase()))&&D.customElements.upgrade(i),KT.some(r=>r in i)},Dc=i=>qT(i)||!!Mc(i).length,dg=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},cg={[S.MEDIA_SUBTITLES_LIST]:Fr,[S.MEDIA_SUBTITLES_SHOWING]:Fr,[S.MEDIA_SEEKABLE]:dg,[S.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(dg).join(" "),[S.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[S.MEDIA_RENDITION_LIST]:xp,[S.MEDIA_AUDIO_TRACK_LIST]:Lp},YT=async(i,e,t)=>{var r,s;if(i.isConnected||await ja(0),typeof t=="boolean"||t==null)return Ne(i,e,t);if(typeof t=="number")return Ke(i,e,t);if(typeof t=="string")return $e(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);let n=(s=(r=cg[e])==null?void 0:r.call(cg,t))!=null?s:t;return i.setAttribute(e,n)},jT=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Br=(i,e)=>{if(jT(i))return;let t=(s,n)=>{var a,o;Dc(s)&&n(s);let{children:l=[]}=s!=null?s:{},d=(o=(a=s==null?void 0:s.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(u=>Br(u,n))},r=i==null?void 0:i.nodeName.toLowerCase();if(r.includes("-")&&!Dc(i)){D.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},ug=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}let s=Mc(r),n=e.toLowerCase();s.includes(n)&&YT(r,n,t)})},hg=(i,e)=>{for(let t of i){if(e in t)return t[e];let r=Mc(t),s=e.toLowerCase();if(r.includes(s))return t.getAttribute(s)}},zT=(i,e,t)=>{Br(i,e);let r=c=>{var u;let h=(u=c==null?void 0:c.composedPath()[0])!=null?u:c.target;e(h)},s=c=>{var u;let h=(u=c==null?void 0:c.composedPath()[0])!=null?u:c.target;t(h)};i.addEventListener(ee.REGISTER_MEDIA_STATE_RECEIVER,r),i.addEventListener(ee.UNREGISTER_MEDIA_STATE_RECEIVER,s);let n=c=>{c.forEach(u=>{let{addedNodes:h=[],removedNodes:f=[],type:g,target:E,attributeName:T}=u;g==="childList"?(Array.prototype.forEach.call(h,A=>Br(A,e)),Array.prototype.forEach.call(f,A=>Br(A,t))):g==="attributes"&&T===me.MEDIA_CHROME_ATTRIBUTES&&(Dc(E)?e(E):t(E))})},a=[],o=c=>{let u=c.target;u.name!=="media"&&(a.forEach(h=>Br(h,t)),a=[...u.assignedElements({flatten:!0})],a.forEach(h=>Br(h,e)))};i.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{Br(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener(ee.REGISTER_MEDIA_STATE_RECEIVER,r),i.removeEventListener(ee.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};D.customElements.get("media-controller")||D.customElements.define("media-controller",go);var Pc=go;var Gc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ui=(i,e,t)=>(Gc(i,e,"read from private field"),t?t.call(i):e.get(i)),Yt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},$r=(i,e,t,r)=>(Gc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ii=(i,e,t)=>(Gc(i,e,"access private method"),t),Li,So,To,_o,vo,Eo,bo,Oc,yo,Nc,Ao,Hc,Uc,mg,Fc,pg,Bc,gg,$c,vg,Eg=q.createElement("template");Eg.innerHTML=`
247
+ `;var YT=Object.values(A),jT="sm:384 md:576 lg:768 xl:960";function zT(i){XT(i.target,i.contentRect.width)}function XT(i,e){var t;if(!i.isConnected)return;let r=(t=i.getAttribute(ke.BREAKPOINTS))!=null?t:jT,s=QT(r),n=ZT(s,e),a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){let o=new CustomEvent(Xi.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}}function QT(i){let e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function ZT(i,e){return Object.keys(i).filter(t=>e>=i[t])}var uo=class extends w.HTMLElement{constructor(){super(),Fr(this,kc),Fr(this,wc),Fr(this,Cn),Fr(this,fo),Fr(this,Ds),Fr(this,co,0),Fr(this,ws,void 0),qT(this,"breakpointsComputed",!1),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ag.content.cloneNode(!0)));let e=a=>{let o=this.media;for(let l of a)l.type==="childList"&&(l.removedNodes.forEach(d=>{if(d.slot=="media"&&l.target==this){let c=l.previousSibling&&l.previousSibling.previousElementSibling;if(!c||!o)this.mediaUnsetCallback(d);else{let u=c.slot!=="media";for(;(c=c.previousSibling)!==null;)c.slot=="media"&&(u=!1);u&&this.mediaUnsetCallback(d)}}}),o&&l.addedNodes.forEach(d=>{d===o&&this.handleMediaUpdated(o)}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let r=!1;Ur(this,a=>{r||(setTimeout(()=>{zT(a),r=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(Xi.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),r=!0)});let n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:!0}).length){Rc(this,ws)&&this.mediaUnsetCallback(Rc(this,ws));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[ke.AUTOHIDE,ke.GESTURES_DISABLED].concat(YT).filter(e=>![A.MEDIA_RENDITION_LIST,A.MEDIA_AUDIO_TRACK_LIST,A.MEDIA_CHAPTERS_CUES].includes(e))}attributeChangedCallback(e,t,r){e.toLowerCase()==ke.AUTOHIDE&&(this.autohide=r)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(Lc(this,ws,e),e.localName.includes("-")&&await w.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;let r=this.getAttribute(ke.AUDIO)!=null?Lt.AUDIO_PLAYER():Lt.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",r),this.handleMediaUpdated(this.media),this.setAttribute(ke.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=w.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=w.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){Lc(this,ws,null)}handleEvent(e){switch(e.type){case"pointerdown":Lc(this,co,e.timeStamp);break;case"pointermove":hi(this,kc,sg).call(this,e);break;case"pointerup":hi(this,wc,ng).call(this,e);break;case"mouseleave":hi(this,Cn,ho).call(this);break;case"mouseup":this.removeAttribute(ke.KEYBOARD_CONTROL);break;case"keyup":hi(this,Ds,Mn).call(this),this.setAttribute(ke.KEYBOARD_CONTROL,"");break}}set autohide(e){e=Number(e),this._autohide=isNaN(e)?0:e}get autohide(){return this._autohide===void 0?2:this._autohide}};co=new WeakMap;ws=new WeakMap;kc=new WeakSet;sg=function(i){i.pointerType!=="mouse"&&i.timeStamp-Rc(this,co)<250||(hi(this,fo,Cc).call(this),clearTimeout(this._inactiveTimeout),[this,this.media].includes(i.target)&&hi(this,Ds,Mn).call(this))};wc=new WeakSet;ng=function(i){if(i.pointerType==="touch"){let e=!this.hasAttribute(ke.USER_INACTIVE);[this,this.media].includes(i.target)&&e?hi(this,Cn,ho).call(this):hi(this,Ds,Mn).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&hi(this,Ds,Mn).call(this)};Cn=new WeakSet;ho=function(){if(this.autohide<0||this.hasAttribute(ke.USER_INACTIVE))return;this.setAttribute(ke.USER_INACTIVE,"");let i=new w.CustomEvent(Xi.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};fo=new WeakSet;Cc=function(){if(!this.hasAttribute(ke.USER_INACTIVE))return;this.removeAttribute(ke.USER_INACTIVE);let i=new w.CustomEvent(Xi.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};Ds=new WeakSet;Mn=function(){hi(this,fo,Cc).call(this),clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=setTimeout(()=>{hi(this,Cn,ho).call(this)},this.autohide*1e3))};var og=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},vt=(i,e,t)=>(og(i,e,"read from private field"),t?t.call(i):e.get(i)),Pn=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},mo=(i,e,t,r)=>(og(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Cs,Ms,po,Br,Qi,ur,hr=class{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){Pn(this,Qi),Pn(this,Cs,void 0),Pn(this,Ms,void 0),Pn(this,po,void 0),Pn(this,Br,new Set),mo(this,Cs,e),mo(this,Ms,t),mo(this,po,new Set(r))}[Symbol.iterator](){return vt(this,Qi,ur).values()}get length(){return vt(this,Qi,ur).size}get value(){var e;return(e=[...vt(this,Qi,ur)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(mo(this,Br,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...vt(this,Qi,ur)][e]}values(){return vt(this,Qi,ur).values()}forEach(e){vt(this,Qi,ur).forEach(e)}add(...e){var t,r;e.forEach(s=>vt(this,Br).add(s)),!(this.value===""&&!((t=vt(this,Cs))!=null&&t.hasAttribute(`${vt(this,Ms)}`)))&&((r=vt(this,Cs))==null||r.setAttribute(`${vt(this,Ms)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>vt(this,Br).delete(r)),(t=vt(this,Cs))==null||t.setAttribute(`${vt(this,Ms)}`,`${this.value}`)}contains(e){return vt(this,Qi,ur).has(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}};Cs=new WeakMap;Ms=new WeakMap;po=new WeakMap;Br=new WeakMap;Qi=new WeakSet;ur=function(){return vt(this,Br).size?vt(this,Br):vt(this,po)};var JT=(i="")=>i.split(/\s+/),lg=(i="")=>{let[e,t,r]=i.split(":"),s=r?decodeURIComponent(r):void 0;return e=e==="cc"?"captions":"subtitles",{kind:e,language:t,label:s}},On=(i="",e={})=>JT(i).map(t=>{let r=lg(t);return{...e,...r}}),Mc=i=>Array.isArray(i)?i.map(e=>typeof e=="string"?lg(e):e):typeof i=="string"?On(i):[i],go=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,$r=(i=[])=>Array.prototype.map.call(i,go).join(" "),e_=(i,e)=>t=>t[i]===e,dg=i=>{let e=Object.entries(i).map(([t,r])=>e_(t,r));return t=>e.every(r=>r(t))},Ps=(i,e=[],t=[])=>{let r=Mc(t).map(dg),s=n=>r.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=i})},Os=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];let t=typeof e=="function"?e:dg(e);return Array.from(i.textTracks).filter(t)},cg=i=>!!i.getAttribute(A.MEDIA_SUBTITLES_SHOWING);var nt={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};q.fullscreenElement===void 0&&(nt.enter="webkitRequestFullScreen",nt.exit=q.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",nt.rootEvents=["webkitfullscreenchange"],nt.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],nt.element="webkitFullscreenElement",nt.error="webkitfullscreenerror",nt.enabled="webkitFullscreenEnabled");var vo,Pc=()=>{var i,e;return vo||(vo=(e=(i=q)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),vo)},ug=async(i=Pc())=>{if(!i)return!1;let e=i.volume;return i.volume=e/2+.1,await Ja(0),i.volume!==e},t_=/.*Version\/.*Safari\/.*/.test(w.navigator.userAgent),i_=(i=Pc())=>w.matchMedia("(display-mode: standalone)").matches&&t_?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",r_=(i=Pc())=>{let e=q[nt.enabled];return!e&&i&&(e="webkitSupportsFullscreen"in i),e},Oc=r_(),hg=i_(),fg=!!w.WebKitPlaybackTargetAvailabilityEvent,mg=!!w.chrome;var bo,pg=ug().then(i=>(bo=i,bo)),s_=Object.values(ui),Eo=i=>Os(i.media,e=>[xi.SUBTITLES,xi.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),gg=i=>Os(i.media,e=>e.mode===Or.SHOWING&&[xi.SUBTITLES,xi.CAPTIONS].includes(e.kind)),Gt={MEDIA_PAUSED:{get:function(i){let{media:e}=i;return e?e.paused:!0},mediaEvents:["play","playing","pause","emptied"]},MEDIA_HAS_PLAYED:{get:function(i){let{media:e}=i;return e?!e.paused:!1},mediaEvents:["playing","emptied"]},MEDIA_ENDED:{get:function(i){let{media:e}=i;return e?e.ended:!1},mediaEvents:["seeked","ended","emptied"]},MEDIA_PLAYBACK_RATE:{get:function(i){let{media:e}=i;return!e||typeof e.playbackRate=="undefined"?1:e.playbackRate},mediaEvents:["ratechange","loadstart"]},MEDIA_MUTED:{get:function(i){let{media:e}=i;return!e||typeof e.muted=="undefined"?!1:e.muted},mediaEvents:["volumechange"]},MEDIA_VOLUME:{get:function(i){let{media:e}=i;return!e||typeof e.volume=="undefined"?1:Number(e.volume)},mediaEvents:["volumechange"]},MEDIA_VOLUME_LEVEL:{get:function(i){let{media:e}=i,t="high";if(!e||typeof e.volume=="undefined")return t;let{muted:r,volume:s}=e;return s===0||r?t="off":s<.5?t="low":s<.75&&(t="medium"),t},mediaEvents:["volumechange"]},MEDIA_CURRENT_TIME:{get:function(i){let{media:e}=i;return!e||typeof e.currentTime=="undefined"?0:e.currentTime},mediaEvents:["playing","pause","timeupdate","loadedmetadata"]},MEDIA_DURATION:{get:function(i){let{media:e}=i;return i.hasAttribute("defaultduration")&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?+i.getAttribute("defaultduration"):!e||!Number.isFinite(e.duration)?Number.NaN:e.duration},mediaEvents:["durationchange","loadedmetadata","emptied"]},MEDIA_SEEKABLE:{get:function(i){var e;let{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;let r=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!r&&!s))return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress"]},MEDIA_LOADING:{get:function(i){var e;return((e=i.media)==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},MEDIA_BUFFERED:{get:function(i){var e,t,r;let s=(e=i.media)==null?void 0:e.buffered;return Array.from((r=(t=i.media)==null?void 0:t.buffered)!=null?r:[]).map((n,a)=>[Number(s.start(a)).toFixed(3),Number(s.end(a)).toFixed(3)])},mediaEvents:["progress","emptied"]},MEDIA_STREAM_TYPE:{get:function(i){let{media:e}=i;if(!e)return;let{streamType:t}=e;if(s_.includes(t)){if(t===ui.UNKNOWN){let s=i.getAttribute("defaultstreamtype");return[ui.LIVE,ui.ON_DEMAND].includes(s)?s:void 0}return t}let r=e.duration;if(r===1/0)return ui.LIVE;if(Number.isFinite(r))return ui.ON_DEMAND;{let s=i.getAttribute("defaultstreamtype");if([ui.LIVE,ui.ON_DEMAND].includes(s))return s}},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},MEDIA_TARGET_LIVE_WINDOW:{get:function(i){let{media:e}=i;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,r=Gt.MEDIA_STREAM_TYPE.get(i);return(t==null||Number.isNaN(t))&&r===ui.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},MEDIA_TIME_IS_LIVE:{get:function(i){let{media:e}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(Gt.MEDIA_STREAM_TYPE.get(i)==="live"))return!1;let r=e.seekable;if(!r)return!0;if(!r.length)return!1;let s=i.hasAttribute("liveedgeoffset")?Number(i.getAttribute("liveedgeoffset")):10,n=r.end(r.length-1)-s;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},MEDIA_IS_FULLSCREEN:{get:function(i,e){var t,r;let s=i.media;if(s&&q[nt.element]===void 0&&"webkitDisplayingFullscreen"in s)return s.webkitDisplayingFullscreen&&s.webkitPresentationMode==="fullscreen";let n;return e?n=q[nt.element]?e.target:null:n=(r=(t=Hp(i))==null?void 0:t.fullscreenElement)!=null?r:q[nt.element],lr(i.fullscreenElement,n)},rootEvents:nt.rootEvents,mediaEvents:nt.mediaEvents},MEDIA_IS_PIP:{get:function(i,e){var t;let r=i.media;if(!r)return!1;if(e)return e.type=="enterpictureinpicture";{let s=(t=i.getRootNode().pictureInPictureElement)!=null?t:q.pictureInPictureElement;return lr(r,s)}},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},MEDIA_IS_AIRPLAYING:{get:function(i){var e;let{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:t.remote.state},remoteEvents:["playing","connect","connecting","disconnect"]},MEDIA_IS_CASTING:{get:function(i){var e;let{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:t.remote.state},remoteEvents:["connect","connecting","disconnect"]},MEDIA_AIRPLAY_UNAVAILABLE:{get:function(i,{availability:e=!1}={}){if(!fg)return zt.UNSUPPORTED;if(!(e==null||e===!0))return zt.UNAVAILABLE},mediaSetCallback(i,e){var t;i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(t=i.remote)==null||t.watchAvailability(s=>e({availability:s})).catch(s=>{s.name==="NotSupportedError"?e({availability:null}):e({availability:!1})})},mediaUnsetCallback(i){var e;i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(e=i.remote)==null||e.cancelWatchAvailability()}},MEDIA_CAST_UNAVAILABLE:{get:function(i,{availability:e=!1}={}){var t;let{media:r}=i;if(!mg||!((t=r==null?void 0:r.remote)!=null&&t.state))return zt.UNSUPPORTED;if(!(e==null||e===!0))return zt.UNAVAILABLE},mediaSetCallback(i,e){var t;i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(t=i.remote)==null||t.watchAvailability(s=>e({availability:s})).catch(s=>{s.name==="NotSupportedError"?e({availability:null}):e({availability:!1})})},mediaUnsetCallback(i){var e;i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(e=i.remote)==null||e.cancelWatchAvailability()}},MEDIA_FULLSCREEN_UNAVAILABLE:{get:function(){return Oc?void 0:zt.UNAVAILABLE}},MEDIA_PIP_UNAVAILABLE:{get:function(){return hg?void 0:zt.UNSUPPORTED}},MEDIA_RENDITION_UNAVAILABLE:{get:function(i){var e;let{media:t}=i;if(!(t!=null&&t.videoRenditions))return zt.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return zt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_AUDIO_TRACK_UNAVAILABLE:{get:function(i){var e,t;let{media:r}=i;if(!(r!=null&&r.audioTracks))return zt.UNSUPPORTED;if(((t=(e=r.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return zt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},MEDIA_VOLUME_UNAVAILABLE:{get:function(i){if(bo!==void 0&&!bo)return zt.UNSUPPORTED;let{media:e}=i;if(e&&typeof e.volume=="undefined")return zt.UNAVAILABLE},mediaEvents:["loadstart"]},MEDIA_SUBTITLES_LIST:{get:function(i){return Eo(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},MEDIA_SUBTITLES_SHOWING:{get:function(i,e){var t;return i.hasAttribute("defaultsubtitles")&&["addtrack","removetrack"].includes(e==null?void 0:e.type)&&[xi.CAPTIONS,xi.SUBTITLES].includes((t=e==null?void 0:e.track)==null?void 0:t.kind)&&Nn.MEDIA_TOGGLE_SUBTITLES_REQUEST(void 0,{detail:!0},i),gg(i).map(({kind:r,label:s,language:n})=>({kind:r,label:s,language:n}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"]},MEDIA_CHAPTERS_CUES:{get:function(i){var e;let{media:t}=i;if(!t)return[];let[r]=Os(t,{kind:xi.CHAPTERS});return Array.from((e=r==null?void 0:r.cues)!=null?e:[]).map(({text:s,startTime:n,endTime:a})=>({text:s,startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack"]},MEDIA_RENDITION_LIST:{get:function(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]]},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_RENDITION_SELECTED:{get:function(i){var e,t,r;let{media:s}=i;return(r=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:r.id},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},MEDIA_AUDIO_TRACK_LIST:{get:function(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},MEDIA_AUDIO_TRACK_ENABLED:{get:function(i){var e,t;let{media:r}=i;return(t=[...(e=r==null?void 0:r.audioTracks)!=null?e:[]].find(s=>s.enabled))==null?void 0:t.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]}},Nn={MEDIA_PLAY_REQUEST:(i,e,t)=>{var r;let s=Gt.MEDIA_STREAM_TYPE.get(t),n=t.getAttribute("noautoseektolive")===null;s==ui.LIVE&&n&&Nn.MEDIA_SEEK_TO_LIVE_REQUEST(i),(r=i.play())==null||r.catch(()=>{})},MEDIA_PAUSE_REQUEST:i=>i.pause(),MEDIA_MUTE_REQUEST:i=>i.muted=!0,MEDIA_UNMUTE_REQUEST:i=>{i.muted=!1,i.volume===0&&(i.volume=.25)},MEDIA_VOLUME_REQUEST:(i,e,t)=>{let r=e.detail;if(i.volume=r,r>0&&i.muted&&(i.muted=!1),!t.hasAttribute("novolumepref"))try{w.localStorage.setItem("media-chrome-pref-volume",r.toString())}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:(i,e,t)=>{if(!Oc){console.warn("MediaChrome: Fullscreen support is unavailable; not entering fullscreen");return}q.pictureInPictureElement&&q.exitPictureInPicture(),t[nt.enter]?t.fullscreenElement[nt.enter]():i.webkitEnterFullscreen?i.webkitEnterFullscreen():i.requestFullscreen?i.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported")},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{q[nt.exit]()},MEDIA_ENTER_PIP_REQUEST:i=>{if(!q.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!i.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}q[nt.element]&&q[nt.exit]();let e=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};i.requestPictureInPicture().catch(t=>{if(t.code===11)if(i.readyState===0&&i.preload==="none"){let r=()=>{i.removeEventListener("loadedmetadata",s),i.preload="none"},s=()=>{i.requestPictureInPicture().catch(e),r()};i.addEventListener("loadedmetadata",s),i.preload="metadata",setTimeout(()=>{i.readyState===0&&e(),r()},1e3)}else throw t;else throw t})},MEDIA_EXIT_PIP_REQUEST:()=>{q.pictureInPictureElement&&q.exitPictureInPicture()},MEDIA_ENTER_CAST_REQUEST:async i=>{var e;if(((e=i.remote)==null?void 0:e.state)==="disconnected"){if(q[nt.element]&&q[nt.exit](),!i.remote.prompt){console.warn("MediaChrome: Casting is not supported in this environment");return}try{await i.remote.prompt()}catch{}}},MEDIA_EXIT_CAST_REQUEST:i=>{var e;((e=i.remote)==null?void 0:e.state)==="connected"&&i.remote.prompt()},MEDIA_SEEK_REQUEST:(i,e)=>{let t=e.detail;(i.readyState>0||i.readyState===void 0)&&(i.currentTime=t)},MEDIA_PLAYBACK_RATE_REQUEST:(i,e)=>{i.playbackRate=e.detail},MEDIA_PREVIEW_REQUEST:(i,e,t)=>{var r,s,n,a,o,l;if(!i)return;let d=e.detail;if(d===null){t.propagateMediaState(A.MEDIA_PREVIEW_TIME,void 0),t.propagateMediaState(A.MEDIA_PREVIEW_IMAGE,void 0),t.propagateMediaState(A.MEDIA_PREVIEW_COORDS,void 0);return}t.propagateMediaState(A.MEDIA_PREVIEW_TIME,d);let[c]=Os(i,{kind:xi.CHAPTERS}),u=Array.from((r=c==null?void 0:c.cues)!=null?r:[]).find(S=>S.startTime<=d&&S.endTime>d);t.propagateMediaState(A.MEDIA_PREVIEW_CHAPTER,u==null?void 0:u.text);let[h]=Os(i,{kind:xi.METADATA,label:"thumbnails"}),f=Array.from((s=h==null?void 0:h.cues)!=null?s:[]).find(S=>S.startTime>=d);if(!f)return;let g=/'^(?:[a-z]+:)?\/\//i.test((n=f==null?void 0:f.text)!=null?n:"")||(a=i.querySelector('track[label="thumbnails"]'))==null?void 0:a.src,E=new URL((o=f==null?void 0:f.text)!=null?o:"./",g),T=(l=new URLSearchParams(E.hash).get("#xywh"))!=null?l:"";t.propagateMediaState(A.MEDIA_PREVIEW_IMAGE,E.href),t.propagateMediaState(A.MEDIA_PREVIEW_COORDS,T.split(","))},MEDIA_SHOW_SUBTITLES_REQUEST:(i,e,t)=>{var r;let s=Eo(t),{detail:n=[]}=e,a=Mc(n),o=(r=a[0])==null?void 0:r.language;o&&!(t!=null&&t.hasAttribute("nosubtitleslangpref"))&&w.localStorage.setItem("media-chrome-pref-subtitles-lang",o),Ps(Or.SHOWING,s,a)},MEDIA_DISABLE_SUBTITLES_REQUEST:(i,e,t)=>{let r=Eo(t),{detail:s=[]}=e;Ps(Or.DISABLED,r,s)},MEDIA_TOGGLE_SUBTITLES_REQUEST:(i,e,t)=>{let{detail:r}=e!=null?e:{},s=Eo(t),n=gg(t),a=!!n.length;if(s.length){if(r===!1||a&&r!==!0)Ps(Or.DISABLED,s,n);else if(r===!0||!a&&r!==!1){let o=s[0];if(!(t!=null&&t.hasAttribute("nosubtitleslangpref"))){let u=w.localStorage.getItem("media-chrome-pref-subtitles-lang"),h=u?[u,...w.navigator.languages]:w.navigator.languages,f=s.filter(g=>h.some(E=>g.language.toLowerCase().startsWith(E.split("-")[0]))).sort((g,E)=>{let T=h.findIndex(k=>g.language.toLowerCase().startsWith(k.split("-")[0])),S=h.findIndex(k=>E.language.toLowerCase().startsWith(k.split("-")[0]));return T-S});f[0]&&(o=f[0])}let{language:l,label:d,kind:c}=o;Ps(Or.DISABLED,s,n),Ps(Or.SHOWING,s,[{language:l,label:d,kind:c}])}}},MEDIA_AIRPLAY_REQUEST:async i=>{if(i!=null&&i.remote){if(!i.remote.prompt){console.warn("MediaChrome: AirPlay is not supported in this environment");return}try{await i.remote.prompt()}catch{}}},MEDIA_SEEK_TO_LIVE_REQUEST:i=>{let e=i.seekable;if(!e){console.warn("MediaChrome: Media element does not support seeking to live.");return}if(!e.length){console.warn("MediaChrome: Media is unable to seek to live.");return}i.currentTime=e.end(e.length-1)},MEDIA_RENDITION_REQUEST:(i,e)=>{if(!(i!=null&&i.videoRenditions)){console.warn("MediaChrome: Rendition selection not supported by this media.");return}let t=e.detail,r=[...i.videoRenditions].findIndex(s=>s.id==t);i.videoRenditions.selectedIndex!=r&&(i.videoRenditions.selectedIndex=r)},MEDIA_AUDIO_TRACK_REQUEST:(i,e)=>{if(!(i!=null&&i.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let t=e.detail;for(let r of i.audioTracks)r.enabled=t==r.id}};var Bc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ri=(i,e,t)=>(Bc(i,e,"read from private field"),t?t.call(i):e.get(i)),Un=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Nc=(i,e,t,r)=>(Bc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Us=(i,e,t)=>(Bc(i,e,"access private method"),t),fr,Fn,Ns,Fs,Bn,yo,Uc,_g=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],n_=10,vg=0,Ot={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys"},To=class extends uo{constructor(){super(),Un(this,Fs),Un(this,yo),Un(this,fr,new hr(this,Ot.HOTKEYS)),Un(this,Fn,void 0),Un(this,Ns,void 0),Gt.MEDIA_VOLUME_UNAVAILABLE.get(this)===void 0&&pg.then(()=>{this.propagateMediaState(A.MEDIA_VOLUME_UNAVAILABLE,Gt.MEDIA_VOLUME_UNAVAILABLE.get(this))}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this),Object.keys(Nn).forEach(e=>{let t=`_handle${Qa(e,!0)}`;this[t]=r=>{if(r.stopPropagation(),!this.media){console.warn("Media Chrome: No media available.");return}Nn[e](this.media,r,this)},this.addEventListener(ee[e],this[t])}),this._mediaStatePropagators={},Object.keys(Gt).forEach(e=>{this._mediaStatePropagators[e]=t=>{this.propagateMediaState(Pr[e],Gt[e].get(this,t))}})}static get observedAttributes(){return super.observedAttributes.concat(Ot.NO_HOTKEYS,Ot.HOTKEYS,Ot.DEFAULT_STREAM_TYPE,Ot.DEFAULT_SUBTITLES,Ot.DEFAULT_DURATION)}get fullscreenElement(){var e;return(e=Ri(this,Fn))!=null?e:this}set fullscreenElement(e){this.hasAttribute(Ot.FULLSCREEN_ELEMENT)&&this.removeAttribute(Ot.FULLSCREEN_ELEMENT),Nc(this,Fn,e)}attributeChangedCallback(e,t,r){var s;if(super.attributeChangedCallback(e,t,r),e===Ot.NO_HOTKEYS)r!==t&&r===""?(this.hasAttribute(Ot.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):r!==t&&r===null&&this.enableHotkeys();else if(e===Ot.HOTKEYS)Ri(this,fr).value=r;else if(e===Ot.DEFAULT_SUBTITLES&&r!==t&&r==="")this.dispatchEvent(new w.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:!0}));else if(e===Ot.DEFAULT_STREAM_TYPE)this.propagateMediaState(Pr.MEDIA_STREAM_TYPE);else if(e===Ot.FULLSCREEN_ELEMENT){let n=r?(s=Ri(this,Ns))==null?void 0:s.getElementById(r):void 0;Nc(this,Fn,n)}}connectedCallback(){Nc(this,Ns,this.getRootNode()),super.connectedCallback(),this.enableHotkeys()}disconnectedCallback(){super.disconnectedCallback(),this.disableHotkeys(),this.dispatchEvent(new w.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:!1}))}mediaSetCallback(e){if(super.mediaSetCallback(e),e.hasAttribute("tabindex")||(e.tabIndex=-1),Object.keys(Gt).forEach(t=>{let{mediaSetCallback:r,mediaEvents:s,rootEvents:n,textTracksEvents:a,videoRenditionsEvents:o,audioTracksEvents:l,remoteEvents:d}=Gt[t],c=this._mediaStatePropagators[t];r&&(r(e,c),c()),s==null||s.forEach(u=>{e.addEventListener(u,c),c()}),n==null||n.forEach(u=>{var h;(h=Ri(this,Ns))==null||h.addEventListener(u,c),c()}),a==null||a.forEach(u=>{var h;(h=e.textTracks)==null||h.addEventListener(u,c),c()}),o==null||o.forEach(u=>{var h;(h=e.videoRenditions)==null||h.addEventListener(u,c),c()}),l==null||l.forEach(u=>{var h;(h=e.audioTracks)==null||h.addEventListener(u,c),c()}),d==null||d.forEach(u=>{var h;(h=e.remote)==null||h.addEventListener(u,c),c()})}),!this.hasAttribute("novolumepref"))try{let t=w.localStorage.getItem("media-chrome-pref-volume");t!==null&&(e.volume=t)}catch(t){console.debug("Media Chrome: Error getting volume pref",t)}}mediaUnsetCallback(e){super.mediaUnsetCallback(e),Object.keys(Gt).forEach(t=>{let{mediaUnsetCallback:r,mediaEvents:s,rootEvents:n,textTracksEvents:a,videoRenditionsEvents:o,audioTracksEvents:l,remoteEvents:d}=Gt[t],c=this._mediaStatePropagators[t];s==null||s.forEach(u=>{e.removeEventListener(u,c)}),n==null||n.forEach(u=>{var h;(h=Ri(this,Ns))==null||h.removeEventListener(u,c)}),a==null||a.forEach(u=>{var h;(h=e.textTracks)==null||h.removeEventListener(u,c)}),o==null||o.forEach(u=>{var h;(h=e.videoRenditions)==null||h.removeEventListener(u,c),c()}),l==null||l.forEach(u=>{var h;(h=e.audioTracks)==null||h.removeEventListener(u,c),c()}),d==null||d.forEach(u=>{var h;(h=e.remote)==null||h.removeEventListener(u,c),c()}),r&&(r(e,c),c())}),this.propagateMediaState(Pr.MEDIA_PAUSED,!0)}propagateMediaState(e,t){let r=Tg(this.mediaStateReceivers,e);if(yg(this.mediaStateReceivers,e,t),r===Tg(this.mediaStateReceivers,e))return;let s=e.toLowerCase(),n=new w.CustomEvent(Mp[s],{composed:!0,bubbles:!0,detail:t});this.dispatchEvent(n)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let r=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=u_(e,r,s);Object.keys(ee).forEach(a=>{e.addEventListener(ee[a],this[`_handle${Qa(a,!0)}`])}),t.set(e,n)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.keys(ee).forEach(s=>{e.removeEventListener(ee[s],this[`_handle${Qa(s,!0)}`])})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),Object.keys(Gt).forEach(s=>{let n=Gt[s];yg([e],Pr[s],n.get(this))}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,r=t.indexOf(e);r<0||t.splice(r,1)}enableHotkeys(){this.addEventListener("keydown",Us(this,yo,Uc))}disableHotkeys(){this.removeEventListener("keydown",Us(this,yo,Uc)),this.removeEventListener("keyup",Us(this,Fs,Bn))}get hotkeys(){return Ri(this,fr)}keyboardShortcutHandler(e){var t,r,s,n;if(((n=(s=(t=e.target.getAttribute(Ot.KEYS_USED))==null?void 0:t.split(" "))!=null?s:(r=e.target)==null?void 0:r.keysUsed)!=null?n:[]).map(f=>f==="Space"?" ":f).filter(Boolean).includes(e.key))return;let o,l,d,c,u,h=n_;if(!Ri(this,fr).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&Ri(this,fr).contains("nospace")))switch(e.key){case" ":case"k":o=this.getAttribute(A.MEDIA_PAUSED)!=null?ee.MEDIA_PLAY_REQUEST:ee.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new w.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"m":o=this.getAttribute(A.MEDIA_VOLUME_LEVEL)==="off"?ee.MEDIA_UNMUTE_REQUEST:ee.MEDIA_MUTE_REQUEST,this.dispatchEvent(new w.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"f":o=this.getAttribute(A.MEDIA_IS_FULLSCREEN)!=null?ee.MEDIA_EXIT_FULLSCREEN_REQUEST:ee.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new w.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new w.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":l=this.getAttribute(A.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:vg,c=Math.max(d-h,0),u=new w.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break;case"ArrowRight":l=this.getAttribute(A.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:vg,c=Math.max(d+h,0),u=new w.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break;default:break}}};fr=new WeakMap;Fn=new WeakMap;Ns=new WeakMap;Fs=new WeakSet;Bn=function(i){let{key:e}=i;if(!_g.includes(e)){this.removeEventListener("keyup",Us(this,Fs,Bn));return}this.keyboardShortcutHandler(i)};yo=new WeakSet;Uc=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!_g.includes(r)){this.removeEventListener("keyup",Us(this,Fs,Bn));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(Ri(this,fr).contains(`no${r.toLowerCase()}`)||r===" "&&Ri(this,fr).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",Us(this,Fs,Bn),{once:!0})};var a_=Object.values(A),o_=Object.values(Pr),$c=i=>{var e,t,r,s;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(w.customElements.upgrade(i),{observedAttributes:n}=i.constructor);let a=(s=(r=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,me.MEDIA_CHROME_ATTRIBUTES))==null?void 0:r.split)==null?void 0:s.call(r,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>a_.includes(o)):[]},l_=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&w.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof w.customElements.get(i.nodeName.toLowerCase()))&&w.customElements.upgrade(i),o_.some(r=>r in i)},Fc=i=>l_(i)||!!$c(i).length,Eg=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},bg={[A.MEDIA_SUBTITLES_LIST]:$r,[A.MEDIA_SUBTITLES_SHOWING]:$r,[A.MEDIA_SEEKABLE]:Eg,[A.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(Eg).join(" "),[A.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[A.MEDIA_RENDITION_LIST]:Pp,[A.MEDIA_AUDIO_TRACK_LIST]:Np},d_=async(i,e,t)=>{var r,s;if(i.isConnected||await Ja(0),typeof t=="boolean"||t==null)return Ue(i,e,t);if(typeof t=="number")return Ke(i,e,t);if(typeof t=="string")return Oe(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);let n=(s=(r=bg[e])==null?void 0:r.call(bg,t))!=null?s:t;return i.setAttribute(e,n)},c_=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Hr=(i,e)=>{if(c_(i))return;let t=(s,n)=>{var a,o;Fc(s)&&n(s);let{children:l=[]}=s!=null?s:{},d=(o=(a=s==null?void 0:s.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(u=>Hr(u,n))},r=i==null?void 0:i.nodeName.toLowerCase();if(r.includes("-")&&!Fc(i)){w.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},yg=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}let s=$c(r),n=e.toLowerCase();s.includes(n)&&d_(r,n,t)})},Tg=(i,e)=>{for(let t of i){if(e in t)return t[e];let r=$c(t),s=e.toLowerCase();if(r.includes(s))return t.getAttribute(s)}},u_=(i,e,t)=>{Hr(i,e);let r=c=>{var u;let h=(u=c==null?void 0:c.composedPath()[0])!=null?u:c.target;e(h)},s=c=>{var u;let h=(u=c==null?void 0:c.composedPath()[0])!=null?u:c.target;t(h)};i.addEventListener(ee.REGISTER_MEDIA_STATE_RECEIVER,r),i.addEventListener(ee.UNREGISTER_MEDIA_STATE_RECEIVER,s);let n=c=>{c.forEach(u=>{let{addedNodes:h=[],removedNodes:f=[],type:g,target:E,attributeName:T}=u;g==="childList"?(Array.prototype.forEach.call(h,S=>Hr(S,e)),Array.prototype.forEach.call(f,S=>Hr(S,t))):g==="attributes"&&T===me.MEDIA_CHROME_ATTRIBUTES&&(Fc(E)?e(E):t(E))})},a=[],o=c=>{let u=c.target;u.name!=="media"&&(a.forEach(h=>Hr(h,t)),a=[...u.assignedElements({flatten:!0})],a.forEach(h=>Hr(h,e)))};i.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{Hr(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener(ee.REGISTER_MEDIA_STATE_RECEIVER,r),i.removeEventListener(ee.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};w.customElements.get("media-controller")||w.customElements.define("media-controller",To);var Hc=To;var jc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},et=(i,e,t)=>(jc(i,e,"read from private field"),t?t.call(i):e.get(i)),Tt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},mr=(i,e,t,r)=>(jc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),fi=(i,e,t)=>(jc(i,e,"access private method"),t),ki,Do,_o,Ao,mi,ko,So,xo,Io,zc,Ag,Lo,Gc,Ro,Vc,wo,Xc,Wc,Sg,Kc,xg,qc,Ig,Yc,Lg,Rg=q.createElement("template");Rg.innerHTML=`
244
248
  <style>
245
249
  :host {
246
250
  --_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
@@ -350,6 +354,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
350
354
  justify-content: center;
351
355
  width: 100%;
352
356
  position: absolute;
357
+
358
+ will-change: transform;
353
359
  }
354
360
 
355
361
  #background,
@@ -376,35 +382,33 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
376
382
  overflow: hidden;
377
383
  }
378
384
 
379
- #progress {
380
- background: var(--media-range-bar-color, var(--media-primary-color, rgb(238 238 238)));
381
- border-radius: var(--media-range-track-border-radius, 1px);
382
- transition: var(--media-range-track-transition);
385
+ #progress,
386
+ #highlight,
387
+ #pointer {
383
388
  position: absolute;
384
389
  height: 100%;
390
+ will-change: width;
385
391
  }
386
392
 
387
- #highlight {
388
- border-radius: var(--media-range-track-border-radius, 1px);
389
- position: absolute;
390
- height: 100%;
393
+ #progress {
394
+ background: var(--media-range-bar-color, var(--media-primary-color, rgb(238 238 238)));
395
+ transition: var(--media-range-track-transition);
391
396
  }
392
397
 
393
398
  #pointer {
394
399
  background: var(--media-range-track-pointer-background);
395
400
  border-right: var(--media-range-track-pointer-border-right);
396
- border-radius: var(--media-range-track-border-radius, 1px);
397
401
  transition: visibility .25s, opacity .25s;
398
402
  visibility: hidden;
399
403
  opacity: 0;
400
- position: absolute;
401
- height: 100%;
402
404
  }
403
405
 
404
- :host(:hover) #pointer {
405
- transition: visibility .5s, opacity .5s;
406
- visibility: visible;
407
- opacity: 1;
406
+ @media (hover: hover) {
407
+ :host(:hover) #pointer {
408
+ transition: visibility .5s, opacity .5s;
409
+ visibility: visible;
410
+ opacity: 1;
411
+ }
408
412
  }
409
413
 
410
414
  #thumb {
@@ -426,12 +430,44 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
426
430
  :host([disabled]) #thumb {
427
431
  background-color: #777;
428
432
  }
433
+
434
+ .segments #appearance {
435
+ height: var(--media-range-segment-hover-height, 7px);
436
+ }
437
+
438
+ #background,
439
+ #track {
440
+ clip-path: url(#segments-clipping);
441
+ }
442
+
443
+ #segments {
444
+ --segments-gap: var(--media-range-segments-gap, 2px);
445
+ position: absolute;
446
+ width: 100%;
447
+ height: 100%;
448
+ }
449
+
450
+ #segments-clipping {
451
+ transform: translateX(calc(var(--segments-gap) / 2));
452
+ }
453
+
454
+ #segments-clipping:empty {
455
+ display: none;
456
+ }
457
+
458
+ #segments-clipping rect {
459
+ height: var(--media-range-track-height, 4px);
460
+ y: calc((var(--media-range-segment-hover-height, 7px) - var(--media-range-track-height, 4px)) / 2);
461
+ transition: var(--media-range-segment-transition, transform .1s ease-in-out);
462
+ transform: var(--media-range-segment-transform, scaleY(1));
463
+ transform-origin: center;
464
+ }
429
465
  </style>
430
466
  <div id="leftgap"></div>
431
467
  <div id="container">
432
468
  <div id="startpoint"></div>
433
469
  <div id="endpoint"></div>
434
- <div id="appearance">
470
+ <div id="appearance" part="appearance">
435
471
  <div id="background"></div>
436
472
  <div id="track">
437
473
  <div id="highlight"></div>
@@ -439,11 +475,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
439
475
  <div id="progress"></div>
440
476
  </div>
441
477
  <div id="thumb"></div>
478
+ <svg id="segments"><clipPath id="segments-clipping"></clipPath></svg>
442
479
  </div>
443
480
  <input id="range" type="range" min="0" max="1" step="any" value="0">
444
481
  </div>
445
482
  <div id="rightgap"></div>
446
- `;var Gr=class extends D.HTMLElement{constructor(){super(),Yt(this,bo),Yt(this,yo),Yt(this,Ao),Yt(this,Uc),Yt(this,Fc),Yt(this,Bc),Yt(this,$c),Yt(this,Li,void 0),Yt(this,So,void 0),Yt(this,To,void 0),Yt(this,_o,void 0),Yt(this,vo,()=>{if(this.range.matches(":focus-visible")){let{style:t}=ze(this.shadowRoot,":host");t.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),Yt(this,Eo,()=>{let{style:t}=ze(this.shadowRoot,":host");t.removeProperty("--_focus-visible-box-shadow")}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Eg.content.cloneNode(!0)));let{style:e}=ze(this.shadowRoot,":host");e.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.container=this.shadowRoot.querySelector("#container"),$r(this,To,this.shadowRoot.querySelector("#startpoint")),$r(this,_o,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range")}static get observedAttributes(){return["disabled","aria-disabled",me.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER?(t&&((n=(s=ui(this,Li))==null?void 0:s.unassociateElement)==null||n.call(s,this),$r(this,Li,null)),r&&this.isConnected&&($r(this,Li,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ui(this,Li))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==r)&&(r==null?(this.range.removeAttribute(e),Ii(this,bo,Oc).call(this)):(this.range.setAttribute(e,r),Ii(this,yo,Nc).call(this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&($r(this,Li,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ui(this,Li))==null?void 0:t.associateElement)==null||r.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",ui(this,vo)),this.shadowRoot.addEventListener("focusout",ui(this,Eo)),Ii(this,bo,Oc).call(this)}disconnectedCallback(){var e,t;Ii(this,yo,Nc).call(this),(t=(e=ui(this,Li))==null?void 0:e.unassociateElement)==null||t.call(e,this),$r(this,Li,null),this.shadowRoot.removeEventListener("focusin",ui(this,vo)),this.shadowRoot.removeEventListener("focusout",ui(this,Eo))}updatePointerBar(e){let t=this.range.getBoundingClientRect(),r=(e.clientX-t.left)/t.width;r=Math.max(0,Math.min(1,r))*100;let{style:s}=ze(this.shadowRoot,"#pointer");s.setProperty("width",`${r}%`)}updateBar(){let e=this.range.valueAsNumber*100,t=ze(this.shadowRoot,"#progress"),r=ze(this.shadowRoot,"#thumb");t.style.setProperty("width",`${e}%`),r.style.setProperty("left",`${e}%`)}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"input":this.updateBar();break;case"pointerenter":Ii(this,Uc,mg).call(this,e);break;case"pointerdown":Ii(this,Ao,Hc).call(this,e);break;case"pointermove":Ii(this,$c,vg).call(this,e);break;case"pointerup":Ii(this,Fc,pg).call(this);break;case"pointerleave":Ii(this,Bc,gg).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};Li=new WeakMap;So=new WeakMap;To=new WeakMap;_o=new WeakMap;vo=new WeakMap;Eo=new WeakMap;bo=new WeakSet;Oc=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};yo=new WeakSet;Nc=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=D.window)==null||i.removeEventListener("pointerup",this),(e=D.window)==null||e.removeEventListener("pointermove",this)};Ao=new WeakSet;Hc=function(i){var e;$r(this,So,i.composedPath().includes(this.range)),(e=D.window)==null||e.addEventListener("pointerup",this)};Uc=new WeakSet;mg=function(i){var e;i.pointerType!=="mouse"&&Ii(this,Ao,Hc).call(this,i),this.addEventListener("pointerleave",this),(e=D.window)==null||e.addEventListener("pointermove",this)};Fc=new WeakSet;pg=function(){var i;(i=D.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};Bc=new WeakSet;gg=function(){var i;this.removeEventListener("pointerleave",this),(i=D.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};$c=new WeakSet;vg=function(i){if(this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),this.dragging&&(i.pointerType!=="mouse"||!ui(this,So))){this.range.disabled=!0;let e=Pp(i.clientX,i.clientY,ui(this,To).getBoundingClientRect(),ui(this,_o).getBoundingClientRect());e=Math.max(0,Math.min(1,e)),this.range.valueAsNumber=e,this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}};D.customElements.get("media-chrome-range")||D.customElements.define("media-chrome-range",Gr);var bg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},xo=(i,e,t)=>(bg(i,e,"read from private field"),t?t.call(i):e.get(i)),XT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Io=(i,e,t,r)=>(bg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ri,yg=q.createElement("template");yg.innerHTML=`
483
+ `;var Gr=class extends w.HTMLElement{constructor(){super(),Tt(this,zc),Tt(this,Lo),Tt(this,Ro),Tt(this,wo),Tt(this,Wc),Tt(this,Kc),Tt(this,qc),Tt(this,Yc),Tt(this,ki,void 0),Tt(this,Do,void 0),Tt(this,_o,void 0),Tt(this,Ao,void 0),Tt(this,mi,{}),Tt(this,ko,[]),Tt(this,So,()=>{if(this.range.matches(":focus-visible")){let{style:e}=Ye(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),Tt(this,xo,()=>{let{style:e}=Ye(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),Tt(this,Io,()=>{let e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Rg.content.cloneNode(!0))),this.container=this.shadowRoot.querySelector("#container"),mr(this,_o,this.shadowRoot.querySelector("#startpoint")),mr(this,Ao,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",me.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER?(t&&((n=(s=et(this,ki))==null?void 0:s.unassociateElement)==null||n.call(s,this),mr(this,ki,null)),r&&this.isConnected&&(mr(this,ki,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=et(this,ki))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==r)&&(r==null?(this.range.removeAttribute(e),fi(this,Lo,Gc).call(this)):(this.range.setAttribute(e,r),fi(this,Ro,Vc).call(this)))}connectedCallback(){var e,t,r;let{style:s}=Ye(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),et(this,mi).pointer=Ye(this.shadowRoot,"#pointer"),et(this,mi).progress=Ye(this.shadowRoot,"#progress"),et(this,mi).thumb=Ye(this.shadowRoot,"#thumb");let n=this.getAttribute(me.MEDIA_CONTROLLER);n&&(mr(this,ki,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=et(this,ki))==null?void 0:t.associateElement)==null||r.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",et(this,So)),this.shadowRoot.addEventListener("focusout",et(this,xo)),fi(this,Lo,Gc).call(this),Ur(this.container,et(this,Io))}disconnectedCallback(){var e,t;fi(this,Ro,Vc).call(this),(t=(e=et(this,ki))==null?void 0:e.unassociateElement)==null||t.call(e,this),mr(this,ki,null),this.shadowRoot.removeEventListener("focusin",et(this,So)),this.shadowRoot.removeEventListener("focusout",et(this,xo)),Dn(this.container,et(this,Io))}updatePointerBar(e){var t;(t=et(this,mi).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`)}updateBar(){var e,t;let r=this.range.valueAsNumber*100;(e=et(this,mi).progress)==null||e.style.setProperty("width",`${r}%`),(t=et(this,mi).thumb)==null||t.style.setProperty("left",`${r}%`)}updateSegments(e){let t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",!(e!=null&&e.length))return;et(this,mi).activeSegment=Tc(this.shadowRoot,"#segments-clipping rect:nth-child(0)"),this.container.classList.toggle("segments",!!e.length);let r=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];mr(this,ko,[...r]);let s=r.pop();for(let[n,a]of r.entries()){let[o,l]=[n===0,n===r.length-1],d=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,u=`calc(${((l?s:r[n+1])-a)*100}%${o||l?"":" - var(--segments-gap)"})`,h=q.createElementNS("http://www.w3.org/2000/svg","rect"),f=Ye(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",d),f.style.setProperty("width",u),t.append(h)}}getPointerRatio(e){let t=Vp(e.clientX,e.clientY,et(this,_o).getBoundingClientRect(),et(this,Ao).getBoundingClientRect());return Math.max(0,Math.min(1,t))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":fi(this,Yc,Lg).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":fi(this,Wc,Sg).call(this,e);break;case"pointerdown":fi(this,wo,Xc).call(this,e);break;case"pointerup":fi(this,Kc,xg).call(this);break;case"pointerleave":fi(this,qc,Ig).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};ki=new WeakMap;Do=new WeakMap;_o=new WeakMap;Ao=new WeakMap;mi=new WeakMap;ko=new WeakMap;So=new WeakMap;xo=new WeakMap;Io=new WeakMap;zc=new WeakSet;Ag=function(i){let e=et(this,mi).activeSegment;if(!e)return;let t=this.getPointerRatio(i),s=`#segments-clipping rect:nth-child(${et(this,ko).findIndex((n,a,o)=>{let l=o[a+1];return l!=null&&t>=n&&t<=l})+1})`;(e.selectorText!=s||!e.style.transform)&&(e.selectorText=s,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))};Lo=new WeakSet;Gc=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};Ro=new WeakSet;Vc=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=w.window)==null||i.removeEventListener("pointerup",this),(e=w.window)==null||e.removeEventListener("pointermove",this)};wo=new WeakSet;Xc=function(i){var e;mr(this,Do,i.composedPath().includes(this.range)),(e=w.window)==null||e.addEventListener("pointerup",this)};Wc=new WeakSet;Sg=function(i){var e;i.pointerType!=="mouse"&&fi(this,wo,Xc).call(this,i),this.addEventListener("pointerleave",this),(e=w.window)==null||e.addEventListener("pointermove",this)};Kc=new WeakSet;xg=function(){var i;(i=w.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};qc=new WeakSet;Ig=function(){var i,e;this.removeEventListener("pointerleave",this),(i=w.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),(e=et(this,mi).activeSegment)==null||e.style.removeProperty("transform")};Yc=new WeakSet;Lg=function(i){this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),fi(this,zc,Ag).call(this,i),this.dragging&&(i.pointerType!=="mouse"||!et(this,Do))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(i),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))};w.customElements.get("media-chrome-range")||w.customElements.define("media-chrome-range",Gr);var kg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Co=(i,e,t)=>(kg(i,e,"read from private field"),t?t.call(i):e.get(i)),h_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Mo=(i,e,t,r)=>(kg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),wi,wg=q.createElement("template");wg.innerHTML=`
447
484
  <style>
448
485
  :host {
449
486
 
@@ -465,7 +502,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
465
502
  </style>
466
503
 
467
504
  <slot></slot>
468
- `;var Vc=class extends D.HTMLElement{constructor(){super(),XT(this,Ri,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(yg.content.cloneNode(!0)))}static get observedAttributes(){return[me.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER&&(t&&((n=(s=xo(this,Ri))==null?void 0:s.unassociateElement)==null||n.call(s,this),Io(this,Ri,null)),r&&this.isConnected&&(Io(this,Ri,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=xo(this,Ri))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(Io(this,Ri,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=xo(this,Ri))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=xo(this,Ri))==null?void 0:e.unassociateElement)==null||t.call(e,this),Io(this,Ri,null)}};Ri=new WeakMap;D.customElements.get("media-control-bar")||D.customElements.define("media-control-bar",Vc);var Tg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Lo=(i,e,t)=>(Tg(i,e,"read from private field"),t?t.call(i):e.get(i)),QT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ro=(i,e,t,r)=>(Tg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ki,_g=q.createElement("template");_g.innerHTML=`
505
+ `;var Qc=class extends w.HTMLElement{constructor(){super(),h_(this,wi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(wg.content.cloneNode(!0)))}static get observedAttributes(){return[me.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER&&(t&&((n=(s=Co(this,wi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Mo(this,wi,null)),r&&this.isConnected&&(Mo(this,wi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Co(this,wi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(Mo(this,wi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Co(this,wi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Co(this,wi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Mo(this,wi,null)}};wi=new WeakMap;w.customElements.get("media-control-bar")||w.customElements.define("media-control-bar",Qc);var Dg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Po=(i,e,t)=>(Dg(i,e,"read from private field"),t?t.call(i):e.get(i)),f_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Oo=(i,e,t,r)=>(Dg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Di,Cg=q.createElement("template");Cg.innerHTML=`
469
506
  <style>
470
507
  :host {
471
508
  font: var(--media-font,
@@ -498,11 +535,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
498
535
  }
499
536
  </style>
500
537
  <slot></slot>
501
- `;var zi=class extends D.HTMLElement{constructor(){super(),QT(this,ki,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(_g.content.cloneNode(!0)));let{style:e}=ze(this.shadowRoot,":host");e.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`)}static get observedAttributes(){return[me.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER&&(t&&((n=(s=Lo(this,ki))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ro(this,ki,null)),r&&this.isConnected&&(Ro(this,ki,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Lo(this,ki))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(Ro(this,ki,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Lo(this,ki))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Lo(this,ki))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ro(this,ki,null)}};ki=new WeakMap;D.customElements.get("media-text-display")||D.customElements.define("media-text-display",zi);var Sg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ag=(i,e,t)=>(Sg(i,e,"read from private field"),t?t.call(i):e.get(i)),ZT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},JT=(i,e,t,r)=>(Sg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Bn,Wc=class extends zi{constructor(){super(),ZT(this,Bn,void 0),JT(this,Bn,this.shadowRoot.querySelector("slot")),Ag(this,Bn).textContent=Ai(0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_DURATION]}attributeChangedCallback(e,t,r){e===S.MEDIA_DURATION&&(Ag(this,Bn).textContent=Ai(r)),super.attributeChangedCallback(e,t,r)}get mediaDuration(){return Fe(this,S.MEDIA_DURATION)}set mediaDuration(e){Ke(this,S.MEDIA_DURATION,e)}};Bn=new WeakMap;D.customElements.get("media-duration-display")||D.customElements.define("media-duration-display",Wc);var Rg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Kc=(i,e,t)=>(Rg(i,e,"read from private field"),t?t.call(i):e.get(i)),e_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},t_=(i,e,t,r)=>(Rg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Us,hi={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},xg=[...Object.values(hi),S.MEDIA_CURRENT_TIME,S.MEDIA_DURATION,S.MEDIA_SEEKABLE],Ig=["Enter"," "],i_="&nbsp;/&nbsp;",Lg=(i,{timesSep:e=i_}={})=>{var t,r,s,n;let a=i.hasAttribute(hi.REMAINING),o=i.hasAttribute(hi.SHOW_DURATION),l=(t=i.mediaCurrentTime)!=null?t:0,[,d]=(r=i.mediaSeekable)!=null?r:[],c=(n=(s=i.mediaDuration)!=null?s:d)!=null?n:0,u=a?Ai(0-(c-l)):Ai(l);return o?`${u}${e}${Ai(c)}`:u},r_="video not loaded, unknown time.",s_=i=>{var e;let t=i.mediaCurrentTime,[,r]=(e=i.mediaSeekable)!=null?e:[],s=i.mediaDuration||r;if(t==null||s==null){i.setAttribute("aria-valuetext",r_);return}let n=i.hasAttribute(hi.REMAINING),a=i.hasAttribute(hi.SHOW_DURATION),o=n?Or(0-(s-t)):Or(t);if(!a){i.setAttribute("aria-valuetext",o);return}let l=Or(s),d=`${o} of ${l}`;i.setAttribute("aria-valuetext",d)},qc=class extends zi{constructor(){super(),e_(this,Us,void 0),t_(this,Us,this.shadowRoot.querySelector("slot")),Kc(this,Us).innerHTML=`${Lg(this)}`;let{style:e}=ze(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))")}static get observedAttributes(){return[...super.observedAttributes,...xg,"disabled"]}connectedCallback(){this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",St.PLAYBACK_TIME());let e=t=>{let{key:r}=t;if(!Ig.includes(r)){this.removeEventListener("keyup",e);return}this.toggleTimeDisplay()};this.addEventListener("keydown",t=>{let{metaKey:r,altKey:s,key:n}=t;if(r||s||!Ig.includes(n)){this.removeEventListener("keyup",e);return}this.addEventListener("keyup",e)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){xg.includes(e)?this.update():e==="disabled"&&r!==t&&(r==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,r)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return Be(this,hi.REMAINING)}set remaining(e){Ne(this,hi.REMAINING,e)}get showDuration(){return Be(this,hi.SHOW_DURATION)}set showDuration(e){Ne(this,hi.SHOW_DURATION,e)}get noToggle(){return Be(this,hi.NO_TOGGLE)}set noToggle(e){Ne(this,hi.NO_TOGGLE,e)}get mediaDuration(){return Fe(this,S.MEDIA_DURATION)}set mediaDuration(e){Ke(this,S.MEDIA_DURATION,e)}get mediaCurrentTime(){return Fe(this,S.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){Ke(this,S.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(S.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(S.MEDIA_SEEKABLE);return}this.setAttribute(S.MEDIA_SEEKABLE,e.join(":"))}update(){let e=Lg(this);s_(this),e!==Kc(this,Us).innerHTML&&(Kc(this,Us).innerHTML=e)}};Us=new WeakMap;D.customElements.get("media-time-display")||D.customElements.define("media-time-display",qc);var n_=`<svg aria-hidden="true" viewBox="0 0 26 24">
538
+ `;var Ci=class extends w.HTMLElement{constructor(){super(),f_(this,Di,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Cg.content.cloneNode(!0)))}static get observedAttributes(){return[me.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER&&(t&&((n=(s=Po(this,Di))==null?void 0:s.unassociateElement)==null||n.call(s,this),Oo(this,Di,null)),r&&this.isConnected&&(Oo(this,Di,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Po(this,Di))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let{style:s}=Ye(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(me.MEDIA_CONTROLLER);n&&(Oo(this,Di,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=Po(this,Di))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Po(this,Di))==null?void 0:e.unassociateElement)==null||t.call(e,this),Oo(this,Di,null)}};Di=new WeakMap;w.customElements.get("media-text-display")||w.customElements.define("media-text-display",Ci);var Mg=Ci;var Og=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Pg=(i,e,t)=>(Og(i,e,"read from private field"),t?t.call(i):e.get(i)),m_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},p_=(i,e,t,r)=>(Og(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),$n,Zc=class extends Ci{constructor(){super(),m_(this,$n,void 0),p_(this,$n,this.shadowRoot.querySelector("slot")),Pg(this,$n).textContent=Ii(0)}static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_DURATION]}attributeChangedCallback(e,t,r){e===A.MEDIA_DURATION&&(Pg(this,$n).textContent=Ii(r)),super.attributeChangedCallback(e,t,r)}get mediaDuration(){return $e(this,A.MEDIA_DURATION)}set mediaDuration(e){Ke(this,A.MEDIA_DURATION,e)}};$n=new WeakMap;w.customElements.get("media-duration-display")||w.customElements.define("media-duration-display",Zc);var Bg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Jc=(i,e,t)=>(Bg(i,e,"read from private field"),t?t.call(i):e.get(i)),g_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},v_=(i,e,t,r)=>(Bg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Bs,pi={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},Ng=[...Object.values(pi),A.MEDIA_CURRENT_TIME,A.MEDIA_DURATION,A.MEDIA_SEEKABLE],Ug=["Enter"," "],E_="&nbsp;/&nbsp;",Fg=(i,{timesSep:e=E_}={})=>{var t,r,s,n;let a=i.hasAttribute(pi.REMAINING),o=i.hasAttribute(pi.SHOW_DURATION),l=(t=i.mediaCurrentTime)!=null?t:0,[,d]=(r=i.mediaSeekable)!=null?r:[],c=(n=(s=i.mediaDuration)!=null?s:d)!=null?n:0,u=a?Ii(0-(c-l)):Ii(l);return o?`${u}${e}${Ii(c)}`:u},b_="video not loaded, unknown time.",y_=i=>{var e;let t=i.mediaCurrentTime,[,r]=(e=i.mediaSeekable)!=null?e:[],s=i.mediaDuration||r;if(t==null||s==null){i.setAttribute("aria-valuetext",b_);return}let n=i.hasAttribute(pi.REMAINING),a=i.hasAttribute(pi.SHOW_DURATION),o=n?Nr(0-(s-t)):Nr(t);if(!a){i.setAttribute("aria-valuetext",o);return}let l=Nr(s),d=`${o} of ${l}`;i.setAttribute("aria-valuetext",d)},eu=class extends Ci{constructor(){super(),g_(this,Bs,void 0),v_(this,Bs,this.shadowRoot.querySelector("slot")),Jc(this,Bs).innerHTML=`${Fg(this)}`}static get observedAttributes(){return[...super.observedAttributes,...Ng,"disabled"]}connectedCallback(){let{style:e}=Ye(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Lt.PLAYBACK_TIME());let t=r=>{let{key:s}=r;if(!Ug.includes(s)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!Ug.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){Ng.includes(e)?this.update():e==="disabled"&&r!==t&&(r==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,r)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return He(this,pi.REMAINING)}set remaining(e){Ue(this,pi.REMAINING,e)}get showDuration(){return He(this,pi.SHOW_DURATION)}set showDuration(e){Ue(this,pi.SHOW_DURATION,e)}get noToggle(){return He(this,pi.NO_TOGGLE)}set noToggle(e){Ue(this,pi.NO_TOGGLE,e)}get mediaDuration(){return $e(this,A.MEDIA_DURATION)}set mediaDuration(e){Ke(this,A.MEDIA_DURATION,e)}get mediaCurrentTime(){return $e(this,A.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){Ke(this,A.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(A.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(A.MEDIA_SEEKABLE);return}this.setAttribute(A.MEDIA_SEEKABLE,e.join(":"))}update(){let e=Fg(this);y_(this),e!==Jc(this,Bs).innerHTML&&(Jc(this,Bs).innerHTML=e)}};Bs=new WeakMap;w.customElements.get("media-time-display")||w.customElements.define("media-time-display",eu);var T_=`<svg aria-hidden="true" viewBox="0 0 26 24">
502
539
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
503
- </svg>`,a_=`<svg aria-hidden="true" viewBox="0 0 26 24">
540
+ </svg>`,__=`<svg aria-hidden="true" viewBox="0 0 26 24">
504
541
  <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
505
- </svg>`,Cg=q.createElement("template");Cg.innerHTML=`
542
+ </svg>`,Vg=q.createElement("template");Vg.innerHTML=`
506
543
  <style>
507
544
  :host([aria-checked="true"]) slot[name=off] {
508
545
  display: none !important;
@@ -515,32 +552,32 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
515
552
  </style>
516
553
 
517
554
  <slot name="icon">
518
- <slot name="on">${n_}</slot>
519
- <slot name="off">${a_}</slot>
555
+ <slot name="on">${T_}</slot>
556
+ <slot name="off">${__}</slot>
520
557
  </slot>
521
- `;var kg=i=>{i.setAttribute("aria-checked",tg(i))},Yc=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_SUBTITLES_LIST,S.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:Cg,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",St.CLOSED_CAPTIONS()),kg(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_SUBTITLES_SHOWING&&kg(this)}get mediaSubtitlesList(){return wg(this,S.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Dg(this,S.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return wg(this,S.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Dg(this,S.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new D.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}},wg=(i,e)=>{let t=i.getAttribute(e);return t?Pn(t):[]},Dg=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=Fr(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};D.customElements.get("media-captions-button")||D.customElements.define("media-captions-button",Yc);var Fs={SEEK_OFFSET:"seekoffset"},ko=30,o_=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${ko}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,Mg=q.createElement("template");Mg.innerHTML=`
522
- <slot name="icon">${o_}</slot>
523
- `;var l_=0,jc=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_CURRENT_TIME,Fs.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Mg,...e})}connectedCallback(){this.seekOffset=Fe(this,Fs.SEEK_OFFSET,ko),super.connectedCallback()}attributeChangedCallback(e,t,r){e===Fs.SEEK_OFFSET&&(this.seekOffset=Fe(this,Fs.SEEK_OFFSET,ko)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return Fe(this,Fs.SEEK_OFFSET,ko)}set seekOffset(e){Ke(this,Fs.SEEK_OFFSET,e),this.setAttribute("aria-label",We.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),za(Xa(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Fe(this,S.MEDIA_CURRENT_TIME,l_)}set mediaCurrentTime(e){Ke(this,S.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new D.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};D.customElements.get("media-seek-forward-button")||D.customElements.define("media-seek-forward-button",jc);var d_=`<svg aria-hidden="true" viewBox="0 0 26 24">
558
+ `;var $g=i=>{i.setAttribute("aria-checked",cg(i))},tu=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_SUBTITLES_LIST,A.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:Vg,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Lt.CLOSED_CAPTIONS()),$g(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===A.MEDIA_SUBTITLES_SHOWING&&$g(this)}get mediaSubtitlesList(){return Hg(this,A.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Gg(this,A.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Hg(this,A.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Gg(this,A.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new w.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}},Hg=(i,e)=>{let t=i.getAttribute(e);return t?On(t):[]},Gg=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=$r(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};w.customElements.get("media-captions-button")||w.customElements.define("media-captions-button",tu);var $s={SEEK_OFFSET:"seekoffset"},No=30,A_=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${No}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,Wg=q.createElement("template");Wg.innerHTML=`
559
+ <slot name="icon">${A_}</slot>
560
+ `;var S_=0,iu=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_CURRENT_TIME,$s.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Wg,...e})}connectedCallback(){this.seekOffset=$e(this,$s.SEEK_OFFSET,No),super.connectedCallback()}attributeChangedCallback(e,t,r){e===$s.SEEK_OFFSET&&(this.seekOffset=$e(this,$s.SEEK_OFFSET,No)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return $e(this,$s.SEEK_OFFSET,No)}set seekOffset(e){Ke(this,$s.SEEK_OFFSET,e),this.setAttribute("aria-label",We.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),eo(to(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return $e(this,A.MEDIA_CURRENT_TIME,S_)}set mediaCurrentTime(e){Ke(this,A.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new w.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};w.customElements.get("media-seek-forward-button")||w.customElements.define("media-seek-forward-button",iu);var x_=`<svg aria-hidden="true" viewBox="0 0 26 24">
524
561
  <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
525
- </svg>`,c_=`<svg aria-hidden="true" viewBox="0 0 26 24">
562
+ </svg>`,I_=`<svg aria-hidden="true" viewBox="0 0 26 24">
526
563
  <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
527
- </svg>`,Og=q.createElement("template");Og.innerHTML=`
564
+ </svg>`,qg=q.createElement("template");qg.innerHTML=`
528
565
  <style>
529
- :host([${S.MEDIA_IS_FULLSCREEN}]) slot:not([name=exit]):not([name=icon]) {
566
+ :host([${A.MEDIA_IS_FULLSCREEN}]) slot:not([name=exit]):not([name=icon]) {
530
567
  display: none !important;
531
568
  }
532
569
 
533
570
 
534
- :host(:not([${S.MEDIA_IS_FULLSCREEN}])) slot:not([name=enter]):not([name=icon]) {
571
+ :host(:not([${A.MEDIA_IS_FULLSCREEN}])) slot:not([name=enter]):not([name=icon]) {
535
572
  display: none !important;
536
573
  }
537
574
  </style>
538
575
 
539
576
  <slot name="icon">
540
- <slot name="enter">${d_}</slot>
541
- <slot name="exit">${c_}</slot>
577
+ <slot name="enter">${x_}</slot>
578
+ <slot name="exit">${I_}</slot>
542
579
  </slot>
543
- `;var Pg=i=>{let e=i.mediaIsFullscreen?We.EXIT_FULLSCREEN():We.ENTER_FULLSCREEN();i.setAttribute("aria-label",e)},zc=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_FULLSCREEN,S.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Og,...e})}connectedCallback(){Pg(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_IS_FULLSCREEN&&Pg(this),super.attributeChangedCallback(e,t,r)}get mediaFullscreenUnavailable(){return He(this,S.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){$e(this,S.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return Be(this,S.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){Ne(this,S.MEDIA_IS_FULLSCREEN,e)}handleClick(){let e=this.mediaIsFullscreen?ee.MEDIA_EXIT_FULLSCREEN_REQUEST:ee.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new D.CustomEvent(e,{composed:!0,bubbles:!0}))}};D.customElements.get("media-fullscreen-button")||D.customElements.define("media-fullscreen-button",zc);var{MEDIA_TIME_IS_LIVE:wo,MEDIA_PAUSED:$n}=S,{MEDIA_SEEK_TO_LIVE_REQUEST:u_,MEDIA_PLAY_REQUEST:h_}=ee,f_='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',Ug=q.createElement("template");Ug.innerHTML=`
580
+ `;var Kg=i=>{let e=i.mediaIsFullscreen?We.EXIT_FULLSCREEN():We.ENTER_FULLSCREEN();i.setAttribute("aria-label",e)},ru=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_IS_FULLSCREEN,A.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:qg,...e})}connectedCallback(){Kg(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===A.MEDIA_IS_FULLSCREEN&&Kg(this),super.attributeChangedCallback(e,t,r)}get mediaFullscreenUnavailable(){return Fe(this,A.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){Oe(this,A.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return He(this,A.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){Ue(this,A.MEDIA_IS_FULLSCREEN,e)}handleClick(){let e=this.mediaIsFullscreen?ee.MEDIA_EXIT_FULLSCREEN_REQUEST:ee.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-fullscreen-button")||w.customElements.define("media-fullscreen-button",ru);var{MEDIA_TIME_IS_LIVE:Uo,MEDIA_PAUSED:Hn}=A,{MEDIA_SEEK_TO_LIVE_REQUEST:L_,MEDIA_PLAY_REQUEST:R_}=ee,k_='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',jg=q.createElement("template");jg.innerHTML=`
544
581
  <style>
545
582
 
546
583
  slot[name=indicator] > *,
@@ -551,28 +588,28 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
551
588
  color: var(--media-live-button-icon-color, rgb(140, 140, 140));
552
589
  }
553
590
 
554
- :host([${wo}]:not([${$n}])) slot[name=indicator] > *,
555
- :host([${wo}]:not([${$n}])) ::slotted([slot=indicator]) {
591
+ :host([${Uo}]:not([${Hn}])) slot[name=indicator] > *,
592
+ :host([${Uo}]:not([${Hn}])) ::slotted([slot=indicator]) {
556
593
  fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
557
594
  color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
558
595
  }
559
596
 
560
- :host([${wo}]:not([${$n}])) {
597
+ :host([${Uo}]:not([${Hn}])) {
561
598
  cursor: not-allowed;
562
599
  }
563
600
 
564
601
  </style>
565
602
 
566
- <slot name="indicator">${f_}</slot>
603
+ <slot name="indicator">${k_}</slot>
567
604
 
568
605
  <slot name="spacer">&nbsp;</slot><slot name="text">LIVE</slot>
569
- `;var Ng=i=>{let e=i.mediaPaused||!i.mediaTimeIsLive,t=e?We.SEEK_LIVE():We.PLAYING_LIVE();i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")},Xc=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,$n,wo]}constructor(e={}){super({slotTemplate:Ug,...e})}connectedCallback(){Ng(this),super.connectedCallback()}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),Ng(this)}get mediaPaused(){return Be(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ne(this,S.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return Be(this,S.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){Ne(this,S.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new D.CustomEvent(u_,{composed:!0,bubbles:!0})),this.hasAttribute($n)&&this.dispatchEvent(new D.CustomEvent(h_,{composed:!0,bubbles:!0})))}};D.customElements.get("media-live-button")||D.customElements.define("media-live-button",Xc);var{MEDIA_VOLUME_LEVEL:Gn}=S,m_=`<svg aria-hidden="true" viewBox="0 0 24 24">
606
+ `;var Yg=i=>{let e=i.mediaPaused||!i.mediaTimeIsLive,t=e?We.SEEK_LIVE():We.PLAYING_LIVE();i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")},su=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,Hn,Uo]}constructor(e={}){super({slotTemplate:jg,...e})}connectedCallback(){Yg(this),super.connectedCallback()}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),Yg(this)}get mediaPaused(){return He(this,A.MEDIA_PAUSED)}set mediaPaused(e){Ue(this,A.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return He(this,A.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){Ue(this,A.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new w.CustomEvent(L_,{composed:!0,bubbles:!0})),this.hasAttribute(Hn)&&this.dispatchEvent(new w.CustomEvent(R_,{composed:!0,bubbles:!0})))}};w.customElements.get("media-live-button")||w.customElements.define("media-live-button",su);var{MEDIA_VOLUME_LEVEL:Gn}=A,w_=`<svg aria-hidden="true" viewBox="0 0 24 24">
570
607
  <path d="M16.5 12A4.5 4.5 0 0 0 14 8v2.18l2.45 2.45a4.22 4.22 0 0 0 .05-.63Zm2.5 0a6.84 6.84 0 0 1-.54 2.64L20 16.15A8.8 8.8 0 0 0 21 12a9 9 0 0 0-7-8.77v2.06A7 7 0 0 1 19 12ZM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25A6.92 6.92 0 0 1 14 18.7v2.06A9 9 0 0 0 17.69 19l2 2.05L21 19.73l-9-9L4.27 3ZM12 4 9.91 6.09 12 8.18V4Z"/>
571
- </svg>`,Fg=`<svg aria-hidden="true" viewBox="0 0 24 24">
608
+ </svg>`,zg=`<svg aria-hidden="true" viewBox="0 0 24 24">
572
609
  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4Z"/>
573
- </svg>`,p_=`<svg aria-hidden="true" viewBox="0 0 24 24">
610
+ </svg>`,D_=`<svg aria-hidden="true" viewBox="0 0 24 24">
574
611
  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4ZM14 3.23v2.06a7 7 0 0 1 0 13.42v2.06a9 9 0 0 0 0-17.54Z"/>
575
- </svg>`,$g=q.createElement("template");$g.innerHTML=`
612
+ </svg>`,Qg=q.createElement("template");Qg.innerHTML=`
576
613
  <style>
577
614
 
578
615
  :host(:not([${Gn}])) slot:not([name=high]):not([name=icon]),
@@ -594,49 +631,49 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
594
631
  </style>
595
632
 
596
633
  <slot name="icon">
597
- <slot name="off">${m_}</slot>
598
- <slot name="low">${Fg}</slot>
599
- <slot name="medium">${Fg}</slot>
600
- <slot name="high">${p_}</slot>
634
+ <slot name="off">${w_}</slot>
635
+ <slot name="low">${zg}</slot>
636
+ <slot name="medium">${zg}</slot>
637
+ <slot name="high">${D_}</slot>
601
638
  </slot>
602
- `;var Bg=i=>{let t=i.mediaVolumeLevel==="off"?We.UNMUTE():We.MUTE();i.setAttribute("aria-label",t)},Qc=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:$g,...e})}connectedCallback(){Bg(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_VOLUME_LEVEL&&Bg(this),super.attributeChangedCallback(e,t,r)}get mediaVolumeLevel(){return He(this,S.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){$e(this,S.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e=this.mediaVolumeLevel==="off"?ee.MEDIA_UNMUTE_REQUEST:ee.MEDIA_MUTE_REQUEST;this.dispatchEvent(new D.CustomEvent(e,{composed:!0,bubbles:!0}))}};D.customElements.get("media-mute-button")||D.customElements.define("media-mute-button",Qc);var Gg=`<svg aria-hidden="true" viewBox="0 0 28 24">
639
+ `;var Xg=i=>{let t=i.mediaVolumeLevel==="off"?We.UNMUTE():We.MUTE();i.setAttribute("aria-label",t)},nu=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:Qg,...e})}connectedCallback(){Xg(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===A.MEDIA_VOLUME_LEVEL&&Xg(this),super.attributeChangedCallback(e,t,r)}get mediaVolumeLevel(){return Fe(this,A.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){Oe(this,A.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e=this.mediaVolumeLevel==="off"?ee.MEDIA_UNMUTE_REQUEST:ee.MEDIA_MUTE_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-mute-button")||w.customElements.define("media-mute-button",nu);var Zg=`<svg aria-hidden="true" viewBox="0 0 28 24">
603
640
  <path d="M24 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h20a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Zm-1 16H5V5h18v14Zm-3-8h-7v5h7v-5Z"/>
604
- </svg>`,Vg=q.createElement("template");Vg.innerHTML=`
641
+ </svg>`,e0=q.createElement("template");e0.innerHTML=`
605
642
  <style>
606
- :host([${S.MEDIA_IS_PIP}]) slot:not([name=exit]):not([name=icon]) {
643
+ :host([${A.MEDIA_IS_PIP}]) slot:not([name=exit]):not([name=icon]) {
607
644
  display: none !important;
608
645
  }
609
646
 
610
647
 
611
- :host(:not([${S.MEDIA_IS_PIP}])) slot:not([name=enter]):not([name=icon]) {
648
+ :host(:not([${A.MEDIA_IS_PIP}])) slot:not([name=enter]):not([name=icon]) {
612
649
  display: none !important;
613
650
  }
614
651
  </style>
615
652
 
616
653
  <slot name="icon">
617
- <slot name="enter">${Gg}</slot>
618
- <slot name="exit">${Gg}</slot>
654
+ <slot name="enter">${Zg}</slot>
655
+ <slot name="exit">${Zg}</slot>
619
656
  </slot>
620
- `;var Hg=i=>{let e=i.mediaIsPip?We.EXIT_PIP():We.ENTER_PIP();i.setAttribute("aria-label",e)},Zc=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_PIP,S.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Vg,...e})}connectedCallback(){Hg(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_IS_PIP&&Hg(this),super.attributeChangedCallback(e,t,r)}get mediaPipUnavailable(){return He(this,S.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){$e(this,S.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return Be(this,S.MEDIA_IS_PIP)}set mediaIsPip(e){Ne(this,S.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?ee.MEDIA_EXIT_PIP_REQUEST:ee.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new D.CustomEvent(e,{composed:!0,bubbles:!0}))}};D.customElements.get("media-pip-button")||D.customElements.define("media-pip-button",Zc);var g_=`<svg aria-hidden="true" viewBox="0 0 24 24">
657
+ `;var Jg=i=>{let e=i.mediaIsPip?We.EXIT_PIP():We.ENTER_PIP();i.setAttribute("aria-label",e)},au=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_IS_PIP,A.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:e0,...e})}connectedCallback(){Jg(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===A.MEDIA_IS_PIP&&Jg(this),super.attributeChangedCallback(e,t,r)}get mediaPipUnavailable(){return Fe(this,A.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){Oe(this,A.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return He(this,A.MEDIA_IS_PIP)}set mediaIsPip(e){Ue(this,A.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?ee.MEDIA_EXIT_PIP_REQUEST:ee.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-pip-button")||w.customElements.define("media-pip-button",au);var C_=`<svg aria-hidden="true" viewBox="0 0 24 24">
621
658
  <path d="m6 21 15-9L6 3v18Z"/>
622
- </svg>`,v_=`<svg aria-hidden="true" viewBox="0 0 24 24">
659
+ </svg>`,M_=`<svg aria-hidden="true" viewBox="0 0 24 24">
623
660
  <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
624
- </svg>`,Kg=q.createElement("template");Kg.innerHTML=`
661
+ </svg>`,i0=q.createElement("template");i0.innerHTML=`
625
662
  <style>
626
- :host([${S.MEDIA_PAUSED}]) slot[name=pause] {
663
+ :host([${A.MEDIA_PAUSED}]) slot[name=pause] {
627
664
  display: none !important;
628
665
  }
629
666
 
630
- :host(:not([${S.MEDIA_PAUSED}])) slot[name=play] {
667
+ :host(:not([${A.MEDIA_PAUSED}])) slot[name=play] {
631
668
  display: none !important;
632
669
  }
633
670
  </style>
634
671
 
635
672
  <slot name="icon">
636
- <slot name="play">${g_}</slot>
637
- <slot name="pause">${v_}</slot>
673
+ <slot name="play">${C_}</slot>
674
+ <slot name="pause">${M_}</slot>
638
675
  </slot>
639
- `;var Wg=i=>{let e=i.mediaPaused?We.PLAY():We.PAUSE();i.setAttribute("aria-label",e)},Jc=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PAUSED,S.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:Kg,...e})}connectedCallback(){Wg(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_PAUSED&&Wg(this),super.attributeChangedCallback(e,t,r)}get mediaPaused(){return Be(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ne(this,S.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?ee.MEDIA_PLAY_REQUEST:ee.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new D.CustomEvent(e,{composed:!0,bubbles:!0}))}};D.customElements.get("media-play-button")||D.customElements.define("media-play-button",Jc);var E_=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Do=(i,e,t)=>(E_(i,e,"read from private field"),t?t.call(i):e.get(i)),b_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Bs,eu={RATES:"rates"},iu=[1,1.2,1.5,1.7,2],$s=1,qg=q.createElement("template");qg.innerHTML=`
676
+ `;var t0=i=>{let e=i.mediaPaused?We.PLAY():We.PAUSE();i.setAttribute("aria-label",e)},ou=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_PAUSED,A.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:i0,...e})}connectedCallback(){t0(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===A.MEDIA_PAUSED&&t0(this),super.attributeChangedCallback(e,t,r)}get mediaPaused(){return He(this,A.MEDIA_PAUSED)}set mediaPaused(e){Ue(this,A.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?ee.MEDIA_PLAY_REQUEST:ee.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-play-button")||w.customElements.define("media-play-button",ou);var P_=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Fo=(i,e,t)=>(P_(i,e,"read from private field"),t?t.call(i):e.get(i)),O_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Hs,lu={RATES:"rates"},cu=[1,1.2,1.5,1.7,2],Gs=1,r0=q.createElement("template");r0.innerHTML=`
640
677
  <style>
641
678
  :host {
642
679
  min-width: 5ch;
@@ -644,7 +681,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
644
681
  }
645
682
  </style>
646
683
  <slot name="icon"></slot>
647
- `;var tu=class extends Ge{constructor(e={}){super({slotTemplate:qg,...e}),b_(this,Bs,new ur(this,eu.RATES,{defaultValue:iu})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${$s}x`}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PLAYBACK_RATE,eu.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===eu.RATES&&(Do(this,Bs).value=r),e===S.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?$s:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",St.PLAYBACK_RATE({playbackRate:n}))}}get rates(){return Do(this,Bs)}set rates(e){e?Array.isArray(e)&&(Do(this,Bs).value=e.join(" ")):Do(this,Bs).value=""}get mediaPlaybackRate(){return Fe(this,S.MEDIA_PLAYBACK_RATE,$s)}set mediaPlaybackRate(e){Ke(this,S.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let r=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),s=(t=(e=r.find(a=>a>this.mediaPlaybackRate))!=null?e:r[0])!=null?t:$s,n=new D.CustomEvent(ee.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}};Bs=new WeakMap;D.customElements.get("media-playback-rate-button")||D.customElements.define("media-playback-rate-button",tu);var wi={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},Yg=q.createElement("template");Yg.innerHTML=`
684
+ `;var du=class extends Ge{constructor(e={}){super({slotTemplate:r0,...e}),O_(this,Hs,new hr(this,lu.RATES,{defaultValue:cu})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${Gs}x`}static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_PLAYBACK_RATE,lu.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===lu.RATES&&(Fo(this,Hs).value=r),e===A.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?Gs:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Lt.PLAYBACK_RATE({playbackRate:n}))}}get rates(){return Fo(this,Hs)}set rates(e){e?Array.isArray(e)&&(Fo(this,Hs).value=e.join(" ")):Fo(this,Hs).value=""}get mediaPlaybackRate(){return $e(this,A.MEDIA_PLAYBACK_RATE,Gs)}set mediaPlaybackRate(e){Ke(this,A.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let r=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),s=(t=(e=r.find(a=>a>this.mediaPlaybackRate))!=null?e:r[0])!=null?t:Gs,n=new w.CustomEvent(ee.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}};Hs=new WeakMap;w.customElements.get("media-playback-rate-button")||w.customElements.define("media-playback-rate-button",du);var Mi={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},s0=q.createElement("template");s0.innerHTML=`
648
685
  <style>
649
686
  :host {
650
687
  pointer-events: none;
@@ -666,9 +703,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
666
703
  </style>
667
704
 
668
705
  <img part="poster img" aria-hidden="true" id="image"/>
669
- `;var y_=i=>{i.style.removeProperty("background-image")},T_=(i,e)=>{i.style["background-image"]=`url('${e}')`},ru=class extends D.HTMLElement{static get observedAttributes(){return[wi.PLACEHOLDER_SRC,wi.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Yg.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,r){e===wi.SRC&&(r==null?this.image.removeAttribute(wi.SRC):this.image.setAttribute(wi.SRC,r)),e===wi.PLACEHOLDER_SRC&&(r==null?y_(this.image):T_(this.image,r))}get placeholderSrc(){return He(this,wi.PLACEHOLDER_SRC)}set placeholderSrc(e){$e(this,wi.SRC,e)}get src(){return He(this,wi.SRC)}set src(e){$e(this,wi.SRC,e)}};D.customElements.get("media-poster-image")||D.customElements.define("media-poster-image",ru);var Gs={SEEK_OFFSET:"seekoffset"},Co=30,__=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${Co}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,jg=q.createElement("template");jg.innerHTML=`
670
- <slot name="icon">${__}</slot>
671
- `;var A_=0,su=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_CURRENT_TIME,Gs.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:jg,...e})}connectedCallback(){this.seekOffset=Fe(this,Gs.SEEK_OFFSET,Co),super.connectedCallback()}attributeChangedCallback(e,t,r){e===Gs.SEEK_OFFSET&&(this.seekOffset=Fe(this,Gs.SEEK_OFFSET,Co)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return Fe(this,Gs.SEEK_OFFSET,Co)}set seekOffset(e){Ke(this,Gs.SEEK_OFFSET,e),this.setAttribute("aria-label",We.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),za(Xa(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Fe(this,S.MEDIA_CURRENT_TIME,A_)}set mediaCurrentTime(e){Ke(this,S.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new D.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};D.customElements.get("media-seek-backward-button")||D.customElements.define("media-seek-backward-button",su);var Xg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},zg=(i,e,t)=>(Xg(i,e,"read from private field"),t?t.call(i):e.get(i)),S_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},x_=(i,e,t,r)=>(Xg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Hn,nu=class extends zi{constructor(){super(),S_(this,Hn,void 0),x_(this,Hn,this.shadowRoot.querySelector("slot")),zg(this,Hn).textContent=Ai(0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,r){e===S.MEDIA_PREVIEW_TIME&&r!=null&&(zg(this,Hn).textContent=Ai(r)),super.attributeChangedCallback(e,t,r)}get mediaPreviewTime(){return Fe(this,S.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){Ke(this,S.MEDIA_PREVIEW_TIME,e)}};Hn=new WeakMap;D.customElements.get("media-preview-time-display")||D.customElements.define("media-preview-time-display",nu);var Qg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Mo=(i,e,t)=>(Qg(i,e,"read from private field"),t?t.call(i):e.get(i)),I_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Po=(i,e,t,r)=>(Qg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Di,Zg=q.createElement("template");Zg.innerHTML=`
706
+ `;var N_=i=>{i.style.removeProperty("background-image")},U_=(i,e)=>{i.style["background-image"]=`url('${e}')`},uu=class extends w.HTMLElement{static get observedAttributes(){return[Mi.PLACEHOLDER_SRC,Mi.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(s0.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,r){e===Mi.SRC&&(r==null?this.image.removeAttribute(Mi.SRC):this.image.setAttribute(Mi.SRC,r)),e===Mi.PLACEHOLDER_SRC&&(r==null?N_(this.image):U_(this.image,r))}get placeholderSrc(){return Fe(this,Mi.PLACEHOLDER_SRC)}set placeholderSrc(e){Oe(this,Mi.SRC,e)}get src(){return Fe(this,Mi.SRC)}set src(e){Oe(this,Mi.SRC,e)}};w.customElements.get("media-poster-image")||w.customElements.define("media-poster-image",uu);var Vs={SEEK_OFFSET:"seekoffset"},Bo=30,F_=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${Bo}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,n0=q.createElement("template");n0.innerHTML=`
707
+ <slot name="icon">${F_}</slot>
708
+ `;var B_=0,hu=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_CURRENT_TIME,Vs.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:n0,...e})}connectedCallback(){this.seekOffset=$e(this,Vs.SEEK_OFFSET,Bo),super.connectedCallback()}attributeChangedCallback(e,t,r){e===Vs.SEEK_OFFSET&&(this.seekOffset=$e(this,Vs.SEEK_OFFSET,Bo)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return $e(this,Vs.SEEK_OFFSET,Bo)}set seekOffset(e){Ke(this,Vs.SEEK_OFFSET,e),this.setAttribute("aria-label",We.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),eo(to(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return $e(this,A.MEDIA_CURRENT_TIME,B_)}set mediaCurrentTime(e){Ke(this,A.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new w.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};w.customElements.get("media-seek-backward-button")||w.customElements.define("media-seek-backward-button",hu);var o0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},a0=(i,e,t)=>(o0(i,e,"read from private field"),t?t.call(i):e.get(i)),$_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},H_=(i,e,t,r)=>(o0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Vn,fu=class extends Ci{constructor(){super(),$_(this,Vn,void 0),H_(this,Vn,this.shadowRoot.querySelector("slot")),a0(this,Vn).textContent=Ii(0)}static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===A.MEDIA_PREVIEW_TIME&&r!=null&&(a0(this,Vn).textContent=Ii(r))}get mediaPreviewTime(){return $e(this,A.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){Ke(this,A.MEDIA_PREVIEW_TIME,e)}};Vn=new WeakMap;w.customElements.get("media-preview-time-display")||w.customElements.define("media-preview-time-display",fu);var l0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},$o=(i,e,t)=>(l0(i,e,"read from private field"),t?t.call(i):e.get(i)),G_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ho=(i,e,t,r)=>(l0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Pi,d0=q.createElement("template");d0.innerHTML=`
672
709
  <style>
673
710
  :host {
674
711
  box-sizing: border-box;
@@ -682,7 +719,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
682
719
  }
683
720
  </style>
684
721
  <img crossorigin loading="eager" decoding="async">
685
- `;var au=class extends D.HTMLElement{constructor(){super(),I_(this,Di,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Zg.content.cloneNode(!0)))}static get observedAttributes(){return[me.MEDIA_CONTROLLER,S.MEDIA_PREVIEW_IMAGE,S.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(Po(this,Di,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Mo(this,Di))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Mo(this,Di))==null?void 0:e.unassociateElement)==null||t.call(e,this),Po(this,Di,null)}attributeChangedCallback(e,t,r){var s,n,a,o,l;[S.MEDIA_PREVIEW_IMAGE,S.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===me.MEDIA_CONTROLLER&&(t&&((n=(s=Mo(this,Di))==null?void 0:s.unassociateElement)==null||n.call(s,this),Po(this,Di,null)),r&&this.isConnected&&(Po(this,Di,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Mo(this,Di))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return He(this,S.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){$e(this,S.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(S.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(S.MEDIA_PREVIEW_COORDS);return}this.setAttribute(S.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[r,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:c,minWidth:u,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(c)/a),g=Math.max(parseInt(u)/n,parseInt(h)/a),E=f<1,T=E?f:g>1?g:1,{style:A}=ze(this.shadowRoot,":host"),k=ze(this.shadowRoot,"img").style,L=this.shadowRoot.querySelector("img"),F=E?"min":"max";A.setProperty(`${F}-width`,"initial","important"),A.setProperty(`${F}-height`,"initial","important"),A.width=`${n*T}px`,A.height=`${a*T}px`;let R=()=>{k.width=`${this.imgWidth*T}px`,k.height=`${this.imgHeight*T}px`,k.display="block"};L.src!==o&&(L.onload=()=>{this.imgWidth=L.naturalWidth,this.imgHeight=L.naturalHeight,R()},L.src=o,R()),R(),k.transform=`translate(-${r*T}px, -${s*T}px)`}};Di=new WeakMap;D.customElements.get("media-preview-thumbnail")||D.customElements.define("media-preview-thumbnail",au);var Jg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},vt=(i,e,t)=>(Jg(i,e,"read from private field"),t?t.call(i):e.get(i)),Ci=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},jt=(i,e,t,r)=>(Jg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),L_=(i,e,t,r)=>({set _(s){jt(i,e,s,t)},get _(){return vt(i,e,r)}}),Hs,Oo,Vs,Vn,No,Uo,Fo,Ws,Hr,Bo,$o=class{constructor(e,t,r){Ci(this,Hs,void 0),Ci(this,Oo,void 0),Ci(this,Vs,void 0),Ci(this,Vn,void 0),Ci(this,No,void 0),Ci(this,Uo,void 0),Ci(this,Fo,void 0),Ci(this,Ws,void 0),Ci(this,Hr,0),Ci(this,Bo,(s=performance.now())=>{jt(this,Hr,requestAnimationFrame(vt(this,Bo))),jt(this,Vn,performance.now()-vt(this,Vs));let n=1e3/this.fps;if(vt(this,Vn)>n){jt(this,Vs,s-vt(this,Vn)%n);let a=1e3/((s-vt(this,Oo))/++L_(this,No)._),o=(s-vt(this,Uo))/1e3/this.duration,l=vt(this,Fo)+o*this.playbackRate;l-vt(this,Hs).valueAsNumber>0?jt(this,Ws,this.playbackRate/this.duration/a):(jt(this,Ws,.995*vt(this,Ws)),l=vt(this,Hs).valueAsNumber+vt(this,Ws)),this.callback(l)}}),jt(this,Hs,e),this.callback=t,this.fps=r}start(){vt(this,Hr)===0&&(jt(this,Vs,performance.now()),jt(this,Oo,vt(this,Vs)),jt(this,No,0),vt(this,Bo).call(this))}stop(){vt(this,Hr)!==0&&(cancelAnimationFrame(vt(this,Hr)),jt(this,Hr,0))}update({start:e,duration:t,playbackRate:r}){let s=e-vt(this,Hs).valueAsNumber;(s>0||s<-.03)&&this.callback(e),jt(this,Fo,e),jt(this,Uo,performance.now()),this.duration=t,this.playbackRate=r}};Hs=new WeakMap;Oo=new WeakMap;Vs=new WeakMap;Vn=new WeakMap;No=new WeakMap;Uo=new WeakMap;Fo=new WeakMap;Ws=new WeakMap;Hr=new WeakMap;Bo=new WeakMap;var uu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},zt=(i,e,t)=>(uu(i,e,"read from private field"),t?t.call(i):e.get(i)),Bt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},fr=(i,e,t,r)=>(uu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ti=(i,e,t)=>(uu(i,e,"access private method"),t),Ks,Vr,Go,Ho,Wn,Vo,Wo,qs,Kn,hu,t0,ou,Ko,fu,lu,i0,qn,qo,du,r0,R_="video not loaded, unknown time.",k_=i=>{let e=i.range,t=Or(+n0(i)),r=Or(+i.mediaSeekableEnd),s=t&&r?`${t} of ${r}`:R_;e.setAttribute("aria-valuetext",s)},s0=q.createElement("template");s0.innerHTML=`
722
+ `;var mu=class extends w.HTMLElement{constructor(){super(),G_(this,Pi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(d0.content.cloneNode(!0)))}static get observedAttributes(){return[me.MEDIA_CONTROLLER,A.MEDIA_PREVIEW_IMAGE,A.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(Ho(this,Pi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=$o(this,Pi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=$o(this,Pi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ho(this,Pi,null)}attributeChangedCallback(e,t,r){var s,n,a,o,l;[A.MEDIA_PREVIEW_IMAGE,A.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===me.MEDIA_CONTROLLER&&(t&&((n=(s=$o(this,Pi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ho(this,Pi,null)),r&&this.isConnected&&(Ho(this,Pi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=$o(this,Pi))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return Fe(this,A.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Oe(this,A.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(A.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(A.MEDIA_PREVIEW_COORDS);return}this.setAttribute(A.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[r,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:c,minWidth:u,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(c)/a),g=Math.max(parseInt(u)/n,parseInt(h)/a),E=f<1,T=E?f:g>1?g:1,{style:S}=Ye(this.shadowRoot,":host"),k=Ye(this.shadowRoot,"img").style,L=this.shadowRoot.querySelector("img"),F=E?"min":"max";S.setProperty(`${F}-width`,"initial","important"),S.setProperty(`${F}-height`,"initial","important"),S.width=`${n*T}px`,S.height=`${a*T}px`;let R=()=>{k.width=`${this.imgWidth*T}px`,k.height=`${this.imgHeight*T}px`,k.display="block"};L.src!==o&&(L.onload=()=>{this.imgWidth=L.naturalWidth,this.imgHeight=L.naturalHeight,R()},L.src=o,R()),R(),k.transform=`translate(-${r*T}px, -${s*T}px)`}};Pi=new WeakMap;w.customElements.get("media-preview-thumbnail")||w.customElements.define("media-preview-thumbnail",mu);var u0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},c0=(i,e,t)=>(u0(i,e,"read from private field"),t?t.call(i):e.get(i)),V_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},W_=(i,e,t,r)=>(u0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Wn,pu=class extends Mg{constructor(){super(),V_(this,Wn,void 0),W_(this,Wn,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===A.MEDIA_PREVIEW_CHAPTER&&r!==t){if(r==null){c0(this,Wn).textContent="",this.removeAttribute("aria-valuetext");return}c0(this,Wn).textContent=r,this.setAttribute("aria-valuetext",`chapter: ${r}`)}}get mediaPreviewChapter(){return Fe(this,A.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){Oe(this,A.MEDIA_PREVIEW_CHAPTER,e)}};Wn=new WeakMap;w.customElements.get("media-preview-chapter-display")||w.customElements.define("media-preview-chapter-display",pu);var h0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Et=(i,e,t)=>(h0(i,e,"read from private field"),t?t.call(i):e.get(i)),Oi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Xt=(i,e,t,r)=>(h0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),K_=(i,e,t,r)=>({set _(s){Xt(i,e,s,t)},get _(){return Et(i,e,r)}}),Ws,Go,Ks,Kn,Vo,Wo,Ko,qs,Vr,qo,Yo=class{constructor(e,t,r){Oi(this,Ws,void 0),Oi(this,Go,void 0),Oi(this,Ks,void 0),Oi(this,Kn,void 0),Oi(this,Vo,void 0),Oi(this,Wo,void 0),Oi(this,Ko,void 0),Oi(this,qs,void 0),Oi(this,Vr,0),Oi(this,qo,(s=performance.now())=>{Xt(this,Vr,requestAnimationFrame(Et(this,qo))),Xt(this,Kn,performance.now()-Et(this,Ks));let n=1e3/this.fps;if(Et(this,Kn)>n){Xt(this,Ks,s-Et(this,Kn)%n);let a=1e3/((s-Et(this,Go))/++K_(this,Vo)._),o=(s-Et(this,Wo))/1e3/this.duration,l=Et(this,Ko)+o*this.playbackRate;l-Et(this,Ws).valueAsNumber>0?Xt(this,qs,this.playbackRate/this.duration/a):(Xt(this,qs,.995*Et(this,qs)),l=Et(this,Ws).valueAsNumber+Et(this,qs)),this.callback(l)}}),Xt(this,Ws,e),this.callback=t,this.fps=r}start(){Et(this,Vr)===0&&(Xt(this,Ks,performance.now()),Xt(this,Go,Et(this,Ks)),Xt(this,Vo,0),Et(this,qo).call(this))}stop(){Et(this,Vr)!==0&&(cancelAnimationFrame(Et(this,Vr)),Xt(this,Vr,0))}update({start:e,duration:t,playbackRate:r}){let s=e-Et(this,Ws).valueAsNumber;(s>0||s<-.03)&&this.callback(e),Xt(this,Ko,e),Xt(this,Wo,performance.now()),this.duration=t,this.playbackRate=r}};Ws=new WeakMap;Go=new WeakMap;Ks=new WeakMap;Kn=new WeakMap;Vo=new WeakMap;Wo=new WeakMap;Ko=new WeakMap;qs=new WeakMap;Vr=new WeakMap;qo=new WeakMap;var yu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},bt=(i,e,t)=>(yu(i,e,"read from private field"),t?t.call(i):e.get(i)),Rt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ni=(i,e,t,r)=>(yu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ii=(i,e,t)=>(yu(i,e,"access private method"),t),Ys,Wr,zo,jn,Xo,qn,Qo,Zo,js,zs,Yn,Tu,f0,gu,Jo,_u,vu,m0,zn,el,Eu,p0,q_="video not loaded, unknown time.",Y_=i=>{let e=i.range,t=Nr(+v0(i)),r=Nr(+i.mediaSeekableEnd),s=t&&r?`${t} of ${r}`:q_;e.setAttribute("aria-valuetext",s)},g0=q.createElement("template");g0.innerHTML=`
686
723
  <style>
687
724
  :host {
688
725
  --media-preview-border-radius: 3px;
@@ -702,6 +739,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
702
739
  left: 0;
703
740
  bottom: 100%;
704
741
  pointer-events: none;
742
+ will-change: transform;
705
743
  }
706
744
 
707
745
  [part~="box"] {
@@ -722,7 +760,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
722
760
  opacity: 0;
723
761
  }
724
762
 
725
- :host(:is([${S.MEDIA_PREVIEW_IMAGE}], [${S.MEDIA_PREVIEW_TIME}])[dragging]) [part~="preview-box"] {
763
+ :host(:is([${A.MEDIA_PREVIEW_IMAGE}], [${A.MEDIA_PREVIEW_TIME}])[dragging]) [part~="preview-box"] {
726
764
  transition-duration: var(--media-preview-transition-duration-in, .5s);
727
765
  transition-delay: var(--media-preview-transition-delay-in, .25s);
728
766
  visibility: visible;
@@ -730,7 +768,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
730
768
  }
731
769
 
732
770
  @media (hover: hover) {
733
- :host(:is([${S.MEDIA_PREVIEW_IMAGE}], [${S.MEDIA_PREVIEW_TIME}]):hover) [part~="preview-box"] {
771
+ :host(:is([${A.MEDIA_PREVIEW_IMAGE}], [${A.MEDIA_PREVIEW_TIME}]):hover) [part~="preview-box"] {
734
772
  transition-duration: var(--media-preview-transition-duration-in, .5s);
735
773
  transition-delay: var(--media-preview-transition-delay-in, .25s);
736
774
  visibility: visible;
@@ -755,26 +793,58 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
755
793
  var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0);
756
794
  }
757
795
 
758
- :host([${S.MEDIA_PREVIEW_IMAGE}][dragging]) media-preview-thumbnail,
759
- :host([${S.MEDIA_PREVIEW_IMAGE}][dragging]) ::slotted(media-preview-thumbnail) {
796
+ :host([${A.MEDIA_PREVIEW_IMAGE}][dragging]) media-preview-thumbnail,
797
+ :host([${A.MEDIA_PREVIEW_IMAGE}][dragging]) ::slotted(media-preview-thumbnail) {
760
798
  transition-delay: var(--media-preview-transition-delay-in, .25s);
761
799
  visibility: visible;
762
800
  }
763
801
 
764
802
  @media (hover: hover) {
765
- :host([${S.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail,
766
- :host([${S.MEDIA_PREVIEW_IMAGE}]:hover) ::slotted(media-preview-thumbnail) {
803
+ :host([${A.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail,
804
+ :host([${A.MEDIA_PREVIEW_IMAGE}]:hover) ::slotted(media-preview-thumbnail) {
767
805
  transition-delay: var(--media-preview-transition-delay-in, .25s);
768
806
  visibility: visible;
769
807
  }
770
808
 
771
- :host([${S.MEDIA_PREVIEW_TIME}]:hover) {
809
+ :host([${A.MEDIA_PREVIEW_TIME}]:hover) {
772
810
  --media-time-range-hover-display: block;
773
811
  }
774
812
  }
775
813
 
814
+ media-preview-chapter-display,
815
+ ::slotted(media-preview-chapter-display) {
816
+ display: none;
817
+ line-height: 1.3;
818
+ min-width: 0;
819
+
820
+ transition: min-width 0s, border-radius 0s, margin 0s, padding 0s;
821
+ transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
822
+ background: var(--media-preview-chapter-background, var(--media-preview-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)))));
823
+ border-radius: var(--media-preview-chapter-border-radius,
824
+ var(--media-preview-border-radius) var(--media-preview-border-radius)
825
+ var(--media-preview-border-radius) var(--media-preview-border-radius));
826
+ padding: var(--media-preview-chapter-padding, 4px 10px);
827
+ margin: var(--media-preview-chapter-margin, 0 0 5px);
828
+ text-shadow: var(--media-preview-chapter-text-shadow, 0 0 4px rgb(0 0 0 / .75));
829
+ }
830
+
831
+ :host([${A.MEDIA_PREVIEW_IMAGE}]) media-preview-chapter-display,
832
+ :host([${A.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-chapter-display) {
833
+ transition-delay: var(--media-preview-transition-delay-in, .25s);
834
+ border-radius: var(--media-preview-chapter-border-radius, 0);
835
+ padding: var(--media-preview-chapter-padding, 4px 10px 0);
836
+ margin: var(--media-preview-chapter-margin, 0);
837
+ min-width: 100%;
838
+ }
839
+
840
+ media-preview-chapter-display[${A.MEDIA_PREVIEW_CHAPTER}]:not([${A.MEDIA_PREVIEW_CHAPTER}=""]),
841
+ ::slotted(media-preview-chapter-display[${A.MEDIA_PREVIEW_CHAPTER}]:not([${A.MEDIA_PREVIEW_CHAPTER}=""])) {
842
+ display: initial;
843
+ }
844
+
776
845
  media-preview-time-display,
777
846
  ::slotted(media-preview-time-display) {
847
+ line-height: 1.3;
778
848
  min-width: 0;
779
849
 
780
850
  transition: min-width 0s, border-radius 0s;
@@ -783,22 +853,27 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
783
853
  border-radius: var(--media-preview-time-border-radius,
784
854
  var(--media-preview-border-radius) var(--media-preview-border-radius)
785
855
  var(--media-preview-border-radius) var(--media-preview-border-radius));
786
- padding: var(--media-preview-time-padding, 1px 10px 0);
856
+ padding: var(--media-preview-time-padding, 4px 10px);
787
857
  margin: var(--media-preview-time-margin, 0 0 10px);
788
858
  text-shadow: var(--media-preview-time-text-shadow, 0 0 4px rgb(0 0 0 / .75));
789
859
  }
790
860
 
791
- :host([${S.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display,
792
- :host([${S.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) {
861
+ :host([${A.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display,
862
+ :host([${A.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) {
793
863
  transition-delay: var(--media-preview-transition-delay-in, .25s);
794
- min-width: 100%;
795
864
  border-radius: var(--media-preview-time-border-radius,
796
865
  0 0 var(--media-preview-border-radius) var(--media-preview-border-radius));
866
+ min-width: 100%;
867
+ }
868
+
869
+ :host([${A.MEDIA_PREVIEW_TIME}]:hover) {
870
+ --media-time-range-hover-display: block;
797
871
  }
798
872
  </style>
799
873
  <div id="preview-rail">
800
874
  <slot name="preview" part="box preview-box">
801
875
  <media-preview-thumbnail></media-preview-thumbnail>
876
+ <media-preview-chapter-display></media-preview-chapter-display>
802
877
  <media-preview-time-display></media-preview-time-display>
803
878
  </slot>
804
879
  </div>
@@ -807,7 +882,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
807
882
 
808
883
  </slot>
809
884
  </div>
810
- `;var e0=(i,e=i.mediaCurrentTime)=>{if(Number.isNaN(i.mediaSeekableEnd))return 0;let t=(e-i.mediaSeekableStart)/(i.mediaSeekableEnd-i.mediaSeekableStart);return Math.max(0,Math.min(t,1))},n0=(i,e=i.range.valueAsNumber)=>Number.isNaN(i.mediaSeekableEnd)?0:e*(i.mediaSeekableEnd-i.mediaSeekableStart)+i.mediaSeekableStart,cu=class extends Gr{constructor(){super(),Bt(this,qs),Bt(this,hu),Bt(this,Ko),Bt(this,lu),Bt(this,qn),Bt(this,du),Bt(this,Ks,void 0),Bt(this,Vr,void 0),Bt(this,Go,void 0),Bt(this,Ho,void 0),Bt(this,Wn,void 0),Bt(this,Vo,void 0),Bt(this,Wo,void 0),Bt(this,ou,t=>{this.dragging||(this.range.valueAsNumber=t,this.updateBar())}),this.container.appendChild(s0.content.cloneNode(!0)),fr(this,Go,this.shadowRoot.querySelectorAll('[part~="box"]')),fr(this,Ho,this.shadowRoot.querySelector('[part~="preview-box"]')),fr(this,Wn,this.shadowRoot.querySelector('[part~="current-box"]'));let e=getComputedStyle(this);fr(this,Vo,parseInt(e.getPropertyValue("--media-box-padding-left"))),fr(this,Wo,parseInt(e.getPropertyValue("--media-box-padding-right"))),fr(this,Vr,new $o(this.range,zt(this,ou),60))}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PAUSED,S.MEDIA_DURATION,S.MEDIA_SEEKABLE,S.MEDIA_CURRENT_TIME,S.MEDIA_PREVIEW_IMAGE,S.MEDIA_PREVIEW_TIME,S.MEDIA_BUFFERED,S.MEDIA_PLAYBACK_RATE,S.MEDIA_LOADING,S.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",St.SEEK()),ti(this,qs,Kn).call(this),fr(this,Ks,this.getRootNode()),(e=zt(this,Ks))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),ti(this,qs,Kn).call(this),(e=zt(this,Ks))==null||e.removeEventListener("transitionstart",this),fr(this,Ks,null)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),t!=r&&(e===S.MEDIA_CURRENT_TIME||e===S.MEDIA_PAUSED||e===S.MEDIA_ENDED||e===S.MEDIA_LOADING||e===S.MEDIA_DURATION||e===S.MEDIA_SEEKABLE?(zt(this,Vr).update({start:e0(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),ti(this,qs,Kn).call(this),k_(this)):e===S.MEDIA_BUFFERED&&this.updateBufferedBar())}get mediaPaused(){return Be(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ne(this,S.MEDIA_PAUSED,e)}get mediaLoading(){return Be(this,S.MEDIA_LOADING)}set mediaLoading(e){Ne(this,S.MEDIA_LOADING,e)}get mediaDuration(){return Fe(this,S.MEDIA_DURATION)}set mediaDuration(e){Ke(this,S.MEDIA_DURATION,e)}get mediaCurrentTime(){return Fe(this,S.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){Ke(this,S.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return Fe(this,S.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){Ke(this,S.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(S.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(S.MEDIA_BUFFERED);return}let t=e.map(r=>r.join(":")).join(" ");this.setAttribute(S.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(S.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(S.MEDIA_SEEKABLE);return}this.setAttribute(S.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return He(this,S.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){$e(this,S.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return Fe(this,S.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){Ke(this,S.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return Be(this,S.MEDIA_ENDED)}set mediaEnded(e){Ne(this,S.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let r;if(this.mediaEnded)r=1;else{let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];r=e0(this,a)}let{style:s}=ze(this.shadowRoot,"#highlight");s.setProperty("width",`${r*100}%`)}updateCurrentBox(){if(!zt(this,Wn).assignedElements().length)return;let e=ti(this,Ko,fu).call(this,zt(this,Wn),this.range.valueAsNumber),{style:t}=ze(this.shadowRoot,"#current-rail");t.transform=`translateX(${e})`}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":ti(this,du,r0).call(this);break;case"pointermove":ti(this,lu,i0).call(this,e);break;case"pointerup":case"pointerleave":ti(this,qn,qo).call(this,null);break;case"transitionstart":or(e.target,this)&&setTimeout(()=>ti(this,qs,Kn).call(this),0);break}}};Ks=new WeakMap;Vr=new WeakMap;Go=new WeakMap;Ho=new WeakMap;Wn=new WeakMap;Vo=new WeakMap;Wo=new WeakMap;qs=new WeakSet;Kn=function(){ti(this,hu,t0).call(this)?zt(this,Vr).start():zt(this,Vr).stop()};hu=new WeakSet;t0=function(){return this.isConnected&&Mp(this)&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded};ou=new WeakMap;Ko=new WeakSet;fu=function(i,e){var t;let r=`${e*100*100}%`,s=i.offsetWidth;if(!s)return r;let n=(t=this.getAttribute("bounds")?lr(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?t:this,a=this.range.getBoundingClientRect(),o=n.getBoundingClientRect(),l=(zt(this,Vo)-(a.left-o.left-s/2))/a.width*100,d=(o.right-a.left-s/2-zt(this,Wo))/a.width*100;return Number.isNaN(l)||(r=`max(${l*100}%, ${r})`),Number.isNaN(d)||(r=`min(${r}, ${d*100}%)`),r};lu=new WeakSet;i0=function(i){let e=[...zt(this,Go)].some(o=>i.composedPath().includes(o));if(!this.dragging&&(e||!i.composedPath().includes(this))){ti(this,qn,qo).call(this,null);return}let t=this.mediaDuration;if(!t)return;let r=this.range.getBoundingClientRect(),s=(i.clientX-r.left)/r.width;s=Math.max(0,Math.min(1,s));let n=ti(this,Ko,fu).call(this,zt(this,Ho),s),{style:a}=ze(this.shadowRoot,"#preview-rail");a.transform=`translateX(${n})`,ti(this,qn,qo).call(this,s*t)};qn=new WeakSet;qo=function(i){this.dispatchEvent(new D.CustomEvent(ee.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};du=new WeakSet;r0=function(){zt(this,Vr).stop();let i=n0(this);this.dispatchEvent(new D.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};D.customElements.get("media-time-range")||D.customElements.define("media-time-range",cu);var o0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ys=(i,e,t)=>(o0(i,e,"read from private field"),t?t.call(i):e.get(i)),mu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},js=(i,e,t,r)=>(o0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mi,Yo,jo,a0={LOADING_DELAY:"loadingdelay"},l0=500,d0=q.createElement("template"),w_=`
885
+ `;var jo=(i,e=i.mediaCurrentTime)=>{if(Number.isNaN(i.mediaSeekableEnd))return 0;let t=(e-i.mediaSeekableStart)/(i.mediaSeekableEnd-i.mediaSeekableStart);return Math.max(0,Math.min(t,1))},v0=(i,e=i.range.valueAsNumber)=>Number.isNaN(i.mediaSeekableEnd)?0:e*(i.mediaSeekableEnd-i.mediaSeekableStart)+i.mediaSeekableStart,bu=class extends Gr{constructor(){super(),Rt(this,zs),Rt(this,Tu),Rt(this,Jo),Rt(this,vu),Rt(this,zn),Rt(this,Eu),Rt(this,Ys,void 0),Rt(this,Wr,void 0),Rt(this,zo,void 0),Rt(this,jn,void 0),Rt(this,Xo,void 0),Rt(this,qn,void 0),Rt(this,Qo,void 0),Rt(this,Zo,void 0),Rt(this,js,void 0),Rt(this,gu,t=>{this.dragging||(this.range.valueAsNumber=t,this.updateBar())}),this.container.appendChild(g0.content.cloneNode(!0)),Ni(this,zo,this.shadowRoot.querySelectorAll('[part~="box"]')),Ni(this,Xo,this.shadowRoot.querySelector('[part~="preview-box"]')),Ni(this,qn,this.shadowRoot.querySelector('[part~="current-box"]'));let e=getComputedStyle(this);Ni(this,Qo,parseInt(e.getPropertyValue("--media-box-padding-left"))),Ni(this,Zo,parseInt(e.getPropertyValue("--media-box-padding-right"))),Ni(this,Wr,new Yo(this.range,bt(this,gu),60))}static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_PAUSED,A.MEDIA_DURATION,A.MEDIA_SEEKABLE,A.MEDIA_CURRENT_TIME,A.MEDIA_PREVIEW_IMAGE,A.MEDIA_PREVIEW_TIME,A.MEDIA_PREVIEW_CHAPTER,A.MEDIA_BUFFERED,A.MEDIA_PLAYBACK_RATE,A.MEDIA_LOADING,A.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",Lt.SEEK()),ii(this,zs,Yn).call(this),Ni(this,Ys,this.getRootNode()),(e=bt(this,Ys))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),ii(this,zs,Yn).call(this),(e=bt(this,Ys))==null||e.removeEventListener("transitionstart",this),Ni(this,Ys,null)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),t!=r&&(e===A.MEDIA_CURRENT_TIME||e===A.MEDIA_PAUSED||e===A.MEDIA_ENDED||e===A.MEDIA_LOADING||e===A.MEDIA_DURATION||e===A.MEDIA_SEEKABLE?(bt(this,Wr).update({start:jo(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),ii(this,zs,Yn).call(this),Y_(this)):e===A.MEDIA_BUFFERED&&this.updateBufferedBar(),e===A.MEDIA_DURATION&&(this.mediaChaptersCues=bt(this,js)))}get mediaChaptersCues(){return bt(this,js)}set mediaChaptersCues(e){var t;Ni(this,js,e),this.updateSegments((t=bt(this,js))==null?void 0:t.map(r=>({start:jo(this,r.startTime),end:jo(this,r.endTime)})))}get mediaPaused(){return He(this,A.MEDIA_PAUSED)}set mediaPaused(e){Ue(this,A.MEDIA_PAUSED,e)}get mediaLoading(){return He(this,A.MEDIA_LOADING)}set mediaLoading(e){Ue(this,A.MEDIA_LOADING,e)}get mediaDuration(){return $e(this,A.MEDIA_DURATION)}set mediaDuration(e){Ke(this,A.MEDIA_DURATION,e)}get mediaCurrentTime(){return $e(this,A.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){Ke(this,A.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return $e(this,A.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){Ke(this,A.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(A.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(A.MEDIA_BUFFERED);return}let t=e.map(r=>r.join(":")).join(" ");this.setAttribute(A.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(A.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(A.MEDIA_SEEKABLE);return}this.setAttribute(A.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return Fe(this,A.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Oe(this,A.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return $e(this,A.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){Ke(this,A.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return He(this,A.MEDIA_ENDED)}set mediaEnded(e){Ue(this,A.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let r;if(this.mediaEnded)r=1;else{let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];r=jo(this,a)}let{style:s}=Ye(this.shadowRoot,"#highlight");s.setProperty("width",`${r*100}%`)}updateCurrentBox(){if(!bt(this,qn).assignedElements().length)return;let e=ii(this,Jo,_u).call(this,bt(this,qn),this.range.valueAsNumber),{style:t}=Ye(this.shadowRoot,"#current-rail");t.transform=`translateX(${e})`}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":ii(this,Eu,p0).call(this);break;case"pointermove":ii(this,vu,m0).call(this,e);break;case"pointerup":case"pointerleave":ii(this,zn,el).call(this,null);break;case"transitionstart":lr(e.target,this)&&setTimeout(()=>ii(this,zs,Yn).call(this),0);break}}};Ys=new WeakMap;Wr=new WeakMap;zo=new WeakMap;jn=new WeakMap;Xo=new WeakMap;qn=new WeakMap;Qo=new WeakMap;Zo=new WeakMap;js=new WeakMap;zs=new WeakSet;Yn=function(){ii(this,Tu,f0).call(this)?bt(this,Wr).start():bt(this,Wr).stop()};Tu=new WeakSet;f0=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaDuration>0&&Gp(this)};gu=new WeakMap;Jo=new WeakSet;_u=function(i,e){var t;let r=`${e*100*100}%`,s=i.offsetWidth;if(!s)return r;let n=(t=this.getAttribute("bounds")?dr(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?t:this,a=this.range.getBoundingClientRect(),o=n.getBoundingClientRect(),l=(bt(this,Qo)-(a.left-o.left-s/2))/a.width*100,d=(o.right-a.left-s/2-bt(this,Zo))/a.width*100;return Number.isNaN(l)||(r=`max(${l*100}%, ${r})`),Number.isNaN(d)||(r=`min(${r}, ${d*100}%)`),r};vu=new WeakSet;m0=function(i){let e=[...bt(this,zo)].some(l=>i.composedPath().includes(l));if(!this.dragging&&(e||!i.composedPath().includes(this))){ii(this,zn,el).call(this,null);return}let t=this.mediaDuration;if(!t)return;let r=this.range.getBoundingClientRect(),s=(i.clientX-r.left)/r.width;s=Math.max(0,Math.min(1,s));let n=ii(this,Jo,_u).call(this,bt(this,Xo),s),{style:a}=Ye(this.shadowRoot,"#preview-rail");a.transform=`translateX(${n})`;let o=Math.round(bt(this,jn))-Math.round(s*t);Math.abs(o)<1||(Ni(this,jn,s*t),ii(this,zn,el).call(this,bt(this,jn)))};zn=new WeakSet;el=function(i){this.dispatchEvent(new w.CustomEvent(ee.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};Eu=new WeakSet;p0=function(){bt(this,Wr).stop();let i=v0(this);this.dispatchEvent(new w.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};w.customElements.get("media-time-range")||w.customElements.define("media-time-range",bu);var y0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Xn=(i,e,t)=>(y0(i,e,"read from private field"),t?t.call(i):e.get(i)),E0=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Qn=(i,e,t,r)=>(y0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ui,tl,b0={LOADING_DELAY:"loadingdelay"},T0=500,_0=q.createElement("template"),j_=`
811
886
  <svg aria-hidden="true" viewBox="0 0 100 100">
812
887
  <path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
813
888
  <animateTransform
@@ -820,13 +895,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
820
895
  repeatCount="indefinite" />
821
896
  </path>
822
897
  </svg>
823
- `;d0.innerHTML=`
898
+ `;_0.innerHTML=`
824
899
  <style>
825
900
  :host {
826
901
  display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
827
902
  vertical-align: middle;
828
903
  box-sizing: border-box;
829
- --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${l0}ms);
904
+ --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${T0}ms);
830
905
  }
831
906
 
832
907
  #status {
@@ -841,8 +916,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
841
916
  transition: opacity 0.15s;
842
917
  }
843
918
 
844
- :host([${S.MEDIA_LOADING}]:not([${S.MEDIA_PAUSED}])) slot[name=icon] > *,
845
- :host([${S.MEDIA_LOADING}]:not([${S.MEDIA_PAUSED}])) ::slotted([slot=icon]) {
919
+ :host([${A.MEDIA_LOADING}]:not([${A.MEDIA_PAUSED}])) slot[name=icon] > *,
920
+ :host([${A.MEDIA_LOADING}]:not([${A.MEDIA_PAUSED}])) ::slotted([slot=icon]) {
846
921
  opacity: var(--media-loading-indicator-opacity, 1);
847
922
  transition: opacity 0.15s var(--_loading-indicator-delay);
848
923
  }
@@ -852,7 +927,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
852
927
  transition: visibility 0.15s;
853
928
  }
854
929
 
855
- :host([${S.MEDIA_LOADING}]:not([${S.MEDIA_PAUSED}])) #status {
930
+ :host([${A.MEDIA_LOADING}]:not([${A.MEDIA_PAUSED}])) #status {
856
931
  visibility: var(--media-loading-indicator-opacity, visible);
857
932
  transition: visibility 0.15s var(--_loading-indicator-delay);
858
933
  }
@@ -865,12 +940,12 @@ svg, img, ::slotted(svg), ::slotted(img) {
865
940
  }
866
941
  </style>
867
942
 
868
- <slot name="icon">${w_}</slot>
869
- <div id="status" role="status" aria-live="polite">${St.MEDIA_LOADING()}</div>
870
- `;var pu=class extends D.HTMLElement{constructor(){if(super(),mu(this,Mi,void 0),mu(this,Yo,l0),mu(this,jo,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),r=d0.content.cloneNode(!0);t.appendChild(r)}let{style:e}=ze(this.shadowRoot,":host");js(this,jo,e)}static get observedAttributes(){return[me.MEDIA_CONTROLLER,S.MEDIA_PAUSED,S.MEDIA_LOADING,a0.LOADING_DELAY]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===a0.LOADING_DELAY&&t!==r?this.loadingDelay=Number(r):e===me.MEDIA_CONTROLLER&&(t&&((n=(s=Ys(this,Mi))==null?void 0:s.unassociateElement)==null||n.call(s,this),js(this,Mi,null)),r&&this.isConnected&&(js(this,Mi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Ys(this,Mi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(js(this,Mi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Ys(this,Mi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Ys(this,Mi))==null?void 0:e.unassociateElement)==null||t.call(e,this),js(this,Mi,null)}get loadingDelay(){return Ys(this,Yo)}set loadingDelay(e){js(this,Yo,e),Ys(this,jo).setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return Be(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ne(this,S.MEDIA_PAUSED,e)}get mediaLoading(){return Be(this,S.MEDIA_LOADING)}set mediaLoading(e){Ne(this,S.MEDIA_LOADING,e)}};Mi=new WeakMap;Yo=new WeakMap;jo=new WeakMap;D.customElements.get("media-loading-indicator")||D.customElements.define("media-loading-indicator",pu);var D_=1,C_=i=>i.mediaMuted?0:i.mediaVolume,M_=({value:i})=>`${Math.round(i*100)}%`,gu=class extends Gr{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_VOLUME,S.MEDIA_MUTED,S.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new D.CustomEvent(ee.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",St.VOLUME())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),(e===S.MEDIA_VOLUME||e===S.MEDIA_MUTED)&&(this.range.valueAsNumber=C_(this),this.range.setAttribute("aria-valuetext",M_(this.range)),this.updateBar())}get mediaVolume(){return Fe(this,S.MEDIA_VOLUME,D_)}set mediaVolume(e){Ke(this,S.MEDIA_VOLUME,e)}get mediaMuted(){return Be(this,S.MEDIA_MUTED)}set mediaMuted(e){Ne(this,S.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return He(this,S.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){$e(this,S.MEDIA_VOLUME_UNAVAILABLE,e)}};D.customElements.get("media-volume-range")||D.customElements.define("media-volume-range",gu);var _u=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},bt=(i,e,t)=>(_u(i,e,"read from private field"),t?t.call(i):e.get(i)),Xt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},mi=(i,e,t,r)=>(_u(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),fi=(i,e,t)=>(_u(i,e,"access private method"),t),Pi,mr,Xs,Yn,zo,Xo,vu,zs,Eu,Qo,bu,jn,Zo,Jo,yu,Tu,c0,Au,u0,P_=`
943
+ <slot name="icon">${j_}</slot>
944
+ <div id="status" role="status" aria-live="polite">${Lt.MEDIA_LOADING()}</div>
945
+ `;var Au=class extends w.HTMLElement{constructor(){if(super(),E0(this,Ui,void 0),E0(this,tl,T0),!this.shadowRoot){let e=this.attachShadow({mode:"open"}),t=_0.content.cloneNode(!0);e.appendChild(t)}}static get observedAttributes(){return[me.MEDIA_CONTROLLER,A.MEDIA_PAUSED,A.MEDIA_LOADING,b0.LOADING_DELAY]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===b0.LOADING_DELAY&&t!==r?this.loadingDelay=Number(r):e===me.MEDIA_CONTROLLER&&(t&&((n=(s=Xn(this,Ui))==null?void 0:s.unassociateElement)==null||n.call(s,this),Qn(this,Ui,null)),r&&this.isConnected&&(Qn(this,Ui,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Xn(this,Ui))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(Qn(this,Ui,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Xn(this,Ui))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Xn(this,Ui))==null?void 0:e.unassociateElement)==null||t.call(e,this),Qn(this,Ui,null)}get loadingDelay(){return Xn(this,tl)}set loadingDelay(e){Qn(this,tl,e);let{style:t}=Ye(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return He(this,A.MEDIA_PAUSED)}set mediaPaused(e){Ue(this,A.MEDIA_PAUSED,e)}get mediaLoading(){return He(this,A.MEDIA_LOADING)}set mediaLoading(e){Ue(this,A.MEDIA_LOADING,e)}};Ui=new WeakMap;tl=new WeakMap;w.customElements.get("media-loading-indicator")||w.customElements.define("media-loading-indicator",Au);var z_=1,X_=i=>i.mediaMuted?0:i.mediaVolume,Q_=({value:i})=>`${Math.round(i*100)}%`,Su=class extends Gr{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_VOLUME,A.MEDIA_MUTED,A.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new w.CustomEvent(ee.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",Lt.VOLUME())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),(e===A.MEDIA_VOLUME||e===A.MEDIA_MUTED)&&(this.range.valueAsNumber=X_(this),this.range.setAttribute("aria-valuetext",Q_(this.range)),this.updateBar())}get mediaVolume(){return $e(this,A.MEDIA_VOLUME,z_)}set mediaVolume(e){Ke(this,A.MEDIA_VOLUME,e)}get mediaMuted(){return He(this,A.MEDIA_MUTED)}set mediaMuted(e){Ue(this,A.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return Fe(this,A.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){Oe(this,A.MEDIA_VOLUME_UNAVAILABLE,e)}};w.customElements.get("media-volume-range")||w.customElements.define("media-volume-range",Su);var wu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},_t=(i,e,t)=>(wu(i,e,"read from private field"),t?t.call(i):e.get(i)),Qt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},vi=(i,e,t,r)=>(wu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),gi=(i,e,t)=>(wu(i,e,"access private method"),t),Fi,pr,Qs,Zn,il,rl,xu,Xs,Iu,sl,Lu,Jn,nl,al,Ru,ku,A0,Du,S0,Z_=`
871
946
  <svg aria-hidden="true" viewBox="0 1 24 24" part="select-indicator indicator">
872
947
  <path d="m10 15.17 9.193-9.191 1.414 1.414-10.606 10.606-6.364-6.364 1.414-1.414 4.95 4.95Z"/>
873
- </svg>`;function Oi(i,e,t){let r=q.createElement("media-chrome-option");r.part.add("option"),r.value=e,r.selected=t;let s=q.createElement("span");return s.textContent=i,r.append(s),r}function pi(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);return(t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t?(t=t.cloneNode(!0),t.removeAttribute("slot"),t):i.shadowRoot.querySelector(`[name="${e}"] > svg`).cloneNode(!0)}var h0=q.createElement("template");h0.innerHTML=`
948
+ </svg>`;function Bi(i,e,t){let r=q.createElement("media-chrome-option");r.part.add("option"),r.value=e,r.selected=t;let s=q.createElement("span");return s.textContent=i,r.append(s),r}function Ei(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);return(t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t?(t=t.cloneNode(!0),t.removeAttribute("slot"),t):i.shadowRoot.querySelector(`[name="${e}"] > svg`).cloneNode(!0)}var x0=q.createElement("template");x0.innerHTML=`
874
949
  <style>
875
950
  :host {
876
951
  font: var(--media-font,
@@ -949,8 +1024,8 @@ svg, img, ::slotted(svg), ::slotted(img) {
949
1024
  </style>
950
1025
  <slot name="header"></slot>
951
1026
  <slot id="container"></slot>
952
- <slot name="select-indicator" hidden>${P_}</slot>
953
- `;var ii=class extends D.HTMLElement{constructor(e={}){super(),Xt(this,Xo),Xt(this,Qo),Xt(this,jn),Xt(this,Jo),Xt(this,Tu),Xt(this,Au),Xt(this,Pi,void 0),Xt(this,mr,""),Xt(this,Xs,null),Xt(this,Yn,!1),Xt(this,zo,t=>{this.handleClick(t)}),Xt(this,zs,t=>{let{key:r}=t;if(r==="Escape"){this.removeEventListener("keyup",bt(this,zs));return}if(r==="Meta"){mi(this,Yn,!1);return}fi(this,Xo,vu).call(this,t)}),Xt(this,Eu,t=>{let{key:r,altKey:s}=t;if(s){this.removeEventListener("keyup",bt(this,zs));return}if(r==="Meta"){mi(this,Yn,!0);return}if(this.keysUsed.includes(r)&&t.preventDefault(),bt(this,Yn)&&this.keysUsed.includes(r)){fi(this,Xo,vu).call(this,t);return}this.addEventListener("keyup",bt(this,zs),{once:!0})}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=h0.content.cloneNode(!0),e.slotTemplate&&this.nativeEl.append(e.slotTemplate.content.cloneNode(!0)),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.container.addEventListener("slotchange",t=>{for(let r of t.target.assignedNodes({flatten:!0}))r.nodeType===3&&r.textContent.trim()===""&&r.remove()})}static get observedAttributes(){return["disabled","style",me.MEDIA_CONTROLLER]}static formatOptionText(e){return e}formatOptionText(e,t){return this.constructor.formatOptionText(e,t)}get options(){var e;let t=this.querySelectorAll("media-chrome-option");return t.length||(t=(e=this.container)==null?void 0:e.querySelectorAll("media-chrome-option")),Array.from(t)}get selectedOptions(){return this.options.filter(e=>e.selected)}get value(){var e,t;return(t=(e=this.selectedOptions[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.options.find(r=>r.value===e);t&&fi(this,Jo,yu).call(this,t)}focus(){var e;(e=this.selectedOptions[0])==null||e.focus()}enable(){this.addEventListener("click",bt(this,zo)),this.addEventListener("keydown",bt(this,Eu))}disable(){this.removeEventListener("click",bt(this,zo)),this.removeEventListener("keyup",bt(this,zs))}attributeChangedCallback(e,t,r){var s,n,a,o,l;e==="style"&&r!==t?fi(this,Qo,bu).call(this):e===me.MEDIA_CONTROLLER?(t&&((n=(s=bt(this,Pi))==null?void 0:s.unassociateElement)==null||n.call(s,this),mi(this,Pi,null)),r&&this.isConnected&&(mi(this,Pi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=bt(this,Pi))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;fi(this,Qo,bu).call(this),this.hasAttribute("disabled")||this.enable(),this.hasAttribute("role")||this.setAttribute("role","listbox");let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(mi(this,Pi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=bt(this,Pi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=bt(this,Pi))==null?void 0:e.unassociateElement)==null||t.call(e,this),mi(this,Pi,null)}get keysUsed(){return["Enter"," ","ArrowDown","ArrowUp","Home","End"]}handleSelection(e,t){let r=fi(this,jn,Zo).call(this,e);r&&fi(this,Jo,yu).call(this,r,t)}handleMovement(e){let{key:t}=e,r=this.options,s=fi(this,jn,Zo).call(this,e);s||(s=r.filter(a=>a.getAttribute("tabindex")==="0")[0]);let n;switch(t){case"ArrowDown":n=s.nextElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.nextElementSibling);break;case"ArrowUp":n=s.previousElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.previousElementSibling);break;case"Home":n=r[0];break;case"End":n=r[r.length-1];break;default:n=fi(this,Tu,c0).call(this,t);break}n&&(r.forEach(a=>a.setAttribute("tabindex","-1")),n.setAttribute("tabindex","0"),n.focus())}handleClick(e){let t=fi(this,jn,Zo).call(this,e);!t||t.hasAttribute("disabled")||(this.options.forEach(r=>r.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0"),this.handleSelection(e,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"))}};Pi=new WeakMap;mr=new WeakMap;Xs=new WeakMap;Yn=new WeakMap;zo=new WeakMap;Xo=new WeakSet;vu=function(i){let{key:e}=i;e==="Enter"||e===" "?this.handleSelection(i,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"):this.handleMovement(i)};zs=new WeakMap;Eu=new WeakMap;Qo=new WeakSet;bu=function(){var i;let e=this.shadowRoot.querySelector("#layout-row"),t=((i=getComputedStyle(this).getPropertyValue("--media-listbox-layout"))==null?void 0:i.trim())==="row";e.setAttribute("media",t?"":"width:0")};jn=new WeakSet;Zo=function(i){let e=i.composedPath(),t=e.findIndex(r=>r.nodeName==="MEDIA-CHROME-OPTION");return e[t]};Jo=new WeakSet;yu=function(i,e){let t=[...this.selectedOptions];(!this.hasAttribute("aria-multiselectable")||this.getAttribute("aria-multiselectable")!=="true")&&this.options.forEach(r=>r.selected=!1),e?i.selected=!i.selected:i.selected=!0,this.selectedOptions.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};Tu=new WeakSet;c0=function(i){fi(this,Au,u0).call(this);let e=this.options,t=e.findIndex(d=>d.getAttribute("tabindex")==="0");mi(this,mr,bt(this,mr)+i);let r=bt(this,mr).split("").every(d=>d===i),s=e.slice(t+(r?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(bt(this,mr))),n=e.slice(0,t-(r?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(bt(this,mr))),a=[],o=[];return r&&(a=e.slice(t+(r?1:0)).filter(d=>d.textContent.startsWith(i)),o=e.slice(0,t-(r?1:0)).filter(d=>d.textContent.startsWith(i))),[...s,...n,...a,...o][0]};Au=new WeakSet;u0=function(){clearTimeout(bt(this,Xs)),mi(this,Xs,null),mi(this,Xs,setTimeout(()=>{mi(this,mr,""),mi(this,Xs,null)},500))};D.customElements.get("media-chrome-listbox")||D.customElements.define("media-chrome-listbox",ii);var ku=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Iu=(i,e,t)=>(ku(i,e,"read from private field"),t?t.call(i):e.get(i)),Su=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},xu=(i,e,t,r)=>(ku(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),f0=(i,e,t)=>(ku(i,e,"access private method"),t),el,Qs,tl,Lu,m0=q.createElement("template");m0.innerHTML=`
1027
+ <slot name="select-indicator" hidden>${Z_}</slot>
1028
+ `;var ri=class extends w.HTMLElement{constructor(e={}){super(),Qt(this,rl),Qt(this,sl),Qt(this,Jn),Qt(this,al),Qt(this,ku),Qt(this,Du),Qt(this,Fi,void 0),Qt(this,pr,""),Qt(this,Qs,null),Qt(this,Zn,!1),Qt(this,il,t=>{this.handleClick(t)}),Qt(this,Xs,t=>{let{key:r}=t;if(r==="Escape"){this.removeEventListener("keyup",_t(this,Xs));return}if(r==="Meta"){vi(this,Zn,!1);return}gi(this,rl,xu).call(this,t)}),Qt(this,Iu,t=>{let{key:r,altKey:s}=t;if(s){this.removeEventListener("keyup",_t(this,Xs));return}if(r==="Meta"){vi(this,Zn,!0);return}if(this.keysUsed.includes(r)&&t.preventDefault(),_t(this,Zn)&&this.keysUsed.includes(r)){gi(this,rl,xu).call(this,t);return}this.addEventListener("keyup",_t(this,Xs),{once:!0})}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=x0.content.cloneNode(!0),e.slotTemplate&&this.nativeEl.append(e.slotTemplate.content.cloneNode(!0)),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.container.addEventListener("slotchange",t=>{for(let r of t.target.assignedNodes({flatten:!0}))r.nodeType===3&&r.textContent.trim()===""&&r.remove()})}static get observedAttributes(){return["disabled","style",me.MEDIA_CONTROLLER]}static formatOptionText(e){return e}formatOptionText(e,t){return this.constructor.formatOptionText(e,t)}get options(){var e;let t=this.querySelectorAll("media-chrome-option");return t.length||(t=(e=this.container)==null?void 0:e.querySelectorAll("media-chrome-option")),Array.from(t)}get selectedOptions(){return this.options.filter(e=>e.selected)}get value(){var e,t;return(t=(e=this.selectedOptions[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.options.find(r=>r.value===e);t&&gi(this,al,Ru).call(this,t)}focus(){var e;(e=this.selectedOptions[0])==null||e.focus()}enable(){this.addEventListener("click",_t(this,il)),this.addEventListener("keydown",_t(this,Iu))}disable(){this.removeEventListener("click",_t(this,il)),this.removeEventListener("keyup",_t(this,Xs))}attributeChangedCallback(e,t,r){var s,n,a,o,l;e==="style"&&r!==t?gi(this,sl,Lu).call(this):e===me.MEDIA_CONTROLLER?(t&&((n=(s=_t(this,Fi))==null?void 0:s.unassociateElement)==null||n.call(s,this),vi(this,Fi,null)),r&&this.isConnected&&(vi(this,Fi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=_t(this,Fi))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;gi(this,sl,Lu).call(this),this.hasAttribute("disabled")||this.enable(),this.hasAttribute("role")||this.setAttribute("role","listbox");let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(vi(this,Fi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=_t(this,Fi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=_t(this,Fi))==null?void 0:e.unassociateElement)==null||t.call(e,this),vi(this,Fi,null)}get keysUsed(){return["Enter"," ","ArrowDown","ArrowUp","Home","End"]}handleSelection(e,t){let r=gi(this,Jn,nl).call(this,e);r&&gi(this,al,Ru).call(this,r,t)}handleMovement(e){let{key:t}=e,r=this.options,s=gi(this,Jn,nl).call(this,e);s||(s=r.filter(a=>a.getAttribute("tabindex")==="0")[0]);let n;switch(t){case"ArrowDown":n=s.nextElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.nextElementSibling);break;case"ArrowUp":n=s.previousElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.previousElementSibling);break;case"Home":n=r[0];break;case"End":n=r[r.length-1];break;default:n=gi(this,ku,A0).call(this,t);break}n&&(r.forEach(a=>a.setAttribute("tabindex","-1")),n.setAttribute("tabindex","0"),n.focus())}handleClick(e){let t=gi(this,Jn,nl).call(this,e);!t||t.hasAttribute("disabled")||(this.options.forEach(r=>r.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0"),this.handleSelection(e,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"))}};Fi=new WeakMap;pr=new WeakMap;Qs=new WeakMap;Zn=new WeakMap;il=new WeakMap;rl=new WeakSet;xu=function(i){let{key:e}=i;e==="Enter"||e===" "?this.handleSelection(i,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"):this.handleMovement(i)};Xs=new WeakMap;Iu=new WeakMap;sl=new WeakSet;Lu=function(){var i;let e=this.shadowRoot.querySelector("#layout-row"),t=((i=getComputedStyle(this).getPropertyValue("--media-listbox-layout"))==null?void 0:i.trim())==="row";e.setAttribute("media",t?"":"width:0")};Jn=new WeakSet;nl=function(i){let e=i.composedPath(),t=e.findIndex(r=>r.nodeName==="MEDIA-CHROME-OPTION");return e[t]};al=new WeakSet;Ru=function(i,e){let t=[...this.selectedOptions];(!this.hasAttribute("aria-multiselectable")||this.getAttribute("aria-multiselectable")!=="true")&&this.options.forEach(r=>r.selected=!1),e?i.selected=!i.selected:i.selected=!0,this.selectedOptions.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};ku=new WeakSet;A0=function(i){gi(this,Du,S0).call(this);let e=this.options,t=e.findIndex(d=>d.getAttribute("tabindex")==="0");vi(this,pr,_t(this,pr)+i);let r=_t(this,pr).split("").every(d=>d===i),s=e.slice(t+(r?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(_t(this,pr))),n=e.slice(0,t-(r?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(_t(this,pr))),a=[],o=[];return r&&(a=e.slice(t+(r?1:0)).filter(d=>d.textContent.startsWith(i)),o=e.slice(0,t-(r?1:0)).filter(d=>d.textContent.startsWith(i))),[...s,...n,...a,...o][0]};Du=new WeakSet;S0=function(){clearTimeout(_t(this,Qs)),vi(this,Qs,null),vi(this,Qs,setTimeout(()=>{vi(this,pr,""),vi(this,Qs,null)},500))};w.customElements.get("media-chrome-listbox")||w.customElements.define("media-chrome-listbox",ri);var Uu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Pu=(i,e,t)=>(Uu(i,e,"read from private field"),t?t.call(i):e.get(i)),Cu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Mu=(i,e,t,r)=>(Uu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),I0=(i,e,t)=>(Uu(i,e,"access private method"),t),ol,Zs,ll,Ou,L0=q.createElement("template");L0.innerHTML=`
954
1029
  <style>
955
1030
  :host {
956
1031
  cursor: pointer;
@@ -988,7 +1063,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
988
1063
  }
989
1064
  </style>
990
1065
  <slot></slot>
991
- `;var pr={VALUE:"value",SELECTED:"selected",DISABLED:"disabled"},il=class extends D.HTMLElement{constructor(){super(),Su(this,tl),Su(this,el,!1),Su(this,Qs,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(m0.content.cloneNode(!0)))}static get observedAttributes(){return[pr.DISABLED,pr.SELECTED,pr.VALUE]}get value(){var e;return(e=this.getAttribute(pr.VALUE))!=null?e:this.text}set value(e){this.setAttribute(pr.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get selected(){return this.getAttribute("aria-selected")==="true"}set selected(e){xu(this,el,!0),this.setAttribute("aria-selected",e?"true":"false"),e?this.part.add("option-selected"):this.part.remove("option-selected")}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex",-1),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false")}disable(){this.removeAttribute("tabindex")}attributeChangedCallback(e,t,r){e===pr.SELECTED&&!Iu(this,el)?this.setAttribute("aria-selected",r!=null?"true":"false"):e===pr.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(pr.DISABLED)||this.enable(),this.setAttribute("role","option"),xu(this,Qs,Ru(this,this.parentNode)),f0(this,tl,Lu).call(this)}disconnectedCallback(){this.disable(),f0(this,tl,Lu).call(this),xu(this,Qs,null)}handleClick(){}};el=new WeakMap;Qs=new WeakMap;tl=new WeakSet;Lu=function(){var i;let e=(i=Iu(this,Qs))==null?void 0:i.options;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-selected")==="true").pop();t||(t=e[0]),Iu(this,Qs).getAttribute("aria-multiselectable")!=="true"&&e.forEach(r=>{r.setAttribute("tabindex","-1"),r.setAttribute("aria-selected","false")}),t==null||t.setAttribute("tabindex","0"),t==null||t.setAttribute("aria-selected","true")};function Ru(i,e){if(!i)return null;let{host:t}=i.getRootNode();return!e&&t?Ru(i,t):e!=null&&e.options?e:Ru(e,e==null?void 0:e.parentNode)}D.customElements.get("media-chrome-option")||D.customElements.define("media-chrome-option",il);var Du=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ie=(i,e,t)=>(Du(i,e,"read from private field"),t?t.call(i):e.get(i)),$t=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ni=(i,e,t,r)=>(Du(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Wr=(i,e,t)=>(Du(i,e,"access private method"),t),Ui,xt,zn,nt,gi,Zs,rl,sl,nl,al,ol,wu,Cu,p0,Js,Xn,Kr,g0=q.createElement("template");g0.innerHTML=`
1066
+ `;var gr={VALUE:"value",SELECTED:"selected",DISABLED:"disabled"},dl=class extends w.HTMLElement{constructor(){super(),Cu(this,ll),Cu(this,ol,!1),Cu(this,Zs,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(L0.content.cloneNode(!0)))}static get observedAttributes(){return[gr.DISABLED,gr.SELECTED,gr.VALUE]}get value(){var e;return(e=this.getAttribute(gr.VALUE))!=null?e:this.text}set value(e){this.setAttribute(gr.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get selected(){return this.getAttribute("aria-selected")==="true"}set selected(e){Mu(this,ol,!0),this.setAttribute("aria-selected",e?"true":"false"),e?this.part.add("option-selected"):this.part.remove("option-selected")}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex",-1),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false")}disable(){this.removeAttribute("tabindex")}attributeChangedCallback(e,t,r){e===gr.SELECTED&&!Pu(this,ol)?this.setAttribute("aria-selected",r!=null?"true":"false"):e===gr.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(gr.DISABLED)||this.enable(),this.setAttribute("role","option"),Mu(this,Zs,Nu(this,this.parentNode)),I0(this,ll,Ou).call(this)}disconnectedCallback(){this.disable(),I0(this,ll,Ou).call(this),Mu(this,Zs,null)}handleClick(){}};ol=new WeakMap;Zs=new WeakMap;ll=new WeakSet;Ou=function(){var i;let e=(i=Pu(this,Zs))==null?void 0:i.options;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-selected")==="true").pop();t||(t=e[0]),Pu(this,Zs).getAttribute("aria-multiselectable")!=="true"&&e.forEach(r=>{r.setAttribute("tabindex","-1"),r.setAttribute("aria-selected","false")}),t==null||t.setAttribute("tabindex","0"),t==null||t.setAttribute("aria-selected","true")};function Nu(i,e){if(!i)return null;let{host:t}=i.getRootNode();return!e&&t?Nu(i,t):e!=null&&e.options?e:Nu(e,e==null?void 0:e.parentNode)}w.customElements.get("media-chrome-option")||w.customElements.define("media-chrome-option",dl);var Bu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ie=(i,e,t)=>(Bu(i,e,"read from private field"),t?t.call(i):e.get(i)),Vt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},$i=(i,e,t,r)=>(Bu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Kr=(i,e,t)=>(Bu(i,e,"access private method"),t),Hi,kt,ea,at,bi,Js,cl,ul,hl,fl,ml,Fu,$u,R0,en,ta,qr,k0=q.createElement("template");k0.innerHTML=`
992
1067
  <style>
993
1068
  :host {
994
1069
  font: var(--media-font,
@@ -1039,48 +1114,48 @@ svg, img, ::slotted(svg), ::slotted(img) {
1039
1114
  <slot></slot>
1040
1115
  </media-chrome-listbox>
1041
1116
  </slot>
1042
- `;var ri=class extends D.HTMLElement{constructor(){var e;super(),$t(this,ol),$t(this,Cu),$t(this,Js),$t(this,Ui,void 0),$t(this,xt,void 0),$t(this,zn,void 0),$t(this,nt,void 0),$t(this,gi,void 0),$t(this,Zs,r=>{let{key:s}=r;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",ie(this,Zs));return}r.composedPath().includes(ie(this,xt))&&(s==="Enter"||s===" ")?Wr(this,ol,wu).call(this):s==="Escape"&&Wr(this,Js,Xn).call(this)}),$t(this,rl,r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",ie(this,Zs));return}r.preventDefault(),this.addEventListener("keyup",ie(this,Zs),{once:!0})}),$t(this,sl,r=>{r.composedPath().includes(this)||Wr(this,Js,Xn).call(this)}),$t(this,nl,r=>{r.composedPath().includes(ie(this,xt))&&Wr(this,ol,wu).call(this)}),$t(this,al,()=>{Wr(this,Js,Xn).call(this)}),$t(this,Kr,()=>{if(ie(this,nt).offsetWidth===0)return;let r=ie(this,nt).offsetWidth,s=ie(this,xt).getBoundingClientRect();if(this.hasAttribute("mediacontroller")||ie(this,xt).hasAttribute("mediacontroller")||ie(this,nt).hasAttribute("mediacontroller")){ie(this,nt).style.zIndex="1",ie(this,nt).style.bottom="unset",ie(this,nt).style.right=null,ie(this,nt).style.left="0",ie(this,nt).style.top=`${s.height}px`;return}let a=Qn(this).getBoundingClientRect(),o=s.x+r,l=Math.max(s.right-o,s.right-a.right);ie(this,nt).style.left=null,ie(this,nt).style.right=`${l}px`,ie(this,nt).style.maxHeight=`${a.height-s.height}px`}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(g0.content.cloneNode(!0)));let{style:t}=ze(this.shadowRoot,":host");t.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),(e=this.init)==null||e.call(this),Ni(this,xt,this.shadowRoot.querySelector("[part=button]")),Ni(this,nt,this.shadowRoot.querySelector("[part=listbox]")),Ni(this,zn,this.shadowRoot.querySelector("slot[name=button]")),ie(this,zn).addEventListener("slotchange",()=>{let r=ie(this,zn).assignedElements()[0];if(!r)return;Ni(this,xt,r),ie(this,xt).preventClick=!0,this.hasAttribute("disabled")||ie(this,xt).hasAttribute("disabled")?this.disable():(this.enable(),ie(this,xt).setAttribute("aria-haspopup","listbox"))}),Ni(this,gi,this.shadowRoot.querySelector("slot[name=listbox]")),ie(this,gi).addEventListener("slotchange",()=>{Ni(this,nt,ie(this,gi).assignedElements()[0]||ie(this,nt))})}static get observedAttributes(){return["disabled",me.MEDIA_CONTROLLER]}enable(){ie(this,xt).toggleAttribute("disabled",!1),this.addEventListener("change",ie(this,al)),this.addEventListener("keydown",ie(this,rl)),this.addEventListener("click",ie(this,nl)),q.addEventListener("click",ie(this,sl))}disable(){ie(this,xt).toggleAttribute("disabled",!0),this.removeEventListener("change",ie(this,al)),this.removeEventListener("keydown",ie(this,rl)),this.removeEventListener("keyup",ie(this,Zs)),this.removeEventListener("click",ie(this,nl)),q.removeEventListener("click",ie(this,sl))}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER?(t&&((n=(s=ie(this,Ui))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ni(this,Ui,null),ie(this,nt).removeAttribute(me.MEDIA_CONTROLLER)),r&&this.isConnected&&(Ni(this,Ui,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ie(this,Ui))==null?void 0:o.associateElement)==null||l.call(o,this),ie(this,nt).setAttribute(me.MEDIA_CONTROLLER,r))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(Ni(this,Ui,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ie(this,Ui))==null?void 0:t.associateElement)==null||r.call(t,this),ie(this,nt).setAttribute(me.MEDIA_CONTROLLER,s)),this.hasAttribute("disabled")||this.enable(),ie(this,gi).hidden||wn(Qn(this),ie(this,Kr))}disconnectedCallback(){var e,t;yc(Qn(this),ie(this,Kr)),this.disable(),(t=(e=ie(this,Ui))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ni(this,Ui,null),ie(this,nt).removeAttribute(me.MEDIA_CONTROLLER)}get keysUsed(){return["Enter","Escape"," ","ArrowUp","ArrowDown","f","c","k","m"]}};Ui=new WeakMap;xt=new WeakMap;zn=new WeakMap;nt=new WeakMap;gi=new WeakMap;Zs=new WeakMap;rl=new WeakMap;sl=new WeakMap;nl=new WeakMap;al=new WeakMap;ol=new WeakSet;wu=function(){ie(this,gi).hidden?Wr(this,Cu,p0).call(this):Wr(this,Js,Xn).call(this)};Cu=new WeakSet;p0=function(){ie(this,gi).hidden&&(ie(this,gi).hidden=!1,ie(this,xt).setAttribute("aria-expanded","true"),ie(this,Kr).call(this),ie(this,nt).focus(),wn(Qn(this),ie(this,Kr)))};Js=new WeakSet;Xn=function(){if(ie(this,gi).hidden)return;yc(Qn(this),ie(this,Kr));let i=fc();ie(this,gi).hidden=!0,ie(this,xt).setAttribute("aria-expanded","false"),or(ie(this,nt),i)&&ie(this,xt).focus()};Kr=new WeakMap;function Qn(i){var e;return(e=i.getAttribute("bounds")?lr(i,`#${i.getAttribute("bounds")}`):O_(i)||i.parentElement)!=null?e:i}function O_(i){var e;let t=i.getAttribute(me.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):lr(i,"media-controller")}D.customElements.get("media-chrome-selectmenu")||D.customElements.define("media-chrome-selectmenu",ri);var Uu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},N_=(i,e,t)=>(Uu(i,e,"read from private field"),t?t.call(i):e.get(i)),Mu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},U_=(i,e,t,r)=>(Uu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Pu=(i,e,t)=>(Uu(i,e,"access private method"),t),dl,Ou,b0,ll,Nu,F_=`
1117
+ `;var si=class extends w.HTMLElement{constructor(){var e;super(),Vt(this,ml),Vt(this,$u),Vt(this,en),Vt(this,Hi,void 0),Vt(this,kt,void 0),Vt(this,ea,void 0),Vt(this,at,void 0),Vt(this,bi,void 0),Vt(this,Js,t=>{let{key:r}=t;if(!this.keysUsed.includes(r)){this.removeEventListener("keyup",ie(this,Js));return}t.composedPath().includes(ie(this,kt))&&(r==="Enter"||r===" ")?Kr(this,ml,Fu).call(this):r==="Escape"&&Kr(this,en,ta).call(this)}),Vt(this,cl,t=>{let{metaKey:r,altKey:s,key:n}=t;if(r||s||!this.keysUsed.includes(n)){this.removeEventListener("keyup",ie(this,Js));return}t.preventDefault(),this.addEventListener("keyup",ie(this,Js),{once:!0})}),Vt(this,ul,t=>{t.composedPath().includes(this)||Kr(this,en,ta).call(this)}),Vt(this,hl,t=>{t.composedPath().includes(ie(this,kt))&&Kr(this,ml,Fu).call(this)}),Vt(this,fl,()=>{Kr(this,en,ta).call(this)}),Vt(this,qr,()=>{if(ie(this,at).offsetWidth===0)return;let t=ie(this,at).offsetWidth,r=ie(this,kt).getBoundingClientRect();if(this.hasAttribute("mediacontroller")||ie(this,kt).hasAttribute("mediacontroller")||ie(this,at).hasAttribute("mediacontroller")){ie(this,at).style.zIndex="1",ie(this,at).style.bottom="unset",ie(this,at).style.right=null,ie(this,at).style.left="0",ie(this,at).style.top=`${r.height}px`;return}let n=ia(this).getBoundingClientRect(),a=r.x+t,o=Math.max(r.right-a,r.right-n.right);ie(this,at).style.left=null,ie(this,at).style.right=`${o}px`,ie(this,at).style.maxHeight=`${n.height-r.height}px`}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(k0.content.cloneNode(!0))),(e=this.init)==null||e.call(this),$i(this,kt,this.shadowRoot.querySelector("[part=button]")),$i(this,at,this.shadowRoot.querySelector("[part=listbox]")),$i(this,ea,this.shadowRoot.querySelector("slot[name=button]")),ie(this,ea).addEventListener("slotchange",()=>{let t=ie(this,ea).assignedElements()[0];if(!t)return;$i(this,kt,t),ie(this,kt).preventClick=!0,this.hasAttribute("disabled")||ie(this,kt).hasAttribute("disabled")?this.disable():(this.enable(),ie(this,kt).setAttribute("aria-haspopup","listbox"))}),$i(this,bi,this.shadowRoot.querySelector("slot[name=listbox]")),ie(this,bi).addEventListener("slotchange",()=>{$i(this,at,ie(this,bi).assignedElements()[0]||ie(this,at))})}static get observedAttributes(){return["disabled",me.MEDIA_CONTROLLER]}enable(){ie(this,kt).toggleAttribute("disabled",!1),this.addEventListener("change",ie(this,fl)),this.addEventListener("keydown",ie(this,cl)),this.addEventListener("click",ie(this,hl)),q.addEventListener("click",ie(this,ul))}disable(){ie(this,kt).toggleAttribute("disabled",!0),this.removeEventListener("change",ie(this,fl)),this.removeEventListener("keydown",ie(this,cl)),this.removeEventListener("keyup",ie(this,Js)),this.removeEventListener("click",ie(this,hl)),q.removeEventListener("click",ie(this,ul))}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER?(t&&((n=(s=ie(this,Hi))==null?void 0:s.unassociateElement)==null||n.call(s,this),$i(this,Hi,null),ie(this,at).removeAttribute(me.MEDIA_CONTROLLER)),r&&this.isConnected&&($i(this,Hi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ie(this,Hi))==null?void 0:o.associateElement)==null||l.call(o,this),ie(this,at).setAttribute(me.MEDIA_CONTROLLER,r))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;let{style:s}=Ye(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(me.MEDIA_CONTROLLER);n&&($i(this,Hi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=ie(this,Hi))==null?void 0:t.associateElement)==null||r.call(t,this),ie(this,at).setAttribute(me.MEDIA_CONTROLLER,n)),this.hasAttribute("disabled")||this.enable(),ie(this,bi).hidden||Ur(ia(this),ie(this,qr))}disconnectedCallback(){var e,t;Dn(ia(this),ie(this,qr)),this.disable(),(t=(e=ie(this,Hi))==null?void 0:e.unassociateElement)==null||t.call(e,this),$i(this,Hi,null),ie(this,at).removeAttribute(me.MEDIA_CONTROLLER)}get keysUsed(){return["Enter","Escape"," ","ArrowUp","ArrowDown","f","c","k","m"]}};Hi=new WeakMap;kt=new WeakMap;ea=new WeakMap;at=new WeakMap;bi=new WeakMap;Js=new WeakMap;cl=new WeakMap;ul=new WeakMap;hl=new WeakMap;fl=new WeakMap;ml=new WeakSet;Fu=function(){ie(this,bi).hidden?Kr(this,$u,R0).call(this):Kr(this,en,ta).call(this)};$u=new WeakSet;R0=function(){ie(this,bi).hidden&&(ie(this,bi).hidden=!1,ie(this,kt).setAttribute("aria-expanded","true"),ie(this,qr).call(this),ie(this,at).focus(),Ur(ia(this),ie(this,qr)))};en=new WeakSet;ta=function(){if(ie(this,bi).hidden)return;Dn(ia(this),ie(this,qr));let i=yc();ie(this,bi).hidden=!0,ie(this,kt).setAttribute("aria-expanded","false"),lr(ie(this,at),i)&&ie(this,kt).focus()};qr=new WeakMap;function ia(i){var e;return(e=i.getAttribute("bounds")?dr(i,`#${i.getAttribute("bounds")}`):J_(i)||i.parentElement)!=null?e:i}function J_(i){var e;let t=i.getAttribute(me.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):dr(i,"media-controller")}w.customElements.get("media-chrome-selectmenu")||w.customElements.define("media-chrome-selectmenu",si);var Ku=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},eA=(i,e,t)=>(Ku(i,e,"read from private field"),t?t.call(i):e.get(i)),Hu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},tA=(i,e,t,r)=>(Ku(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Gu=(i,e,t)=>(Ku(i,e,"access private method"),t),gl,Vu,C0,pl,Wu,iA=`
1043
1118
  <svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
1044
1119
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
1045
- </svg>`,y0=q.createElement("template");y0.innerHTML=`
1046
- <slot name="captions-indicator" hidden>${F_}</slot>
1047
- `;var cl=class extends ii{constructor(){super({slotTemplate:y0}),Mu(this,Ou),Mu(this,ll),Mu(this,dl,void 0)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",S.MEDIA_SUBTITLES_LIST,S.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_SUBTITLES_LIST&&t!==r?Pu(this,Ou,b0).call(this):e===S.MEDIA_SUBTITLES_SHOWING&&t!==r?this.value=r:e==="aria-multiselectable"&&(this.removeAttribute("aria-multiselectable"),console.warn("Captions List doesn't currently support multiple selections. You can enable multiple items via the media.textTracks API."))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Pu(this,ll,Nu))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Pu(this,ll,Nu))}get mediaSubtitlesList(){return v0(this,S.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){E0(this,S.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return v0(this,S.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){E0(this,S.MEDIA_SUBTITLES_SHOWING,e)}};dl=new WeakMap;Ou=new WeakSet;b0=function(){var i;if(N_(this,dl)===JSON.stringify(this.mediaSubtitlesList))return;U_(this,dl,JSON.stringify(this.mediaSubtitlesList));let e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.value,r=Oi(this.formatOptionText("Off"),"off",t);r.prepend(pi(this,"select-indicator")),e.append(r);let s=this.mediaSubtitlesList;for(let n of s){let a=Oi(this.formatOptionText(n.label,n),co(n),this.value==co(n));a.prepend(pi(this,"select-indicator")),((i=n.kind)!=null?i:"subs")==="captions"&&a.append(pi(this,"captions-indicator")),e.append(a)}};ll=new WeakSet;Nu=function(){let i=this.mediaSubtitlesShowing,e=this.getAttribute(S.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new D.CustomEvent(ee.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;let r=new D.CustomEvent(ee.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};var v0=(i,e)=>{let t=i.getAttribute(e);return t?Pn(t):[]},E0=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=Fr(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};D.customElements.get("media-captions-listbox")||D.customElements.define("media-captions-listbox",cl);var ul=class extends ri{init(){let e=q.createElement("media-captions-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-captions-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};D.customElements.get("media-captions-selectmenu")||D.customElements.define("media-captions-selectmenu",ul);var T0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},hl=(i,e,t)=>(T0(i,e,"read from private field"),t?t.call(i):e.get(i)),Fu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Zn=(i,e,t)=>(T0(i,e,"access private method"),t),en,Jn,fl,ml,$u,Bu={RATES:"rates"},pl=class extends ii{constructor(){super(),Fu(this,Jn),Fu(this,ml),Fu(this,en,new ur(this,Bu.RATES,{defaultValue:iu})),Zn(this,Jn,fl).call(this)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",S.MEDIA_PLAYBACK_RATE,Bu.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===Bu.RATES&&t!=r&&(hl(this,en).value=r,Zn(this,Jn,fl).call(this))}get rates(){return hl(this,en)}set rates(e){e?Array.isArray(e)&&(hl(this,en).value=e.join(" ")):hl(this,en).value="",Zn(this,Jn,fl).call(this)}get mediaPlaybackRate(){return Fe(this,S.MEDIA_PLAYBACK_RATE,$s)}set mediaPlaybackRate(e){Ke(this,S.MEDIA_PLAYBACK_RATE,e)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Zn(this,ml,$u))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Zn(this,ml,$u))}};en=new WeakMap;Jn=new WeakSet;fl=function(){let i=this.shadowRoot.querySelector("#container");i.textContent="";for(let e of this.rates){let t=Oi(this.formatOptionText(`${e}x`,e),e,this.mediaPlaybackRate==e);t.prepend(pi(this,"select-indicator")),i.append(t)}};ml=new WeakSet;$u=function(){if(!this.value)return;let i=new D.CustomEvent(ee.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};D.customElements.get("media-playback-rate-listbox")||D.customElements.define("media-playback-rate-listbox",pl);var gl=class extends ri{init(){let e=q.createElement("media-playback-rate-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-playback-rate-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};D.customElements.get("media-playback-rate-selectmenu")||D.customElements.define("media-playback-rate-selectmenu",gl);var Wu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},_0=(i,e,t)=>(Wu(i,e,"read from private field"),t?t.call(i):e.get(i)),vl=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Gu=(i,e,t,r)=>(Wu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),El=(i,e,t)=>(Wu(i,e,"access private method"),t),ea,Tl,bl,Hu,yl,Vu,_l=class extends ii{constructor(){super(...arguments),vl(this,bl),vl(this,yl),vl(this,ea,[]),vl(this,Tl,void 0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_LIST,S.MEDIA_RENDITION_SELECTED]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_RENDITION_SELECTED&&t!==r?this.value=r!=null?r:"auto":e===S.MEDIA_RENDITION_LIST&&t!==r&&(Gu(this,ea,Ip(r)),El(this,bl,Hu).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",El(this,yl,Vu))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",El(this,yl,Vu))}get mediaRenditionList(){return _0(this,ea)}set mediaRenditionList(e){Gu(this,ea,e),El(this,bl,Hu).call(this)}get mediaRenditionSelected(){return He(this,S.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){$e(this,S.MEDIA_RENDITION_SELECTED,e)}};ea=new WeakMap;Tl=new WeakMap;bl=new WeakSet;Hu=function(){if(_0(this,Tl)===JSON.stringify(this.mediaRenditionList))return;Gu(this,Tl,JSON.stringify(this.mediaRenditionList));let i=this.mediaRenditionList.sort((s,n)=>n.height-s.height),e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.mediaRenditionSelected;for(let s of i){let n=this.formatOptionText(`${Math.min(s.width,s.height)}p`,s),a=Oi(n,`${s.id}`,s.selected&&!t);a.prepend(pi(this,"select-indicator")),e.append(a)}let r=Oi(this.formatOptionText("Auto"),"auto",t);r.prepend(pi(this,"select-indicator")),e.append(r)};yl=new WeakSet;Vu=function(){if(this.value==null)return;let i=new D.CustomEvent(ee.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};D.customElements.get("media-rendition-listbox")||D.customElements.define("media-rendition-listbox",_l);var B_=`<svg aria-hidden="true" viewBox="0 0 24 24">
1120
+ </svg>`,M0=q.createElement("template");M0.innerHTML=`
1121
+ <slot name="captions-indicator" hidden>${iA}</slot>
1122
+ `;var vl=class extends ri{constructor(){super({slotTemplate:M0}),Hu(this,Vu),Hu(this,pl),Hu(this,gl,void 0)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",A.MEDIA_SUBTITLES_LIST,A.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===A.MEDIA_SUBTITLES_LIST&&t!==r?Gu(this,Vu,C0).call(this):e===A.MEDIA_SUBTITLES_SHOWING&&t!==r?this.value=r:e==="aria-multiselectable"&&(this.removeAttribute("aria-multiselectable"),console.warn("Captions List doesn't currently support multiple selections. You can enable multiple items via the media.textTracks API."))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Gu(this,pl,Wu))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Gu(this,pl,Wu))}get mediaSubtitlesList(){return w0(this,A.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){D0(this,A.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return w0(this,A.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){D0(this,A.MEDIA_SUBTITLES_SHOWING,e)}};gl=new WeakMap;Vu=new WeakSet;C0=function(){var i;if(eA(this,gl)===JSON.stringify(this.mediaSubtitlesList))return;tA(this,gl,JSON.stringify(this.mediaSubtitlesList));let e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.value,r=Bi(this.formatOptionText("Off"),"off",t);r.prepend(Ei(this,"select-indicator")),e.append(r);let s=this.mediaSubtitlesList;for(let n of s){let a=Bi(this.formatOptionText(n.label,n),go(n),this.value==go(n));a.prepend(Ei(this,"select-indicator")),((i=n.kind)!=null?i:"subs")==="captions"&&a.append(Ei(this,"captions-indicator")),e.append(a)}};pl=new WeakSet;Wu=function(){let i=this.mediaSubtitlesShowing,e=this.getAttribute(A.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new w.CustomEvent(ee.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;let r=new w.CustomEvent(ee.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};var w0=(i,e)=>{let t=i.getAttribute(e);return t?On(t):[]},D0=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=$r(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};w.customElements.get("media-captions-listbox")||w.customElements.define("media-captions-listbox",vl);var El=class extends si{init(){let e=q.createElement("media-captions-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-captions-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};w.customElements.get("media-captions-selectmenu")||w.customElements.define("media-captions-selectmenu",El);var P0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},bl=(i,e,t)=>(P0(i,e,"read from private field"),t?t.call(i):e.get(i)),qu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ra=(i,e,t)=>(P0(i,e,"access private method"),t),tn,sa,yl,Tl,ju,Yu={RATES:"rates"},_l=class extends ri{constructor(){super(),qu(this,sa),qu(this,Tl),qu(this,tn,new hr(this,Yu.RATES,{defaultValue:cu})),ra(this,sa,yl).call(this)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",A.MEDIA_PLAYBACK_RATE,Yu.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===A.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===Yu.RATES&&t!=r&&(bl(this,tn).value=r,ra(this,sa,yl).call(this))}get rates(){return bl(this,tn)}set rates(e){e?Array.isArray(e)&&(bl(this,tn).value=e.join(" ")):bl(this,tn).value="",ra(this,sa,yl).call(this)}get mediaPlaybackRate(){return $e(this,A.MEDIA_PLAYBACK_RATE,Gs)}set mediaPlaybackRate(e){Ke(this,A.MEDIA_PLAYBACK_RATE,e)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",ra(this,Tl,ju))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",ra(this,Tl,ju))}};tn=new WeakMap;sa=new WeakSet;yl=function(){let i=this.shadowRoot.querySelector("#container");i.textContent="";for(let e of this.rates){let t=Bi(this.formatOptionText(`${e}x`,e),e,this.mediaPlaybackRate==e);t.prepend(Ei(this,"select-indicator")),i.append(t)}};Tl=new WeakSet;ju=function(){if(!this.value)return;let i=new w.CustomEvent(ee.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};w.customElements.get("media-playback-rate-listbox")||w.customElements.define("media-playback-rate-listbox",_l);var Al=class extends si{init(){let e=q.createElement("media-playback-rate-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-playback-rate-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};w.customElements.get("media-playback-rate-selectmenu")||w.customElements.define("media-playback-rate-selectmenu",Al);var Zu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},O0=(i,e,t)=>(Zu(i,e,"read from private field"),t?t.call(i):e.get(i)),Sl=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},zu=(i,e,t,r)=>(Zu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),xl=(i,e,t)=>(Zu(i,e,"access private method"),t),na,Rl,Il,Xu,Ll,Qu,kl=class extends ri{constructor(){super(...arguments),Sl(this,Il),Sl(this,Ll),Sl(this,na,[]),Sl(this,Rl,void 0)}static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_RENDITION_LIST,A.MEDIA_RENDITION_SELECTED]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===A.MEDIA_RENDITION_SELECTED&&t!==r?this.value=r!=null?r:"auto":e===A.MEDIA_RENDITION_LIST&&t!==r&&(zu(this,na,Op(r)),xl(this,Il,Xu).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",xl(this,Ll,Qu))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",xl(this,Ll,Qu))}get mediaRenditionList(){return O0(this,na)}set mediaRenditionList(e){zu(this,na,e),xl(this,Il,Xu).call(this)}get mediaRenditionSelected(){return Fe(this,A.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Oe(this,A.MEDIA_RENDITION_SELECTED,e)}};na=new WeakMap;Rl=new WeakMap;Il=new WeakSet;Xu=function(){if(O0(this,Rl)===JSON.stringify(this.mediaRenditionList))return;zu(this,Rl,JSON.stringify(this.mediaRenditionList));let i=this.mediaRenditionList.sort((s,n)=>n.height-s.height),e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.mediaRenditionSelected;for(let s of i){let n=this.formatOptionText(`${Math.min(s.width,s.height)}p`,s),a=Bi(n,`${s.id}`,s.selected&&!t);a.prepend(Ei(this,"select-indicator")),e.append(a)}let r=Bi(this.formatOptionText("Auto"),"auto",t);r.prepend(Ei(this,"select-indicator")),e.append(r)};Ll=new WeakSet;Qu=function(){if(this.value==null)return;let i=new w.CustomEvent(ee.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};w.customElements.get("media-rendition-listbox")||w.customElements.define("media-rendition-listbox",kl);var rA=`<svg aria-hidden="true" viewBox="0 0 24 24">
1048
1123
  <path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" />
1049
- </svg>`,A0=q.createElement("template");A0.innerHTML=`
1050
- <slot name="icon">${B_}</slot>
1051
- `;var Ku=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_SELECTED,S.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:A0})}get mediaRenditionSelected(){return He(this,S.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){$e(this,S.MEDIA_RENDITION_SELECTED,e)}};D.customElements.get("media-rendition-button")||D.customElements.define("media-rendition-button",Ku);var Al=class extends ri{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_SELECTED,S.MEDIA_RENDITION_UNAVAILABLE]}init(){let e=q.createElement("media-rendition-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-rendition-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};D.customElements.get("media-rendition-selectmenu")||D.customElements.define("media-rendition-selectmenu",Al);var zu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},S0=(i,e,t)=>(zu(i,e,"read from private field"),t?t.call(i):e.get(i)),Sl=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},qu=(i,e,t,r)=>(zu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),xl=(i,e,t)=>(zu(i,e,"access private method"),t),ta,Rl,Il,Yu,Ll,ju,kl=class extends ii{constructor(){super(...arguments),Sl(this,Il),Sl(this,Ll),Sl(this,ta,[]),Sl(this,Rl,void 0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_AUDIO_TRACK_LIST,S.MEDIA_AUDIO_TRACK_ENABLED]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===S.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(qu(this,ta,Rp(r)),xl(this,Il,Yu).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",xl(this,Ll,ju))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",xl(this,Ll,ju))}get mediaAudioTrackList(){return S0(this,ta)}set mediaAudioTrackList(e){qu(this,ta,e),xl(this,Il,Yu).call(this)}get mediaAudioTrackEnabled(){return He(this,S.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){$e(this,S.MEDIA_AUDIO_TRACK_ENABLED,e)}};ta=new WeakMap;Rl=new WeakMap;Il=new WeakSet;Yu=function(){if(S0(this,Rl)===JSON.stringify(this.mediaAudioTrackList))return;qu(this,Rl,JSON.stringify(this.mediaAudioTrackList));let i=this.mediaAudioTrackList,e=this.shadowRoot.querySelector("#container");e.textContent="";for(let t of i){let r=this.formatOptionText(t.label,t),s=Oi(r,`${t.id}`,t.enabled);s.prepend(pi(this,"select-indicator")),e.append(s)}};Ll=new WeakSet;ju=function(){if(this.value==null)return;let i=new D.CustomEvent(ee.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};D.customElements.get("media-audio-track-listbox")||D.customElements.define("media-audio-track-listbox",kl);var $_=`<svg aria-hidden="true" viewBox="0 0 24 24">
1124
+ </svg>`,N0=q.createElement("template");N0.innerHTML=`
1125
+ <slot name="icon">${rA}</slot>
1126
+ `;var Ju=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_RENDITION_SELECTED,A.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:N0})}get mediaRenditionSelected(){return Fe(this,A.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Oe(this,A.MEDIA_RENDITION_SELECTED,e)}};w.customElements.get("media-rendition-button")||w.customElements.define("media-rendition-button",Ju);var wl=class extends si{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_RENDITION_SELECTED,A.MEDIA_RENDITION_UNAVAILABLE]}init(){let e=q.createElement("media-rendition-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-rendition-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};w.customElements.get("media-rendition-selectmenu")||w.customElements.define("media-rendition-selectmenu",wl);var rh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},U0=(i,e,t)=>(rh(i,e,"read from private field"),t?t.call(i):e.get(i)),Dl=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},eh=(i,e,t,r)=>(rh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Cl=(i,e,t)=>(rh(i,e,"access private method"),t),aa,Ol,Ml,th,Pl,ih,Nl=class extends ri{constructor(){super(...arguments),Dl(this,Ml),Dl(this,Pl),Dl(this,aa,[]),Dl(this,Ol,void 0)}static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_AUDIO_TRACK_LIST,A.MEDIA_AUDIO_TRACK_ENABLED]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===A.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===A.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(eh(this,aa,Up(r)),Cl(this,Ml,th).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Cl(this,Pl,ih))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Cl(this,Pl,ih))}get mediaAudioTrackList(){return U0(this,aa)}set mediaAudioTrackList(e){eh(this,aa,e),Cl(this,Ml,th).call(this)}get mediaAudioTrackEnabled(){return Fe(this,A.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){Oe(this,A.MEDIA_AUDIO_TRACK_ENABLED,e)}};aa=new WeakMap;Ol=new WeakMap;Ml=new WeakSet;th=function(){if(U0(this,Ol)===JSON.stringify(this.mediaAudioTrackList))return;eh(this,Ol,JSON.stringify(this.mediaAudioTrackList));let i=this.mediaAudioTrackList,e=this.shadowRoot.querySelector("#container");e.textContent="";for(let t of i){let r=this.formatOptionText(t.label,t),s=Bi(r,`${t.id}`,t.enabled);s.prepend(Ei(this,"select-indicator")),e.append(s)}};Pl=new WeakSet;ih=function(){if(this.value==null)return;let i=new w.CustomEvent(ee.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};w.customElements.get("media-audio-track-listbox")||w.customElements.define("media-audio-track-listbox",Nl);var sA=`<svg aria-hidden="true" viewBox="0 0 24 24">
1052
1127
  <path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
1053
1128
  <path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/>
1054
- </svg>`,x0=q.createElement("template");x0.innerHTML=`
1055
- <slot name="icon">${$_}</slot>
1056
- `;var Xu=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_AUDIO_TRACK_ENABLED,S.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:x0})}get mediaAudioTrackEnabled(){return He(this,S.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){$e(this,S.MEDIA_AUDIO_TRACK_ENABLED,e)}};D.customElements.get("media-audio-track-button")||D.customElements.define("media-audio-track-button",Xu);var wl=class extends ri{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_AUDIO_TRACK_ENABLED,S.MEDIA_AUDIO_TRACK_UNAVAILABLE]}init(){let e=q.createElement("media-audio-track-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-audio-track-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};D.customElements.get("media-audio-track-selectmenu")||D.customElements.define("media-audio-track-selectmenu",wl);var fd=cT(I0(),1);function G_(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var mv={exports:{}};(function(i,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,c){if(c=c||{},l=l.trim(),d=d.trim(),!d){if(!c.alwaysNormalize)return l;var u=o.parseURL(l);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return c.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var g=s.exec(f.path);f.netLoc=g[1],f.path=g[2]}f.netLoc&&!f.path&&(f.path="/");var E={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(E.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)E.path=f.path,h.params||(E.params=f.params,h.query||(E.query=f.query));else{var T=f.path,A=T.substring(0,T.lastIndexOf("/")+1)+h.path;E.path=o.normalizePath(A)}return E.path===null&&(E.path=c.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(E)},parseURL:function(l){var d=r.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(mv);var Tf=mv.exports;function L0(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function Ct(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?L0(Object(t),!0).forEach(function(r){H_(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):L0(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function H_(i,e,t){return e=W_(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ht(){return ht=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},ht.apply(this,arguments)}function V_(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function W_(i){var e=V_(i,"string");return typeof e=="symbol"?e:String(e)}var oe=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},K_=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=q_},q_=Number.MAX_SAFE_INTEGER||9007199254740991,b=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i}({}),ue=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),$=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({}),Yr=function(){},Eh={trace:Yr,debug:Yr,log:Yr,warn:Yr,info:Yr,error:Yr},sa=Eh;function Y_(i){let e=self.console[i];return e?e.bind(self.console,`[${i}] >`):Yr}function j_(i,...e){e.forEach(function(t){sa[t]=i[t]?i[t].bind(i):Y_(t)})}function z_(i,e){if(self.console&&i===!0||typeof i=="object"){j_(i,"debug","log","info","warn","error");try{sa.log(`Debug logs enabled for "${e}" in hls.js version 1.4.13`)}catch{sa=Eh}}else sa=Eh}var M=sa,X_=/^(\d+)x(\d+)$/,R0=/(.+?)=(".*?"|.*?)(?:,|$)/g,et=class i{constructor(e){typeof e=="string"&&(e=i.parseAttrList(e));for(let t in e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=X_.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,r={},s='"';for(R0.lastIndex=0;(t=R0.exec(e))!==null;){let n=t[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));let a=t[1].trim();r[a]=n}return r}};function Q_(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function Z_(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}var Hl=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let r=t.attr;for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){M.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=ht(new et({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let r=new Date(this.attr["END-DATE"]);oe(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(oe(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&oe(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},on=class{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},Ve={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Vl=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Ve.AUDIO]:null,[Ve.VIDEO]:null,[Ve.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let r=e.split("@",2),s=[];r.length===1?s[0]=t?t.byteRangeEndOffset:0:s[0]=parseInt(r[1]),s[1]=parseInt(r[0])+s[0],this._byteRange=s}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Tf.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},na=class extends Vl{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new on,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{let r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!oe(this.programDateTime))return null;let e=oe(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){let t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,n,a=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[Ve.AUDIO]=null,e[Ve.VIDEO]=null,e[Ve.AUDIOVIDEO]=null}},bh=class extends Vl{constructor(e,t,r,s,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new on,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}},J_=10,yh=class{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?oe(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||J_}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}};function _f(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function eA(i){let e=pv(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function tA(i){let e=function(r,s,n){let a=r[s];r[s]=r[n],r[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function iA(i){let e=i.split(":"),t=null;if(e[0]==="data"&&e.length===2){let r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){let n=s[0]==="base64",a=s[1];n?(r.splice(-1,1),t=_f(a)):t=eA(a)}}return t}function pv(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}var tt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Wt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function k0(i){switch(i){case Wt.FAIRPLAY:return tt.FAIRPLAY;case Wt.PLAYREADY:return tt.PLAYREADY;case Wt.WIDEVINE:return tt.WIDEVINE;case Wt.CLEARKEY:return tt.CLEARKEY}}var gv={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function rA(i){if(i===gv.WIDEVINE)return tt.WIDEVINE}function w0(i){switch(i){case tt.FAIRPLAY:return Wt.FAIRPLAY;case tt.PLAYREADY:return Wt.PLAYREADY;case tt.WIDEVINE:return Wt.WIDEVINE;case tt.CLEARKEY:return Wt.CLEARKEY}}function Zu(i){let{drmSystems:e,widevineLicenseUrl:t}=i,r=e?[tt.FAIRPLAY,tt.WIDEVINE,tt.PLAYREADY,tt.CLEARKEY].filter(s=>!!e[s]):[];return!r[tt.WIDEVINE]&&t&&r.push(tt.WIDEVINE),r}var vv=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function sA(i,e,t,r){let s;switch(i){case tt.FAIRPLAY:s=["cenc","sinf"];break;case tt.WIDEVINE:case tt.PLAYREADY:s=["cenc"];break;case tt.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return nA(s,e,t,r)}function nA(i,e,t,r){return[{initDataTypes:i,persistentState:r.persistentState||"not-allowed",distinctiveIdentifier:r.distinctiveIdentifier||"not-allowed",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function zr(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}var Af=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Ev=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Wl=(i,e)=>{let t=e,r=0;for(;Af(i,e);){r+=10;let s=cd(i,e+6);r+=s,Ev(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},cd=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},aA=(i,e)=>Af(i,e)&&cd(i,e+6)+10<=i.length-e,oA=i=>{let e=yv(i);for(let t=0;t<e.length;t++){let r=e[t];if(bv(r))return fA(r)}},bv=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",lA=i=>{let e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=cd(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},yv=i=>{let e=0,t=[];for(;Af(i,e);){let r=cd(i,e+6);e+=10;let s=e+r;for(;e+8<s;){let n=lA(i.subarray(e)),a=dA(n);a&&t.push(a),e+=n.size+10}Ev(i,e)&&(e+=10)}return t},dA=i=>i.type==="PRIV"?cA(i):i.type[0]==="W"?hA(i):uA(i),cA=i=>{if(i.size<2)return;let e=$i(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},uA=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1,r=$i(i.data.subarray(t),!0);t+=r.length+1;let s=$i(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=$i(i.data.subarray(1));return{key:i.type,data:e}},hA=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1,r=$i(i.data.subarray(t),!0);t+=r.length+1;let s=$i(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=$i(i.data);return{key:i.type,data:e}},fA=i=>{if(i.data.byteLength===8){let e=new Uint8Array(i.data),t=e[3]&1,r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},$i=(i,e=!1)=>{let t=mA();if(t){let d=t.decode(i);if(e){let c=d.indexOf("\0");return c!==-1?d.substring(0,c):d}return d.replace(/\0/g,"")}let r=i.length,s,n,a,o="",l=0;for(;l<r;){if(s=i[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},Ju;function mA(){return!Ju&&typeof self.TextDecoder!="undefined"&&(Ju=new self.TextDecoder("utf-8")),Ju}var Fi={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let r=i[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},Kl=Math.pow(2,32)-1,pA=[].push,Tv={video:1,audio:2,id3:3,text:4};function yt(i){return String.fromCharCode.apply(null,i)}function _v(i,e){let t=i[e]<<8|i[e+1];return t<0?65536+t:t}function pe(i,e){let t=Av(i,e);return t<0?4294967296+t:t}function Av(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function eh(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function Ce(i,e){let t=[];if(!e.length)return t;let r=i.byteLength;for(let s=0;s<r;){let n=pe(i,s),a=yt(i.subarray(s+4,s+8)),o=n>1?s+n:r;if(a===e[0])if(e.length===1)t.push(i.subarray(s+8,o));else{let l=Ce(i.subarray(s+8,o),e.slice(1));l.length&&pA.apply(t,l)}s=o}return t}function gA(i){let e=[],t=i[0],r=8,s=pe(i,r);r+=4;let n=0,a=0;t===0?r+=8:r+=16,r+=2;let o=i.length+a,l=_v(i,r);r+=2;for(let d=0;d<l;d++){let c=r,u=pe(i,c);c+=4;let h=u&2147483647;if((u&2147483648)>>>31===1)return M.warn("SIDX has hierarchical references (not supported)"),null;let g=pe(i,c);c+=4,e.push({referenceSize:h,subsegmentDuration:g,info:{duration:g/s,start:o,end:o+h-1}}),o+=h,c+=4,r=c}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function Sv(i){let e=[],t=Ce(i,["moov","trak"]);for(let s=0;s<t.length;s++){let n=t[s],a=Ce(n,["tkhd"])[0];if(a){let o=a[0],l=o===0?12:20,d=pe(a,l),c=Ce(n,["mdia","mdhd"])[0];if(c){o=c[0],l=o===0?12:20;let u=pe(c,l),h=Ce(n,["mdia","hdlr"])[0];if(h){let f=yt(h.subarray(8,12)),g={soun:Ve.AUDIO,vide:Ve.VIDEO}[f];if(g){let E=Ce(n,["mdia","minf","stbl","stsd"])[0],T;E&&(T=yt(E.subarray(12,16))),e[d]={timescale:u,type:g},e[g]={timescale:u,id:d,codec:T}}}}}}return Ce(i,["moov","mvex","trex"]).forEach(s=>{let n=pe(s,4),a=e[n];a&&(a.default={duration:pe(s,12),flags:pe(s,20)})}),e}function vA(i,e){if(!i||!e)return i;let t=e.keyId;return t&&e.isCommonEncryption&&Ce(i,["moov","trak"]).forEach(s=>{let a=Ce(s,["mdia","minf","stbl","stsd"])[0].subarray(8),o=Ce(a,["enca"]),l=o.length>0;l||(o=Ce(a,["encv"])),o.forEach(d=>{let c=l?d.subarray(28):d.subarray(78);Ce(c,["sinf"]).forEach(h=>{let f=xv(h);if(f){let g=f.subarray(8,24);g.some(E=>E!==0)||(M.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Fi.hexDump(g)} -> ${Fi.hexDump(t)}`),f.set(t,8))}})})}),i}function xv(i){let e=Ce(i,["schm"])[0];if(e){let t=yt(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return Ce(i,["schi","tenc"])[0]}return M.error("[eme] missing 'schm' box"),null}function EA(i,e){return Ce(e,["moof","traf"]).reduce((t,r)=>{let s=Ce(r,["tfdt"])[0],n=s[0],a=Ce(r,["tfhd"]).reduce((o,l)=>{let d=pe(l,4),c=i[d];if(c){let u=pe(s,4);if(n===1){if(u===Kl)return M.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;u*=Kl+1,u+=pe(s,8)}let h=c.timescale||9e4,f=u/h;if(oe(f)&&(o===null||f<o))return f}return o},null);return a!==null&&oe(a)&&(t===null||a<t)?a:t},null)}function bA(i,e){let t=0,r=0,s=0,n=Ce(i,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=Ce(o,["tfhd"])[0],d=pe(l,4),c=e[d];if(!c)continue;let u=c.default,h=pe(l,0)|(u==null?void 0:u.flags),f=u==null?void 0:u.duration;h&8&&(h&2?f=pe(l,12):f=pe(l,8));let g=c.timescale||9e4,E=Ce(o,["trun"]);for(let T=0;T<E.length;T++){if(t=yA(E[T]),!t&&f){let A=pe(E[T],4);t=f*A}c.type===Ve.VIDEO?r+=t/g:c.type===Ve.AUDIO&&(s+=t/g)}}if(r===0&&s===0){let a=0,o=Ce(i,["sidx"]);for(let l=0;l<o.length;l++){let d=gA(o[l]);d!=null&&d.references&&(a+=d.references.reduce((c,u)=>c+u.info.duration||0,0))}return a}return r||s}function yA(i){let e=pe(i,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0,s=pe(i,4);for(let n=0;n<s;n++){if(e&256){let a=pe(i,t);r+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function TA(i,e,t){Ce(e,["moof","traf"]).forEach(r=>{Ce(r,["tfhd"]).forEach(s=>{let n=pe(s,4),a=i[n];if(!a)return;let o=a.timescale||9e4;Ce(r,["tfdt"]).forEach(l=>{let d=l[0],c=pe(l,4);if(d===0)c-=t*o,c=Math.max(c,0),eh(l,4,c);else{c*=Math.pow(2,32),c+=pe(l,8),c-=t*o,c=Math.max(c,0);let u=Math.floor(c/(Kl+1)),h=Math.floor(c%(Kl+1));eh(l,4,u),eh(l,8,h)}})})})}function _A(i){let e={valid:null,remainder:null},t=Ce(i,["moof"]);if(t){if(t.length<2)return e.remainder=i,e}else return e;let r=t[t.length-1];return e.valid=zr(i,0,r.byteOffset-8),e.remainder=zr(i,r.byteOffset-8),e}function Xr(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function D0(i,e){let t=[],r=e.samples,s=e.timescale,n=e.id,a=!1;return Ce(r,["moof"]).map(l=>{let d=l.byteOffset-8;Ce(l,["traf"]).map(u=>{let h=Ce(u,["tfdt"]).map(f=>{let g=f[0],E=pe(f,4);return g===1&&(E*=Math.pow(2,32),E+=pe(f,8)),E/s})[0];return h!==void 0&&(i=h),Ce(u,["tfhd"]).map(f=>{let g=pe(f,4),E=pe(f,0)&16777215,T=(E&1)!==0,A=(E&2)!==0,k=(E&8)!==0,L=0,F=(E&16)!==0,R=0,B=(E&32)!==0,P=8;g===n&&(T&&(P+=8),A&&(P+=4),k&&(L=pe(f,P),P+=4),F&&(R=pe(f,P),P+=4),B&&(P+=4),e.type==="video"&&(a=AA(e.codec)),Ce(u,["trun"]).map(G=>{let K=G[0],N=pe(G,0)&16777215,j=(N&1)!==0,Y=0,Ee=(N&4)!==0,ge=(N&256)!==0,ye=0,we=(N&512)!==0,Ie=0,Z=(N&1024)!==0,te=(N&2048)!==0,re=0,Le=pe(G,4),Re=8;j&&(Y=pe(G,Re),Re+=4),Ee&&(Re+=4);let Qe=Y+d;for(let Ot=0;Ot<Le;Ot++){if(ge?(ye=pe(G,Re),Re+=4):ye=L,we?(Ie=pe(G,Re),Re+=4):Ie=R,Z&&(Re+=4),te&&(K===0?re=pe(G,Re):re=Av(G,Re),Re+=4),e.type===Ve.VIDEO){let Nt=0;for(;Nt<Ie;){let kt=pe(r,Qe);if(Qe+=4,SA(a,r[Qe])){let Wi=r.subarray(Qe,Qe+kt);Iv(Wi,a?2:1,i+re/s,t)}Qe+=kt,Nt+=kt+4}}i+=ye/s}}))})})}),t}function AA(i){if(!i)return!1;let e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function SA(i,e){if(i){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Iv(i,e,t,r){let s=Lv(i),n=0;n+=e;let a=0,o=0,l=!1,d=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;d=s[n++],a+=d}while(d===255);o=0;do{if(n>=s.length)break;d=s[n++],o+=d}while(d===255);let c=s.length-n;if(!l&&a===4&&n<s.length){if(l=!0,s[n++]===181){let h=_v(s,n);if(n+=2,h===49){let f=pe(s,n);if(n+=4,f===1195456820){let g=s[n++];if(g===3){let E=s[n++],T=31&E,A=64&E,k=A?2+T*3:0,L=new Uint8Array(k);if(A){L[0]=E;for(let F=1;F<k;F++)L[F]=s[n++]}r.push({type:g,payloadType:a,pts:t,bytes:L})}}}}}else if(a===5&&o<c){if(l=!0,o>16){let u=[];for(let g=0;g<16;g++){let E=s[n++].toString(16);u.push(E.length==1?"0"+E:E),(g===3||g===5||g===7||g===9)&&u.push("-")}let h=o-16,f=new Uint8Array(h);for(let g=0;g<h;g++)f[g]=s[n++];r.push({payloadType:a,pts:t,uuid:u.join(""),userData:$i(f),userDataBytes:f})}}else if(o<c)n+=o;else if(o>c)break}}function Lv(i){let e=i.byteLength,t=[],r=1;for(;r<e-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return i;let s=e-t.length,n=new Uint8Array(s),a=0;for(r=0;r<s;a++,r++)a===t[0]&&(a++,t.shift()),n[r]=i[a];return n}function xA(i){let e=i[0],t="",r="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;yt(i.subarray(d,d+1))!=="\0";)t+=yt(i.subarray(d,d+1)),d+=1;for(t+=yt(i.subarray(d,d+1)),d+=1;yt(i.subarray(d,d+1))!=="\0";)r+=yt(i.subarray(d,d+1)),d+=1;r+=yt(i.subarray(d,d+1)),d+=1,s=pe(i,12),n=pe(i,16),o=pe(i,20),l=pe(i,24),d=28}else if(e===1){d+=4,s=pe(i,d),d+=4;let u=pe(i,d);d+=4;let h=pe(i,d);for(d+=4,a=2**32*u+h,K_(a)||(a=Number.MAX_SAFE_INTEGER,M.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=pe(i,d),d+=4,l=pe(i,d),d+=4;yt(i.subarray(d,d+1))!=="\0";)t+=yt(i.subarray(d,d+1)),d+=1;for(t+=yt(i.subarray(d,d+1)),d+=1;yt(i.subarray(d,d+1))!=="\0";)r+=yt(i.subarray(d,d+1)),d+=1;r+=yt(i.subarray(d,d+1)),d+=1}let c=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:c}}function IA(i,...e){let t=e.length,r=8,s=t;for(;s--;)r+=e[s].byteLength;let n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=r&255,n.set(i,4),s=0,r=8;s<t;s++)n.set(e[s],r),r+=e[s].byteLength;return n}function LA(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,s;if(e){r=1,s=new Uint8Array(e.length*16);for(let o=0;o<e.length;o++){let l=e[o];if(l.byteLength!==16)throw new RangeError("Invalid key");s.set(l,o*16)}}else r=0,s=new Uint8Array;let n;r>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;let a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),IA([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function RA(i){if(!(i instanceof ArrayBuffer)||i.byteLength<32)return null;let e={version:0,systemId:"",kids:null,data:null},t=new DataView(i),r=t.getUint32(0);if(i.byteLength!==r&&r>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=Fi.hexDump(new Uint8Array(i,12,16));let n=t.getUint32(28);if(e.version===0){if(r-32<n)return null;e.data=new Uint8Array(i,32,n)}else if(e.version===1){e.kids=[];for(let a=0;a<n;a++)e.kids.push(new Uint8Array(i,32+a*16,16))}return e}var Cl={},da=class i{static clearKeyUriToKeyIdMap(){Cl={}}constructor(e,t,r,s=[1],n=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=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Wt.FAIRPLAY:case Wt.WIDEVINE:case Wt.PLAYREADY:case Wt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&M.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let r=kA(e);return new i(this.method,this.uri,"identity",this.keyFormatVersions,r)}let t=iA(this.uri);if(t)switch(this.keyFormat){case Wt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Wt.PLAYREADY:{let r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=LA(r,null,t);let s=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(s)),a=n.substring(n.indexOf("<"),n.length),d=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(d){let c=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(c){let u=_f(c).subarray(0,16);tA(u),this.keyId=u}}break}default:{let r=t.subarray(0,16);if(r.length!==16){let s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=Cl[this.uri];if(!r){let s=Object.keys(Cl).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),Cl[this.uri]=r}this.keyId=r}return this}};function kA(i){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}var Rv=/\{\$([a-zA-Z0-9-_]+)\}/g;function C0(i){return Rv.test(i)}function Ht(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let r=t.length;r--;){let s=t[r],n=e[s];n&&(e[s]=Th(i,n))}}function Th(i,e){if(i.variableList!==null||i.hasVariableRefs){let t=i.variableList;return e.replace(Rv,r=>{let s=r.substring(2,r.length-1),n=t==null?void 0:t[s];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):n})}return e}function M0(i,e,t){let r=i.variableList;r||(i.variableList=r={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{let a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function wA(i,e,t){let r=e.IMPORT;if(t&&r in t){let s=i.variableList;s||(i.variableList=s={}),s[r]=t[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function ud(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var DA={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}},P0=ud();function CA(i,e){let t=DA[e];return!!t&&t[i.slice(0,4)]===!0}function th(i,e){var t;return(t=P0==null?void 0:P0.isTypeSupported(`${e||"video"}/mp4;codecs="${i}"`))!=null?t:!1}var O0=/#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,N0=/#EXT-X-MEDIA:(.*)/g,MA=/^#EXT(?:INF|-X-TARGETDURATION):/m,U0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),PA=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("|")),jr=class i{static findGroup(e,t){for(let r=0;r<e.length;r++){let s=e[r];if(s.id===t)return s}}static convertAVC1ToAVCOTI(e){let t=e.split(".");if(t.length>2){let r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).slice(-4),r}return e}static resolve(e,t){return Tf.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return MA.test(e)}static parseMasterPlaylist(e,t){let r=C0(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];O0.lastIndex=0;let a;for(;(a=O0.exec(e))!=null;)if(a[1]){var o;let d=new et(a[1]);Ht(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let c=Th(s,a[2]),u={attrs:d,bitrate:d.decimalInteger("AVERAGE-BANDWIDTH")||d.decimalInteger("BANDWIDTH"),name:d.NAME,url:i.resolve(c,t)},h=d.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),OA((d.CODECS||"").split(/[ ,]+/).filter(f=>f),u),u.videoCodec&&u.videoCodec.indexOf("avc1")!==-1&&(u.videoCodec=i.convertAVC1ToAVCOTI(u.videoCodec)),(o=u.unknownCodecs)!=null&&o.length||n.push(u),s.levels.push(u)}else if(a[3]){let d=a[3],c=a[4];switch(d){case"SESSION-DATA":{let u=new et(c);Ht(s,u,["DATA-ID","LANGUAGE","VALUE","URI"]);let h=u["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=u);break}case"SESSION-KEY":{let u=F0(c,t,s);u.encrypted&&u.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(u)):M.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case"DEFINE":{{let u=new et(c);Ht(s,u,["NAME","VALUE","QUERYPARAM"]),M0(s,u,t)}break}case"CONTENT-STEERING":{let u=new et(c);Ht(s,u,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:i.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=B0(c);break}}}let l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s,n={},a=r.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(N0.lastIndex=0;(s=N0.exec(e))!==null;){let d=new et(s[1]),c=d.TYPE;if(c){let u=o[c],h=n[c]||[];n[c]=h,Ht(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let f={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",instreamId:d["INSTREAM-ID"],name:d.NAME||d.LANGUAGE||"",type:c,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:d.LANGUAGE,url:d.URI?i.resolve(d.URI,t):""};if(u!=null&&u.length){let g=i.findGroup(u,f.groupId)||u[0];$0(f,g,"audioCodec"),$0(f,g,"textCodec")}h.push(f)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){let o=new yh(t),l=o.fragments,d=null,c=0,u=0,h=0,f=0,g=null,E=new na(s,t),T,A,k,L=-1,F=!1;for(U0.lastIndex=0,o.m3u8=e,o.hasVariableRefs=C0(e);(T=U0.exec(e))!==null;){F&&(F=!1,E=new na(s,t),E.start=h,E.sn=c,E.cc=f,E.level=r,d&&(E.initSegment=d,E.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null));let G=T[1];if(G){E.duration=parseFloat(G);let K=(" "+T[2]).slice(1);E.title=K||null,E.tagList.push(K?["INF",G,K]:["INF",G])}else if(T[3]){if(oe(E.duration)){E.start=h,k&&V0(E,k,o),E.sn=c,E.level=r,E.cc=f,E.urlId=n,l.push(E);let K=(" "+T[3]).slice(1);E.relurl=Th(o,K),G0(E,g),g=E,h+=E.duration,c++,u=0,F=!0}}else if(T[4]){let K=(" "+T[4]).slice(1);g?E.setByteRange(K,g):E.setByteRange(K)}else if(T[5])E.rawProgramDateTime=(" "+T[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),L===-1&&(L=l.length);else{if(T=T[0].match(PA),!T){M.warn("No matches on slow regex match for level playlist!");continue}for(A=1;A<T.length&&typeof T[A]=="undefined";A++);let K=(" "+T[A]).slice(1),N=(" "+T[A+1]).slice(1),j=T[A+2]?(" "+T[A+2]).slice(1):"";switch(K){case"PLAYLIST-TYPE":o.type=N.toUpperCase();break;case"MEDIA-SEQUENCE":c=o.startSN=parseInt(N);break;case"SKIP":{let Y=new et(N);Ht(o,Y,["RECENTLY-REMOVED-DATERANGES"]);let Ee=Y.decimalInteger("SKIPPED-SEGMENTS");if(oe(Ee)){o.skippedSegments=Ee;for(let ye=Ee;ye--;)l.unshift(null);c+=Ee}let ge=Y.enumeratedString("RECENTLY-REMOVED-DATERANGES");ge&&(o.recentlyRemovedDateranges=ge.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(N),1);break;case"VERSION":o.version=parseInt(N);break;case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(N||j)&&E.tagList.push(j?[N,j]:[N]);break;case"DISCONTINUITY":f++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([K]);break;case"BITRATE":E.tagList.push([K,N]);break;case"DATERANGE":{let Y=new et(N);Ht(o,Y,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Ht(o,Y,Y.clientAttrs);let Ee=new Hl(Y,o.dateRanges[Y.ID]);Ee.isValid||o.skippedSegments?o.dateRanges[Ee.id]=Ee:M.warn(`Ignoring invalid DATERANGE tag: "${N}"`),E.tagList.push(["EXT-X-DATERANGE",N]);break}case"DEFINE":{{let Y=new et(N);Ht(o,Y,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in Y?wA(o,Y,a):M0(o,Y,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(N);break;case"KEY":{let Y=F0(N,t,o);if(Y.isSupported()){if(Y.method==="NONE"){k=void 0;break}k||(k={}),k[Y.keyFormat]&&(k=ht({},k)),k[Y.keyFormat]=Y}else M.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${N}"`);break}case"START":o.startTimeOffset=B0(N);break;case"MAP":{let Y=new et(N);if(Ht(o,Y,["BYTERANGE","URI"]),E.duration){let Ee=new na(s,t);H0(Ee,Y,r,k),d=Ee,E.initSegment=d,d.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=d.rawProgramDateTime)}else H0(E,Y,r,k),d=E,F=!0;break}case"SERVER-CONTROL":{let Y=new et(N);o.canBlockReload=Y.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=Y.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&Y.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=Y.optionalFloat("PART-HOLD-BACK",0),o.holdBack=Y.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let Y=new et(N);o.partTarget=Y.decimalFloatingPoint("PART-TARGET");break}case"PART":{let Y=o.partList;Y||(Y=o.partList=[]);let Ee=u>0?Y[Y.length-1]:void 0,ge=u++,ye=new et(N);Ht(o,ye,["BYTERANGE","URI"]);let we=new bh(ye,E,t,ge,Ee);Y.push(we),E.duration+=we.duration;break}case"PRELOAD-HINT":{let Y=new et(N);Ht(o,Y,["URI"]),o.preloadHint=Y;break}case"RENDITION-REPORT":{let Y=new et(N);Ht(o,Y,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(Y);break}default:M.warn(`line parsed but not handled: ${T}`);break}}}g&&!g.relurl?(l.pop(),h-=g.duration,o.partList&&(o.fragmentHint=g)):o.partList&&(G0(E,g),E.cc=f,o.fragmentHint=E,k&&V0(E,k,o));let R=l.length,B=l[0],P=l[R-1];if(h+=o.skippedSegments*o.targetduration,h>0&&R&&P){o.averagetargetduration=h/R;let G=P.sn;o.endSN=G!=="initSegment"?G:0,o.live||(P.endList=!0),B&&(o.startCC=B.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,L>0&&NA(l,L),o}};function F0(i,e,t){var r,s;let n=new et(i);Ht(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(r=n.METHOD)!=null?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,c=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&M.error(`Invalid IV: ${n.IV}`);let u=o?jr.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new da(a,u,c,h,l)}function B0(i){let t=new et(i).decimalFloatingPoint("TIME-OFFSET");return oe(t)?t:null}function OA(i,e){["video","audio","text"].forEach(t=>{let r=i.filter(s=>CA(s,t));if(r.length){let s=r.filter(n=>n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0);e[`${t}Codec`]=s.length>0?s[0]:r[0],i=i.filter(n=>r.indexOf(n)===-1)}}),e.unknownCodecs=i}function $0(i,e,t){let r=e[t];r&&(i[t]=r)}function NA(i,e){let t=i[e];for(let r=e;r--;){let s=i[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function G0(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),oe(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function H0(i,e,t,r){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function V0(i,e,t){i.levelkeys=e;let{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(i)}var Me={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},he={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function W0(i){let{type:e}=i;switch(e){case Me.AUDIO_TRACK:return he.AUDIO;case Me.SUBTITLE_TRACK:return he.SUBTITLE;default:return he.MAIN}}function ih(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var _h=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(b.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(b.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,r=t.pLoader,s=t.loader,n=r||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Me.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){let{id:r,level:s,url:n,deliveryDirectives:a}=t;this.load({id:r,level:s,responseType:"text",type:Me.LEVEL,url:n,deliveryDirectives:a})}onAudioTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Me.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Me.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;let r=this.hls.config,s=this.getInternalLoader(e);if(s){let d=s.context;if(d&&d.url===e.url){M.trace("[playlist-loader]: playlist request ongoing");return}M.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===Me.MANIFEST?n=r.manifestLoadPolicy.default:n=ht({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part){let d;if(e.type===Me.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Me.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Me.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let c=d.partTarget,u=d.targetduration;if(c&&u){let h=Math.max(c*3,u*.8)*1e3;n=ht({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,c,u,h)=>{let f=this.getInternalLoader(u);this.resetInternalLoader(u.type);let g=d.data;if(g.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,u,new Error("no EXTM3U delimiter"),h||null,c);return}c.parsing.start=performance.now(),jr.isMediaPlaylist(g)?this.handleTrackOrLevelPlaylist(d,c,u,h||null,f):this.handleMasterPlaylist(d,c,u,h)},onError:(d,c,u,h)=>{this.handleNetworkError(c,u,!1,d,h)},onTimeout:(d,c,u)=>{this.handleNetworkError(c,u,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,r,s){let n=this.hls,a=e.data,o=ih(e,r),l=jr.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}let{contentSteering:d,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:g}=l;this.variableList=g;let{AUDIO:E=[],SUBTITLES:T,"CLOSED-CAPTIONS":A}=jr.parseMasterPlaylistMedia(a,o,l);E.length&&!E.some(L=>!L.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(M.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 et({}),bitrate:0,url:""})),n.trigger(b.MANIFEST_LOADED,{levels:c,audioTracks:E,subtitles:T,captions:A,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:g})}handleTrackOrLevelPlaylist(e,t,r,s,n){let a=this.hls,{id:o,level:l,type:d}=r,c=ih(e,r),u=oe(o)?o:0,h=oe(l)?l:u,f=W0(r),g=jr.parseLevelPlaylist(e.data,c,h,f,u,this.variableList);if(d===Me.MANIFEST){let E={attrs:new et({}),bitrate:0,details:g,name:"",url:c};a.trigger(b.MANIFEST_LOADED,{levels:[E],audioTracks:[],url:c,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=g,this.handlePlaylistLoaded(g,e,t,r,s,n)}handleManifestParsingError(e,t,r,s,n){this.hls.trigger(b.ERROR,{type:ue.NETWORK_ERROR,details:$.MANIFEST_PARSING_ERROR,fatal:t.type===Me.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,r=!1,s,n){let a=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===Me.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Me.AUDIO_TRACK||e.type===Me.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);M.warn(`[playlist-loader]: ${a}`);let l=$.UNKNOWN,d=!1,c=this.getInternalLoader(e);switch(e.type){case Me.MANIFEST:l=r?$.MANIFEST_LOAD_TIMEOUT:$.MANIFEST_LOAD_ERROR,d=!0;break;case Me.LEVEL:l=r?$.LEVEL_LOAD_TIMEOUT:$.LEVEL_LOAD_ERROR,d=!1;break;case Me.AUDIO_TRACK:l=r?$.AUDIO_TRACK_LOAD_TIMEOUT:$.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Me.SUBTITLE_TRACK:l=r?$.SUBTITLE_TRACK_LOAD_TIMEOUT:$.SUBTITLE_LOAD_ERROR,d=!1;break}c&&this.resetInternalLoader(e.type);let u={type:ue.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(s){let h=(t==null?void 0:t.url)||e.url;u.response=Ct({url:h,data:void 0},s)}this.hls.trigger(b.ERROR,u)}handlePlaylistLoaded(e,t,r,s,n,a){let o=this.hls,{type:l,level:d,id:c,groupId:u,deliveryDirectives:h}=s,f=ih(t,s),g=W0(s),E=typeof s.level=="number"&&g===he.MAIN?d:void 0;if(!e.fragments.length){let A=new Error("No Segments found in Playlist");o.trigger(b.ERROR,{type:ue.NETWORK_ERROR,details:$.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:A,reason:A.message,response:t,context:s,level:E,parent:g,networkDetails:n,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let T=e.playlistParsingError;if(T){o.trigger(b.ERROR,{type:ue.NETWORK_ERROR,details:$.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:T,reason:T.message,response:t,context:s,level:E,parent:g,networkDetails:n,stats:r});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case Me.MANIFEST:case Me.LEVEL:o.trigger(b.LEVEL_LOADED,{details:e,level:E||0,id:c||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case Me.AUDIO_TRACK:o.trigger(b.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case Me.SUBTITLE_TRACK:o.trigger(b.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break}}};function kv(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function wv(i,e){let t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){M.debug(`[texttrack-utils]: ${r}`);try{let s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,i.addCue(s)}catch(s){M.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(i.mode=t)}function nn(i){let e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function Ah(i,e,t,r){let s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){let n=FA(i.cues,e,t);for(let a=0;a<n.length;a++)(!r||r(n[a]))&&i.removeCue(n[a])}s==="disabled"&&(i.mode=s)}function UA(i,e){if(e<i[0].startTime)return 0;let t=i.length-1;if(e>i[t].endTime)return-1;let r=0,s=t;for(;r<=s;){let n=Math.floor((s+r)/2);if(e<i[n].startTime)s=n-1;else if(e>i[n].startTime&&r<t)r=n+1;else return n}return i[r].startTime-e<e-i[s].startTime?r:s}function FA(i,e,t){let r=[],s=UA(i,e);if(s>-1)for(let n=s,a=i.length;n<a;n++){let o=i[n];if(o.startTime>=e&&o.endTime<=t)r.push(o);else if(o.startTime>t)return r}return r}var bi={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},BA=.25;function Sh(){if(typeof self!="undefined")return self.VTTCue||self.TextTrackCue}function K0(i,e,t,r,s){let n=new i(e,t,"");try{n.value=r,s&&(n.type=s)}catch{n=new i(e,t,JSON.stringify(s?Ct({type:s},r):r))}return n}var Ml=(()=>{let i=Sh();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function rh(i,e){return i.getTime()/1e3-e}function $A(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var xh=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(nn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let r=e[t];if(r.kind==="metadata"&&r.label==="id3")return kv(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=Sh();if(a)for(let o=0;o<n.length;o++){let l=n[o].type;if(l===bi.emsg&&!r||!s)continue;let d=yv(n[o].data);if(d){let c=n[o].pts,u=c+n[o].duration;u>Ml&&(u=Ml),u-c<=0&&(u=c+BA);for(let f=0;f<d.length;f++){let g=d[f];if(!bv(g)){this.updateId3CueEnds(c,l);let E=K0(a,c,u,g,l);E&&this.id3Track.addCue(E)}}}}}updateId3CueEnds(e,t){var r;let s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let n=s.length;n--;){let a=s[n];a.type===t&&a.startTime<e&&a.endTime===Ml&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;s==="audio"?d=c=>c.type===bi.audioId3&&l:s==="video"?d=c=>c.type===bi.emsg&&o:d=c=>c.type===bi.audioId3&&l||c.type===bi.emsg&&o,Ah(n,t,r,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){let c=Object.keys(r).filter(u=>!a.includes(u));for(let u=c.length;u--;){let h=c[u];Object.keys(r[h].cues).forEach(f=>{s.removeCue(r[h].cues[f])}),delete r[h]}}let o=t.fragments[t.fragments.length-1];if(a.length===0||!oe(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,d=Sh();for(let c=0;c<a.length;c++){let u=a[c],h=n[u],f=r[u],g=(f==null?void 0:f.cues)||{},E=(f==null?void 0:f.durationKnown)||!1,T=rh(h.startDate,l),A=Ml,k=h.endDate;if(k)A=rh(k,l),E=!0;else if(h.endOnNext&&!E){let F=a.reduce((R,B)=>{let P=n[B];return P.class===h.class&&P.id!==B&&P.startDate>h.startDate&&R.push(P),R},[]).sort((R,B)=>R.startDate.getTime()-B.startDate.getTime())[0];F&&(A=rh(F.startDate,l),E=!0)}let L=Object.keys(h.attr);for(let F=0;F<L.length;F++){let R=L[F];if(!Q_(R))continue;let B=g[R];if(B)E&&!f.durationKnown&&(B.endTime=A);else if(d){let P=h.attr[R];Z_(R)&&(P=$A(P));let G=K0(d,T,A,{key:R,data:P},bi.dateRange);G&&(G.id=u,this.id3Track.addCue(G),g[R]=G)}}r[u]={cues:g,dateRange:h,durationKnown:E}}}},Ih=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(e===null)return null;let{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*s);let c=s,u=1;return d+Math.min(this.stallCount*u,c)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;let s=r.edge,n=e-t-this.edgeStalled,a=s-r.totalduration,o=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(b.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(b.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(b.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(b.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===$.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&M.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1)return;let a=this.targetLatency;if(a===null)return;let o=r-a,l=Math.min(this.maxLatency,a+t.targetduration),d=o<l;if(t.live&&d&&o>.05&&this.forwardBufferLength>1){let c=Math.min(2,Math.max(1,n)),u=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,u))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){let{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},Lh=["NONE","TYPE-0","TYPE-1",null],aa={No:"",Yes:"YES",v2:"v2"};function GA(i,e){let{canSkipUntil:t,canSkipDateRanges:r,endSN:s}=i,n=e!==void 0?e-s:0;return t&&n<t?r?aa.v2:aa.Yes:aa.No}var ql=class{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){let t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}},Qr=class{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>t).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){let t=e%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var e;return(e=this.audioGroupIds)==null?void 0:e[this.urlId]}get textGroupId(){var e;return(e=this.textGroupIds)==null?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}};function sh(i,e){let t=e.startPTS;if(oe(t)){let r=0,s;e.sn>i.sn?(r=t-i.start,s=i):(r=i.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function Dv(i,e,t,r,s,n){r-t<=0&&(M.warn("Fragment should have a positive duration",e),r=t+e.duration,n=s+e.duration);let o=t,l=r,d=e.startPTS,c=e.endPTS;if(oe(d)){let T=Math.abs(d-t);oe(e.deltaPTS)?e.deltaPTS=Math.max(T,e.deltaPTS):e.deltaPTS=T,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(r,c),r=Math.max(r,c),n=Math.max(n,e.endDTS)}let u=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=n;let h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f,g=h-i.startSN,E=i.fragments;for(E[g]=e,f=g;f>0;f--)sh(E[f],E[f-1]);for(f=g;f<E.length-1;f++)sh(E[f],E[f+1]);return i.fragmentHint&&sh(E[E.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,u}function HA(i,e){let t=null,r=i.fragments;for(let l=r.length-1;l>=0;l--){let d=r[l].initSegment;if(d){t=d;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let s=0,n;if(KA(i,e,(l,d)=>{l.relurl&&(s=l.cc-d.cc),oe(l.startPTS)&&oe(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(n=d),e.PTSKnown=e.alignedSliding=!0),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,d.urlId=l.urlId,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var c;(!d.initSegment||d.initSegment.relurl===((c=t)==null?void 0:c.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){M.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=VA(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));let a=e.fragments;if(s){M.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),WA(i.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?Dv(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Cv(i,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;let o=e.advancedDateTime;if(e.advanced&&o){let l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function VA(i,e,t){let r=ht({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{let n=new Hl(e[s].attr,r[s]);n.isValid?r[s]=n:M.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function WA(i,e,t){if(i&&e){let r=0;for(let s=0,n=i.length;s<=n;s++){let a=i[s],o=e[s+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):r--}}}function KA(i,e,t){let r=e.skippedSegments,s=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(r?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=s;d<=n;d++){let c=l[a+d],u=o[d];r&&!u&&d<r&&(u=e.fragments[d]=c),c&&u&&t(c,u)}}function Cv(i,e){let t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||Rh(e,r[t].start)}function Rh(i,e){if(e){let t=i.fragments;for(let r=i.skippedSegments;r<t.length;r++)t[r].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function qA(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){let r=i.fragments,s=4;if(r.length&&t*s>e){let n=r[r.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function YA(i,e,t){if(!(i!=null&&i.details))return null;let r=i.details,s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function q0(i,e,t){var r;return i!=null&&i.details?Mv((r=i.details)==null?void 0:r.partList,e,t):null}function Mv(i,e,t){if(i)for(let r=i.length;r--;){let s=i[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function Yl(i){switch(i.details){case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_TIMEOUT:case $.LEVEL_LOAD_TIMEOUT:case $.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Y0(i,e){let t=Yl(e);return i.default[`${t?"timeout":"error"}Retry`]}function Sf(i,e){let t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function j0(i){return Ct(Ct({},i),{errorRetry:null,timeoutRetry:null})}function jl(i,e,t,r){return!!i&&e<i.maxNumRetry&&(jA(r)||!!t)}function jA(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}var Pv={search:function(i,e){let t=0,r=i.length-1,s=null,n=null;for(;t<=r;){s=(t+r)/2|0,n=i[s];let a=e(n);if(a>0)t=s+1;else if(a<0)r=s-1;else return n}return null}};function zA(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!oe(e))return null;let r=i[0].programDateTime;if(e<(r||0))return null;let s=i[i.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<i.length;++n){let a=i[n];if(XA(e,t,a))return a}return null}function ca(i,e,t=0,r=0){let s=null;if(i?s=e[i.sn-e[0].sn+1]||null:t===0&&e[0].start===0&&(s=e[0]),s&&kh(t,r,s)===0)return s;let n=Pv.search(e,kh.bind(null,t,r));return n&&(n!==i||!s)?n:s}function kh(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=i?1:t.start-r>i&&t.start?-1:0}function XA(i,e,t){let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function QA(i,e){return Pv.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var ZA=3e5,Lt={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},si={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},wh=class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=M.log.bind(M,"[info]:"),this.warn=M.warn.bind(M,"[warning]:"),this.error=M.error.bind(M,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(b.ERROR,this.onError,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(b.ERROR,this.onError,this),e.off(b.ERROR,this.onErrorOut,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(e==null?void 0:e.type)===he.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;let n=this.hls,a=t.context;switch(t.details){case $.FRAG_LOAD_ERROR:case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_ERROR:case $.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case $.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:Lt.DoNothing,flags:si.None};return}case $.FRAG_GAP:case $.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Lt.SendAlternateToPenaltyBox;return}case $.LEVEL_EMPTY_ERROR:case $.LEVEL_PARSING_ERROR:{var o,l;let d=t.parent===he.MAIN?t.level:n.loadLevel;t.details===$.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))}return;case $.LEVEL_LOAD_ERROR:case $.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case $.AUDIO_TRACK_LOAD_ERROR:case $.AUDIO_TRACK_LOAD_TIMEOUT:case $.SUBTITLE_LOAD_ERROR:case $.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){let d=n.levels[n.loadLevel];if(d&&(a.type===Me.AUDIO_TRACK&&a.groupId===d.audioGroupId||a.type===Me.SUBTITLE_TRACK&&a.groupId===d.textGroupId)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=Lt.SendAlternateToPenaltyBox,t.errorAction.flags=si.MoveAllAlternatesMatchingHost;return}}return;case $.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let d=n.levels[n.loadLevel],c=d==null?void 0:d.attrs["HDCP-LEVEL"];c&&(t.errorAction={action:Lt.SendAlternateToPenaltyBox,flags:si.MoveAllAlternatesMatchingHDCP,hdcpLevel:c})}return;case $.BUFFER_ADD_CODEC_ERROR:case $.REMUX_ALLOC_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:n.loadLevel);return;case $.INTERNAL_EXCEPTION:case $.BUFFER_APPENDING_ERROR:case $.BUFFER_APPEND_ERROR:case $.BUFFER_FULL_ERROR:case $.LEVEL_SWITCH_ERROR:case $.BUFFER_STALLED_ERROR:case $.BUFFER_SEEK_OVER_HOLE:case $.BUFFER_NUDGE_ON_STALL:t.errorAction={action:Lt.DoNothing,flags:si.None};return}if(t.type===ue.KEY_SYSTEM_ERROR){let d=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d);return}}getPlaylistRetryOrSwitchAction(e,t){var r;let s=this.hls,n=Y0(s.config.playlistLoadPolicy,e),a=this.playlistError++,o=(r=e.response)==null?void 0:r.code;if(jl(n,a,Yl(e),o))return{action:Lt.RetryRequest,flags:si.None,retryConfig:n,retryCount:a};let d=this.getLevelSwitchAction(e,t);return n&&(d.retryConfig=n,d.retryCount=a),d}getFragRetryOrSwitchAction(e){let t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=Y0(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((u,h)=>u+h.fragmentError,0);if(s){var d;e.details!==$.FRAG_GAP&&s.fragmentError++;let u=(d=e.response)==null?void 0:d.code;if(jl(o,l,Yl(e),u))return{action:Lt.RetryRequest,flags:si.None,retryConfig:o,retryCount:l}}let c=this.getLevelSwitchAction(e,r);return o&&(c.retryConfig=o,c.retryCount=l),c}getLevelSwitchAction(e,t){let r=this.hls;t==null&&(t=r.loadLevel);let s=this.hls.levels[t];if(s&&(s.loadError++,r.autoLevelEnabled)){var n,a;let o=-1,{levels:l,loadLevel:d,minAutoLevel:c,maxAutoLevel:u}=r,h=(n=e.frag)==null?void 0:n.type,{type:f,groupId:g}=(a=e.context)!=null?a:{};for(let E=l.length;E--;){let T=(E+d)%l.length;if(T!==d&&T>=c&&T<=u&&l[T].loadError===0){let A=l[T];if(e.details===$.FRAG_GAP&&e.frag){let k=l[T].details;if(k){let L=ca(e.frag,k.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(f===Me.AUDIO_TRACK&&g===A.audioGroupId||f===Me.SUBTITLE_TRACK&&g===A.textGroupId)continue;if(h===he.AUDIO&&s.audioGroupId===A.audioGroupId||h===he.SUBTITLE&&s.textGroupId===A.textGroupId)continue}o=T;break}}if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:Lt.SendAlternateToPenaltyBox,flags:si.None,nextAutoLevel:o}}return{action:Lt.SendAlternateToPenaltyBox,flags:si.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case Lt.DoNothing:break;case Lt.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==$.FRAG_GAP&&(t.fatal=!0);break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,r=e.errorAction;if(!r)return;let{flags:s,hdcpLevel:n,nextAutoLevel:a}=r;switch(s){case si.None:this.switchLevel(e,a);break;case si.MoveAllAlternatesMatchingHost:r.resolved||(r.resolved=this.redundantFailover(e));break;case si.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Lh[Lh.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(e){let{hls:t,penalizedRenditions:r}=this,s=e.parent===he.MAIN?e.level:t.loadLevel,n=t.levels[s],a=n.url.length,o=e.frag?e.frag.urlId:n.urlId;n.urlId===o&&(!e.frag||n.details)&&this.penalizeRendition(n,e);for(let l=1;l<a;l++){let d=(o+l)%a,c=r[d];if(!c||JA(c,e,r[o]))return this.warn(`Switching to Redundant Stream ${d+1}/${a}: "${n.url[d]}" after ${e.details}`),this.playlistError=0,t.levels.forEach(u=>{u.urlId=d}),t.nextLoadLevel=s,!0}return!1}penalizeRendition(e,t){let{penalizedRenditions:r}=this,s=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};s.lastErrorPerfMs=performance.now(),s.errors.push(t),s.details=e.details,r[e.urlId]=s}};function JA(i,e,t){if(performance.now()-i.lastErrorPerfMs>ZA)return!0;let r=i.details;if(e.details===$.FRAG_GAP&&r&&e.frag){let s=e.frag.start,n=ca(null,r.fragments,s);if(n&&!n.gap)return!0}if(t&&i.errors.length<t.errors.length){let s=i.errors[i.errors.length-1];if(r&&s.frag&&e.frag&&Math.abs(s.frag.start-e.frag.start)>r.targetduration*3)return!0}return!1}var ua=class{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=M.log.bind(M,`${t}:`),this.warn=M.warn.bind(M,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t){let r=t==null?void 0:t.renditionReports;if(r){let s=-1;for(let n=0;n<r.length;n++){let a=r[n],o;try{o=new self.URL(a.URI,t.url).href}catch(l){M.warn(`Could not construct new URL for Rendition Report: ${l}`),o=a.URI||""}if(o===e){s=n;break}else o===e.substring(0,o.length)&&(s=n)}if(s!==-1){let n=r[s],a=parseInt(n["LAST-MSN"])||(t==null?void 0:t.lastPartSn),o=parseInt(n["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){let l=Math.min(t.age-t.partTarget,t.targetduration);o>=0&&l>t.partTarget&&(o+=1)}return new ql(a,o>=0?o:void 0,aa.No)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){let{details:s,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),r&&s.fragments.length>0&&HA(r,s),!this.canLoad||!s.live)return;let l,d,c;if(s.canBlockReload&&s.endSN&&s.advanced){let T=this.hls.config.lowLatencyMode,A=s.lastPartSn,k=s.endSN,L=s.lastPartIndex,F=L!==-1,R=A===k,B=T?0:L;F?(d=R?k+1:A,c=R?B:L+1):d=k+1;let P=s.age,G=P+s.ageHeader,K=Math.min(G-s.partTarget,s.targetduration*1.5);if(K>0){if(r&&K>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${K} with playlist age: ${s.age}`),K=0;else{let N=Math.floor(K/s.targetduration);if(d+=N,c!==void 0){let j=Math.round(K%s.targetduration/s.partTarget);c+=j}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${P.toFixed(2)}s goal: ${K} skip sn ${N} to part ${c}`)}s.tuneInGoal=K}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,c),T||!R){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,c));let u=this.hls.mainForwardBufferInfo,h=u?u.end-u.len:0,f=(s.edge-h)*1e3,g=qA(s,f);s.updated&&a>this.requestScheduled+g&&(this.requestScheduled=n.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+g-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+g<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=g);let E=this.requestScheduled-a;E=Math.max(0,E),this.log(`reload live playlist ${e} in ${Math.round(E)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),E)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let n=GA(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=aa.No),new ql(r,s,n)}checkRetry(e){let t=e.details,r=Yl(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===Lt.RetryRequest||!s.resolved&&n===Lt.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(r&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let c=Sf(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${c}ms`)}e.levelRetry=!0,s.resolved=!0}return l}},nh,Dh=class extends ua{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let r=[],s={},n;t.levels.forEach(a=>{var o;let l=a.attrs;((o=a.audioCodec)==null?void 0:o.indexOf("mp4a.40.34"))!==-1&&(nh||(nh=/chrome|firefox/i.test(navigator.userAgent)),nh&&(a.audioCodec=void 0));let{AUDIO:d,CODECS:c,"FRAME-RATE":u,"PATHWAY-ID":h,RESOLUTION:f,SUBTITLES:g}=l,T=`${`${h||"."}-`}${a.bitrate}-${f}-${u}-${c}`;n=s[T],n?n.addFallback(a):(n=new Qr(a),s[T]=n,r.push(n)),zl(n,"audio",d),zl(n,"text",g)}),this.filterAndSortMediaOptions(r,t)}filterAndSortMediaOptions(e,t){let r=[],s=[],n=!1,a=!1,o=!1,l=e.filter(({audioCodec:f,videoCodec:g,width:E,height:T,unknownCodecs:A})=>(n||(n=!!(E&&T)),a||(a=!!g),o||(o=!!f),!(A!=null&&A.length)&&(!f||th(f,"audio"))&&(!g||th(g,"video"))));if((n||a)&&o&&(l=l.filter(({videoCodec:f,width:g,height:E})=>!!f||!!(g&&E))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let f=new Error("no level with compatible codecs found in manifest");this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:f,reason:f.message})}});return}t.audioTracks&&(r=t.audioTracks.filter(f=>!f.audioCodec||th(f.audioCodec,"audio")),z0(r)),t.subtitles&&(s=t.subtitles,z0(s));let d=l.slice(0);l.sort((f,g)=>f.attrs["HDCP-LEVEL"]!==g.attrs["HDCP-LEVEL"]?(f.attrs["HDCP-LEVEL"]||"")>(g.attrs["HDCP-LEVEL"]||"")?1:-1:f.bitrate!==g.bitrate?f.bitrate-g.bitrate:f.attrs["FRAME-RATE"]!==g.attrs["FRAME-RATE"]?f.attrs.decimalFloatingPoint("FRAME-RATE")-g.attrs.decimalFloatingPoint("FRAME-RATE"):f.attrs.SCORE!==g.attrs.SCORE?f.attrs.decimalFloatingPoint("SCORE")-g.attrs.decimalFloatingPoint("SCORE"):n&&f.height!==g.height?f.height-g.height:0);let c=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let f=0;f<d.length;f++)if(d[f].pathwayId===l[0].pathwayId){c=d[f];break}}this._levels=l;for(let f=0;f<l.length;f++)if(l[f]===c){this._firstLevel=f,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${c.bitrate}`);break}let u=o&&!a,h={levels:l,audioTracks:r,subtitleTracks:s,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:o,video:a,altAudio:!u&&r.some(f=>!!f.url)};this.hls.trigger(b.MANIFEST_PARSED,h),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(b.ERROR,{type:ue.OTHER_ERROR,details:$.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,t.length-1)}let r=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&s&&n===o)return;this.log(`Switching to level ${e}${o?" with Pathway "+o:""} from level ${r}${n?" with Pathway "+n:""}`);let l=ht({},a,{level:e,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(b.LEVEL_SWITCHING,l);let d=a.details;if(!d||d.live){let c=this.switchParams(a.uri,s==null?void 0:s.details);this.loadPlaylist(c)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){let e=this.hls.config.startLevel;return e!==void 0?e:this._firstLevel}else return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===Me.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(t!==void 0&&t.type===he.MAIN){let r=this._levels[t.level];r!==void 0&&(r.loadError=0)}}onLevelLoaded(e,t){var r;let{level:s,details:n}=t,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(n.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){let r=this.currentLevel;if(!r)return;let s=this.hls.audioTracks[t.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==s){let n=-1;for(let a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===s){n=a;break}n!==-1&&n!==r.urlId&&(r.urlId=n,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.urlId,n=r.uri;if(e)try{n=e.addDirectives(n)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}let a=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${a?" Pathway "+a:""} URI ${s+1}/${r.url.length} ${n}`),this.clearTimer(),this.hls.trigger(b.LEVEL_LOADING,{url:n,level:t,id:s,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e,t){let r=(n,a)=>a!==t,s=this._levels.filter((n,a)=>a!==e?!0:n.url.length>1&&t!==void 0?(n.url=n.url.filter(r),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(r)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(r)),n.urlId=0,!0):(this.steering&&this.steering.removeLevel(n),!1));this.hls.trigger(b.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(e,{levels:t}){t.forEach((r,s)=>{let{details:n}=r;n!=null&&n.fragments&&n.fragments.forEach(a=>{a.level=s})}),this._levels=t}};function zl(i,e,t){t&&(e==="audio"?(i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds[i.url.length-1]=t):e==="text"&&(i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds[i.url.length-1]=t))}function z0(i){let e={};i.forEach(t=>{let r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}var Et={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Ch=class{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(b.BUFFER_APPENDED,this.onBufferAppended,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.BUFFER_APPENDED,this.onBufferAppended,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let r=this.activePartLists[t];if(r)for(let s=r.length;s--;){let n=r[s];if(!n)break;let a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:r}=this,s=Object.keys(r);for(let n=s.length;n--;){let a=r[s[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){let o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);let n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===r&&this.removeFragment(o.body);return}let l=o.range[e];l&&l.time.some(d=>{let c=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return c&&this.removeFragment(o.body),c})})}detectPartialFragments(e){let t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;let n=tn(r),a=this.fragments[n];if(!a||a.buffered&&r.gap)return;let o=!r.relurl;Object.keys(t).forEach(l=>{let d=r.elementaryStreams[l];if(!d)return;let c=t[l],u=o||d.partial===!0;a.range[l]=this.getBufferedTimes(r,s,u,c)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),Pl(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){let r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){let r=tn(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){let n={time:[],partial:r},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let c=0;c<s.length;c++){let u=s.start(c)-this.bufferPadding,h=s.end(c)+this.bufferPadding;if(d>=u&&l<=h){n.time.push({startPTS:Math.max(a,s.start(c)),endPTS:Math.min(o,s.end(c))});break}else if(a<h&&o>u)n.partial=!0,n.time.push({startPTS:Math.max(a,s.start(c)),endPTS:Math.min(o,s.end(c))});else if(o<=u)break}return n}getPartialFragment(e){let t=null,r,s,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let c=l[d];c&&Pl(c)&&(s=c.body.start-o,n=c.body.end+o,e>=s&&e<=n&&(r=Math.min(e-s,n-e),a<=r&&(t=c.body,a=r)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||Pl(t))}getState(e){let t=tn(e),r=this.fragments[t];return r?r.buffered?Pl(r)?Et.PARTIAL:Et.OK:Et.APPENDING:Et.NOT_LOADED}isTimeBuffered(e,t,r){let s,n;for(let a=0;a<r.length;a++){if(s=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){let{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;let n=s?null:t,a=tn(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:r,part:s,timeRanges:n}=t;if(r.sn==="initSegment")return;let a=r.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{let l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=tn(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let l=o.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){let t=tn(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let r=this.activePartLists[e.type];if(r){let s=e.sn;this.activePartLists[e.type]=r.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}};function Pl(i){var e,t,r;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function tn(i){return`${i.type}_${i.level}_${i.urlId}_${i.sn}`}var X0=Math.pow(2,17),Mh=class{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let r=e.url;if(!r)return Promise.reject(new Ei({type:ue.NETWORK_ERROR,details:$.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(Z0(e));return}else e.gap=!1;let d=this.loader=e.loader=n?new n(s):new a(s),c=Q0(e),u=j0(s.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:X0};e.stats=d.stats,d.load(c,h,{onSuccess:(f,g,E,T)=>{this.resetLoader(e,d);let A=f.data;E.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(A.slice(0,16)),A=A.slice(16)),o({frag:e,part:null,payload:A,networkDetails:T})},onError:(f,g,E,T)=>{this.resetLoader(e,d),l(new Ei({type:ue.NETWORK_ERROR,details:$.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Ct({url:r,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:E,stats:T}))},onAbort:(f,g,E)=>{this.resetLoader(e,d),l(new Ei({type:ue.NETWORK_ERROR,details:$.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:E,stats:f}))},onTimeout:(f,g,E)=>{this.resetLoader(e,d),l(new Ei({type:ue.NETWORK_ERROR,details:$.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:f}))},onProgress:(f,g,E,T)=>{t&&t({frag:e,part:null,payload:E,networkDetails:T})}})})}loadPart(e,t,r){this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(Z0(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),c=Q0(e,t),u=j0(s.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:X0};t.stats=d.stats,d.load(c,h,{onSuccess:(f,g,E,T)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);let A={frag:e,part:t,payload:f.data,networkDetails:T};r(A),o(A)},onError:(f,g,E,T)=>{this.resetLoader(e,d),l(new Ei({type:ue.NETWORK_ERROR,details:$.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Ct({url:c.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:E,stats:T}))},onAbort:(f,g,E)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new Ei({type:ue.NETWORK_ERROR,details:$.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:E,stats:f}))},onTimeout:(f,g,E)=>{this.resetLoader(e,d),l(new Ei({type:ue.NETWORK_ERROR,details:$.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:f}))}})})}updateStatsFromPart(e,t){let r=e.stats,s=t.stats,n=s.total;if(r.loaded+=s.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/n),l),u=(l-d)*Math.round(r.loaded/d);r.total=r.loaded+u}else r.total=Math.max(r.loaded,r.total);let a=r.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}};function Q0(i,e=null){let t=e||i,r={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(oe(s)&&oe(n)){var a;let o=s,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function Z0(i,e){let t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:ue.MEDIA_ERROR,details:$.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(r.part=e),(e||i).stats.aborted=!0,new Ei(r)}var Ei=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},Ph=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let t in this.keyUriToKeyInfo){let r=this.keyUriToKeyInfo[t].loader;if(r){if(e&&e!==r.context.frag.type)return;r.abort()}}}detach(){for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=$.KEY_LOAD_ERROR,r,s,n){return new Ei({type:ue.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:r,cc:s}=e;for(let n=0;n<t.length;n++){let a=t[n];if(s<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,s;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let d=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,$.KEY_LOAD_ERROR,d))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,$.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((r=o)!=null&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,$.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,r))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(r)}loadKeyHTTP(e,t){let r=this.config,s=r.loader,n=new s(r);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,E)=>{let{frag:T,keyInfo:A,url:k}=g;if(!T.decryptdata||A!==this.keyUriToKeyInfo[k])return o(this.createKeyLoadError(T,$.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),E));A.decryptdata.key=T.decryptdata.key=new Uint8Array(h.data),T.keyLoader=null,A.loader=null,a({frag:T,keyInfo:A})},onError:(h,f,g,E)=>{this.resetLoader(f),o(this.createKeyLoadError(t,$.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),g,Ct({url:l.url,data:void 0},h)))},onTimeout:(h,f,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,$.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),g))},onAbort:(h,f,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,$.INTERNAL_ABORTED,new Error("key loading aborted"),g))}};n.load(l,c,u)})}resetLoader(e){let{frag:t,keyInfo:r,url:s}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}},Oh=class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}},e1={length:0,start:()=>0,end:()=>0},Xe=class i{static isBuffered(e,t){try{if(e){let r=i.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){let s=i.getBuffered(e),n=[],a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(d,c){let u=d.start-c.start;return u||c.end-d.end});let s=[];if(r)for(let d=0;d<e.length;d++){let c=s.length;if(c){let u=s[c-1].end;e[d].start-u<r?e[d].end>u&&(s[c-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let n=0,a,o=t,l=t;for(let d=0;d<s.length;d++){let c=s[d].start,u=s[d].end;if(t+r>=c&&t<u)o=c,l=u,n=l-t;else if(t+r<c){a=c;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return M.log("failed to get media.buffered",t),e1}}},ha=class{constructor(e,t,r,s=0,n=-1,a=!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=Ol(),this.buffering={audio:Ol(),video:Ol(),audiovideo:Ol()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}};function Ol(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Ov(i,e){let t=null;for(let r=0,s=i.length;r<s;r++){let n=i[r];if(n&&n.cc===e){t=n;break}}return t}function t1(i,e,t){return!!(e.details&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function i1(i,e,t=0){let r=i.fragments,s=e.fragments;if(!s.length||!r.length){M.log("No fragments to align");return}let n=Ov(r,s[0].cc);if(!n||n&&!n.startPTS){M.log("No frag in previous level to align on");return}return n}function J0(i,e){if(i){let t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function xf(i,e){let t=e.fragments;for(let r=0,s=t.length;r<s;r++)J0(t[r],i);e.fragmentHint&&J0(e.fragmentHint,i),e.alignedSliding=!0}function r1(i,e,t){e&&(s1(i,t,e),!t.alignedSliding&&e.details&&n1(t,e.details),!t.alignedSliding&&e.details&&!t.skippedSegments&&Cv(e.details,t))}function s1(i,e,t){if(t1(i,t,e)){let r=i1(t.details,e);r&&oe(r.start)&&(M.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),xf(r.start,e))}}function n1(i,e){if(!e.fragments.length||!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=e.fragments[0].programDateTime,r=i.fragments[0].programDateTime,s=(r-t)/1e3+e.fragments[0].start;s&&oe(s)&&(M.log(`Adjusting PTS using programDateTime delta ${r-t}ms, sliding:${s.toFixed(3)} ${i.url} `),xf(s,i))}function Nv(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=i.fragments,r=e.fragments;if(!t.length||!r.length)return;let s=Math.round(r.length/2)-1,n=r[s],a=Ov(t,n.cc)||t[Math.round(t.length/2)-1],o=n.programDateTime,l=a.programDateTime;if(o===null||l===null)return;let d=(l-o)/1e3-(a.start-n.start);xf(d,i)}var Nh=class{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}},Uh=class{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}};function a1(i){let e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?zr(i,0,e-t):i}var Fh=class{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){let t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){let e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],n=r[1],a=r[2],o=r[3],l=this.invSubMix,d=l[0],c=l[1],u=l[2],h=l[3],f=new Uint32Array(256),g=0,E=0,T=0;for(T=0;T<256;T++)T<128?f[T]=T<<1:f[T]=T<<1^283;for(T=0;T<256;T++){let A=E^E<<1^E<<2^E<<3^E<<4;A=A>>>8^A&255^99,e[g]=A,t[A]=g;let k=f[g],L=f[k],F=f[L],R=f[A]*257^A*16843008;s[g]=R<<24|R>>>8,n[g]=R<<16|R>>>16,a[g]=R<<8|R>>>24,o[g]=R,R=F*16843009^L*65537^k*257^g*16843008,d[A]=R<<24|R>>>8,c[A]=R<<16|R>>>16,u[A]=R<<8|R>>>24,h[A]=R,g?(g=k^f[f[f[F^k]]],E^=f[f[E]]):g=E=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;let n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);let a=this.ksRows=(n+6+1)*4,o,l,d=this.keySchedule=new Uint32Array(a),c=this.invKeySchedule=new Uint32Array(a),u=this.sBox,h=this.rcon,f=this.invSubMix,g=f[0],E=f[1],T=f[2],A=f[3],k,L;for(o=0;o<a;o++){if(o<n){k=d[o]=t[o];continue}L=k,o%n===0?(L=L<<8|L>>>24,L=u[L>>>24]<<24|u[L>>>16&255]<<16|u[L>>>8&255]<<8|u[L&255],L^=h[o/n|0]<<24):n>6&&o%n===4&&(L=u[L>>>24]<<24|u[L>>>16&255]<<16|u[L>>>8&255]<<8|u[L&255]),d[o]=k=(d[o-n]^L)>>>0}for(l=0;l<a;l++)o=a-l,l&3?L=d[o]:L=d[o-4],l<4||o<=4?c[l]=L:c[l]=g[u[L>>>24]]^E[u[L>>>16&255]]^T[u[L>>>8&255]]^A[u[L&255]],c[l]=c[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){let s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],c=o[2],u=o[3],h=this.uint8ArrayToUint32Array_(r),f=h[0],g=h[1],E=h[2],T=h[3],A=new Int32Array(e),k=new Int32Array(A.length),L,F,R,B,P,G,K,N,j,Y,Ee,ge,ye,we,Ie=this.networkToHostOrderSwap;for(;t<A.length;){for(j=Ie(A[t]),Y=Ie(A[t+1]),Ee=Ie(A[t+2]),ge=Ie(A[t+3]),P=j^n[0],G=ge^n[1],K=Ee^n[2],N=Y^n[3],ye=4,we=1;we<s;we++)L=l[P>>>24]^d[G>>16&255]^c[K>>8&255]^u[N&255]^n[ye],F=l[G>>>24]^d[K>>16&255]^c[N>>8&255]^u[P&255]^n[ye+1],R=l[K>>>24]^d[N>>16&255]^c[P>>8&255]^u[G&255]^n[ye+2],B=l[N>>>24]^d[P>>16&255]^c[G>>8&255]^u[K&255]^n[ye+3],P=L,G=F,K=R,N=B,ye=ye+4;L=a[P>>>24]<<24^a[G>>16&255]<<16^a[K>>8&255]<<8^a[N&255]^n[ye],F=a[G>>>24]<<24^a[K>>16&255]<<16^a[N>>8&255]<<8^a[P&255]^n[ye+1],R=a[K>>>24]<<24^a[N>>16&255]<<16^a[P>>8&255]<<8^a[G&255]^n[ye+2],B=a[N>>>24]<<24^a[P>>16&255]<<16^a[G>>8&255]<<8^a[K&255]^n[ye+3],k[t]=Ie(L^f),k[t+1]=Ie(B^g),k[t+2]=Ie(R^E),k[t+3]=Ie(F^T),f=j,g=Y,E=Ee,T=ge,t=t+4}return k.buffer}},o1=16,fa=class{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?a1(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,r);let a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){let{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Xr(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Fh),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=zr(o,-16).buffer,d||null}webCryptoDecrypt(e,t,r){let s=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new Uh(s,t)),this.fastAesKey.expandKey().then(n=>s?(this.logOnce("WebCrypto AES decrypt"),new Nh(s,new Uint8Array(r)).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(M.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);let s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,r=e.length-e.length%o1;return r!==e.length&&(t=zr(e,0,r),this.remainderData=zr(e,r)),t}logOnce(e){this.logEnabled&&(M.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},l1={toString:function(i){let e="",t=i.length;for(let r=0;r<t;r++)e+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return e}},V={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},ma=class extends Oh{constructor(e,t,r,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=V.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=M.log.bind(M,`${s}:`),this.warn=M.warn.bind(M,`${s}:`),this.hls=e,this.fragmentLoader=new Mh(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new fa(e.config),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=V.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;let r=t.partList;if(r!=null&&r.length){let n=r[r.length-1];return Xe.isBuffered(this.media,n.start+n.duration/2)}let s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levels[this.levelLastLoaded])==null?void 0:e.details}}onMediaAttached(e,t){let r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);let s=this.config;this.levels&&s.autoStartLoad&&this.state===V.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){let e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){let{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:n}=this,a=r?r.currentTime:0,o=Xe.bufferInfo(s||r,a,e.maxBufferHole);if(this.log(`media seeking to ${oe(a)?a.toFixed(3):a}, state: ${n}`),this.state===V.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,d=t.start-l,c=t.start+t.duration+l;if(!o.len||c<o.start||d>o.end){let u=a>c;(a<d||u)&&(u&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=V.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){let s=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,r,s).then(n=>{if(!n)return;let a=this.state;if(this.fragContextChanged(e)){(a===V.FRAG_LOADING||!this.fragCurrent&&a===V.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=V.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(b.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===V.STOPPED||this.state===V.ERROR||(this.warn(n),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:r}=this;if(r.getState(e)===Et.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength);this.reduceMaxBufferLength(o)&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===Et.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;let s={startOffset:e,endOffset:t,type:r};this.hls.trigger(b.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{let{hls:s}=this,{payload:n}=r,a=e.decryptdata;if(n&&n.byteLength>0&&a&&a.key&&a.iv&&a.method==="AES-128"){let o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{let d=self.performance.now();return s.trigger(b.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),r.payload=l,r})}return r}).then(r=>{let{fragCurrent:s,hls:n,levels:a}=this;if(!a)throw new Error("init load aborted, missing levels");let o=e.stats;this.state=V.IDLE,t.fragmentError=0,e.data=new Uint8Array(r.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),r.frag===s&&n.trigger(b.FRAG_BUFFERED,{stats:o,frag:s,part:null,id:e.type}),this.tick()}).catch(r=>{this.state===V.STOPPED||this.state===V.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var r,s,n,a;let o=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===he.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?l1.toString(Xe.getBuffered(o)):"(detached)"})`),this.state=V.IDLE,o&&(!this.loadedmetadata&&e.type==he.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:r,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new ha(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var n;let a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=V.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(c=>{if(!this.fragContextChanged(c.frag))return this.hls.trigger(b.KEY_LOADED,c),this.state===V.KEY_LOADING&&(this.state=V.IDLE),c}),this.hls.trigger(b.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let c=a.partList;if(c&&s){r>e.end&&a.fragmentHint&&(e=a.fragmentHint);let u=this.getNextPart(c,e,r);if(u>-1){let h=c[u];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${u}-${c.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=V.FRAG_LOADING;let f;return o?f=o.then(g=>!g||this.fragContextChanged(g.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(g=>this.handleFragLoadError(g)):f=this.doFragPartsLoad(e,h,t,s).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(b.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(c,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),oe(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=V.FRAG_LOADING;let l=this.config.progressive,d;return l&&o?d=o.then(c=>!c||this.fragContextChanged(c==null?void 0:c.frag)?null:this.fragmentLoader.load(e,s)).catch(c=>this.handleFragLoadError(c)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([c])=>(!l&&c&&s&&s(c),c)).catch(c=>this.handleFragLoadError(c)),this.hls.trigger(b.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,s){return new Promise((n,a)=>{var o;let l=[],d=(o=r.details)==null?void 0:o.partList,c=u=>{this.fragmentLoader.loadPart(e,u,s).then(h=>{l[u.index]=h;let f=h.part;this.hls.trigger(b.FRAG_LOADED,h);let g=q0(r,e.sn,u.index+1)||Mv(d,e.sn,u.index+1);if(g)c(g);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};c(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===$.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(b.ERROR,t)}else this.hls.trigger(b.ERROR,{type:ue.OTHER_ERROR,details:$.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==V.PARSING){!this.fragCurrent&&this.state!==V.STOPPED&&this.state!==V.ERROR&&(this.state=V.IDLE);return}let{frag:r,part:s,level:n}=t,a=self.performance.now();r.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(r,s,n,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:r}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;let o=t[s],l=a>-1?q0(o,n,a):null,d=l?l.fragment:YA(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,r,s,n){var a;if(!e||this.state!==V.PARSING)return;let{data1:o,data2:l}=e,d=o;if(o&&l&&(d=Xr(o,l)),!((a=d)!=null&&a.length))return;let c={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(b.BUFFER_APPENDING,c),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!Xe.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let r=t.currentTime,s=Xe.bufferInfo(t,r,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let r=this.getLoadPosition();return oe(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){let{config:{maxBufferHole:s}}=this,n=Xe.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return Xe.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){let{config:t}=this,r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e){let t=this.config,r=e||t.maxBufferLength;return t.maxMaxBufferLength>=r?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=he.MAIN){let r=this.fragmentTracker.getAppendedFrag(e,he.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){let r=t.fragments,s=r.length;if(!s)return null;let{config:n}=this,a=r[0].start,o;if(t.live){let l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(o=this.getInitialLiveFragment(t,r),this.startPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=r[0]);if(!o){let l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){let r=this.fragmentTracker.getState(e);return(r===Et.OK||r===Et.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){let d=e[o];if(a=a&&!d.independent,s>-1&&r<d.start)break;let c=d.loaded;c?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=c}return s}loadedEndOfParts(e,t){let r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){let r=this.fragPrevious,s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=zA(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){let n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];r.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=QA(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{let n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){let{config:s}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=r,{fragmentHint:l}=r,d=s.maxFragLookUpTolerance,c=r.partList,u=!!(s.lowLatencyMode&&c!=null&&c.length&&l);u&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){let f=e>t-d?0:d;h=ca(n,a,e,f)}else h=a[a.length-1];if(h){let f=h.sn-r.startSN,g=this.fragmentTracker.getState(h);if((g===Et.OK||g===Et.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!u||c[0].fragment.sn>h.sn)&&n&&h.level===n.level){let T=a[f+1];h.sn<o&&this.fragmentTracker.getState(T)!==Et.OK?h=T:h=null}}return h}synchronizeToLiveEdge(e){let{config:t,media:r}=this;if(!r)return;let s=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&r.duration>s&&(n<s||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t){let{levels:r,levelLastLoaded:s,fragPrevious:n}=this,a=s!==null?r[s]:null,o=e.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;let l=e.fragments[0].start,d=!t,c=e.alignedSliding&&oe(l);if(d||!c&&!l){r1(n,a,e);let u=e.fragments[0].start;return this.log(`Live playlist sliding: ${u.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${n?n.sn:"na"} fragments: ${o}`),u}return l}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),r===-1||this.lastCurrentTime===-1){let s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&oe(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==V.FRAG_LOADING_WAITING_RETRY)&&(this.state=V.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}let n=t.details===$.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===Lt.RetryRequest&&d){var c;this.resetStartWhenNotLoaded((c=this.levelLastLoaded)!=null?c:r.level);let u=Sf(d,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=V.FRAG_LOADING_WAITING_RETRY}else d&&a?(this.resetFragmentErrors(e),l<d.maxNumRetry?n||(a.resolved=!0):M.warn(`${t.details} reached or exceeded max retry (${l})`)):(a==null?void 0:a.action)===Lt.SendAlternateToPenaltyBox?this.state=V.WAITING_LEVEL:this.state=V.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===V.PARSING||this.state===V.PARSED){let t=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,t),s=r&&r.len>.5;s&&this.reduceMaxBufferLength(r.len);let n=!s;return n&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===he.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==V.STOPPED&&(this.state=V.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;let s=Xe.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===V.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=V.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;let t=this.levels?this.levels[e].details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){var t;this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((t=this.levelLastLoaded)!=null?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var n;let a=r.details;if(!a){this.warn("level.details undefined");return}if(Object.keys(e.elementaryStreams).reduce((l,d)=>{let c=e.elementaryStreams[d];if(c){let u=c.endPTS-c.startPTS;if(u<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${u})`),l||!1;let h=s?0:Dv(a,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS);return this.hls.trigger(b.LEVEL_PTS_UPDATED,{details:a,level:r,drift:h,type:d,frag:e,start:c.startPTS,end:c.endPTS}),!0}return l},!1))r.fragmentError=0;else if(((n=this.transmuxer)==null?void 0:n.error)===null){let l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=V.PARSED,this.hls.trigger(b.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){if(e.event==="demuxerWorker"){var t,r,s;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((t=(r=this.levelLastLoaded)!=null?r:(s=this.fragCurrent)==null?void 0:s.level)!=null?t:0),this.resetLoadingState()}}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}};function Uv(){return self.SourceBuffer||self.WebKitSourceBuffer}function d1(){let i=ud();if(!i)return!1;let e=Uv(),t=i&&typeof i.isTypeSupported=="function"&&i.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),r=!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function";return!!t&&!!r}function c1(){var i;let e=Uv();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}function u1(){return typeof __HLS_WORKER_BUNDLE__=="function"}function h1(){let i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function f1(i){let e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function Bi(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var Xl=class{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Xr(this.cachedData,e),this.cachedData=null);let r=Wl(e,0),s=r?r.length:0,n,a=this._audioTrack,o=this._id3Track,l=r?oA(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&oe(l))&&(this.basePTS=m1(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:bi.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){let c=this.appendFrame(a,e,s);c?(this.frameIndex++,this.lastPTS=c.sample.pts,s+=c.length,n=s):s=d}else aA(e,s)?(r=Wl(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:bi.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===d&&n!==d){let c=zr(e,n);this.cachedData?this.cachedData=Xr(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:Bi(),id3Track:o,textTrack:Bi()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Bi(),id3Track:this._id3Track,textTrack:Bi()}}destroy(){}},m1=(i,e,t)=>{if(oe(i))return i*90;let r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function p1(i,e,t,r){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=r,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;let u=(e[t+2]&60)>>>2;if(u>c.length-1){i.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${u}`});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,M.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${u}`),/firefox/i.test(l)?u>=6?(s=5,o=new Array(4),n=u-3):(s=2,o=new Array(2),n=u):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=u):(s=5,o=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&u>=6?n=u-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(u>=6&&a===1||/vivaldi/i.test(l))||!r&&a===1)&&(s=2,o=new Array(2)),n=u)),o[0]=s<<3,o[0]|=(u&14)>>1,o[1]|=(u&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:c[u],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function Fv(i,e){return i[e]===255&&(i[e+1]&246)===240}function Bv(i,e){return i[e+1]&1?7:9}function If(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function g1(i,e){return e+5<i.length}function Ql(i,e){return e+1<i.length&&Fv(i,e)}function v1(i,e){return g1(i,e)&&Fv(i,e)&&If(i,e)<=i.length-e}function E1(i,e){if(Ql(i,e)){let t=Bv(i,e);if(e+t>=i.length)return!1;let r=If(i,e);if(r<=t)return!1;let s=e+r;return s===i.length||Ql(i,s)}return!1}function $v(i,e,t,r,s){if(!i.samplerate){let n=p1(e,t,r,s);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,M.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Gv(i){return 1024*9e4/i}function b1(i,e){let t=Bv(i,e);if(e+t<=i.length){let r=If(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function Hv(i,e,t,r,s){let n=Gv(i.samplerate),a=r+s*n,o=b1(e,t),l;if(o){let{frameLength:u,headerLength:h}=o,f=h+u,g=Math.max(0,t+f-e.length);g?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);let E={unit:l,pts:a};return g||i.samples.push(E),{sample:E,length:f,missing:g}}let d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}var Bh=class extends Xl{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let r=(Wl(e,0)||[]).length;for(let s=e.length;r<s;r++)if(E1(e,r))return M.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return v1(e,t)}appendFrame(e,t,r){$v(e,this.observer,t,r,e.manifestCodec);let s=Hv(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},y1=/\/emsg[-/]ID3/i,$h=class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){let n=this.videoTrack=Bi("video",1),a=this.audioTrack=Bi("audio",1),o=this.txtTrack=Bi("text",1);if(this.id3Track=Bi("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=Sv(e);if(l.video){let{id:d,timescale:c,codec:u}=l.video;n.id=d,n.timescale=o.timescale=c,n.codec=u}if(l.audio){let{id:d,timescale:c,codec:u}=l.audio;a.id=d,a.timescale=c,a.codec=u}o.id=Tv.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return e=e.length>16384?e.subarray(0,16384):e,Ce(e,["moof"]).length>0}demux(e,t){this.timeOffset=t;let r=e,s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Xr(this.remainderData,e));let o=_A(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;let a=this.extractID3Track(s,t);return n.samples=D0(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return r.samples=D0(e,t),{videoTrack:t,audioTrack:Bi(),id3Track:s,textTrack:Bi()}}extractID3Track(e,t){let r=this.id3Track;if(e.samples.length){let s=Ce(e.samples,["emsg"]);s&&s.forEach(n=>{let a=xA(n);if(y1.test(a.schemeIdUri)){let o=oe(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale,l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);let d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:bi.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},Nl=null,T1=[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],_1=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],A1=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],S1=[0,1,1,4];function Vv(i,e,t,r,s){if(t+24>e.length)return;let n=Wv(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=r+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function Wv(i,e){let t=i[e+1]>>3&3,r=i[e+1]>>1&3,s=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){let a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-r:r===3?3:4,d=T1[l*14+s-1]*1e3,u=_1[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=A1[t][r],g=S1[r],E=f*8*g,T=Math.floor(f*d/u+a)*g;if(Nl===null){let L=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Nl=L?parseInt(L[1]):0}return!!Nl&&Nl<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:u,channelCount:h,frameLength:T,samplesPerFrame:E}}}function Lf(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function Kv(i,e){return e+1<i.length&&Lf(i,e)}function x1(i,e){return Lf(i,e)&&4<=i.length-e}function I1(i,e){if(e+1<i.length&&Lf(i,e)){let r=Wv(i,e),s=4;r!=null&&r.frameLength&&(s=r.frameLength);let n=e+s;return n===i.length||Kv(i,n)}return!1}var Zl=class{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(r,r+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&M.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let n=0;n<e;n++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,n,a,o,l=this.readUByte.bind(this),d=this.readBits.bind(this),c=this.readUEG.bind(this),u=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),g=this.skipUEG.bind(this),E=this.skipScalingList.bind(this);l();let T=l();if(d(5),h(3),l(),g(),T===100||T===110||T===122||T===244||T===44||T===83||T===86||T===118||T===128){let B=c();if(B===3&&h(1),g(),g(),h(1),u())for(a=B!==3?8:12,o=0;o<a;o++)u()&&(o<6?E(16):E(64))}g();let A=c();if(A===0)c();else if(A===1)for(h(1),f(),f(),n=c(),o=0;o<n;o++)f();g(),h(1);let k=c(),L=c(),F=d(1);F===0&&h(1),h(1),u()&&(e=c(),t=c(),r=c(),s=c());let R=[1,1];if(u()&&u())switch(l()){case 1:R=[1,1];break;case 2:R=[12,11];break;case 3:R=[10,11];break;case 4:R=[16,11];break;case 5:R=[40,33];break;case 6:R=[24,11];break;case 7:R=[20,11];break;case 8:R=[32,11];break;case 9:R=[80,33];break;case 10:R=[18,11];break;case 11:R=[15,11];break;case 12:R=[64,33];break;case 13:R=[160,99];break;case 14:R=[4,3];break;case 15:R=[3,2];break;case 16:R=[2,1];break;case 255:{R=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((k+1)*16-e*2-t*2),height:(2-F)*(L+1)*16-(F?2:4)*(r+s),pixelRatio:R}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},Gh=class{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new fa(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){let s=e[t].unit;if(s.length<=16)return;let n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)r.set(e.subarray(n,n+16),s);return r}getAvcDecryptedUnit(e,t){let r=new Uint8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(r.subarray(s,s+16),n);return e}decryptAvcSample(e,t,r,s,n){let a=Lv(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}let n=e[t].units;for(;!(r>=n.length);r++){let a=n[r];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,r,s,a),!this.decrypter.isSync()))return}}}},It=188,Hh=class i{constructor(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}static probe(e){let t=i.syncOffset(e);return t>0&&M.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,r=Math.min(It*5,e.length-It)+1,s=0;for(;s<r;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=It)if(e[l]===71){if(o++,a===-1&&(a=l,a!==0&&(r=Math.min(a+It*99,e.length-It)+1)),n||(n=Vh(e,l)===0),n&&o>1&&(a===0&&o>2||l+It>r))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Tv[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=i.createTrack("video"),this._audioTrack=i.createTrack("audio",s),this._id3Track=i.createTrack("id3"),this._txtTrack=i.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_avcTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let n,a=this._avcTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,c=a.pid,u=a.pesData,h=o.pid,f=l.pid,g=o.pesData,E=l.pesData,T=null,A=this.pmtParsed,k=this._pmtId,L=e.length;if(this.remainderData&&(e=Xr(this.remainderData,e),L=e.length,this.remainderData=null),L<It&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let F=Math.max(0,i.syncOffset(e));L-=(L-F)%It,L<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));let R=0;for(let P=F;P<L;P+=It)if(e[P]===71){let G=!!(e[P+1]&64),K=Vh(e,P),N=(e[P+3]&48)>>4,j;if(N>1){if(j=P+5+e[P+4],j===P+It)continue}else j=P+4;switch(K){case c:G&&(u&&(n=rn(u))&&this.parseAVCPES(a,d,n,!1),u={data:[],size:0}),u&&(u.data.push(e.subarray(j,P+It)),u.size+=P+It-j);break;case h:if(G){if(g&&(n=rn(g)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break}g={data:[],size:0}}g&&(g.data.push(e.subarray(j,P+It)),g.size+=P+It-j);break;case f:G&&(E&&(n=rn(E))&&this.parseID3PES(l,n),E={data:[],size:0}),E&&(E.data.push(e.subarray(j,P+It)),E.size+=P+It-j);break;case 0:G&&(j+=e[j]+1),k=this._pmtId=L1(e,j);break;case k:{G&&(j+=e[j]+1);let Y=R1(e,j,this.typeSupported,r);c=Y.avc,c>0&&(a.pid=c),h=Y.audio,h>0&&(o.pid=h,o.segmentCodec=Y.segmentCodec),f=Y.id3,f>0&&(l.pid=f),T!==null&&!A&&(M.warn(`MPEG-TS PMT found at ${P} after unknown PID '${T}'. Backtracking to sync byte @${F} to parse all TS packets.`),T=null,P=F-188),A=this.pmtParsed=!0;break}case 17:case 8191:break;default:T=K;break}}else R++;if(R>0){let P=new Error(`Found ${R} TS packet/s that do not start with 0x47`);this.observer.emit(b.ERROR,b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,error:P,reason:P.message})}a.pesData=u,o.pesData=g,l.pesData=E;let B={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples(B),B}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){let{audioTrack:t,videoTrack:r,id3Track:s,textTrack:n}=e,a=r.pesData,o=t.pesData,l=s.pesData,d;if(a&&(d=rn(a))?(this.parseAVCPES(r,n,d,!0),r.pesData=null):r.pesData=a,o&&(d=rn(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break}t.pesData=null}else o!=null&&o.size&&M.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=rn(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){let s=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new Gh(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(r=>{let{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAVCPES(e,t,r,s){let n=this.parseAVCNALu(e,r.data),a=this.avcSample,o,l=!1;r.data=null,a&&n.length&&!e.audFound&&(ia(a,e),a=this.avcSample=Ul(!1,r.pts,r.dts,"")),n.forEach(d=>{var c;switch(d.type){case 1:{let h=!1;o=!0;let f=d.data;if(l&&f.length>4){let g=new Zl(f).readSliceType();(g===2||g===4||g===7||g===9)&&(h=!0)}if(h){var u;(u=a)!=null&&u.frame&&!a.key&&(ia(a,e),a=this.avcSample=null)}a||(a=this.avcSample=Ul(!0,r.pts,r.dts,"")),a.frame=!0,a.key=h;break}case 5:o=!0,(c=a)!=null&&c.frame&&!a.key&&(ia(a,e),a=this.avcSample=null),a||(a=this.avcSample=Ul(!0,r.pts,r.dts,"")),a.key=!0,a.frame=!0;break;case 6:{o=!0,Iv(d.data,1,r.pts,t.samples);break}case 7:if(o=!0,l=!0,!e.sps){let h=d.data,g=new Zl(h).readSPS();e.width=g.width,e.height=g.height,e.pixelRatio=g.pixelRatio,e.sps=[h],e.duration=this._duration;let E=h.subarray(1,4),T="avc1.";for(let A=0;A<3;A++){let k=E[A].toString(16);k.length<2&&(k="0"+k),T+=k}e.codec=T}break;case 8:o=!0,e.pps||(e.pps=[d.data]);break;case 9:o=!1,e.audFound=!0,a&&ia(a,e),a=this.avcSample=Ul(!1,r.pts,r.dts,"");break;case 12:o=!0;break;default:o=!1,a&&(a.debug+="unknown NAL "+d.type+" ");break}a&&o&&a.units.push(d)}),s&&a&&(ia(a,e),this.avcSample=null)}getLastNalUnit(e){var t;let r=this.avcSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){let n=r.units;s=n[n.length-1]}return s}parseAVCNALu(e,t){let r=t.byteLength,s=e.naluState||0,n=s,a=[],o=0,l,d,c,u=-1,h=0;for(s===-1&&(u=0,h=t[0]&31,s=0,o=1);o<r;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(u>=0){let f={data:t.subarray(u,o-s-1),type:h};a.push(f)}else{let f=this.getLastNalUnit(e.samples);if(f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d=o-s-1,d>0)){let g=new Uint8Array(f.data.byteLength+d);g.set(f.data,0),g.set(t.subarray(0,d),f.data.byteLength),f.data=g,f.state=0}}o<r?(c=t[o]&31,u=o,h=c,s=0):s=-1}else s=0}if(u>=0&&s>=0){let f={data:t.subarray(u,r),type:h,state:s};a.push(f)}if(a.length===0){let f=this.getLastNalUnit(e.samples);if(f){let g=new Uint8Array(f.data.byteLength+t.byteLength);g.set(f.data,0),g.set(t,f.data.byteLength),f.data=g}}return e.naluState=s,a}parseAACPES(e,t){let r=0,s=this.aacOverFlow,n=t.data;if(s){this.aacOverFlow=null;let u=s.missing,h=s.sample.unit.byteLength;if(u===-1){let f=new Uint8Array(h+n.byteLength);f.set(s.sample.unit,0),f.set(n,h),n=f}else{let f=h-u;s.sample.unit.set(n.subarray(0,u),f),e.samples.push(s.sample),r=s.missing}}let a,o;for(a=r,o=n.length;a<o-1&&!Ql(n,a);a++);if(a!==r){let u,h=a<o-1;h?u=`AAC PES did not start with ADTS header,offset:${a}`:u="No ADTS header found in AAC PES";let f=new Error(u);if(M.warn(`parsing error: ${u}`),this.observer.emit(b.ERROR,b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,levelRetry:h,error:f,reason:u}),!h)return}$v(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let u=Gv(e.samplerate);l=s.sample.pts+u}else{M.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,c;for(;a<o;)if(c=Hv(e,n,a,l,d),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(d++;a<o-1&&!Ql(n,a);a++);}parseMPEGPES(e,t){let r=t.data,s=r.length,n=0,a=0,o=t.pts;if(o===void 0){M.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(Kv(r,a)){let l=Vv(e,r,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseID3PES(e,t){if(t.pts===void 0){M.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let r=ht({},t,{type:this._avcTrack?bi.emsg:bi.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}};function Ul(i,e,t,r){return{key:i,frame:!1,pts:e,dts:t,units:[],debug:r,length:0}}function Vh(i,e){return((i[e+1]&31)<<8)+i[e+2]}function L1(i,e){return(i[e+10]&31)<<8|i[e+11]}function R1(i,e,t,r){let s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=(i[e+1]&15)<<8|i[e+2],a=e+3+n-4,o=(i[e+10]&15)<<8|i[e+11];for(e+=12+o;e<a;){let l=Vh(i,e);switch(i[e]){case 207:if(!r){M.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:s.audio===-1&&(s.audio=l);break;case 21:s.id3===-1&&(s.id3=l);break;case 219:if(!r){M.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:s.avc===-1&&(s.avc=l);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?M.log("MPEG audio found, not supported in this browser"):s.audio===-1&&(s.audio=l,s.segmentCodec="mp3");break;case 36:M.warn("Unsupported HEVC stream type found");break}e+=((i[e+3]&15)<<8|i[e+4])+5}return s}function rn(i){let e=0,t,r,s,n,a,o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;){let d=new Uint8Array(o[0].length+o[1].length);d.set(o[0]),d.set(o[1],o[0].length),o[0]=d,o.splice(1,1)}if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>i.size-6)return null;let d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(M.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let c=s+9;if(i.size<=c)return null;i.size-=c;let u=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let g=t.byteLength;if(c)if(c>g){c-=g;continue}else t=t.subarray(c),g-=c,c=0;u.set(t,e),e+=g}return r&&(r-=s+3),{data:u,pts:n,dts:a,len:r}}return null}function ia(i,e){if(i.units.length&&i.frame){if(i.pts===void 0){let t=e.samples,r=t.length;if(r){let s=t[r-1];i.pts=s.pts,i.dts=s.dts}else{e.dropped++;return}}e.samples.push(i)}i.debug.length&&M.log(i.pts+"/"+i.dts+":"+i.debug)}var Wh=class extends Xl{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let r=(Wl(e,0)||[]).length;for(let s=e.length;r<s;r++)if(I1(e,r))return M.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return x1(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return Vv(e,t,r,this.basePTS,this.frameIndex)}},Jl=class{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}},gr=Math.pow(2,32)-1,ut=class i{static init(){i.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in i.types)i.types.hasOwnProperty(e)&&(i.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=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]);i.HDLR_TYPES={video:t,audio:r};let s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);i.STTS=i.STSC=i.STCO=n,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);i.FTYP=i.box(i.types.ftyp,a,l,a,o),i.DINF=i.box(i.types.dinf,i.box(i.types.dref,s))}static box(e,...t){let r=8,s=t.length,n=s;for(;s--;)r+=t[s].byteLength;let a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=r&255,a.set(e,4),s=0,r=8;s<n;s++)a.set(t[s],r),r+=t[s].byteLength;return a}static hdlr(e){return i.box(i.types.hdlr,i.HDLR_TYPES[e])}static mdat(e){return i.box(i.types.mdat,e)}static mdhd(e,t){t*=e;let r=Math.floor(t/(gr+1)),s=Math.floor(t%(gr+1));return i.box(i.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return i.box(i.types.mdia,i.mdhd(e.timescale,e.duration),i.hdlr(e.type),i.minf(e))}static mfhd(e){return i.box(i.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?i.box(i.types.minf,i.box(i.types.smhd,i.SMHD),i.DINF,i.stbl(e)):i.box(i.types.minf,i.box(i.types.vmhd,i.VMHD),i.DINF,i.stbl(e))}static moof(e,t,r){return i.box(i.types.moof,i.mfhd(e),i.traf(r,t))}static moov(e){let t=e.length,r=[];for(;t--;)r[t]=i.trak(e[t]);return i.box.apply(null,[i.types.moov,i.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(i.mvex(e)))}static mvex(e){let t=e.length,r=[];for(;t--;)r[t]=i.trex(e[t]);return i.box.apply(null,[i.types.mvex,...r])}static mvhd(e,t){t*=e;let r=Math.floor(t/(gr+1)),s=Math.floor(t%(gr+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return i.box(i.types.mvhd,n)}static sdtp(e){let t=e.samples||[],r=new Uint8Array(4+t.length),s,n;for(s=0;s<t.length;s++)n=t[s].flags,r[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return i.box(i.types.sdtp,r)}static stbl(e){return i.box(i.types.stbl,i.stsd(e),i.box(i.types.stts,i.STTS),i.box(i.types.stsc,i.STSC),i.box(i.types.stsz,i.STSZ),i.box(i.types.stco,i.STCO))}static avc1(e){let t=[],r=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,r.push(a>>>8&255),r.push(a&255),r=r.concat(Array.prototype.slice.call(n));let o=i.box(i.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,d=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return i.box(i.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,i.box(i.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),i.box(i.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,u>>24,u>>16&255,u>>8&255,u&255])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){let t=e.samplerate;return i.box(i.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]),i.box(i.types.esds,i.esds(e)))}static mp3(e){let t=e.samplerate;return i.box(i.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?i.box(i.types.stsd,i.STSD,i.mp3(e)):i.box(i.types.stsd,i.STSD,i.mp4a(e)):i.box(i.types.stsd,i.STSD,i.avc1(e))}static tkhd(e){let t=e.id,r=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(r/(gr+1)),o=Math.floor(r%(gr+1));return i.box(i.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let r=i.sdtp(e),s=e.id,n=Math.floor(t/(gr+1)),a=Math.floor(t%(gr+1));return i.box(i.types.traf,i.box(i.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),i.box(i.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),i.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,i.box(i.types.trak,i.tkhd(e),i.mdia(e))}static trex(e){let t=e.id;return i.box(i.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let r=e.samples||[],s=r.length,n=12+16*s,a=new Uint8Array(n),o,l,d,c,u,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=r[o],d=l.duration,c=l.size,u=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,u.degradPrio&61440,u.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return i.box(i.types.trun,a)}static initSegment(e){i.types||i.init();let t=i.moov(e),r=new Uint8Array(i.FTYP.byteLength+t.byteLength);return r.set(i.FTYP),r.set(t,i.FTYP.byteLength),r}};ut.types=void 0;ut.HDLR_TYPES=void 0;ut.STTS=void 0;ut.STSC=void 0;ut.STCO=void 0;ut.STSZ=void 0;ut.VMHD=void 0;ut.SMHD=void 0;ut.STSD=void 0;ut.FTYP=void 0;ut.DINF=void 0;var qv=9e4;function Rf(i,e,t=1,r=!1){let s=i*e*t;return r?Math.round(s):s}function k1(i,e,t=1,r=!1){return Rf(i,e,1/t,r)}function ra(i,e=!1){return Rf(i,1e3,1/qv,e)}function w1(i,e=1){return Rf(i,qv,1/e)}var D1=10*1e3,ev=1024,C1=1152,Fl=null,ah=null,oa=class{constructor(e,t,r,s=""){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,Fl===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Fl=a?parseInt(a[1]):0}if(ah===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);ah=n?parseInt(n[1]):0}}destroy(){}resetTimeStamp(e){M.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){M.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){M.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let t=!1,r=e.reduce((s,n)=>{let a=n.pts-s;return a<-4294967296?(t=!0,ni(s,n.pts)):a>0?s:n.pts},e[0].pts);return t&&M.debug("PTS rollover detected"),r}remux(e,t,r,s,n,a,o,l){let d,c,u,h,f,g,E=n,T=n,A=e.pid>-1,k=t.pid>-1,L=t.samples.length,F=e.samples.length>0,R=o&&L>0||L>1;if((!A||F)&&(!k||R)||this.ISGenerated||o){this.ISGenerated||(u=this.generateIS(e,t,n,a));let P=this.isVideoContiguous,G=-1,K;if(R&&(G=M1(t.samples),!P&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,G>0){M.warn(`[mp4-remuxer]: Dropped ${G} out of ${L} video samples due to a missing keyframe`);let N=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(G),t.dropped+=G,T+=(t.samples[0].pts-N)/t.inputTimeScale,K=T}else G===-1&&(M.warn(`[mp4-remuxer]: No keyframe found out of ${L} video samples`),g=!1);if(this.ISGenerated){if(F&&R){let N=this.getVideoStartPts(t.samples),Y=(ni(e.samples[0].pts,N)-N)/t.inputTimeScale;E+=Math.max(0,Y),T+=Math.max(0,-Y)}if(F){if(e.samplerate||(M.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(e,t,n,a)),c=this.remuxAudio(e,E,this.isAudioContiguous,a,k||R||l===he.AUDIO?T:void 0),R){let N=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(M.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,T,P,N)}}else R&&(d=this.remuxVideo(t,T,P,0));d&&(d.firstKeyFrame=G,d.independent=G!==-1,d.firstKeyFramePTS=K)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=Yv(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=jv(s,n,this._initPTS))),{audio:c,video:d,initSegment:u,independent:g,text:h,id3:f}}generateIS(e,t,r,s){let n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,c=!d||s,u="audio/mp4",h,f,g;if(c&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(u="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break}l.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):ut.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(g=e.inputTimeScale,!d||g!==d.timescale?h=f=n[0].pts-Math.round(g*r):c=!1)}if(t.sps&&t.pps&&a.length&&(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:ut.initSegment([t]),metadata:{width:t.width,height:t.height}},c))if(g=t.inputTimeScale,!d||g!==d.timescale){let E=this.getVideoStartPts(a),T=Math.round(g*r);f=Math.min(f,ni(a[0].dts,E)-T),h=Math.min(h,E-T)}else c=!1;if(Object.keys(l).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:h,timescale:g},this._initDTS={baseTime:f,timescale:g}):h=g=void 0,{tracks:l,initPTS:h,timescale:g}}remuxVideo(e,t,r,s){let n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS,c=this.nextAvcDts,u=8,h=this.videoSampleDuration,f,g,E=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,A=!1;if(!r||c===null){let Z=t*n,te=a[0].pts-ni(a[0].dts,a[0].pts);c=Z-te}let k=d.baseTime*n/d.timescale;for(let Z=0;Z<l;Z++){let te=a[Z];te.pts=ni(te.pts-k,c),te.dts=ni(te.dts-k,c),te.dts<a[Z>0?Z-1:Z].dts&&(A=!0)}A&&a.sort(function(Z,te){let re=Z.dts-te.dts,Le=Z.pts-te.pts;return re||Le}),f=a[0].dts,g=a[a.length-1].dts;let L=g-f,F=L?Math.round(L/(l-1)):h||e.inputTimeScale/30;if(r){let Z=f-c,te=Z>F,re=Z<-1;if((te||re)&&(te?M.warn(`AVC: ${ra(Z,!0)} ms (${Z}dts) hole between fragments detected, filling it`):M.warn(`AVC: ${ra(-Z,!0)} ms (${Z}dts) overlapping between fragments detected`),!re||c>=a[0].pts)){f=c;let Le=a[0].pts-Z;a[0].dts=f,a[0].pts=Le,M.log(`Video: First PTS/DTS adjusted: ${ra(Le,!0)}/${ra(f,!0)}, delta: ${ra(Z,!0)} ms`)}}f=Math.max(0,f);let R=0,B=0;for(let Z=0;Z<l;Z++){let te=a[Z],re=te.units,Le=re.length,Re=0;for(let Qe=0;Qe<Le;Qe++)Re+=re[Qe].data.length;B+=Re,R+=Le,te.length=Re,te.dts=Math.max(te.dts,f),E=Math.min(te.pts,E),T=Math.max(te.pts,T)}g=a[l-1].dts;let P=B+4*R+8,G;try{G=new Uint8Array(P)}catch(Z){this.observer.emit(b.ERROR,b.ERROR,{type:ue.MUX_ERROR,details:$.REMUX_ALLOC_ERROR,fatal:!1,error:Z,bytes:P,reason:`fail allocating video mdat ${P}`});return}let K=new DataView(G.buffer);K.setUint32(0,P),G.set(ut.types.mdat,4);let N=!1,j=Number.POSITIVE_INFINITY,Y=Number.POSITIVE_INFINITY,Ee=Number.NEGATIVE_INFINITY,ge=Number.NEGATIVE_INFINITY;for(let Z=0;Z<l;Z++){let te=a[Z],re=te.units,Le=0;for(let Ot=0,Nt=re.length;Ot<Nt;Ot++){let kt=re[Ot],Wi=kt.data,yn=kt.data.byteLength;K.setUint32(u,yn),u+=4,G.set(Wi,u),u+=yn,Le+=4+yn}let Re;if(Z<l-1)h=a[Z+1].dts-te.dts,Re=a[Z+1].pts-te.pts;else{let Ot=this.config,Nt=Z>0?te.dts-a[Z-1].dts:F;if(Re=Z>0?te.pts-a[Z-1].pts:F,Ot.stretchShortVideoTrack&&this.nextAudioPts!==null){let kt=Math.floor(Ot.maxBufferHole*n),Wi=(s?E+s*n:this.nextAudioPts)-te.pts;Wi>kt?(h=Wi-Nt,h<0?h=Nt:N=!0,M.log(`[mp4-remuxer]: It is approximately ${Wi/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=Nt}else h=Nt}let Qe=Math.round(te.pts-te.dts);j=Math.min(j,h),Ee=Math.max(Ee,h),Y=Math.min(Y,Re),ge=Math.max(ge,Re),o.push(new ed(te.key,h,Le,Qe))}if(o.length){if(Fl){if(Fl<70){let Z=o[0].flags;Z.dependsOn=2,Z.isNonSync=0}}else if(ah&&ge-Y<Ee-j&&F/Ee<.025&&o[0].cts===0){M.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let Z=f;for(let te=0,re=o.length;te<re;te++){let Le=Z+o[te].duration,Re=Z+o[te].cts;if(te<re-1){let Qe=Le+o[te+1].cts;o[te].duration=Qe-Re}else o[te].duration=te?o[te-1].duration:F;o[te].cts=0,Z=Le}}}h=N||!h?F:h,this.nextAvcDts=c=g+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let ye=ut.moof(e.sequenceNumber++,f,ht({},e,{samples:o})),we="video",Ie={data1:ye,data2:G,startPTS:E/n,endPTS:(T+h)/n,startDTS:f/n,endDTS:c/n,type:we,hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Ie}remuxAudio(e,t,r,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=e.segmentCodec==="aac"?ev:C1,c=d*l,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],g=n!==void 0,E=e.samples,T=h?0:8,A=this.nextAudioPts||-1,k=t*a,L=u.baseTime*a/u.timescale;if(this.isAudioContiguous=r=r||E.length&&A>0&&(s&&Math.abs(k-A)<9e3||Math.abs(ni(E[0].pts-L,k)-A)<20*c),E.forEach(function(we){we.pts=ni(we.pts-L,k)}),!r||A<0){if(E=E.filter(we=>we.pts>=0),!E.length)return;n===0?A=0:s&&!g?A=Math.max(0,k):A=E[0].pts}if(e.segmentCodec==="aac"){let we=this.config.maxAudioFramesDrift;for(let Ie=0,Z=A;Ie<E.length;Ie++){let te=E[Ie],re=te.pts,Le=re-Z,Re=Math.abs(1e3*Le/a);if(Le<=-we*c&&g)Ie===0&&(M.warn(`Audio frame @ ${(re/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*Le/a)} ms.`),this.nextAudioPts=A=Z=re);else if(Le>=we*c&&Re<D1&&g){let Qe=Math.round(Le/c);Z=re-Qe*c,Z<0&&(Qe--,Z+=c),Ie===0&&(this.nextAudioPts=A=Z),M.warn(`[mp4-remuxer]: Injecting ${Qe} audio frame @ ${(Z/a).toFixed(3)}s due to ${Math.round(1e3*Le/a)} ms gap.`);for(let Ot=0;Ot<Qe;Ot++){let Nt=Math.max(Z,0),kt=Jl.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);kt||(M.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),kt=te.unit.subarray()),E.splice(Ie,0,{unit:kt,pts:Nt}),Z+=c,Ie++}}te.pts=Z,Z+=c}}let F=null,R=null,B,P=0,G=E.length;for(;G--;)P+=E[G].unit.byteLength;for(let we=0,Ie=E.length;we<Ie;we++){let Z=E[we],te=Z.unit,re=Z.pts;if(R!==null){let Re=f[we-1];Re.duration=Math.round((re-R)/l)}else if(r&&e.segmentCodec==="aac"&&(re=A),F=re,P>0){P+=T;try{B=new Uint8Array(P)}catch(Re){this.observer.emit(b.ERROR,b.ERROR,{type:ue.MUX_ERROR,details:$.REMUX_ALLOC_ERROR,fatal:!1,error:Re,bytes:P,reason:`fail allocating audio mdat ${P}`});return}h||(new DataView(B.buffer).setUint32(0,P),B.set(ut.types.mdat,4))}else return;B.set(te,T);let Le=te.byteLength;T+=Le,f.push(new ed(!0,d,Le,0)),R=re}let K=f.length;if(!K)return;let N=f[f.length-1];this.nextAudioPts=A=R+l*N.duration;let j=h?new Uint8Array(0):ut.moof(e.sequenceNumber++,F/l,ht({},e,{samples:f}));e.samples=[];let Y=F/a,Ee=A/a,ye={data1:j,data2:B,startPTS:Y,endPTS:Ee,startDTS:Y,endDTS:Ee,type:"audio",hasAudio:!0,hasVideo:!1,nb:K};return this.isAudioContiguous=!0,ye}remuxEmptyAudio(e,t,r,s){let n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,c=d.baseTime*9e4/d.timescale,u=(l!==null?l:s.startDTS*n)+c,h=s.endDTS*n+c,f=o*ev,g=Math.ceil((h-u)/f),E=Jl.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(M.warn("[mp4-remuxer]: remux empty Audio"),!E){M.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let T=[];for(let A=0;A<g;A++){let k=u+A*f;T.push({unit:E,pts:k,dts:k})}return e.samples=T,this.remuxAudio(e,t,r,!1)}};function ni(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function M1(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function Yv(i,e,t,r){let s=i.samples.length;if(!s)return;let n=i.inputTimeScale;for(let o=0;o<s;o++){let l=i.samples[o];l.pts=ni(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=ni(l.dts-r.baseTime*n/r.timescale,e*n)/n}let a=i.samples;return i.samples=[],{samples:a}}function jv(i,e,t){let r=i.samples.length;if(!r)return;let s=i.inputTimeScale;for(let a=0;a<r;a++){let o=i.samples[a];o.pts=ni(o.pts-t.baseTime*s/t.timescale,e*s)/s}i.samples.sort((a,o)=>a.pts-o.pts);let n=i.samples;return i.samples=[],{samples:n}}var ed=class{constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags=new Kh(e)}},Kh=class{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}},qh=class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(vA(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let s=this.initData=Sv(e);t||(t=tv(s.audio,Ve.AUDIO)),r||(r=tv(s.video,Ve.VIDEO));let n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:M.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,s,n,a){var o,l;let{initPTS:d,lastEndTime:c}=this,u={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};oe(c)||(c=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return u;let f={initPTS:void 0,timescale:1},g=this.initData;if((o=g)!=null&&o.length||(this.generateInitSegment(h),g=this.initData),!((l=g)!=null&&l.length))return M.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);let E=bA(h,g),T=EA(g,h),A=T===null?n:T;(P1(d,A,n,E)||f.timescale!==d.timescale&&a)&&(f.initPTS=A-n,d&&d.timescale===1&&M.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});let k=e?A-d.baseTime/d.timescale:c,L=k+E;TA(g,h,d.baseTime/d.timescale),E>0?this.lastEndTime=L:(M.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let F=!!g.audio,R=!!g.video,B="";F&&(B+="audio"),R&&(B+="video");let P={data1:h,startPTS:k,startDTS:k,endPTS:L,endDTS:L,type:B,hasAudio:F,hasVideo:R,nb:1,dropped:0};return u.audio=P.type==="audio"?P:void 0,u.video=P.type!=="audio"?P:void 0,u.initSegment=f,u.id3=Yv(r,n,d,d),s.samples.length&&(u.text=jv(s,n,d)),u}};function P1(i,e,t,r){if(i===null)return!0;let s=Math.max(r,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>s}function tv(i,e){let t=i==null?void 0:i.codec;return t&&t.length>4?t:t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":t==="avc1"||e===Ve.VIDEO?"avc1.42e01e":"mp4a.40.5"}var Qi;try{Qi=self.performance.now.bind(self.performance)}catch{M.debug("Unable to use Performance API on this environment"),Qi=typeof self!="undefined"&&self.Date.now}var oh=[{demux:$h,remux:qh},{demux:Hh,remux:oa},{demux:Bh,remux:oa},{demux:Wh,remux:oa}],td=class{constructor(e,t,r,s,n){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=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){let n=r.transmuxing;n.executeStart=Qi();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);let{contiguous:d,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:g}=s||o,{audioCodec:E,videoCodec:T,defaultInitPts:A,duration:k,initSegmentData:L}=l,F=O1(a,t);if(F&&F.method==="AES-128"){let G=this.getDecrypter();if(G.isSync()){let K=G.softwareDecrypt(a,F.key.buffer,F.iv.buffer);if(r.part>-1&&(K=G.flush()),!K)return n.executeEnd=Qi(),lh(r);a=new Uint8Array(K)}else return this.decryptionPromise=G.webCryptoDecrypt(a,F.key.buffer,F.iv.buffer).then(K=>{let N=this.push(K,null,r);return this.decryptionPromise=null,N}),this.decryptionPromise}let R=this.needsProbing(c,u);if(R){let G=this.configureTransmuxer(a);if(G)return M.warn(`[transmuxer] ${G.message}`),this.observer.emit(b.ERROR,b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,error:G,reason:G.message}),n.executeEnd=Qi(),lh(r)}(c||u||g||R)&&this.resetInitSegment(L,E,T,k,t),(c||g||R)&&this.resetInitialTimestamp(A),d||this.resetContiguity();let B=this.transmux(a,F,f,h,r),P=this.currentTransmuxState;return P.contiguous=!0,P.discontinuity=!1,P.trackSwitch=!1,n.executeEnd=Qi(),B}flush(e){let t=e.transmuxing;t.executeStart=Qi();let{decrypter:r,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(r){let u=r.flush();u&&a.push(this.push(u,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=Qi(),[lh(e)];let c=l.flush(o);return Gl(c)?c.then(u=>(this.flushRemux(a,u,e),a)):(this.flushRemux(a,c,e),a)}flushRemux(e,t,r){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;M.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);let c=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=Qi()}resetInitialTimestamp(e){let{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,r,s),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,r,s,n):a=this.transmuxUnencrypted(e,r,s,n),a}transmuxUnencrypted(e,t,r,s){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,n){return this.demuxer.demuxSampleAes(e,t,r).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,r,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:r,typeSupported:s,vendor:n}=this,a;for(let u=0,h=oh.length;u<h;u++)if(oh[u].demux.probe(e)){a=oh[u];break}if(!a)return new Error("Failed to find demuxer by probing fragment data");let o=this.demuxer,l=this.remuxer,d=a.remux,c=a.demux;(!l||!(l instanceof d))&&(this.remuxer=new d(r,t,s,n)),(!o||!(o instanceof c))&&(this.demuxer=new c(r,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new fa(this.config)),e}};function O1(i,e){let t=null;return i.byteLength>0&&e!=null&&e.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var lh=i=>({remuxResult:{},chunkMeta:i});function Gl(i){return"then"in i&&i.then instanceof Function}var Yh=class{constructor(e,t,r,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=n||null}},jh=class{constructor(e,t,r,s,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}},zv={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,d,c){this.fn=l,this.context=d,this.once=c||!1}function n(l,d,c,u,h){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,u||l,h),g=t?t+d:d;return l._events[g]?l._events[g].fn?l._events[g]=[l._events[g],f]:l._events[g].push(f):(l._events[g]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new r:delete l._events[d]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],c,u;if(this._eventsCount===0)return d;for(u in c=this._events)e.call(c,u)&&d.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},o.prototype.listeners=function(d){var c=t?t+d:d,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,g=new Array(f);h<f;h++)g[h]=u[h].fn;return g},o.prototype.listenerCount=function(d){var c=t?t+d:d,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(d,c,u,h,f,g){var E=t?t+d:d;if(!this._events[E])return!1;var T=this._events[E],A=arguments.length,k,L;if(T.fn){switch(T.once&&this.removeListener(d,T.fn,void 0,!0),A){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,c),!0;case 3:return T.fn.call(T.context,c,u),!0;case 4:return T.fn.call(T.context,c,u,h),!0;case 5:return T.fn.call(T.context,c,u,h,f),!0;case 6:return T.fn.call(T.context,c,u,h,f,g),!0}for(L=1,k=new Array(A-1);L<A;L++)k[L-1]=arguments[L];T.fn.apply(T.context,k)}else{var F=T.length,R;for(L=0;L<F;L++)switch(T[L].once&&this.removeListener(d,T[L].fn,void 0,!0),A){case 1:T[L].fn.call(T[L].context);break;case 2:T[L].fn.call(T[L].context,c);break;case 3:T[L].fn.call(T[L].context,c,u);break;case 4:T[L].fn.call(T[L].context,c,u,h);break;default:if(!k)for(R=1,k=new Array(A-1);R<A;R++)k[R-1]=arguments[R];T[L].fn.apply(T[L].context,k)}}return!0},o.prototype.on=function(d,c,u){return n(this,d,c,u,!1)},o.prototype.once=function(d,c,u){return n(this,d,c,u,!0)},o.prototype.removeListener=function(d,c,u,h){var f=t?t+d:d;if(!this._events[f])return this;if(!c)return a(this,f),this;var g=this._events[f];if(g.fn)g.fn===c&&(!h||g.once)&&(!u||g.context===u)&&a(this,f);else{for(var E=0,T=[],A=g.length;E<A;E++)(g[E].fn!==c||h&&!g[E].once||u&&g[E].context!==u)&&T.push(g[E]);T.length?this._events[f]=T.length===1?T[0]:T:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var c;return d?(c=t?t+d:d,this._events[c]&&a(this,c)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(zv);var N1=zv.exports,kf=G_(N1),dh=ud()||{isTypeSupported:()=>!1},id=class{constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;let a=(d,c)=>{c=c||{},c.frag=this.frag,c.id=this.id,d===b.ERROR&&(this.error=c.error),this.hls.trigger(d,c)};this.observer=new kf,this.observer.on(b.FRAG_DECRYPTED,a),this.observer.on(b.ERROR,a);let o={mp4:dh.isTypeSupported("video/mp4"),mpeg:dh.isTypeSupported("audio/mpeg"),mp3:dh.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||u1())){try{n.workerPath?(M.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=f1(n.workerPath)):(M.log(`injecting Web Worker for "${t}"`),this.workerContext=h1()),this.onwmsg=u=>this.onWorkerMessage(u);let{worker:c}=this.workerContext;c.addEventListener("message",this.onwmsg),c.onerror=u=>{let h=new Error(`${u.message} (${u.filename}:${u.lineno})`);n.enableWorker=!1,M.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(b.ERROR,{type:ue.OTHER_ERROR,details:$.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},c.postMessage({cmd:"init",typeSupported:o,vendor:l,id:t,config:JSON.stringify(n)})}catch(c){M.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.resetWorker(),this.error=null,this.transmuxer=new td(this.observer,o,n,l,t)}return}this.transmuxer=new td(this.observer,o,n,l,t)}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,n,a,o,l,d,c){var u,h;d.transmuxing.start=self.performance.now();let{transmuxer:f}=this,g=a?a.start:n.start,E=n.decryptdata,T=this.frag,A=!(T&&n.cc===T.cc),k=!(T&&d.level===T.level),L=T?d.sn-T.sn:-1,F=this.part?d.part-this.part.index:-1,R=L===0&&d.id>1&&d.id===(T==null?void 0:T.stats.chunkCount),B=!k&&(L===1||L===0&&(F===1||R&&F<=0)),P=self.performance.now();(k||L||n.stats.parsing.start===0)&&(n.stats.parsing.start=P),a&&(F||!B)&&(a.stats.parsing.start=P);let G=!(T&&((u=n.initSegment)==null?void 0:u.url)===((h=T.initSegment)==null?void 0:h.url)),K=new jh(A,B,l,k,g,G);if(!B||A||G){M.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
1057
- discontinuity: ${A}
1129
+ </svg>`,F0=q.createElement("template");F0.innerHTML=`
1130
+ <slot name="icon">${sA}</slot>
1131
+ `;var sh=class extends Ge{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_AUDIO_TRACK_ENABLED,A.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:F0})}get mediaAudioTrackEnabled(){return Fe(this,A.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){Oe(this,A.MEDIA_AUDIO_TRACK_ENABLED,e)}};w.customElements.get("media-audio-track-button")||w.customElements.define("media-audio-track-button",sh);var Ul=class extends si{static get observedAttributes(){return[...super.observedAttributes,A.MEDIA_AUDIO_TRACK_ENABLED,A.MEDIA_AUDIO_TRACK_UNAVAILABLE]}init(){let e=q.createElement("media-audio-track-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-audio-track-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};w.customElements.get("media-audio-track-selectmenu")||w.customElements.define("media-audio-track-selectmenu",Ul);var yd=ST(B0(),1);function nA(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Lv={exports:{}};(function(i,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,c){if(c=c||{},l=l.trim(),d=d.trim(),!d){if(!c.alwaysNormalize)return l;var u=o.parseURL(l);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return c.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var g=s.exec(f.path);f.netLoc=g[1],f.path=g[2]}f.netLoc&&!f.path&&(f.path="/");var E={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(E.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)E.path=f.path,h.params||(E.params=f.params,h.query||(E.query=f.query));else{var T=f.path,S=T.substring(0,T.lastIndexOf("/")+1)+h.path;E.path=o.normalizePath(S)}return E.path===null&&(E.path=c.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(E)},parseURL:function(l){var d=r.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(Lv);var kf=Lv.exports;function $0(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function Nt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?$0(Object(t),!0).forEach(function(r){aA(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):$0(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function aA(i,e,t){return e=lA(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ft(){return ft=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},ft.apply(this,arguments)}function oA(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function lA(i){var e=oA(i,"string");return typeof e=="symbol"?e:String(e)}var oe=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},dA=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=cA},cA=Number.MAX_SAFE_INTEGER||9007199254740991,b=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i}({}),ue=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),$=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({}),jr=function(){},Ih={trace:jr,debug:jr,log:jr,warn:jr,info:jr,error:jr},da=Ih;function uA(i){let e=self.console[i];return e?e.bind(self.console,`[${i}] >`):jr}function hA(i,...e){e.forEach(function(t){da[t]=i[t]?i[t].bind(i):uA(t)})}function fA(i,e){if(self.console&&i===!0||typeof i=="object"){hA(i,"debug","log","info","warn","error");try{da.log(`Debug logs enabled for "${e}" in hls.js version 1.4.13`)}catch{da=Ih}}else da=Ih}var M=da,mA=/^(\d+)x(\d+)$/,H0=/(.+?)=(".*?"|.*?)(?:,|$)/g,tt=class i{constructor(e){typeof e=="string"&&(e=i.parseAttrList(e));for(let t in e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=mA.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,r={},s='"';for(H0.lastIndex=0;(t=H0.exec(e))!==null;){let n=t[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));let a=t[1].trim();r[a]=n}return r}};function pA(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function gA(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}var zl=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let r=t.attr;for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){M.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=ft(new tt({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let r=new Date(this.attr["END-DATE"]);oe(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(oe(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&oe(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},ln=class{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},Ve={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Xl=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Ve.AUDIO]:null,[Ve.VIDEO]:null,[Ve.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let r=e.split("@",2),s=[];r.length===1?s[0]=t?t.byteRangeEndOffset:0:s[0]=parseInt(r[1]),s[1]=parseInt(r[0])+s[0],this._byteRange=s}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=kf.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},ca=class extends Xl{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new ln,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{let r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!oe(this.programDateTime))return null;let e=oe(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){let t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,n,a=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[Ve.AUDIO]=null,e[Ve.VIDEO]=null,e[Ve.AUDIOVIDEO]=null}},Lh=class extends Xl{constructor(e,t,r,s,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new ln,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}},vA=10,Rh=class{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?oe(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||vA}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}};function wf(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function EA(i){let e=Rv(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function bA(i){let e=function(r,s,n){let a=r[s];r[s]=r[n],r[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function yA(i){let e=i.split(":"),t=null;if(e[0]==="data"&&e.length===2){let r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){let n=s[0]==="base64",a=s[1];n?(r.splice(-1,1),t=wf(a)):t=EA(a)}}return t}function Rv(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}var it={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Yt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function G0(i){switch(i){case Yt.FAIRPLAY:return it.FAIRPLAY;case Yt.PLAYREADY:return it.PLAYREADY;case Yt.WIDEVINE:return it.WIDEVINE;case Yt.CLEARKEY:return it.CLEARKEY}}var kv={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function TA(i){if(i===kv.WIDEVINE)return it.WIDEVINE}function V0(i){switch(i){case it.FAIRPLAY:return Yt.FAIRPLAY;case it.PLAYREADY:return Yt.PLAYREADY;case it.WIDEVINE:return Yt.WIDEVINE;case it.CLEARKEY:return Yt.CLEARKEY}}function ah(i){let{drmSystems:e,widevineLicenseUrl:t}=i,r=e?[it.FAIRPLAY,it.WIDEVINE,it.PLAYREADY,it.CLEARKEY].filter(s=>!!e[s]):[];return!r[it.WIDEVINE]&&t&&r.push(it.WIDEVINE),r}var wv=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function _A(i,e,t,r){let s;switch(i){case it.FAIRPLAY:s=["cenc","sinf"];break;case it.WIDEVINE:case it.PLAYREADY:s=["cenc"];break;case it.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return AA(s,e,t,r)}function AA(i,e,t,r){return[{initDataTypes:i,persistentState:r.persistentState||"not-allowed",distinctiveIdentifier:r.distinctiveIdentifier||"not-allowed",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function Xr(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}var Df=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Dv=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Ql=(i,e)=>{let t=e,r=0;for(;Df(i,e);){r+=10;let s=vd(i,e+6);r+=s,Dv(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},vd=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},SA=(i,e)=>Df(i,e)&&vd(i,e+6)+10<=i.length-e,xA=i=>{let e=Mv(i);for(let t=0;t<e.length;t++){let r=e[t];if(Cv(r))return DA(r)}},Cv=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",IA=i=>{let e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=vd(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},Mv=i=>{let e=0,t=[];for(;Df(i,e);){let r=vd(i,e+6);e+=10;let s=e+r;for(;e+8<s;){let n=IA(i.subarray(e)),a=LA(n);a&&t.push(a),e+=n.size+10}Dv(i,e)&&(e+=10)}return t},LA=i=>i.type==="PRIV"?RA(i):i.type[0]==="W"?wA(i):kA(i),RA=i=>{if(i.size<2)return;let e=Wi(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},kA=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1,r=Wi(i.data.subarray(t),!0);t+=r.length+1;let s=Wi(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=Wi(i.data.subarray(1));return{key:i.type,data:e}},wA=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1,r=Wi(i.data.subarray(t),!0);t+=r.length+1;let s=Wi(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=Wi(i.data);return{key:i.type,data:e}},DA=i=>{if(i.data.byteLength===8){let e=new Uint8Array(i.data),t=e[3]&1,r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},Wi=(i,e=!1)=>{let t=CA();if(t){let d=t.decode(i);if(e){let c=d.indexOf("\0");return c!==-1?d.substring(0,c):d}return d.replace(/\0/g,"")}let r=i.length,s,n,a,o="",l=0;for(;l<r;){if(s=i[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},oh;function CA(){return!oh&&typeof self.TextDecoder!="undefined"&&(oh=new self.TextDecoder("utf-8")),oh}var Gi={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let r=i[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},Zl=Math.pow(2,32)-1,MA=[].push,Pv={video:1,audio:2,id3:3,text:4};function At(i){return String.fromCharCode.apply(null,i)}function Ov(i,e){let t=i[e]<<8|i[e+1];return t<0?65536+t:t}function pe(i,e){let t=Nv(i,e);return t<0?4294967296+t:t}function Nv(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function lh(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function Ce(i,e){let t=[];if(!e.length)return t;let r=i.byteLength;for(let s=0;s<r;){let n=pe(i,s),a=At(i.subarray(s+4,s+8)),o=n>1?s+n:r;if(a===e[0])if(e.length===1)t.push(i.subarray(s+8,o));else{let l=Ce(i.subarray(s+8,o),e.slice(1));l.length&&MA.apply(t,l)}s=o}return t}function PA(i){let e=[],t=i[0],r=8,s=pe(i,r);r+=4;let n=0,a=0;t===0?r+=8:r+=16,r+=2;let o=i.length+a,l=Ov(i,r);r+=2;for(let d=0;d<l;d++){let c=r,u=pe(i,c);c+=4;let h=u&2147483647;if((u&2147483648)>>>31===1)return M.warn("SIDX has hierarchical references (not supported)"),null;let g=pe(i,c);c+=4,e.push({referenceSize:h,subsegmentDuration:g,info:{duration:g/s,start:o,end:o+h-1}}),o+=h,c+=4,r=c}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function Uv(i){let e=[],t=Ce(i,["moov","trak"]);for(let s=0;s<t.length;s++){let n=t[s],a=Ce(n,["tkhd"])[0];if(a){let o=a[0],l=o===0?12:20,d=pe(a,l),c=Ce(n,["mdia","mdhd"])[0];if(c){o=c[0],l=o===0?12:20;let u=pe(c,l),h=Ce(n,["mdia","hdlr"])[0];if(h){let f=At(h.subarray(8,12)),g={soun:Ve.AUDIO,vide:Ve.VIDEO}[f];if(g){let E=Ce(n,["mdia","minf","stbl","stsd"])[0],T;E&&(T=At(E.subarray(12,16))),e[d]={timescale:u,type:g},e[g]={timescale:u,id:d,codec:T}}}}}}return Ce(i,["moov","mvex","trex"]).forEach(s=>{let n=pe(s,4),a=e[n];a&&(a.default={duration:pe(s,12),flags:pe(s,20)})}),e}function OA(i,e){if(!i||!e)return i;let t=e.keyId;return t&&e.isCommonEncryption&&Ce(i,["moov","trak"]).forEach(s=>{let a=Ce(s,["mdia","minf","stbl","stsd"])[0].subarray(8),o=Ce(a,["enca"]),l=o.length>0;l||(o=Ce(a,["encv"])),o.forEach(d=>{let c=l?d.subarray(28):d.subarray(78);Ce(c,["sinf"]).forEach(h=>{let f=Fv(h);if(f){let g=f.subarray(8,24);g.some(E=>E!==0)||(M.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Gi.hexDump(g)} -> ${Gi.hexDump(t)}`),f.set(t,8))}})})}),i}function Fv(i){let e=Ce(i,["schm"])[0];if(e){let t=At(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return Ce(i,["schi","tenc"])[0]}return M.error("[eme] missing 'schm' box"),null}function NA(i,e){return Ce(e,["moof","traf"]).reduce((t,r)=>{let s=Ce(r,["tfdt"])[0],n=s[0],a=Ce(r,["tfhd"]).reduce((o,l)=>{let d=pe(l,4),c=i[d];if(c){let u=pe(s,4);if(n===1){if(u===Zl)return M.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;u*=Zl+1,u+=pe(s,8)}let h=c.timescale||9e4,f=u/h;if(oe(f)&&(o===null||f<o))return f}return o},null);return a!==null&&oe(a)&&(t===null||a<t)?a:t},null)}function UA(i,e){let t=0,r=0,s=0,n=Ce(i,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=Ce(o,["tfhd"])[0],d=pe(l,4),c=e[d];if(!c)continue;let u=c.default,h=pe(l,0)|(u==null?void 0:u.flags),f=u==null?void 0:u.duration;h&8&&(h&2?f=pe(l,12):f=pe(l,8));let g=c.timescale||9e4,E=Ce(o,["trun"]);for(let T=0;T<E.length;T++){if(t=FA(E[T]),!t&&f){let S=pe(E[T],4);t=f*S}c.type===Ve.VIDEO?r+=t/g:c.type===Ve.AUDIO&&(s+=t/g)}}if(r===0&&s===0){let a=0,o=Ce(i,["sidx"]);for(let l=0;l<o.length;l++){let d=PA(o[l]);d!=null&&d.references&&(a+=d.references.reduce((c,u)=>c+u.info.duration||0,0))}return a}return r||s}function FA(i){let e=pe(i,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0,s=pe(i,4);for(let n=0;n<s;n++){if(e&256){let a=pe(i,t);r+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function BA(i,e,t){Ce(e,["moof","traf"]).forEach(r=>{Ce(r,["tfhd"]).forEach(s=>{let n=pe(s,4),a=i[n];if(!a)return;let o=a.timescale||9e4;Ce(r,["tfdt"]).forEach(l=>{let d=l[0],c=pe(l,4);if(d===0)c-=t*o,c=Math.max(c,0),lh(l,4,c);else{c*=Math.pow(2,32),c+=pe(l,8),c-=t*o,c=Math.max(c,0);let u=Math.floor(c/(Zl+1)),h=Math.floor(c%(Zl+1));lh(l,4,u),lh(l,8,h)}})})})}function $A(i){let e={valid:null,remainder:null},t=Ce(i,["moof"]);if(t){if(t.length<2)return e.remainder=i,e}else return e;let r=t[t.length-1];return e.valid=Xr(i,0,r.byteOffset-8),e.remainder=Xr(i,r.byteOffset-8),e}function Qr(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function W0(i,e){let t=[],r=e.samples,s=e.timescale,n=e.id,a=!1;return Ce(r,["moof"]).map(l=>{let d=l.byteOffset-8;Ce(l,["traf"]).map(u=>{let h=Ce(u,["tfdt"]).map(f=>{let g=f[0],E=pe(f,4);return g===1&&(E*=Math.pow(2,32),E+=pe(f,8)),E/s})[0];return h!==void 0&&(i=h),Ce(u,["tfhd"]).map(f=>{let g=pe(f,4),E=pe(f,0)&16777215,T=(E&1)!==0,S=(E&2)!==0,k=(E&8)!==0,L=0,F=(E&16)!==0,R=0,B=(E&32)!==0,P=8;g===n&&(T&&(P+=8),S&&(P+=4),k&&(L=pe(f,P),P+=4),F&&(R=pe(f,P),P+=4),B&&(P+=4),e.type==="video"&&(a=HA(e.codec)),Ce(u,["trun"]).map(H=>{let V=H[0],N=pe(H,0)&16777215,j=(N&1)!==0,Y=0,Ee=(N&4)!==0,ge=(N&256)!==0,ye=0,we=(N&512)!==0,Ie=0,Z=(N&1024)!==0,te=(N&2048)!==0,re=0,Le=pe(H,4),Re=8;j&&(Y=pe(H,Re),Re+=4),Ee&&(Re+=4);let Qe=Y+d;for(let Bt=0;Bt<Le;Bt++){if(ge?(ye=pe(H,Re),Re+=4):ye=L,we?(Ie=pe(H,Re),Re+=4):Ie=R,Z&&(Re+=4),te&&(V===0?re=pe(H,Re):re=Nv(H,Re),Re+=4),e.type===Ve.VIDEO){let $t=0;for(;$t<Ie;){let Mt=pe(r,Qe);if(Qe+=4,GA(a,r[Qe])){let ji=r.subarray(Qe,Qe+Mt);Bv(ji,a?2:1,i+re/s,t)}Qe+=Mt,$t+=Mt+4}}i+=ye/s}}))})})}),t}function HA(i){if(!i)return!1;let e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function GA(i,e){if(i){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Bv(i,e,t,r){let s=$v(i),n=0;n+=e;let a=0,o=0,l=!1,d=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;d=s[n++],a+=d}while(d===255);o=0;do{if(n>=s.length)break;d=s[n++],o+=d}while(d===255);let c=s.length-n;if(!l&&a===4&&n<s.length){if(l=!0,s[n++]===181){let h=Ov(s,n);if(n+=2,h===49){let f=pe(s,n);if(n+=4,f===1195456820){let g=s[n++];if(g===3){let E=s[n++],T=31&E,S=64&E,k=S?2+T*3:0,L=new Uint8Array(k);if(S){L[0]=E;for(let F=1;F<k;F++)L[F]=s[n++]}r.push({type:g,payloadType:a,pts:t,bytes:L})}}}}}else if(a===5&&o<c){if(l=!0,o>16){let u=[];for(let g=0;g<16;g++){let E=s[n++].toString(16);u.push(E.length==1?"0"+E:E),(g===3||g===5||g===7||g===9)&&u.push("-")}let h=o-16,f=new Uint8Array(h);for(let g=0;g<h;g++)f[g]=s[n++];r.push({payloadType:a,pts:t,uuid:u.join(""),userData:Wi(f),userDataBytes:f})}}else if(o<c)n+=o;else if(o>c)break}}function $v(i){let e=i.byteLength,t=[],r=1;for(;r<e-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return i;let s=e-t.length,n=new Uint8Array(s),a=0;for(r=0;r<s;a++,r++)a===t[0]&&(a++,t.shift()),n[r]=i[a];return n}function VA(i){let e=i[0],t="",r="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;At(i.subarray(d,d+1))!=="\0";)t+=At(i.subarray(d,d+1)),d+=1;for(t+=At(i.subarray(d,d+1)),d+=1;At(i.subarray(d,d+1))!=="\0";)r+=At(i.subarray(d,d+1)),d+=1;r+=At(i.subarray(d,d+1)),d+=1,s=pe(i,12),n=pe(i,16),o=pe(i,20),l=pe(i,24),d=28}else if(e===1){d+=4,s=pe(i,d),d+=4;let u=pe(i,d);d+=4;let h=pe(i,d);for(d+=4,a=2**32*u+h,dA(a)||(a=Number.MAX_SAFE_INTEGER,M.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=pe(i,d),d+=4,l=pe(i,d),d+=4;At(i.subarray(d,d+1))!=="\0";)t+=At(i.subarray(d,d+1)),d+=1;for(t+=At(i.subarray(d,d+1)),d+=1;At(i.subarray(d,d+1))!=="\0";)r+=At(i.subarray(d,d+1)),d+=1;r+=At(i.subarray(d,d+1)),d+=1}let c=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:c}}function WA(i,...e){let t=e.length,r=8,s=t;for(;s--;)r+=e[s].byteLength;let n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=r&255,n.set(i,4),s=0,r=8;s<t;s++)n.set(e[s],r),r+=e[s].byteLength;return n}function KA(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,s;if(e){r=1,s=new Uint8Array(e.length*16);for(let o=0;o<e.length;o++){let l=e[o];if(l.byteLength!==16)throw new RangeError("Invalid key");s.set(l,o*16)}}else r=0,s=new Uint8Array;let n;r>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;let a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),WA([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function qA(i){if(!(i instanceof ArrayBuffer)||i.byteLength<32)return null;let e={version:0,systemId:"",kids:null,data:null},t=new DataView(i),r=t.getUint32(0);if(i.byteLength!==r&&r>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=Gi.hexDump(new Uint8Array(i,12,16));let n=t.getUint32(28);if(e.version===0){if(r-32<n)return null;e.data=new Uint8Array(i,32,n)}else if(e.version===1){e.kids=[];for(let a=0;a<n;a++)e.kids.push(new Uint8Array(i,32+a*16,16))}return e}var Bl={},ma=class i{static clearKeyUriToKeyIdMap(){Bl={}}constructor(e,t,r,s=[1],n=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=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Yt.FAIRPLAY:case Yt.WIDEVINE:case Yt.PLAYREADY:case Yt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&M.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let r=YA(e);return new i(this.method,this.uri,"identity",this.keyFormatVersions,r)}let t=yA(this.uri);if(t)switch(this.keyFormat){case Yt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Yt.PLAYREADY:{let r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=KA(r,null,t);let s=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(s)),a=n.substring(n.indexOf("<"),n.length),d=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(d){let c=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(c){let u=wf(c).subarray(0,16);bA(u),this.keyId=u}}break}default:{let r=t.subarray(0,16);if(r.length!==16){let s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=Bl[this.uri];if(!r){let s=Object.keys(Bl).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),Bl[this.uri]=r}this.keyId=r}return this}};function YA(i){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}var Hv=/\{\$([a-zA-Z0-9-_]+)\}/g;function K0(i){return Hv.test(i)}function Kt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let r=t.length;r--;){let s=t[r],n=e[s];n&&(e[s]=kh(i,n))}}function kh(i,e){if(i.variableList!==null||i.hasVariableRefs){let t=i.variableList;return e.replace(Hv,r=>{let s=r.substring(2,r.length-1),n=t==null?void 0:t[s];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):n})}return e}function q0(i,e,t){let r=i.variableList;r||(i.variableList=r={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{let a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function jA(i,e,t){let r=e.IMPORT;if(t&&r in t){let s=i.variableList;s||(i.variableList=s={}),s[r]=t[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function Ed(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var zA={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}},Y0=Ed();function XA(i,e){let t=zA[e];return!!t&&t[i.slice(0,4)]===!0}function dh(i,e){var t;return(t=Y0==null?void 0:Y0.isTypeSupported(`${e||"video"}/mp4;codecs="${i}"`))!=null?t:!1}var j0=/#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,z0=/#EXT-X-MEDIA:(.*)/g,QA=/^#EXT(?:INF|-X-TARGETDURATION):/m,X0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ZA=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("|")),zr=class i{static findGroup(e,t){for(let r=0;r<e.length;r++){let s=e[r];if(s.id===t)return s}}static convertAVC1ToAVCOTI(e){let t=e.split(".");if(t.length>2){let r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).slice(-4),r}return e}static resolve(e,t){return kf.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return QA.test(e)}static parseMasterPlaylist(e,t){let r=K0(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];j0.lastIndex=0;let a;for(;(a=j0.exec(e))!=null;)if(a[1]){var o;let d=new tt(a[1]);Kt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let c=kh(s,a[2]),u={attrs:d,bitrate:d.decimalInteger("AVERAGE-BANDWIDTH")||d.decimalInteger("BANDWIDTH"),name:d.NAME,url:i.resolve(c,t)},h=d.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),JA((d.CODECS||"").split(/[ ,]+/).filter(f=>f),u),u.videoCodec&&u.videoCodec.indexOf("avc1")!==-1&&(u.videoCodec=i.convertAVC1ToAVCOTI(u.videoCodec)),(o=u.unknownCodecs)!=null&&o.length||n.push(u),s.levels.push(u)}else if(a[3]){let d=a[3],c=a[4];switch(d){case"SESSION-DATA":{let u=new tt(c);Kt(s,u,["DATA-ID","LANGUAGE","VALUE","URI"]);let h=u["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=u);break}case"SESSION-KEY":{let u=Q0(c,t,s);u.encrypted&&u.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(u)):M.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case"DEFINE":{{let u=new tt(c);Kt(s,u,["NAME","VALUE","QUERYPARAM"]),q0(s,u,t)}break}case"CONTENT-STEERING":{let u=new tt(c);Kt(s,u,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:i.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=Z0(c);break}}}let l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s,n={},a=r.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(z0.lastIndex=0;(s=z0.exec(e))!==null;){let d=new tt(s[1]),c=d.TYPE;if(c){let u=o[c],h=n[c]||[];n[c]=h,Kt(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let f={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",instreamId:d["INSTREAM-ID"],name:d.NAME||d.LANGUAGE||"",type:c,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:d.LANGUAGE,url:d.URI?i.resolve(d.URI,t):""};if(u!=null&&u.length){let g=i.findGroup(u,f.groupId)||u[0];J0(f,g,"audioCodec"),J0(f,g,"textCodec")}h.push(f)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){let o=new Rh(t),l=o.fragments,d=null,c=0,u=0,h=0,f=0,g=null,E=new ca(s,t),T,S,k,L=-1,F=!1;for(X0.lastIndex=0,o.m3u8=e,o.hasVariableRefs=K0(e);(T=X0.exec(e))!==null;){F&&(F=!1,E=new ca(s,t),E.start=h,E.sn=c,E.cc=f,E.level=r,d&&(E.initSegment=d,E.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null));let H=T[1];if(H){E.duration=parseFloat(H);let V=(" "+T[2]).slice(1);E.title=V||null,E.tagList.push(V?["INF",H,V]:["INF",H])}else if(T[3]){if(oe(E.duration)){E.start=h,k&&iv(E,k,o),E.sn=c,E.level=r,E.cc=f,E.urlId=n,l.push(E);let V=(" "+T[3]).slice(1);E.relurl=kh(o,V),ev(E,g),g=E,h+=E.duration,c++,u=0,F=!0}}else if(T[4]){let V=(" "+T[4]).slice(1);g?E.setByteRange(V,g):E.setByteRange(V)}else if(T[5])E.rawProgramDateTime=(" "+T[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),L===-1&&(L=l.length);else{if(T=T[0].match(ZA),!T){M.warn("No matches on slow regex match for level playlist!");continue}for(S=1;S<T.length&&typeof T[S]=="undefined";S++);let V=(" "+T[S]).slice(1),N=(" "+T[S+1]).slice(1),j=T[S+2]?(" "+T[S+2]).slice(1):"";switch(V){case"PLAYLIST-TYPE":o.type=N.toUpperCase();break;case"MEDIA-SEQUENCE":c=o.startSN=parseInt(N);break;case"SKIP":{let Y=new tt(N);Kt(o,Y,["RECENTLY-REMOVED-DATERANGES"]);let Ee=Y.decimalInteger("SKIPPED-SEGMENTS");if(oe(Ee)){o.skippedSegments=Ee;for(let ye=Ee;ye--;)l.unshift(null);c+=Ee}let ge=Y.enumeratedString("RECENTLY-REMOVED-DATERANGES");ge&&(o.recentlyRemovedDateranges=ge.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(N),1);break;case"VERSION":o.version=parseInt(N);break;case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(N||j)&&E.tagList.push(j?[N,j]:[N]);break;case"DISCONTINUITY":f++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([V]);break;case"BITRATE":E.tagList.push([V,N]);break;case"DATERANGE":{let Y=new tt(N);Kt(o,Y,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Kt(o,Y,Y.clientAttrs);let Ee=new zl(Y,o.dateRanges[Y.ID]);Ee.isValid||o.skippedSegments?o.dateRanges[Ee.id]=Ee:M.warn(`Ignoring invalid DATERANGE tag: "${N}"`),E.tagList.push(["EXT-X-DATERANGE",N]);break}case"DEFINE":{{let Y=new tt(N);Kt(o,Y,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in Y?jA(o,Y,a):q0(o,Y,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(N);break;case"KEY":{let Y=Q0(N,t,o);if(Y.isSupported()){if(Y.method==="NONE"){k=void 0;break}k||(k={}),k[Y.keyFormat]&&(k=ft({},k)),k[Y.keyFormat]=Y}else M.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${N}"`);break}case"START":o.startTimeOffset=Z0(N);break;case"MAP":{let Y=new tt(N);if(Kt(o,Y,["BYTERANGE","URI"]),E.duration){let Ee=new ca(s,t);tv(Ee,Y,r,k),d=Ee,E.initSegment=d,d.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=d.rawProgramDateTime)}else tv(E,Y,r,k),d=E,F=!0;break}case"SERVER-CONTROL":{let Y=new tt(N);o.canBlockReload=Y.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=Y.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&Y.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=Y.optionalFloat("PART-HOLD-BACK",0),o.holdBack=Y.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let Y=new tt(N);o.partTarget=Y.decimalFloatingPoint("PART-TARGET");break}case"PART":{let Y=o.partList;Y||(Y=o.partList=[]);let Ee=u>0?Y[Y.length-1]:void 0,ge=u++,ye=new tt(N);Kt(o,ye,["BYTERANGE","URI"]);let we=new Lh(ye,E,t,ge,Ee);Y.push(we),E.duration+=we.duration;break}case"PRELOAD-HINT":{let Y=new tt(N);Kt(o,Y,["URI"]),o.preloadHint=Y;break}case"RENDITION-REPORT":{let Y=new tt(N);Kt(o,Y,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(Y);break}default:M.warn(`line parsed but not handled: ${T}`);break}}}g&&!g.relurl?(l.pop(),h-=g.duration,o.partList&&(o.fragmentHint=g)):o.partList&&(ev(E,g),E.cc=f,o.fragmentHint=E,k&&iv(E,k,o));let R=l.length,B=l[0],P=l[R-1];if(h+=o.skippedSegments*o.targetduration,h>0&&R&&P){o.averagetargetduration=h/R;let H=P.sn;o.endSN=H!=="initSegment"?H:0,o.live||(P.endList=!0),B&&(o.startCC=B.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,L>0&&e1(l,L),o}};function Q0(i,e,t){var r,s;let n=new tt(i);Kt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(r=n.METHOD)!=null?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,c=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&M.error(`Invalid IV: ${n.IV}`);let u=o?zr.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new ma(a,u,c,h,l)}function Z0(i){let t=new tt(i).decimalFloatingPoint("TIME-OFFSET");return oe(t)?t:null}function JA(i,e){["video","audio","text"].forEach(t=>{let r=i.filter(s=>XA(s,t));if(r.length){let s=r.filter(n=>n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0);e[`${t}Codec`]=s.length>0?s[0]:r[0],i=i.filter(n=>r.indexOf(n)===-1)}}),e.unknownCodecs=i}function J0(i,e,t){let r=e[t];r&&(i[t]=r)}function e1(i,e){let t=i[e];for(let r=e;r--;){let s=i[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function ev(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),oe(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function tv(i,e,t,r){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function iv(i,e,t){i.levelkeys=e;let{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(i)}var Me={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},he={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function rv(i){let{type:e}=i;switch(e){case Me.AUDIO_TRACK:return he.AUDIO;case Me.SUBTITLE_TRACK:return he.SUBTITLE;default:return he.MAIN}}function ch(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var wh=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(b.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(b.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,r=t.pLoader,s=t.loader,n=r||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Me.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){let{id:r,level:s,url:n,deliveryDirectives:a}=t;this.load({id:r,level:s,responseType:"text",type:Me.LEVEL,url:n,deliveryDirectives:a})}onAudioTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Me.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Me.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;let r=this.hls.config,s=this.getInternalLoader(e);if(s){let d=s.context;if(d&&d.url===e.url){M.trace("[playlist-loader]: playlist request ongoing");return}M.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===Me.MANIFEST?n=r.manifestLoadPolicy.default:n=ft({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part){let d;if(e.type===Me.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Me.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Me.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let c=d.partTarget,u=d.targetduration;if(c&&u){let h=Math.max(c*3,u*.8)*1e3;n=ft({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,c,u,h)=>{let f=this.getInternalLoader(u);this.resetInternalLoader(u.type);let g=d.data;if(g.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,u,new Error("no EXTM3U delimiter"),h||null,c);return}c.parsing.start=performance.now(),zr.isMediaPlaylist(g)?this.handleTrackOrLevelPlaylist(d,c,u,h||null,f):this.handleMasterPlaylist(d,c,u,h)},onError:(d,c,u,h)=>{this.handleNetworkError(c,u,!1,d,h)},onTimeout:(d,c,u)=>{this.handleNetworkError(c,u,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,r,s){let n=this.hls,a=e.data,o=ch(e,r),l=zr.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}let{contentSteering:d,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:g}=l;this.variableList=g;let{AUDIO:E=[],SUBTITLES:T,"CLOSED-CAPTIONS":S}=zr.parseMasterPlaylistMedia(a,o,l);E.length&&!E.some(L=>!L.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(M.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 tt({}),bitrate:0,url:""})),n.trigger(b.MANIFEST_LOADED,{levels:c,audioTracks:E,subtitles:T,captions:S,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:g})}handleTrackOrLevelPlaylist(e,t,r,s,n){let a=this.hls,{id:o,level:l,type:d}=r,c=ch(e,r),u=oe(o)?o:0,h=oe(l)?l:u,f=rv(r),g=zr.parseLevelPlaylist(e.data,c,h,f,u,this.variableList);if(d===Me.MANIFEST){let E={attrs:new tt({}),bitrate:0,details:g,name:"",url:c};a.trigger(b.MANIFEST_LOADED,{levels:[E],audioTracks:[],url:c,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=g,this.handlePlaylistLoaded(g,e,t,r,s,n)}handleManifestParsingError(e,t,r,s,n){this.hls.trigger(b.ERROR,{type:ue.NETWORK_ERROR,details:$.MANIFEST_PARSING_ERROR,fatal:t.type===Me.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,r=!1,s,n){let a=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===Me.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Me.AUDIO_TRACK||e.type===Me.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);M.warn(`[playlist-loader]: ${a}`);let l=$.UNKNOWN,d=!1,c=this.getInternalLoader(e);switch(e.type){case Me.MANIFEST:l=r?$.MANIFEST_LOAD_TIMEOUT:$.MANIFEST_LOAD_ERROR,d=!0;break;case Me.LEVEL:l=r?$.LEVEL_LOAD_TIMEOUT:$.LEVEL_LOAD_ERROR,d=!1;break;case Me.AUDIO_TRACK:l=r?$.AUDIO_TRACK_LOAD_TIMEOUT:$.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Me.SUBTITLE_TRACK:l=r?$.SUBTITLE_TRACK_LOAD_TIMEOUT:$.SUBTITLE_LOAD_ERROR,d=!1;break}c&&this.resetInternalLoader(e.type);let u={type:ue.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(s){let h=(t==null?void 0:t.url)||e.url;u.response=Nt({url:h,data:void 0},s)}this.hls.trigger(b.ERROR,u)}handlePlaylistLoaded(e,t,r,s,n,a){let o=this.hls,{type:l,level:d,id:c,groupId:u,deliveryDirectives:h}=s,f=ch(t,s),g=rv(s),E=typeof s.level=="number"&&g===he.MAIN?d:void 0;if(!e.fragments.length){let S=new Error("No Segments found in Playlist");o.trigger(b.ERROR,{type:ue.NETWORK_ERROR,details:$.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:S,reason:S.message,response:t,context:s,level:E,parent:g,networkDetails:n,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let T=e.playlistParsingError;if(T){o.trigger(b.ERROR,{type:ue.NETWORK_ERROR,details:$.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:T,reason:T.message,response:t,context:s,level:E,parent:g,networkDetails:n,stats:r});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case Me.MANIFEST:case Me.LEVEL:o.trigger(b.LEVEL_LOADED,{details:e,level:E||0,id:c||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case Me.AUDIO_TRACK:o.trigger(b.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case Me.SUBTITLE_TRACK:o.trigger(b.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break}}};function Gv(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function Vv(i,e){let t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){M.debug(`[texttrack-utils]: ${r}`);try{let s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,i.addCue(s)}catch(s){M.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(i.mode=t)}function an(i){let e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function Dh(i,e,t,r){let s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){let n=i1(i.cues,e,t);for(let a=0;a<n.length;a++)(!r||r(n[a]))&&i.removeCue(n[a])}s==="disabled"&&(i.mode=s)}function t1(i,e){if(e<i[0].startTime)return 0;let t=i.length-1;if(e>i[t].endTime)return-1;let r=0,s=t;for(;r<=s;){let n=Math.floor((s+r)/2);if(e<i[n].startTime)s=n-1;else if(e>i[n].startTime&&r<t)r=n+1;else return n}return i[r].startTime-e<e-i[s].startTime?r:s}function i1(i,e,t){let r=[],s=t1(i,e);if(s>-1)for(let n=s,a=i.length;n<a;n++){let o=i[n];if(o.startTime>=e&&o.endTime<=t)r.push(o);else if(o.startTime>t)return r}return r}var _i={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},r1=.25;function Ch(){if(typeof self!="undefined")return self.VTTCue||self.TextTrackCue}function sv(i,e,t,r,s){let n=new i(e,t,"");try{n.value=r,s&&(n.type=s)}catch{n=new i(e,t,JSON.stringify(s?Nt({type:s},r):r))}return n}var $l=(()=>{let i=Ch();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function uh(i,e){return i.getTime()/1e3-e}function s1(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Mh=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(an(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let r=e[t];if(r.kind==="metadata"&&r.label==="id3")return Gv(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=Ch();if(a)for(let o=0;o<n.length;o++){let l=n[o].type;if(l===_i.emsg&&!r||!s)continue;let d=Mv(n[o].data);if(d){let c=n[o].pts,u=c+n[o].duration;u>$l&&(u=$l),u-c<=0&&(u=c+r1);for(let f=0;f<d.length;f++){let g=d[f];if(!Cv(g)){this.updateId3CueEnds(c,l);let E=sv(a,c,u,g,l);E&&this.id3Track.addCue(E)}}}}}updateId3CueEnds(e,t){var r;let s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let n=s.length;n--;){let a=s[n];a.type===t&&a.startTime<e&&a.endTime===$l&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;s==="audio"?d=c=>c.type===_i.audioId3&&l:s==="video"?d=c=>c.type===_i.emsg&&o:d=c=>c.type===_i.audioId3&&l||c.type===_i.emsg&&o,Dh(n,t,r,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){let c=Object.keys(r).filter(u=>!a.includes(u));for(let u=c.length;u--;){let h=c[u];Object.keys(r[h].cues).forEach(f=>{s.removeCue(r[h].cues[f])}),delete r[h]}}let o=t.fragments[t.fragments.length-1];if(a.length===0||!oe(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,d=Ch();for(let c=0;c<a.length;c++){let u=a[c],h=n[u],f=r[u],g=(f==null?void 0:f.cues)||{},E=(f==null?void 0:f.durationKnown)||!1,T=uh(h.startDate,l),S=$l,k=h.endDate;if(k)S=uh(k,l),E=!0;else if(h.endOnNext&&!E){let F=a.reduce((R,B)=>{let P=n[B];return P.class===h.class&&P.id!==B&&P.startDate>h.startDate&&R.push(P),R},[]).sort((R,B)=>R.startDate.getTime()-B.startDate.getTime())[0];F&&(S=uh(F.startDate,l),E=!0)}let L=Object.keys(h.attr);for(let F=0;F<L.length;F++){let R=L[F];if(!pA(R))continue;let B=g[R];if(B)E&&!f.durationKnown&&(B.endTime=S);else if(d){let P=h.attr[R];gA(R)&&(P=s1(P));let H=sv(d,T,S,{key:R,data:P},_i.dateRange);H&&(H.id=u,this.id3Track.addCue(H),g[R]=H)}}r[u]={cues:g,dateRange:h,durationKnown:E}}}},Ph=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(e===null)return null;let{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*s);let c=s,u=1;return d+Math.min(this.stallCount*u,c)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;let s=r.edge,n=e-t-this.edgeStalled,a=s-r.totalduration,o=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(b.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(b.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(b.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(b.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===$.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&M.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1)return;let a=this.targetLatency;if(a===null)return;let o=r-a,l=Math.min(this.maxLatency,a+t.targetduration),d=o<l;if(t.live&&d&&o>.05&&this.forwardBufferLength>1){let c=Math.min(2,Math.max(1,n)),u=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,u))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){let{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},Oh=["NONE","TYPE-0","TYPE-1",null],ua={No:"",Yes:"YES",v2:"v2"};function n1(i,e){let{canSkipUntil:t,canSkipDateRanges:r,endSN:s}=i,n=e!==void 0?e-s:0;return t&&n<t?r?ua.v2:ua.Yes:ua.No}var Jl=class{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){let t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}},Zr=class{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>t).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){let t=e%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var e;return(e=this.audioGroupIds)==null?void 0:e[this.urlId]}get textGroupId(){var e;return(e=this.textGroupIds)==null?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}};function hh(i,e){let t=e.startPTS;if(oe(t)){let r=0,s;e.sn>i.sn?(r=t-i.start,s=i):(r=i.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function Wv(i,e,t,r,s,n){r-t<=0&&(M.warn("Fragment should have a positive duration",e),r=t+e.duration,n=s+e.duration);let o=t,l=r,d=e.startPTS,c=e.endPTS;if(oe(d)){let T=Math.abs(d-t);oe(e.deltaPTS)?e.deltaPTS=Math.max(T,e.deltaPTS):e.deltaPTS=T,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(r,c),r=Math.max(r,c),n=Math.max(n,e.endDTS)}let u=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=n;let h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f,g=h-i.startSN,E=i.fragments;for(E[g]=e,f=g;f>0;f--)hh(E[f],E[f-1]);for(f=g;f<E.length-1;f++)hh(E[f],E[f+1]);return i.fragmentHint&&hh(E[E.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,u}function a1(i,e){let t=null,r=i.fragments;for(let l=r.length-1;l>=0;l--){let d=r[l].initSegment;if(d){t=d;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let s=0,n;if(d1(i,e,(l,d)=>{l.relurl&&(s=l.cc-d.cc),oe(l.startPTS)&&oe(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(n=d),e.PTSKnown=e.alignedSliding=!0),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,d.urlId=l.urlId,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var c;(!d.initSegment||d.initSegment.relurl===((c=t)==null?void 0:c.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){M.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=o1(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));let a=e.fragments;if(s){M.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),l1(i.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?Wv(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Kv(i,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;let o=e.advancedDateTime;if(e.advanced&&o){let l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function o1(i,e,t){let r=ft({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{let n=new zl(e[s].attr,r[s]);n.isValid?r[s]=n:M.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function l1(i,e,t){if(i&&e){let r=0;for(let s=0,n=i.length;s<=n;s++){let a=i[s],o=e[s+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):r--}}}function d1(i,e,t){let r=e.skippedSegments,s=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(r?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=s;d<=n;d++){let c=l[a+d],u=o[d];r&&!u&&d<r&&(u=e.fragments[d]=c),c&&u&&t(c,u)}}function Kv(i,e){let t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||Nh(e,r[t].start)}function Nh(i,e){if(e){let t=i.fragments;for(let r=i.skippedSegments;r<t.length;r++)t[r].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function c1(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){let r=i.fragments,s=4;if(r.length&&t*s>e){let n=r[r.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function u1(i,e,t){if(!(i!=null&&i.details))return null;let r=i.details,s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function nv(i,e,t){var r;return i!=null&&i.details?qv((r=i.details)==null?void 0:r.partList,e,t):null}function qv(i,e,t){if(i)for(let r=i.length;r--;){let s=i[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function ed(i){switch(i.details){case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_TIMEOUT:case $.LEVEL_LOAD_TIMEOUT:case $.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function av(i,e){let t=ed(e);return i.default[`${t?"timeout":"error"}Retry`]}function Cf(i,e){let t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function ov(i){return Nt(Nt({},i),{errorRetry:null,timeoutRetry:null})}function td(i,e,t,r){return!!i&&e<i.maxNumRetry&&(h1(r)||!!t)}function h1(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}var Yv={search:function(i,e){let t=0,r=i.length-1,s=null,n=null;for(;t<=r;){s=(t+r)/2|0,n=i[s];let a=e(n);if(a>0)t=s+1;else if(a<0)r=s-1;else return n}return null}};function f1(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!oe(e))return null;let r=i[0].programDateTime;if(e<(r||0))return null;let s=i[i.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<i.length;++n){let a=i[n];if(m1(e,t,a))return a}return null}function pa(i,e,t=0,r=0){let s=null;if(i?s=e[i.sn-e[0].sn+1]||null:t===0&&e[0].start===0&&(s=e[0]),s&&Uh(t,r,s)===0)return s;let n=Yv.search(e,Uh.bind(null,t,r));return n&&(n!==i||!s)?n:s}function Uh(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=i?1:t.start-r>i&&t.start?-1:0}function m1(i,e,t){let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function p1(i,e){return Yv.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var g1=3e5,Dt={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},ni={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},Fh=class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=M.log.bind(M,"[info]:"),this.warn=M.warn.bind(M,"[warning]:"),this.error=M.error.bind(M,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(b.ERROR,this.onError,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(b.ERROR,this.onError,this),e.off(b.ERROR,this.onErrorOut,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(e==null?void 0:e.type)===he.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;let n=this.hls,a=t.context;switch(t.details){case $.FRAG_LOAD_ERROR:case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_ERROR:case $.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case $.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:Dt.DoNothing,flags:ni.None};return}case $.FRAG_GAP:case $.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Dt.SendAlternateToPenaltyBox;return}case $.LEVEL_EMPTY_ERROR:case $.LEVEL_PARSING_ERROR:{var o,l;let d=t.parent===he.MAIN?t.level:n.loadLevel;t.details===$.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))}return;case $.LEVEL_LOAD_ERROR:case $.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case $.AUDIO_TRACK_LOAD_ERROR:case $.AUDIO_TRACK_LOAD_TIMEOUT:case $.SUBTITLE_LOAD_ERROR:case $.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){let d=n.levels[n.loadLevel];if(d&&(a.type===Me.AUDIO_TRACK&&a.groupId===d.audioGroupId||a.type===Me.SUBTITLE_TRACK&&a.groupId===d.textGroupId)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=Dt.SendAlternateToPenaltyBox,t.errorAction.flags=ni.MoveAllAlternatesMatchingHost;return}}return;case $.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let d=n.levels[n.loadLevel],c=d==null?void 0:d.attrs["HDCP-LEVEL"];c&&(t.errorAction={action:Dt.SendAlternateToPenaltyBox,flags:ni.MoveAllAlternatesMatchingHDCP,hdcpLevel:c})}return;case $.BUFFER_ADD_CODEC_ERROR:case $.REMUX_ALLOC_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:n.loadLevel);return;case $.INTERNAL_EXCEPTION:case $.BUFFER_APPENDING_ERROR:case $.BUFFER_APPEND_ERROR:case $.BUFFER_FULL_ERROR:case $.LEVEL_SWITCH_ERROR:case $.BUFFER_STALLED_ERROR:case $.BUFFER_SEEK_OVER_HOLE:case $.BUFFER_NUDGE_ON_STALL:t.errorAction={action:Dt.DoNothing,flags:ni.None};return}if(t.type===ue.KEY_SYSTEM_ERROR){let d=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d);return}}getPlaylistRetryOrSwitchAction(e,t){var r;let s=this.hls,n=av(s.config.playlistLoadPolicy,e),a=this.playlistError++,o=(r=e.response)==null?void 0:r.code;if(td(n,a,ed(e),o))return{action:Dt.RetryRequest,flags:ni.None,retryConfig:n,retryCount:a};let d=this.getLevelSwitchAction(e,t);return n&&(d.retryConfig=n,d.retryCount=a),d}getFragRetryOrSwitchAction(e){let t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=av(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((u,h)=>u+h.fragmentError,0);if(s){var d;e.details!==$.FRAG_GAP&&s.fragmentError++;let u=(d=e.response)==null?void 0:d.code;if(td(o,l,ed(e),u))return{action:Dt.RetryRequest,flags:ni.None,retryConfig:o,retryCount:l}}let c=this.getLevelSwitchAction(e,r);return o&&(c.retryConfig=o,c.retryCount=l),c}getLevelSwitchAction(e,t){let r=this.hls;t==null&&(t=r.loadLevel);let s=this.hls.levels[t];if(s&&(s.loadError++,r.autoLevelEnabled)){var n,a;let o=-1,{levels:l,loadLevel:d,minAutoLevel:c,maxAutoLevel:u}=r,h=(n=e.frag)==null?void 0:n.type,{type:f,groupId:g}=(a=e.context)!=null?a:{};for(let E=l.length;E--;){let T=(E+d)%l.length;if(T!==d&&T>=c&&T<=u&&l[T].loadError===0){let S=l[T];if(e.details===$.FRAG_GAP&&e.frag){let k=l[T].details;if(k){let L=pa(e.frag,k.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(f===Me.AUDIO_TRACK&&g===S.audioGroupId||f===Me.SUBTITLE_TRACK&&g===S.textGroupId)continue;if(h===he.AUDIO&&s.audioGroupId===S.audioGroupId||h===he.SUBTITLE&&s.textGroupId===S.textGroupId)continue}o=T;break}}if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:Dt.SendAlternateToPenaltyBox,flags:ni.None,nextAutoLevel:o}}return{action:Dt.SendAlternateToPenaltyBox,flags:ni.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case Dt.DoNothing:break;case Dt.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==$.FRAG_GAP&&(t.fatal=!0);break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,r=e.errorAction;if(!r)return;let{flags:s,hdcpLevel:n,nextAutoLevel:a}=r;switch(s){case ni.None:this.switchLevel(e,a);break;case ni.MoveAllAlternatesMatchingHost:r.resolved||(r.resolved=this.redundantFailover(e));break;case ni.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Oh[Oh.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(e){let{hls:t,penalizedRenditions:r}=this,s=e.parent===he.MAIN?e.level:t.loadLevel,n=t.levels[s],a=n.url.length,o=e.frag?e.frag.urlId:n.urlId;n.urlId===o&&(!e.frag||n.details)&&this.penalizeRendition(n,e);for(let l=1;l<a;l++){let d=(o+l)%a,c=r[d];if(!c||v1(c,e,r[o]))return this.warn(`Switching to Redundant Stream ${d+1}/${a}: "${n.url[d]}" after ${e.details}`),this.playlistError=0,t.levels.forEach(u=>{u.urlId=d}),t.nextLoadLevel=s,!0}return!1}penalizeRendition(e,t){let{penalizedRenditions:r}=this,s=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};s.lastErrorPerfMs=performance.now(),s.errors.push(t),s.details=e.details,r[e.urlId]=s}};function v1(i,e,t){if(performance.now()-i.lastErrorPerfMs>g1)return!0;let r=i.details;if(e.details===$.FRAG_GAP&&r&&e.frag){let s=e.frag.start,n=pa(null,r.fragments,s);if(n&&!n.gap)return!0}if(t&&i.errors.length<t.errors.length){let s=i.errors[i.errors.length-1];if(r&&s.frag&&e.frag&&Math.abs(s.frag.start-e.frag.start)>r.targetduration*3)return!0}return!1}var ga=class{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=M.log.bind(M,`${t}:`),this.warn=M.warn.bind(M,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t){let r=t==null?void 0:t.renditionReports;if(r){let s=-1;for(let n=0;n<r.length;n++){let a=r[n],o;try{o=new self.URL(a.URI,t.url).href}catch(l){M.warn(`Could not construct new URL for Rendition Report: ${l}`),o=a.URI||""}if(o===e){s=n;break}else o===e.substring(0,o.length)&&(s=n)}if(s!==-1){let n=r[s],a=parseInt(n["LAST-MSN"])||(t==null?void 0:t.lastPartSn),o=parseInt(n["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){let l=Math.min(t.age-t.partTarget,t.targetduration);o>=0&&l>t.partTarget&&(o+=1)}return new Jl(a,o>=0?o:void 0,ua.No)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){let{details:s,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),r&&s.fragments.length>0&&a1(r,s),!this.canLoad||!s.live)return;let l,d,c;if(s.canBlockReload&&s.endSN&&s.advanced){let T=this.hls.config.lowLatencyMode,S=s.lastPartSn,k=s.endSN,L=s.lastPartIndex,F=L!==-1,R=S===k,B=T?0:L;F?(d=R?k+1:S,c=R?B:L+1):d=k+1;let P=s.age,H=P+s.ageHeader,V=Math.min(H-s.partTarget,s.targetduration*1.5);if(V>0){if(r&&V>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${V} with playlist age: ${s.age}`),V=0;else{let N=Math.floor(V/s.targetduration);if(d+=N,c!==void 0){let j=Math.round(V%s.targetduration/s.partTarget);c+=j}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${P.toFixed(2)}s goal: ${V} skip sn ${N} to part ${c}`)}s.tuneInGoal=V}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,c),T||!R){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,c));let u=this.hls.mainForwardBufferInfo,h=u?u.end-u.len:0,f=(s.edge-h)*1e3,g=c1(s,f);s.updated&&a>this.requestScheduled+g&&(this.requestScheduled=n.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+g-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+g<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=g);let E=this.requestScheduled-a;E=Math.max(0,E),this.log(`reload live playlist ${e} in ${Math.round(E)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),E)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let n=n1(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=ua.No),new Jl(r,s,n)}checkRetry(e){let t=e.details,r=ed(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===Dt.RetryRequest||!s.resolved&&n===Dt.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(r&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let c=Cf(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${c}ms`)}e.levelRetry=!0,s.resolved=!0}return l}},fh,Bh=class extends ga{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let r=[],s={},n;t.levels.forEach(a=>{var o;let l=a.attrs;((o=a.audioCodec)==null?void 0:o.indexOf("mp4a.40.34"))!==-1&&(fh||(fh=/chrome|firefox/i.test(navigator.userAgent)),fh&&(a.audioCodec=void 0));let{AUDIO:d,CODECS:c,"FRAME-RATE":u,"PATHWAY-ID":h,RESOLUTION:f,SUBTITLES:g}=l,T=`${`${h||"."}-`}${a.bitrate}-${f}-${u}-${c}`;n=s[T],n?n.addFallback(a):(n=new Zr(a),s[T]=n,r.push(n)),id(n,"audio",d),id(n,"text",g)}),this.filterAndSortMediaOptions(r,t)}filterAndSortMediaOptions(e,t){let r=[],s=[],n=!1,a=!1,o=!1,l=e.filter(({audioCodec:f,videoCodec:g,width:E,height:T,unknownCodecs:S})=>(n||(n=!!(E&&T)),a||(a=!!g),o||(o=!!f),!(S!=null&&S.length)&&(!f||dh(f,"audio"))&&(!g||dh(g,"video"))));if((n||a)&&o&&(l=l.filter(({videoCodec:f,width:g,height:E})=>!!f||!!(g&&E))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let f=new Error("no level with compatible codecs found in manifest");this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:f,reason:f.message})}});return}t.audioTracks&&(r=t.audioTracks.filter(f=>!f.audioCodec||dh(f.audioCodec,"audio")),lv(r)),t.subtitles&&(s=t.subtitles,lv(s));let d=l.slice(0);l.sort((f,g)=>f.attrs["HDCP-LEVEL"]!==g.attrs["HDCP-LEVEL"]?(f.attrs["HDCP-LEVEL"]||"")>(g.attrs["HDCP-LEVEL"]||"")?1:-1:f.bitrate!==g.bitrate?f.bitrate-g.bitrate:f.attrs["FRAME-RATE"]!==g.attrs["FRAME-RATE"]?f.attrs.decimalFloatingPoint("FRAME-RATE")-g.attrs.decimalFloatingPoint("FRAME-RATE"):f.attrs.SCORE!==g.attrs.SCORE?f.attrs.decimalFloatingPoint("SCORE")-g.attrs.decimalFloatingPoint("SCORE"):n&&f.height!==g.height?f.height-g.height:0);let c=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let f=0;f<d.length;f++)if(d[f].pathwayId===l[0].pathwayId){c=d[f];break}}this._levels=l;for(let f=0;f<l.length;f++)if(l[f]===c){this._firstLevel=f,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${c.bitrate}`);break}let u=o&&!a,h={levels:l,audioTracks:r,subtitleTracks:s,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:o,video:a,altAudio:!u&&r.some(f=>!!f.url)};this.hls.trigger(b.MANIFEST_PARSED,h),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(b.ERROR,{type:ue.OTHER_ERROR,details:$.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,t.length-1)}let r=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&s&&n===o)return;this.log(`Switching to level ${e}${o?" with Pathway "+o:""} from level ${r}${n?" with Pathway "+n:""}`);let l=ft({},a,{level:e,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(b.LEVEL_SWITCHING,l);let d=a.details;if(!d||d.live){let c=this.switchParams(a.uri,s==null?void 0:s.details);this.loadPlaylist(c)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){let e=this.hls.config.startLevel;return e!==void 0?e:this._firstLevel}else return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===Me.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(t!==void 0&&t.type===he.MAIN){let r=this._levels[t.level];r!==void 0&&(r.loadError=0)}}onLevelLoaded(e,t){var r;let{level:s,details:n}=t,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(n.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){let r=this.currentLevel;if(!r)return;let s=this.hls.audioTracks[t.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==s){let n=-1;for(let a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===s){n=a;break}n!==-1&&n!==r.urlId&&(r.urlId=n,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.urlId,n=r.uri;if(e)try{n=e.addDirectives(n)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}let a=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${a?" Pathway "+a:""} URI ${s+1}/${r.url.length} ${n}`),this.clearTimer(),this.hls.trigger(b.LEVEL_LOADING,{url:n,level:t,id:s,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e,t){let r=(n,a)=>a!==t,s=this._levels.filter((n,a)=>a!==e?!0:n.url.length>1&&t!==void 0?(n.url=n.url.filter(r),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(r)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(r)),n.urlId=0,!0):(this.steering&&this.steering.removeLevel(n),!1));this.hls.trigger(b.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(e,{levels:t}){t.forEach((r,s)=>{let{details:n}=r;n!=null&&n.fragments&&n.fragments.forEach(a=>{a.level=s})}),this._levels=t}};function id(i,e,t){t&&(e==="audio"?(i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds[i.url.length-1]=t):e==="text"&&(i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds[i.url.length-1]=t))}function lv(i){let e={};i.forEach(t=>{let r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}var yt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},$h=class{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(b.BUFFER_APPENDED,this.onBufferAppended,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.BUFFER_APPENDED,this.onBufferAppended,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let r=this.activePartLists[t];if(r)for(let s=r.length;s--;){let n=r[s];if(!n)break;let a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:r}=this,s=Object.keys(r);for(let n=s.length;n--;){let a=r[s[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){let o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);let n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===r&&this.removeFragment(o.body);return}let l=o.range[e];l&&l.time.some(d=>{let c=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return c&&this.removeFragment(o.body),c})})}detectPartialFragments(e){let t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;let n=rn(r),a=this.fragments[n];if(!a||a.buffered&&r.gap)return;let o=!r.relurl;Object.keys(t).forEach(l=>{let d=r.elementaryStreams[l];if(!d)return;let c=t[l],u=o||d.partial===!0;a.range[l]=this.getBufferedTimes(r,s,u,c)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),Hl(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){let r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){let r=rn(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){let n={time:[],partial:r},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let c=0;c<s.length;c++){let u=s.start(c)-this.bufferPadding,h=s.end(c)+this.bufferPadding;if(d>=u&&l<=h){n.time.push({startPTS:Math.max(a,s.start(c)),endPTS:Math.min(o,s.end(c))});break}else if(a<h&&o>u)n.partial=!0,n.time.push({startPTS:Math.max(a,s.start(c)),endPTS:Math.min(o,s.end(c))});else if(o<=u)break}return n}getPartialFragment(e){let t=null,r,s,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let c=l[d];c&&Hl(c)&&(s=c.body.start-o,n=c.body.end+o,e>=s&&e<=n&&(r=Math.min(e-s,n-e),a<=r&&(t=c.body,a=r)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||Hl(t))}getState(e){let t=rn(e),r=this.fragments[t];return r?r.buffered?Hl(r)?yt.PARTIAL:yt.OK:yt.APPENDING:yt.NOT_LOADED}isTimeBuffered(e,t,r){let s,n;for(let a=0;a<r.length;a++){if(s=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){let{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;let n=s?null:t,a=rn(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:r,part:s,timeRanges:n}=t;if(r.sn==="initSegment")return;let a=r.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{let l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=rn(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let l=o.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){let t=rn(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let r=this.activePartLists[e.type];if(r){let s=e.sn;this.activePartLists[e.type]=r.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}};function Hl(i){var e,t,r;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function rn(i){return`${i.type}_${i.level}_${i.urlId}_${i.sn}`}var dv=Math.pow(2,17),Hh=class{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let r=e.url;if(!r)return Promise.reject(new Ti({type:ue.NETWORK_ERROR,details:$.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(uv(e));return}else e.gap=!1;let d=this.loader=e.loader=n?new n(s):new a(s),c=cv(e),u=ov(s.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:dv};e.stats=d.stats,d.load(c,h,{onSuccess:(f,g,E,T)=>{this.resetLoader(e,d);let S=f.data;E.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(S.slice(0,16)),S=S.slice(16)),o({frag:e,part:null,payload:S,networkDetails:T})},onError:(f,g,E,T)=>{this.resetLoader(e,d),l(new Ti({type:ue.NETWORK_ERROR,details:$.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Nt({url:r,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:E,stats:T}))},onAbort:(f,g,E)=>{this.resetLoader(e,d),l(new Ti({type:ue.NETWORK_ERROR,details:$.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:E,stats:f}))},onTimeout:(f,g,E)=>{this.resetLoader(e,d),l(new Ti({type:ue.NETWORK_ERROR,details:$.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:f}))},onProgress:(f,g,E,T)=>{t&&t({frag:e,part:null,payload:E,networkDetails:T})}})})}loadPart(e,t,r){this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(uv(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),c=cv(e,t),u=ov(s.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:dv};t.stats=d.stats,d.load(c,h,{onSuccess:(f,g,E,T)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);let S={frag:e,part:t,payload:f.data,networkDetails:T};r(S),o(S)},onError:(f,g,E,T)=>{this.resetLoader(e,d),l(new Ti({type:ue.NETWORK_ERROR,details:$.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Nt({url:c.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:E,stats:T}))},onAbort:(f,g,E)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new Ti({type:ue.NETWORK_ERROR,details:$.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:E,stats:f}))},onTimeout:(f,g,E)=>{this.resetLoader(e,d),l(new Ti({type:ue.NETWORK_ERROR,details:$.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:f}))}})})}updateStatsFromPart(e,t){let r=e.stats,s=t.stats,n=s.total;if(r.loaded+=s.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/n),l),u=(l-d)*Math.round(r.loaded/d);r.total=r.loaded+u}else r.total=Math.max(r.loaded,r.total);let a=r.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}};function cv(i,e=null){let t=e||i,r={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(oe(s)&&oe(n)){var a;let o=s,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function uv(i,e){let t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:ue.MEDIA_ERROR,details:$.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(r.part=e),(e||i).stats.aborted=!0,new Ti(r)}var Ti=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},Gh=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let t in this.keyUriToKeyInfo){let r=this.keyUriToKeyInfo[t].loader;if(r){if(e&&e!==r.context.frag.type)return;r.abort()}}}detach(){for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=$.KEY_LOAD_ERROR,r,s,n){return new Ti({type:ue.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:r,cc:s}=e;for(let n=0;n<t.length;n++){let a=t[n];if(s<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,s;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let d=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,$.KEY_LOAD_ERROR,d))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,$.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((r=o)!=null&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,$.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,r))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(r)}loadKeyHTTP(e,t){let r=this.config,s=r.loader,n=new s(r);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,E)=>{let{frag:T,keyInfo:S,url:k}=g;if(!T.decryptdata||S!==this.keyUriToKeyInfo[k])return o(this.createKeyLoadError(T,$.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),E));S.decryptdata.key=T.decryptdata.key=new Uint8Array(h.data),T.keyLoader=null,S.loader=null,a({frag:T,keyInfo:S})},onError:(h,f,g,E)=>{this.resetLoader(f),o(this.createKeyLoadError(t,$.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),g,Nt({url:l.url,data:void 0},h)))},onTimeout:(h,f,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,$.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),g))},onAbort:(h,f,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,$.INTERNAL_ABORTED,new Error("key loading aborted"),g))}};n.load(l,c,u)})}resetLoader(e){let{frag:t,keyInfo:r,url:s}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}},Vh=class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}},E1={length:0,start:()=>0,end:()=>0},Xe=class i{static isBuffered(e,t){try{if(e){let r=i.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){let s=i.getBuffered(e),n=[],a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(d,c){let u=d.start-c.start;return u||c.end-d.end});let s=[];if(r)for(let d=0;d<e.length;d++){let c=s.length;if(c){let u=s[c-1].end;e[d].start-u<r?e[d].end>u&&(s[c-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let n=0,a,o=t,l=t;for(let d=0;d<s.length;d++){let c=s[d].start,u=s[d].end;if(t+r>=c&&t<u)o=c,l=u,n=l-t;else if(t+r<c){a=c;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return M.log("failed to get media.buffered",t),E1}}},va=class{constructor(e,t,r,s=0,n=-1,a=!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=Gl(),this.buffering={audio:Gl(),video:Gl(),audiovideo:Gl()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}};function Gl(){return{start:0,executeStart:0,executeEnd:0,end:0}}function jv(i,e){let t=null;for(let r=0,s=i.length;r<s;r++){let n=i[r];if(n&&n.cc===e){t=n;break}}return t}function b1(i,e,t){return!!(e.details&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function y1(i,e,t=0){let r=i.fragments,s=e.fragments;if(!s.length||!r.length){M.log("No fragments to align");return}let n=jv(r,s[0].cc);if(!n||n&&!n.startPTS){M.log("No frag in previous level to align on");return}return n}function hv(i,e){if(i){let t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function Mf(i,e){let t=e.fragments;for(let r=0,s=t.length;r<s;r++)hv(t[r],i);e.fragmentHint&&hv(e.fragmentHint,i),e.alignedSliding=!0}function T1(i,e,t){e&&(_1(i,t,e),!t.alignedSliding&&e.details&&A1(t,e.details),!t.alignedSliding&&e.details&&!t.skippedSegments&&Kv(e.details,t))}function _1(i,e,t){if(b1(i,t,e)){let r=y1(t.details,e);r&&oe(r.start)&&(M.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Mf(r.start,e))}}function A1(i,e){if(!e.fragments.length||!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=e.fragments[0].programDateTime,r=i.fragments[0].programDateTime,s=(r-t)/1e3+e.fragments[0].start;s&&oe(s)&&(M.log(`Adjusting PTS using programDateTime delta ${r-t}ms, sliding:${s.toFixed(3)} ${i.url} `),Mf(s,i))}function zv(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=i.fragments,r=e.fragments;if(!t.length||!r.length)return;let s=Math.round(r.length/2)-1,n=r[s],a=jv(t,n.cc)||t[Math.round(t.length/2)-1],o=n.programDateTime,l=a.programDateTime;if(o===null||l===null)return;let d=(l-o)/1e3-(a.start-n.start);Mf(d,i)}var Wh=class{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}},Kh=class{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}};function S1(i){let e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?Xr(i,0,e-t):i}var qh=class{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){let t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){let e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],n=r[1],a=r[2],o=r[3],l=this.invSubMix,d=l[0],c=l[1],u=l[2],h=l[3],f=new Uint32Array(256),g=0,E=0,T=0;for(T=0;T<256;T++)T<128?f[T]=T<<1:f[T]=T<<1^283;for(T=0;T<256;T++){let S=E^E<<1^E<<2^E<<3^E<<4;S=S>>>8^S&255^99,e[g]=S,t[S]=g;let k=f[g],L=f[k],F=f[L],R=f[S]*257^S*16843008;s[g]=R<<24|R>>>8,n[g]=R<<16|R>>>16,a[g]=R<<8|R>>>24,o[g]=R,R=F*16843009^L*65537^k*257^g*16843008,d[S]=R<<24|R>>>8,c[S]=R<<16|R>>>16,u[S]=R<<8|R>>>24,h[S]=R,g?(g=k^f[f[f[F^k]]],E^=f[f[E]]):g=E=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;let n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);let a=this.ksRows=(n+6+1)*4,o,l,d=this.keySchedule=new Uint32Array(a),c=this.invKeySchedule=new Uint32Array(a),u=this.sBox,h=this.rcon,f=this.invSubMix,g=f[0],E=f[1],T=f[2],S=f[3],k,L;for(o=0;o<a;o++){if(o<n){k=d[o]=t[o];continue}L=k,o%n===0?(L=L<<8|L>>>24,L=u[L>>>24]<<24|u[L>>>16&255]<<16|u[L>>>8&255]<<8|u[L&255],L^=h[o/n|0]<<24):n>6&&o%n===4&&(L=u[L>>>24]<<24|u[L>>>16&255]<<16|u[L>>>8&255]<<8|u[L&255]),d[o]=k=(d[o-n]^L)>>>0}for(l=0;l<a;l++)o=a-l,l&3?L=d[o]:L=d[o-4],l<4||o<=4?c[l]=L:c[l]=g[u[L>>>24]]^E[u[L>>>16&255]]^T[u[L>>>8&255]]^S[u[L&255]],c[l]=c[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){let s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],c=o[2],u=o[3],h=this.uint8ArrayToUint32Array_(r),f=h[0],g=h[1],E=h[2],T=h[3],S=new Int32Array(e),k=new Int32Array(S.length),L,F,R,B,P,H,V,N,j,Y,Ee,ge,ye,we,Ie=this.networkToHostOrderSwap;for(;t<S.length;){for(j=Ie(S[t]),Y=Ie(S[t+1]),Ee=Ie(S[t+2]),ge=Ie(S[t+3]),P=j^n[0],H=ge^n[1],V=Ee^n[2],N=Y^n[3],ye=4,we=1;we<s;we++)L=l[P>>>24]^d[H>>16&255]^c[V>>8&255]^u[N&255]^n[ye],F=l[H>>>24]^d[V>>16&255]^c[N>>8&255]^u[P&255]^n[ye+1],R=l[V>>>24]^d[N>>16&255]^c[P>>8&255]^u[H&255]^n[ye+2],B=l[N>>>24]^d[P>>16&255]^c[H>>8&255]^u[V&255]^n[ye+3],P=L,H=F,V=R,N=B,ye=ye+4;L=a[P>>>24]<<24^a[H>>16&255]<<16^a[V>>8&255]<<8^a[N&255]^n[ye],F=a[H>>>24]<<24^a[V>>16&255]<<16^a[N>>8&255]<<8^a[P&255]^n[ye+1],R=a[V>>>24]<<24^a[N>>16&255]<<16^a[P>>8&255]<<8^a[H&255]^n[ye+2],B=a[N>>>24]<<24^a[P>>16&255]<<16^a[H>>8&255]<<8^a[V&255]^n[ye+3],k[t]=Ie(L^f),k[t+1]=Ie(B^g),k[t+2]=Ie(R^E),k[t+3]=Ie(F^T),f=j,g=Y,E=Ee,T=ge,t=t+4}return k.buffer}},x1=16,Ea=class{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?S1(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,r);let a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){let{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Qr(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new qh),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=Xr(o,-16).buffer,d||null}webCryptoDecrypt(e,t,r){let s=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new Kh(s,t)),this.fastAesKey.expandKey().then(n=>s?(this.logOnce("WebCrypto AES decrypt"),new Wh(s,new Uint8Array(r)).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(M.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);let s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,r=e.length-e.length%x1;return r!==e.length&&(t=Xr(e,0,r),this.remainderData=Xr(e,r)),t}logOnce(e){this.logEnabled&&(M.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},I1={toString:function(i){let e="",t=i.length;for(let r=0;r<t;r++)e+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return e}},W={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},ba=class extends Vh{constructor(e,t,r,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=W.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=M.log.bind(M,`${s}:`),this.warn=M.warn.bind(M,`${s}:`),this.hls=e,this.fragmentLoader=new Hh(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Ea(e.config),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=W.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;let r=t.partList;if(r!=null&&r.length){let n=r[r.length-1];return Xe.isBuffered(this.media,n.start+n.duration/2)}let s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levels[this.levelLastLoaded])==null?void 0:e.details}}onMediaAttached(e,t){let r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);let s=this.config;this.levels&&s.autoStartLoad&&this.state===W.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){let e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){let{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:n}=this,a=r?r.currentTime:0,o=Xe.bufferInfo(s||r,a,e.maxBufferHole);if(this.log(`media seeking to ${oe(a)?a.toFixed(3):a}, state: ${n}`),this.state===W.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,d=t.start-l,c=t.start+t.duration+l;if(!o.len||c<o.start||d>o.end){let u=a>c;(a<d||u)&&(u&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=W.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){let s=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,r,s).then(n=>{if(!n)return;let a=this.state;if(this.fragContextChanged(e)){(a===W.FRAG_LOADING||!this.fragCurrent&&a===W.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=W.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(b.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===W.STOPPED||this.state===W.ERROR||(this.warn(n),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:r}=this;if(r.getState(e)===yt.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength);this.reduceMaxBufferLength(o)&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===yt.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;let s={startOffset:e,endOffset:t,type:r};this.hls.trigger(b.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{let{hls:s}=this,{payload:n}=r,a=e.decryptdata;if(n&&n.byteLength>0&&a&&a.key&&a.iv&&a.method==="AES-128"){let o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{let d=self.performance.now();return s.trigger(b.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),r.payload=l,r})}return r}).then(r=>{let{fragCurrent:s,hls:n,levels:a}=this;if(!a)throw new Error("init load aborted, missing levels");let o=e.stats;this.state=W.IDLE,t.fragmentError=0,e.data=new Uint8Array(r.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),r.frag===s&&n.trigger(b.FRAG_BUFFERED,{stats:o,frag:s,part:null,id:e.type}),this.tick()}).catch(r=>{this.state===W.STOPPED||this.state===W.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var r,s,n,a;let o=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===he.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?I1.toString(Xe.getBuffered(o)):"(detached)"})`),this.state=W.IDLE,o&&(!this.loadedmetadata&&e.type==he.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:r,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new va(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var n;let a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=W.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(c=>{if(!this.fragContextChanged(c.frag))return this.hls.trigger(b.KEY_LOADED,c),this.state===W.KEY_LOADING&&(this.state=W.IDLE),c}),this.hls.trigger(b.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let c=a.partList;if(c&&s){r>e.end&&a.fragmentHint&&(e=a.fragmentHint);let u=this.getNextPart(c,e,r);if(u>-1){let h=c[u];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${u}-${c.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=W.FRAG_LOADING;let f;return o?f=o.then(g=>!g||this.fragContextChanged(g.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(g=>this.handleFragLoadError(g)):f=this.doFragPartsLoad(e,h,t,s).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(b.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(c,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),oe(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=W.FRAG_LOADING;let l=this.config.progressive,d;return l&&o?d=o.then(c=>!c||this.fragContextChanged(c==null?void 0:c.frag)?null:this.fragmentLoader.load(e,s)).catch(c=>this.handleFragLoadError(c)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([c])=>(!l&&c&&s&&s(c),c)).catch(c=>this.handleFragLoadError(c)),this.hls.trigger(b.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,s){return new Promise((n,a)=>{var o;let l=[],d=(o=r.details)==null?void 0:o.partList,c=u=>{this.fragmentLoader.loadPart(e,u,s).then(h=>{l[u.index]=h;let f=h.part;this.hls.trigger(b.FRAG_LOADED,h);let g=nv(r,e.sn,u.index+1)||qv(d,e.sn,u.index+1);if(g)c(g);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};c(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===$.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(b.ERROR,t)}else this.hls.trigger(b.ERROR,{type:ue.OTHER_ERROR,details:$.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==W.PARSING){!this.fragCurrent&&this.state!==W.STOPPED&&this.state!==W.ERROR&&(this.state=W.IDLE);return}let{frag:r,part:s,level:n}=t,a=self.performance.now();r.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(r,s,n,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:r}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;let o=t[s],l=a>-1?nv(o,n,a):null,d=l?l.fragment:u1(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,r,s,n){var a;if(!e||this.state!==W.PARSING)return;let{data1:o,data2:l}=e,d=o;if(o&&l&&(d=Qr(o,l)),!((a=d)!=null&&a.length))return;let c={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(b.BUFFER_APPENDING,c),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!Xe.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let r=t.currentTime,s=Xe.bufferInfo(t,r,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let r=this.getLoadPosition();return oe(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){let{config:{maxBufferHole:s}}=this,n=Xe.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return Xe.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){let{config:t}=this,r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e){let t=this.config,r=e||t.maxBufferLength;return t.maxMaxBufferLength>=r?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=he.MAIN){let r=this.fragmentTracker.getAppendedFrag(e,he.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){let r=t.fragments,s=r.length;if(!s)return null;let{config:n}=this,a=r[0].start,o;if(t.live){let l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(o=this.getInitialLiveFragment(t,r),this.startPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=r[0]);if(!o){let l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){let r=this.fragmentTracker.getState(e);return(r===yt.OK||r===yt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){let d=e[o];if(a=a&&!d.independent,s>-1&&r<d.start)break;let c=d.loaded;c?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=c}return s}loadedEndOfParts(e,t){let r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){let r=this.fragPrevious,s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=f1(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){let n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];r.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=p1(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{let n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){let{config:s}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=r,{fragmentHint:l}=r,d=s.maxFragLookUpTolerance,c=r.partList,u=!!(s.lowLatencyMode&&c!=null&&c.length&&l);u&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){let f=e>t-d?0:d;h=pa(n,a,e,f)}else h=a[a.length-1];if(h){let f=h.sn-r.startSN,g=this.fragmentTracker.getState(h);if((g===yt.OK||g===yt.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!u||c[0].fragment.sn>h.sn)&&n&&h.level===n.level){let T=a[f+1];h.sn<o&&this.fragmentTracker.getState(T)!==yt.OK?h=T:h=null}}return h}synchronizeToLiveEdge(e){let{config:t,media:r}=this;if(!r)return;let s=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&r.duration>s&&(n<s||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t){let{levels:r,levelLastLoaded:s,fragPrevious:n}=this,a=s!==null?r[s]:null,o=e.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;let l=e.fragments[0].start,d=!t,c=e.alignedSliding&&oe(l);if(d||!c&&!l){T1(n,a,e);let u=e.fragments[0].start;return this.log(`Live playlist sliding: ${u.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${n?n.sn:"na"} fragments: ${o}`),u}return l}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),r===-1||this.lastCurrentTime===-1){let s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&oe(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==W.FRAG_LOADING_WAITING_RETRY)&&(this.state=W.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}let n=t.details===$.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===Dt.RetryRequest&&d){var c;this.resetStartWhenNotLoaded((c=this.levelLastLoaded)!=null?c:r.level);let u=Cf(d,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=W.FRAG_LOADING_WAITING_RETRY}else d&&a?(this.resetFragmentErrors(e),l<d.maxNumRetry?n||(a.resolved=!0):M.warn(`${t.details} reached or exceeded max retry (${l})`)):(a==null?void 0:a.action)===Dt.SendAlternateToPenaltyBox?this.state=W.WAITING_LEVEL:this.state=W.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===W.PARSING||this.state===W.PARSED){let t=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,t),s=r&&r.len>.5;s&&this.reduceMaxBufferLength(r.len);let n=!s;return n&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===he.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==W.STOPPED&&(this.state=W.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;let s=Xe.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===W.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=W.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;let t=this.levels?this.levels[e].details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){var t;this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((t=this.levelLastLoaded)!=null?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var n;let a=r.details;if(!a){this.warn("level.details undefined");return}if(Object.keys(e.elementaryStreams).reduce((l,d)=>{let c=e.elementaryStreams[d];if(c){let u=c.endPTS-c.startPTS;if(u<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${u})`),l||!1;let h=s?0:Wv(a,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS);return this.hls.trigger(b.LEVEL_PTS_UPDATED,{details:a,level:r,drift:h,type:d,frag:e,start:c.startPTS,end:c.endPTS}),!0}return l},!1))r.fragmentError=0;else if(((n=this.transmuxer)==null?void 0:n.error)===null){let l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=W.PARSED,this.hls.trigger(b.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){if(e.event==="demuxerWorker"){var t,r,s;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((t=(r=this.levelLastLoaded)!=null?r:(s=this.fragCurrent)==null?void 0:s.level)!=null?t:0),this.resetLoadingState()}}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}};function Xv(){return self.SourceBuffer||self.WebKitSourceBuffer}function L1(){let i=Ed();if(!i)return!1;let e=Xv(),t=i&&typeof i.isTypeSupported=="function"&&i.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),r=!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function";return!!t&&!!r}function R1(){var i;let e=Xv();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}function k1(){return typeof __HLS_WORKER_BUNDLE__=="function"}function w1(){let i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function D1(i){let e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function Vi(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var rd=class{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Qr(this.cachedData,e),this.cachedData=null);let r=Ql(e,0),s=r?r.length:0,n,a=this._audioTrack,o=this._id3Track,l=r?xA(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&oe(l))&&(this.basePTS=C1(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:_i.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){let c=this.appendFrame(a,e,s);c?(this.frameIndex++,this.lastPTS=c.sample.pts,s+=c.length,n=s):s=d}else SA(e,s)?(r=Ql(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:_i.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===d&&n!==d){let c=Xr(e,n);this.cachedData?this.cachedData=Qr(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:Vi(),id3Track:o,textTrack:Vi()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Vi(),id3Track:this._id3Track,textTrack:Vi()}}destroy(){}},C1=(i,e,t)=>{if(oe(i))return i*90;let r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function M1(i,e,t,r){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=r,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;let u=(e[t+2]&60)>>>2;if(u>c.length-1){i.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${u}`});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,M.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${u}`),/firefox/i.test(l)?u>=6?(s=5,o=new Array(4),n=u-3):(s=2,o=new Array(2),n=u):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=u):(s=5,o=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&u>=6?n=u-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(u>=6&&a===1||/vivaldi/i.test(l))||!r&&a===1)&&(s=2,o=new Array(2)),n=u)),o[0]=s<<3,o[0]|=(u&14)>>1,o[1]|=(u&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:c[u],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function Qv(i,e){return i[e]===255&&(i[e+1]&246)===240}function Zv(i,e){return i[e+1]&1?7:9}function Pf(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function P1(i,e){return e+5<i.length}function sd(i,e){return e+1<i.length&&Qv(i,e)}function O1(i,e){return P1(i,e)&&Qv(i,e)&&Pf(i,e)<=i.length-e}function N1(i,e){if(sd(i,e)){let t=Zv(i,e);if(e+t>=i.length)return!1;let r=Pf(i,e);if(r<=t)return!1;let s=e+r;return s===i.length||sd(i,s)}return!1}function Jv(i,e,t,r,s){if(!i.samplerate){let n=M1(e,t,r,s);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,M.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function eE(i){return 1024*9e4/i}function U1(i,e){let t=Zv(i,e);if(e+t<=i.length){let r=Pf(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function tE(i,e,t,r,s){let n=eE(i.samplerate),a=r+s*n,o=U1(e,t),l;if(o){let{frameLength:u,headerLength:h}=o,f=h+u,g=Math.max(0,t+f-e.length);g?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);let E={unit:l,pts:a};return g||i.samples.push(E),{sample:E,length:f,missing:g}}let d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}var Yh=class extends rd{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let r=(Ql(e,0)||[]).length;for(let s=e.length;r<s;r++)if(N1(e,r))return M.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return O1(e,t)}appendFrame(e,t,r){Jv(e,this.observer,t,r,e.manifestCodec);let s=tE(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},F1=/\/emsg[-/]ID3/i,jh=class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){let n=this.videoTrack=Vi("video",1),a=this.audioTrack=Vi("audio",1),o=this.txtTrack=Vi("text",1);if(this.id3Track=Vi("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=Uv(e);if(l.video){let{id:d,timescale:c,codec:u}=l.video;n.id=d,n.timescale=o.timescale=c,n.codec=u}if(l.audio){let{id:d,timescale:c,codec:u}=l.audio;a.id=d,a.timescale=c,a.codec=u}o.id=Pv.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return e=e.length>16384?e.subarray(0,16384):e,Ce(e,["moof"]).length>0}demux(e,t){this.timeOffset=t;let r=e,s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Qr(this.remainderData,e));let o=$A(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;let a=this.extractID3Track(s,t);return n.samples=W0(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return r.samples=W0(e,t),{videoTrack:t,audioTrack:Vi(),id3Track:s,textTrack:Vi()}}extractID3Track(e,t){let r=this.id3Track;if(e.samples.length){let s=Ce(e.samples,["emsg"]);s&&s.forEach(n=>{let a=VA(n);if(F1.test(a.schemeIdUri)){let o=oe(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale,l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);let d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:_i.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},Vl=null,B1=[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],$1=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],H1=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],G1=[0,1,1,4];function iE(i,e,t,r,s){if(t+24>e.length)return;let n=rE(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=r+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function rE(i,e){let t=i[e+1]>>3&3,r=i[e+1]>>1&3,s=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){let a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-r:r===3?3:4,d=B1[l*14+s-1]*1e3,u=$1[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=H1[t][r],g=G1[r],E=f*8*g,T=Math.floor(f*d/u+a)*g;if(Vl===null){let L=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Vl=L?parseInt(L[1]):0}return!!Vl&&Vl<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:u,channelCount:h,frameLength:T,samplesPerFrame:E}}}function Of(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function sE(i,e){return e+1<i.length&&Of(i,e)}function V1(i,e){return Of(i,e)&&4<=i.length-e}function W1(i,e){if(e+1<i.length&&Of(i,e)){let r=rE(i,e),s=4;r!=null&&r.frameLength&&(s=r.frameLength);let n=e+s;return n===i.length||sE(i,n)}return!1}var nd=class{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(r,r+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&M.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let n=0;n<e;n++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,n,a,o,l=this.readUByte.bind(this),d=this.readBits.bind(this),c=this.readUEG.bind(this),u=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),g=this.skipUEG.bind(this),E=this.skipScalingList.bind(this);l();let T=l();if(d(5),h(3),l(),g(),T===100||T===110||T===122||T===244||T===44||T===83||T===86||T===118||T===128){let B=c();if(B===3&&h(1),g(),g(),h(1),u())for(a=B!==3?8:12,o=0;o<a;o++)u()&&(o<6?E(16):E(64))}g();let S=c();if(S===0)c();else if(S===1)for(h(1),f(),f(),n=c(),o=0;o<n;o++)f();g(),h(1);let k=c(),L=c(),F=d(1);F===0&&h(1),h(1),u()&&(e=c(),t=c(),r=c(),s=c());let R=[1,1];if(u()&&u())switch(l()){case 1:R=[1,1];break;case 2:R=[12,11];break;case 3:R=[10,11];break;case 4:R=[16,11];break;case 5:R=[40,33];break;case 6:R=[24,11];break;case 7:R=[20,11];break;case 8:R=[32,11];break;case 9:R=[80,33];break;case 10:R=[18,11];break;case 11:R=[15,11];break;case 12:R=[64,33];break;case 13:R=[160,99];break;case 14:R=[4,3];break;case 15:R=[3,2];break;case 16:R=[2,1];break;case 255:{R=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((k+1)*16-e*2-t*2),height:(2-F)*(L+1)*16-(F?2:4)*(r+s),pixelRatio:R}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},zh=class{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Ea(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){let s=e[t].unit;if(s.length<=16)return;let n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)r.set(e.subarray(n,n+16),s);return r}getAvcDecryptedUnit(e,t){let r=new Uint8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(r.subarray(s,s+16),n);return e}decryptAvcSample(e,t,r,s,n){let a=$v(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}let n=e[t].units;for(;!(r>=n.length);r++){let a=n[r];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,r,s,a),!this.decrypter.isSync()))return}}}},wt=188,Xh=class i{constructor(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}static probe(e){let t=i.syncOffset(e);return t>0&&M.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,r=Math.min(wt*5,e.length-wt)+1,s=0;for(;s<r;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=wt)if(e[l]===71){if(o++,a===-1&&(a=l,a!==0&&(r=Math.min(a+wt*99,e.length-wt)+1)),n||(n=Qh(e,l)===0),n&&o>1&&(a===0&&o>2||l+wt>r))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Pv[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=i.createTrack("video"),this._audioTrack=i.createTrack("audio",s),this._id3Track=i.createTrack("id3"),this._txtTrack=i.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_avcTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let n,a=this._avcTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,c=a.pid,u=a.pesData,h=o.pid,f=l.pid,g=o.pesData,E=l.pesData,T=null,S=this.pmtParsed,k=this._pmtId,L=e.length;if(this.remainderData&&(e=Qr(this.remainderData,e),L=e.length,this.remainderData=null),L<wt&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let F=Math.max(0,i.syncOffset(e));L-=(L-F)%wt,L<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));let R=0;for(let P=F;P<L;P+=wt)if(e[P]===71){let H=!!(e[P+1]&64),V=Qh(e,P),N=(e[P+3]&48)>>4,j;if(N>1){if(j=P+5+e[P+4],j===P+wt)continue}else j=P+4;switch(V){case c:H&&(u&&(n=sn(u))&&this.parseAVCPES(a,d,n,!1),u={data:[],size:0}),u&&(u.data.push(e.subarray(j,P+wt)),u.size+=P+wt-j);break;case h:if(H){if(g&&(n=sn(g)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break}g={data:[],size:0}}g&&(g.data.push(e.subarray(j,P+wt)),g.size+=P+wt-j);break;case f:H&&(E&&(n=sn(E))&&this.parseID3PES(l,n),E={data:[],size:0}),E&&(E.data.push(e.subarray(j,P+wt)),E.size+=P+wt-j);break;case 0:H&&(j+=e[j]+1),k=this._pmtId=K1(e,j);break;case k:{H&&(j+=e[j]+1);let Y=q1(e,j,this.typeSupported,r);c=Y.avc,c>0&&(a.pid=c),h=Y.audio,h>0&&(o.pid=h,o.segmentCodec=Y.segmentCodec),f=Y.id3,f>0&&(l.pid=f),T!==null&&!S&&(M.warn(`MPEG-TS PMT found at ${P} after unknown PID '${T}'. Backtracking to sync byte @${F} to parse all TS packets.`),T=null,P=F-188),S=this.pmtParsed=!0;break}case 17:case 8191:break;default:T=V;break}}else R++;if(R>0){let P=new Error(`Found ${R} TS packet/s that do not start with 0x47`);this.observer.emit(b.ERROR,b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,error:P,reason:P.message})}a.pesData=u,o.pesData=g,l.pesData=E;let B={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples(B),B}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){let{audioTrack:t,videoTrack:r,id3Track:s,textTrack:n}=e,a=r.pesData,o=t.pesData,l=s.pesData,d;if(a&&(d=sn(a))?(this.parseAVCPES(r,n,d,!0),r.pesData=null):r.pesData=a,o&&(d=sn(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break}t.pesData=null}else o!=null&&o.size&&M.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=sn(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){let s=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new zh(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(r=>{let{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAVCPES(e,t,r,s){let n=this.parseAVCNALu(e,r.data),a=this.avcSample,o,l=!1;r.data=null,a&&n.length&&!e.audFound&&(oa(a,e),a=this.avcSample=Wl(!1,r.pts,r.dts,"")),n.forEach(d=>{var c;switch(d.type){case 1:{let h=!1;o=!0;let f=d.data;if(l&&f.length>4){let g=new nd(f).readSliceType();(g===2||g===4||g===7||g===9)&&(h=!0)}if(h){var u;(u=a)!=null&&u.frame&&!a.key&&(oa(a,e),a=this.avcSample=null)}a||(a=this.avcSample=Wl(!0,r.pts,r.dts,"")),a.frame=!0,a.key=h;break}case 5:o=!0,(c=a)!=null&&c.frame&&!a.key&&(oa(a,e),a=this.avcSample=null),a||(a=this.avcSample=Wl(!0,r.pts,r.dts,"")),a.key=!0,a.frame=!0;break;case 6:{o=!0,Bv(d.data,1,r.pts,t.samples);break}case 7:if(o=!0,l=!0,!e.sps){let h=d.data,g=new nd(h).readSPS();e.width=g.width,e.height=g.height,e.pixelRatio=g.pixelRatio,e.sps=[h],e.duration=this._duration;let E=h.subarray(1,4),T="avc1.";for(let S=0;S<3;S++){let k=E[S].toString(16);k.length<2&&(k="0"+k),T+=k}e.codec=T}break;case 8:o=!0,e.pps||(e.pps=[d.data]);break;case 9:o=!1,e.audFound=!0,a&&oa(a,e),a=this.avcSample=Wl(!1,r.pts,r.dts,"");break;case 12:o=!0;break;default:o=!1,a&&(a.debug+="unknown NAL "+d.type+" ");break}a&&o&&a.units.push(d)}),s&&a&&(oa(a,e),this.avcSample=null)}getLastNalUnit(e){var t;let r=this.avcSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){let n=r.units;s=n[n.length-1]}return s}parseAVCNALu(e,t){let r=t.byteLength,s=e.naluState||0,n=s,a=[],o=0,l,d,c,u=-1,h=0;for(s===-1&&(u=0,h=t[0]&31,s=0,o=1);o<r;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(u>=0){let f={data:t.subarray(u,o-s-1),type:h};a.push(f)}else{let f=this.getLastNalUnit(e.samples);if(f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d=o-s-1,d>0)){let g=new Uint8Array(f.data.byteLength+d);g.set(f.data,0),g.set(t.subarray(0,d),f.data.byteLength),f.data=g,f.state=0}}o<r?(c=t[o]&31,u=o,h=c,s=0):s=-1}else s=0}if(u>=0&&s>=0){let f={data:t.subarray(u,r),type:h,state:s};a.push(f)}if(a.length===0){let f=this.getLastNalUnit(e.samples);if(f){let g=new Uint8Array(f.data.byteLength+t.byteLength);g.set(f.data,0),g.set(t,f.data.byteLength),f.data=g}}return e.naluState=s,a}parseAACPES(e,t){let r=0,s=this.aacOverFlow,n=t.data;if(s){this.aacOverFlow=null;let u=s.missing,h=s.sample.unit.byteLength;if(u===-1){let f=new Uint8Array(h+n.byteLength);f.set(s.sample.unit,0),f.set(n,h),n=f}else{let f=h-u;s.sample.unit.set(n.subarray(0,u),f),e.samples.push(s.sample),r=s.missing}}let a,o;for(a=r,o=n.length;a<o-1&&!sd(n,a);a++);if(a!==r){let u,h=a<o-1;h?u=`AAC PES did not start with ADTS header,offset:${a}`:u="No ADTS header found in AAC PES";let f=new Error(u);if(M.warn(`parsing error: ${u}`),this.observer.emit(b.ERROR,b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,levelRetry:h,error:f,reason:u}),!h)return}Jv(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let u=eE(e.samplerate);l=s.sample.pts+u}else{M.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,c;for(;a<o;)if(c=tE(e,n,a,l,d),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(d++;a<o-1&&!sd(n,a);a++);}parseMPEGPES(e,t){let r=t.data,s=r.length,n=0,a=0,o=t.pts;if(o===void 0){M.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(sE(r,a)){let l=iE(e,r,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseID3PES(e,t){if(t.pts===void 0){M.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let r=ft({},t,{type:this._avcTrack?_i.emsg:_i.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}};function Wl(i,e,t,r){return{key:i,frame:!1,pts:e,dts:t,units:[],debug:r,length:0}}function Qh(i,e){return((i[e+1]&31)<<8)+i[e+2]}function K1(i,e){return(i[e+10]&31)<<8|i[e+11]}function q1(i,e,t,r){let s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=(i[e+1]&15)<<8|i[e+2],a=e+3+n-4,o=(i[e+10]&15)<<8|i[e+11];for(e+=12+o;e<a;){let l=Qh(i,e);switch(i[e]){case 207:if(!r){M.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:s.audio===-1&&(s.audio=l);break;case 21:s.id3===-1&&(s.id3=l);break;case 219:if(!r){M.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:s.avc===-1&&(s.avc=l);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?M.log("MPEG audio found, not supported in this browser"):s.audio===-1&&(s.audio=l,s.segmentCodec="mp3");break;case 36:M.warn("Unsupported HEVC stream type found");break}e+=((i[e+3]&15)<<8|i[e+4])+5}return s}function sn(i){let e=0,t,r,s,n,a,o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;){let d=new Uint8Array(o[0].length+o[1].length);d.set(o[0]),d.set(o[1],o[0].length),o[0]=d,o.splice(1,1)}if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>i.size-6)return null;let d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(M.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let c=s+9;if(i.size<=c)return null;i.size-=c;let u=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let g=t.byteLength;if(c)if(c>g){c-=g;continue}else t=t.subarray(c),g-=c,c=0;u.set(t,e),e+=g}return r&&(r-=s+3),{data:u,pts:n,dts:a,len:r}}return null}function oa(i,e){if(i.units.length&&i.frame){if(i.pts===void 0){let t=e.samples,r=t.length;if(r){let s=t[r-1];i.pts=s.pts,i.dts=s.dts}else{e.dropped++;return}}e.samples.push(i)}i.debug.length&&M.log(i.pts+"/"+i.dts+":"+i.debug)}var Zh=class extends rd{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let r=(Ql(e,0)||[]).length;for(let s=e.length;r<s;r++)if(W1(e,r))return M.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return V1(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return iE(e,t,r,this.basePTS,this.frameIndex)}},ad=class{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}},vr=Math.pow(2,32)-1,ht=class i{static init(){i.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in i.types)i.types.hasOwnProperty(e)&&(i.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=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]);i.HDLR_TYPES={video:t,audio:r};let s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);i.STTS=i.STSC=i.STCO=n,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);i.FTYP=i.box(i.types.ftyp,a,l,a,o),i.DINF=i.box(i.types.dinf,i.box(i.types.dref,s))}static box(e,...t){let r=8,s=t.length,n=s;for(;s--;)r+=t[s].byteLength;let a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=r&255,a.set(e,4),s=0,r=8;s<n;s++)a.set(t[s],r),r+=t[s].byteLength;return a}static hdlr(e){return i.box(i.types.hdlr,i.HDLR_TYPES[e])}static mdat(e){return i.box(i.types.mdat,e)}static mdhd(e,t){t*=e;let r=Math.floor(t/(vr+1)),s=Math.floor(t%(vr+1));return i.box(i.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return i.box(i.types.mdia,i.mdhd(e.timescale,e.duration),i.hdlr(e.type),i.minf(e))}static mfhd(e){return i.box(i.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?i.box(i.types.minf,i.box(i.types.smhd,i.SMHD),i.DINF,i.stbl(e)):i.box(i.types.minf,i.box(i.types.vmhd,i.VMHD),i.DINF,i.stbl(e))}static moof(e,t,r){return i.box(i.types.moof,i.mfhd(e),i.traf(r,t))}static moov(e){let t=e.length,r=[];for(;t--;)r[t]=i.trak(e[t]);return i.box.apply(null,[i.types.moov,i.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(i.mvex(e)))}static mvex(e){let t=e.length,r=[];for(;t--;)r[t]=i.trex(e[t]);return i.box.apply(null,[i.types.mvex,...r])}static mvhd(e,t){t*=e;let r=Math.floor(t/(vr+1)),s=Math.floor(t%(vr+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return i.box(i.types.mvhd,n)}static sdtp(e){let t=e.samples||[],r=new Uint8Array(4+t.length),s,n;for(s=0;s<t.length;s++)n=t[s].flags,r[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return i.box(i.types.sdtp,r)}static stbl(e){return i.box(i.types.stbl,i.stsd(e),i.box(i.types.stts,i.STTS),i.box(i.types.stsc,i.STSC),i.box(i.types.stsz,i.STSZ),i.box(i.types.stco,i.STCO))}static avc1(e){let t=[],r=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,r.push(a>>>8&255),r.push(a&255),r=r.concat(Array.prototype.slice.call(n));let o=i.box(i.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,d=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return i.box(i.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,i.box(i.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),i.box(i.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,u>>24,u>>16&255,u>>8&255,u&255])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){let t=e.samplerate;return i.box(i.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]),i.box(i.types.esds,i.esds(e)))}static mp3(e){let t=e.samplerate;return i.box(i.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?i.box(i.types.stsd,i.STSD,i.mp3(e)):i.box(i.types.stsd,i.STSD,i.mp4a(e)):i.box(i.types.stsd,i.STSD,i.avc1(e))}static tkhd(e){let t=e.id,r=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(r/(vr+1)),o=Math.floor(r%(vr+1));return i.box(i.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let r=i.sdtp(e),s=e.id,n=Math.floor(t/(vr+1)),a=Math.floor(t%(vr+1));return i.box(i.types.traf,i.box(i.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),i.box(i.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),i.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,i.box(i.types.trak,i.tkhd(e),i.mdia(e))}static trex(e){let t=e.id;return i.box(i.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let r=e.samples||[],s=r.length,n=12+16*s,a=new Uint8Array(n),o,l,d,c,u,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=r[o],d=l.duration,c=l.size,u=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,u.degradPrio&61440,u.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return i.box(i.types.trun,a)}static initSegment(e){i.types||i.init();let t=i.moov(e),r=new Uint8Array(i.FTYP.byteLength+t.byteLength);return r.set(i.FTYP),r.set(t,i.FTYP.byteLength),r}};ht.types=void 0;ht.HDLR_TYPES=void 0;ht.STTS=void 0;ht.STSC=void 0;ht.STCO=void 0;ht.STSZ=void 0;ht.VMHD=void 0;ht.SMHD=void 0;ht.STSD=void 0;ht.FTYP=void 0;ht.DINF=void 0;var nE=9e4;function Nf(i,e,t=1,r=!1){let s=i*e*t;return r?Math.round(s):s}function Y1(i,e,t=1,r=!1){return Nf(i,e,1/t,r)}function la(i,e=!1){return Nf(i,1e3,1/nE,e)}function j1(i,e=1){return Nf(i,nE,1/e)}var z1=10*1e3,fv=1024,X1=1152,Kl=null,mh=null,ha=class{constructor(e,t,r,s=""){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,Kl===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Kl=a?parseInt(a[1]):0}if(mh===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);mh=n?parseInt(n[1]):0}}destroy(){}resetTimeStamp(e){M.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){M.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){M.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let t=!1,r=e.reduce((s,n)=>{let a=n.pts-s;return a<-4294967296?(t=!0,ai(s,n.pts)):a>0?s:n.pts},e[0].pts);return t&&M.debug("PTS rollover detected"),r}remux(e,t,r,s,n,a,o,l){let d,c,u,h,f,g,E=n,T=n,S=e.pid>-1,k=t.pid>-1,L=t.samples.length,F=e.samples.length>0,R=o&&L>0||L>1;if((!S||F)&&(!k||R)||this.ISGenerated||o){this.ISGenerated||(u=this.generateIS(e,t,n,a));let P=this.isVideoContiguous,H=-1,V;if(R&&(H=Q1(t.samples),!P&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,H>0){M.warn(`[mp4-remuxer]: Dropped ${H} out of ${L} video samples due to a missing keyframe`);let N=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(H),t.dropped+=H,T+=(t.samples[0].pts-N)/t.inputTimeScale,V=T}else H===-1&&(M.warn(`[mp4-remuxer]: No keyframe found out of ${L} video samples`),g=!1);if(this.ISGenerated){if(F&&R){let N=this.getVideoStartPts(t.samples),Y=(ai(e.samples[0].pts,N)-N)/t.inputTimeScale;E+=Math.max(0,Y),T+=Math.max(0,-Y)}if(F){if(e.samplerate||(M.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(e,t,n,a)),c=this.remuxAudio(e,E,this.isAudioContiguous,a,k||R||l===he.AUDIO?T:void 0),R){let N=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(M.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,T,P,N)}}else R&&(d=this.remuxVideo(t,T,P,0));d&&(d.firstKeyFrame=H,d.independent=H!==-1,d.firstKeyFramePTS=V)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=aE(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=oE(s,n,this._initPTS))),{audio:c,video:d,initSegment:u,independent:g,text:h,id3:f}}generateIS(e,t,r,s){let n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,c=!d||s,u="audio/mp4",h,f,g;if(c&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(u="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break}l.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):ht.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(g=e.inputTimeScale,!d||g!==d.timescale?h=f=n[0].pts-Math.round(g*r):c=!1)}if(t.sps&&t.pps&&a.length&&(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:ht.initSegment([t]),metadata:{width:t.width,height:t.height}},c))if(g=t.inputTimeScale,!d||g!==d.timescale){let E=this.getVideoStartPts(a),T=Math.round(g*r);f=Math.min(f,ai(a[0].dts,E)-T),h=Math.min(h,E-T)}else c=!1;if(Object.keys(l).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:h,timescale:g},this._initDTS={baseTime:f,timescale:g}):h=g=void 0,{tracks:l,initPTS:h,timescale:g}}remuxVideo(e,t,r,s){let n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS,c=this.nextAvcDts,u=8,h=this.videoSampleDuration,f,g,E=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,S=!1;if(!r||c===null){let Z=t*n,te=a[0].pts-ai(a[0].dts,a[0].pts);c=Z-te}let k=d.baseTime*n/d.timescale;for(let Z=0;Z<l;Z++){let te=a[Z];te.pts=ai(te.pts-k,c),te.dts=ai(te.dts-k,c),te.dts<a[Z>0?Z-1:Z].dts&&(S=!0)}S&&a.sort(function(Z,te){let re=Z.dts-te.dts,Le=Z.pts-te.pts;return re||Le}),f=a[0].dts,g=a[a.length-1].dts;let L=g-f,F=L?Math.round(L/(l-1)):h||e.inputTimeScale/30;if(r){let Z=f-c,te=Z>F,re=Z<-1;if((te||re)&&(te?M.warn(`AVC: ${la(Z,!0)} ms (${Z}dts) hole between fragments detected, filling it`):M.warn(`AVC: ${la(-Z,!0)} ms (${Z}dts) overlapping between fragments detected`),!re||c>=a[0].pts)){f=c;let Le=a[0].pts-Z;a[0].dts=f,a[0].pts=Le,M.log(`Video: First PTS/DTS adjusted: ${la(Le,!0)}/${la(f,!0)}, delta: ${la(Z,!0)} ms`)}}f=Math.max(0,f);let R=0,B=0;for(let Z=0;Z<l;Z++){let te=a[Z],re=te.units,Le=re.length,Re=0;for(let Qe=0;Qe<Le;Qe++)Re+=re[Qe].data.length;B+=Re,R+=Le,te.length=Re,te.dts=Math.max(te.dts,f),E=Math.min(te.pts,E),T=Math.max(te.pts,T)}g=a[l-1].dts;let P=B+4*R+8,H;try{H=new Uint8Array(P)}catch(Z){this.observer.emit(b.ERROR,b.ERROR,{type:ue.MUX_ERROR,details:$.REMUX_ALLOC_ERROR,fatal:!1,error:Z,bytes:P,reason:`fail allocating video mdat ${P}`});return}let V=new DataView(H.buffer);V.setUint32(0,P),H.set(ht.types.mdat,4);let N=!1,j=Number.POSITIVE_INFINITY,Y=Number.POSITIVE_INFINITY,Ee=Number.NEGATIVE_INFINITY,ge=Number.NEGATIVE_INFINITY;for(let Z=0;Z<l;Z++){let te=a[Z],re=te.units,Le=0;for(let Bt=0,$t=re.length;Bt<$t;Bt++){let Mt=re[Bt],ji=Mt.data,Tn=Mt.data.byteLength;V.setUint32(u,Tn),u+=4,H.set(ji,u),u+=Tn,Le+=4+Tn}let Re;if(Z<l-1)h=a[Z+1].dts-te.dts,Re=a[Z+1].pts-te.pts;else{let Bt=this.config,$t=Z>0?te.dts-a[Z-1].dts:F;if(Re=Z>0?te.pts-a[Z-1].pts:F,Bt.stretchShortVideoTrack&&this.nextAudioPts!==null){let Mt=Math.floor(Bt.maxBufferHole*n),ji=(s?E+s*n:this.nextAudioPts)-te.pts;ji>Mt?(h=ji-$t,h<0?h=$t:N=!0,M.log(`[mp4-remuxer]: It is approximately ${ji/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=$t}else h=$t}let Qe=Math.round(te.pts-te.dts);j=Math.min(j,h),Ee=Math.max(Ee,h),Y=Math.min(Y,Re),ge=Math.max(ge,Re),o.push(new od(te.key,h,Le,Qe))}if(o.length){if(Kl){if(Kl<70){let Z=o[0].flags;Z.dependsOn=2,Z.isNonSync=0}}else if(mh&&ge-Y<Ee-j&&F/Ee<.025&&o[0].cts===0){M.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let Z=f;for(let te=0,re=o.length;te<re;te++){let Le=Z+o[te].duration,Re=Z+o[te].cts;if(te<re-1){let Qe=Le+o[te+1].cts;o[te].duration=Qe-Re}else o[te].duration=te?o[te-1].duration:F;o[te].cts=0,Z=Le}}}h=N||!h?F:h,this.nextAvcDts=c=g+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let ye=ht.moof(e.sequenceNumber++,f,ft({},e,{samples:o})),we="video",Ie={data1:ye,data2:H,startPTS:E/n,endPTS:(T+h)/n,startDTS:f/n,endDTS:c/n,type:we,hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Ie}remuxAudio(e,t,r,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=e.segmentCodec==="aac"?fv:X1,c=d*l,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],g=n!==void 0,E=e.samples,T=h?0:8,S=this.nextAudioPts||-1,k=t*a,L=u.baseTime*a/u.timescale;if(this.isAudioContiguous=r=r||E.length&&S>0&&(s&&Math.abs(k-S)<9e3||Math.abs(ai(E[0].pts-L,k)-S)<20*c),E.forEach(function(we){we.pts=ai(we.pts-L,k)}),!r||S<0){if(E=E.filter(we=>we.pts>=0),!E.length)return;n===0?S=0:s&&!g?S=Math.max(0,k):S=E[0].pts}if(e.segmentCodec==="aac"){let we=this.config.maxAudioFramesDrift;for(let Ie=0,Z=S;Ie<E.length;Ie++){let te=E[Ie],re=te.pts,Le=re-Z,Re=Math.abs(1e3*Le/a);if(Le<=-we*c&&g)Ie===0&&(M.warn(`Audio frame @ ${(re/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*Le/a)} ms.`),this.nextAudioPts=S=Z=re);else if(Le>=we*c&&Re<z1&&g){let Qe=Math.round(Le/c);Z=re-Qe*c,Z<0&&(Qe--,Z+=c),Ie===0&&(this.nextAudioPts=S=Z),M.warn(`[mp4-remuxer]: Injecting ${Qe} audio frame @ ${(Z/a).toFixed(3)}s due to ${Math.round(1e3*Le/a)} ms gap.`);for(let Bt=0;Bt<Qe;Bt++){let $t=Math.max(Z,0),Mt=ad.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Mt||(M.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Mt=te.unit.subarray()),E.splice(Ie,0,{unit:Mt,pts:$t}),Z+=c,Ie++}}te.pts=Z,Z+=c}}let F=null,R=null,B,P=0,H=E.length;for(;H--;)P+=E[H].unit.byteLength;for(let we=0,Ie=E.length;we<Ie;we++){let Z=E[we],te=Z.unit,re=Z.pts;if(R!==null){let Re=f[we-1];Re.duration=Math.round((re-R)/l)}else if(r&&e.segmentCodec==="aac"&&(re=S),F=re,P>0){P+=T;try{B=new Uint8Array(P)}catch(Re){this.observer.emit(b.ERROR,b.ERROR,{type:ue.MUX_ERROR,details:$.REMUX_ALLOC_ERROR,fatal:!1,error:Re,bytes:P,reason:`fail allocating audio mdat ${P}`});return}h||(new DataView(B.buffer).setUint32(0,P),B.set(ht.types.mdat,4))}else return;B.set(te,T);let Le=te.byteLength;T+=Le,f.push(new od(!0,d,Le,0)),R=re}let V=f.length;if(!V)return;let N=f[f.length-1];this.nextAudioPts=S=R+l*N.duration;let j=h?new Uint8Array(0):ht.moof(e.sequenceNumber++,F/l,ft({},e,{samples:f}));e.samples=[];let Y=F/a,Ee=S/a,ye={data1:j,data2:B,startPTS:Y,endPTS:Ee,startDTS:Y,endDTS:Ee,type:"audio",hasAudio:!0,hasVideo:!1,nb:V};return this.isAudioContiguous=!0,ye}remuxEmptyAudio(e,t,r,s){let n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,c=d.baseTime*9e4/d.timescale,u=(l!==null?l:s.startDTS*n)+c,h=s.endDTS*n+c,f=o*fv,g=Math.ceil((h-u)/f),E=ad.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(M.warn("[mp4-remuxer]: remux empty Audio"),!E){M.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let T=[];for(let S=0;S<g;S++){let k=u+S*f;T.push({unit:E,pts:k,dts:k})}return e.samples=T,this.remuxAudio(e,t,r,!1)}};function ai(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function Q1(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function aE(i,e,t,r){let s=i.samples.length;if(!s)return;let n=i.inputTimeScale;for(let o=0;o<s;o++){let l=i.samples[o];l.pts=ai(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=ai(l.dts-r.baseTime*n/r.timescale,e*n)/n}let a=i.samples;return i.samples=[],{samples:a}}function oE(i,e,t){let r=i.samples.length;if(!r)return;let s=i.inputTimeScale;for(let a=0;a<r;a++){let o=i.samples[a];o.pts=ai(o.pts-t.baseTime*s/t.timescale,e*s)/s}i.samples.sort((a,o)=>a.pts-o.pts);let n=i.samples;return i.samples=[],{samples:n}}var od=class{constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags=new Jh(e)}},Jh=class{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}},ef=class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(OA(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let s=this.initData=Uv(e);t||(t=mv(s.audio,Ve.AUDIO)),r||(r=mv(s.video,Ve.VIDEO));let n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:M.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,s,n,a){var o,l;let{initPTS:d,lastEndTime:c}=this,u={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};oe(c)||(c=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return u;let f={initPTS:void 0,timescale:1},g=this.initData;if((o=g)!=null&&o.length||(this.generateInitSegment(h),g=this.initData),!((l=g)!=null&&l.length))return M.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);let E=UA(h,g),T=NA(g,h),S=T===null?n:T;(Z1(d,S,n,E)||f.timescale!==d.timescale&&a)&&(f.initPTS=S-n,d&&d.timescale===1&&M.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});let k=e?S-d.baseTime/d.timescale:c,L=k+E;BA(g,h,d.baseTime/d.timescale),E>0?this.lastEndTime=L:(M.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let F=!!g.audio,R=!!g.video,B="";F&&(B+="audio"),R&&(B+="video");let P={data1:h,startPTS:k,startDTS:k,endPTS:L,endDTS:L,type:B,hasAudio:F,hasVideo:R,nb:1,dropped:0};return u.audio=P.type==="audio"?P:void 0,u.video=P.type!=="audio"?P:void 0,u.initSegment=f,u.id3=aE(r,n,d,d),s.samples.length&&(u.text=oE(s,n,d)),u}};function Z1(i,e,t,r){if(i===null)return!0;let s=Math.max(r,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>s}function mv(i,e){let t=i==null?void 0:i.codec;return t&&t.length>4?t:t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":t==="avc1"||e===Ve.VIDEO?"avc1.42e01e":"mp4a.40.5"}var Ji;try{Ji=self.performance.now.bind(self.performance)}catch{M.debug("Unable to use Performance API on this environment"),Ji=typeof self!="undefined"&&self.Date.now}var ph=[{demux:jh,remux:ef},{demux:Xh,remux:ha},{demux:Yh,remux:ha},{demux:Zh,remux:ha}],ld=class{constructor(e,t,r,s,n){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=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){let n=r.transmuxing;n.executeStart=Ji();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);let{contiguous:d,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:g}=s||o,{audioCodec:E,videoCodec:T,defaultInitPts:S,duration:k,initSegmentData:L}=l,F=J1(a,t);if(F&&F.method==="AES-128"){let H=this.getDecrypter();if(H.isSync()){let V=H.softwareDecrypt(a,F.key.buffer,F.iv.buffer);if(r.part>-1&&(V=H.flush()),!V)return n.executeEnd=Ji(),gh(r);a=new Uint8Array(V)}else return this.decryptionPromise=H.webCryptoDecrypt(a,F.key.buffer,F.iv.buffer).then(V=>{let N=this.push(V,null,r);return this.decryptionPromise=null,N}),this.decryptionPromise}let R=this.needsProbing(c,u);if(R){let H=this.configureTransmuxer(a);if(H)return M.warn(`[transmuxer] ${H.message}`),this.observer.emit(b.ERROR,b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,error:H,reason:H.message}),n.executeEnd=Ji(),gh(r)}(c||u||g||R)&&this.resetInitSegment(L,E,T,k,t),(c||g||R)&&this.resetInitialTimestamp(S),d||this.resetContiguity();let B=this.transmux(a,F,f,h,r),P=this.currentTransmuxState;return P.contiguous=!0,P.discontinuity=!1,P.trackSwitch=!1,n.executeEnd=Ji(),B}flush(e){let t=e.transmuxing;t.executeStart=Ji();let{decrypter:r,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(r){let u=r.flush();u&&a.push(this.push(u,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=Ji(),[gh(e)];let c=l.flush(o);return jl(c)?c.then(u=>(this.flushRemux(a,u,e),a)):(this.flushRemux(a,c,e),a)}flushRemux(e,t,r){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;M.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);let c=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=Ji()}resetInitialTimestamp(e){let{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,r,s),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,r,s,n):a=this.transmuxUnencrypted(e,r,s,n),a}transmuxUnencrypted(e,t,r,s){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,n){return this.demuxer.demuxSampleAes(e,t,r).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,r,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:r,typeSupported:s,vendor:n}=this,a;for(let u=0,h=ph.length;u<h;u++)if(ph[u].demux.probe(e)){a=ph[u];break}if(!a)return new Error("Failed to find demuxer by probing fragment data");let o=this.demuxer,l=this.remuxer,d=a.remux,c=a.demux;(!l||!(l instanceof d))&&(this.remuxer=new d(r,t,s,n)),(!o||!(o instanceof c))&&(this.demuxer=new c(r,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Ea(this.config)),e}};function J1(i,e){let t=null;return i.byteLength>0&&e!=null&&e.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var gh=i=>({remuxResult:{},chunkMeta:i});function jl(i){return"then"in i&&i.then instanceof Function}var tf=class{constructor(e,t,r,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=n||null}},rf=class{constructor(e,t,r,s,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}},lE={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,d,c){this.fn=l,this.context=d,this.once=c||!1}function n(l,d,c,u,h){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,u||l,h),g=t?t+d:d;return l._events[g]?l._events[g].fn?l._events[g]=[l._events[g],f]:l._events[g].push(f):(l._events[g]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new r:delete l._events[d]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],c,u;if(this._eventsCount===0)return d;for(u in c=this._events)e.call(c,u)&&d.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},o.prototype.listeners=function(d){var c=t?t+d:d,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,g=new Array(f);h<f;h++)g[h]=u[h].fn;return g},o.prototype.listenerCount=function(d){var c=t?t+d:d,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(d,c,u,h,f,g){var E=t?t+d:d;if(!this._events[E])return!1;var T=this._events[E],S=arguments.length,k,L;if(T.fn){switch(T.once&&this.removeListener(d,T.fn,void 0,!0),S){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,c),!0;case 3:return T.fn.call(T.context,c,u),!0;case 4:return T.fn.call(T.context,c,u,h),!0;case 5:return T.fn.call(T.context,c,u,h,f),!0;case 6:return T.fn.call(T.context,c,u,h,f,g),!0}for(L=1,k=new Array(S-1);L<S;L++)k[L-1]=arguments[L];T.fn.apply(T.context,k)}else{var F=T.length,R;for(L=0;L<F;L++)switch(T[L].once&&this.removeListener(d,T[L].fn,void 0,!0),S){case 1:T[L].fn.call(T[L].context);break;case 2:T[L].fn.call(T[L].context,c);break;case 3:T[L].fn.call(T[L].context,c,u);break;case 4:T[L].fn.call(T[L].context,c,u,h);break;default:if(!k)for(R=1,k=new Array(S-1);R<S;R++)k[R-1]=arguments[R];T[L].fn.apply(T[L].context,k)}}return!0},o.prototype.on=function(d,c,u){return n(this,d,c,u,!1)},o.prototype.once=function(d,c,u){return n(this,d,c,u,!0)},o.prototype.removeListener=function(d,c,u,h){var f=t?t+d:d;if(!this._events[f])return this;if(!c)return a(this,f),this;var g=this._events[f];if(g.fn)g.fn===c&&(!h||g.once)&&(!u||g.context===u)&&a(this,f);else{for(var E=0,T=[],S=g.length;E<S;E++)(g[E].fn!==c||h&&!g[E].once||u&&g[E].context!==u)&&T.push(g[E]);T.length?this._events[f]=T.length===1?T[0]:T:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var c;return d?(c=t?t+d:d,this._events[c]&&a(this,c)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(lE);var eS=lE.exports,Uf=nA(eS),vh=Ed()||{isTypeSupported:()=>!1},dd=class{constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;let a=(d,c)=>{c=c||{},c.frag=this.frag,c.id=this.id,d===b.ERROR&&(this.error=c.error),this.hls.trigger(d,c)};this.observer=new Uf,this.observer.on(b.FRAG_DECRYPTED,a),this.observer.on(b.ERROR,a);let o={mp4:vh.isTypeSupported("video/mp4"),mpeg:vh.isTypeSupported("audio/mpeg"),mp3:vh.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||k1())){try{n.workerPath?(M.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=D1(n.workerPath)):(M.log(`injecting Web Worker for "${t}"`),this.workerContext=w1()),this.onwmsg=u=>this.onWorkerMessage(u);let{worker:c}=this.workerContext;c.addEventListener("message",this.onwmsg),c.onerror=u=>{let h=new Error(`${u.message} (${u.filename}:${u.lineno})`);n.enableWorker=!1,M.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(b.ERROR,{type:ue.OTHER_ERROR,details:$.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},c.postMessage({cmd:"init",typeSupported:o,vendor:l,id:t,config:JSON.stringify(n)})}catch(c){M.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.resetWorker(),this.error=null,this.transmuxer=new ld(this.observer,o,n,l,t)}return}this.transmuxer=new ld(this.observer,o,n,l,t)}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,n,a,o,l,d,c){var u,h;d.transmuxing.start=self.performance.now();let{transmuxer:f}=this,g=a?a.start:n.start,E=n.decryptdata,T=this.frag,S=!(T&&n.cc===T.cc),k=!(T&&d.level===T.level),L=T?d.sn-T.sn:-1,F=this.part?d.part-this.part.index:-1,R=L===0&&d.id>1&&d.id===(T==null?void 0:T.stats.chunkCount),B=!k&&(L===1||L===0&&(F===1||R&&F<=0)),P=self.performance.now();(k||L||n.stats.parsing.start===0)&&(n.stats.parsing.start=P),a&&(F||!B)&&(a.stats.parsing.start=P);let H=!(T&&((u=n.initSegment)==null?void 0:u.url)===((h=T.initSegment)==null?void 0:h.url)),V=new rf(S,B,l,k,g,H);if(!B||S||H){M.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
1132
+ discontinuity: ${S}
1058
1133
  trackSwitch: ${k}
1059
1134
  contiguous: ${B}
1060
1135
  accurateTimeOffset: ${l}
1061
1136
  timeOffset: ${g}
1062
- initSegmentChange: ${G}`);let N=new Yh(r,s,t,o,c);this.configureTransmuxer(N)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:E,chunkMeta:d,state:K},e instanceof ArrayBuffer?[e]:[]);else if(f){let N=f.push(e,E,d,K);Gl(N)?(f.async=!0,N.then(j=>{this.handleTransmuxComplete(j)}).catch(j=>{this.transmuxerError(j,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(N))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);Gl(r)||t.async?(Gl(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data,r=this.hls;switch(t.event){case"init":{var s;let n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":M[t.data.logType]&&M[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);break}}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}},U1=250,ch=2,F1=.1,B1=.05,zh=class{constructor(e,t,r,s){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=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:r,media:s,stalled:n}=this;if(s===null)return;let{currentTime:a,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,n!==null){if(this.stallReported){let A=self.performance.now()-n;M.warn(`playback not stuck anymore @${a}, after ${Math.round(A)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!Xe.getBuffered(s).length)return;let c=Xe.bufferInfo(s,a,0),u=c.len>0,h=c.nextStart||0;if(!u&&!h)return;if(o){let A=c.len>ch,k=!h||t&&t.start<=a||h-a>ch&&!this.fragmentTracker.getPartialFragment(a);if(A||k)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f;let A=Math.max(h,c.start||0)-a,k=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,F=(k==null||(f=k.details)==null?void 0:f.live)?k.details.targetduration*2:ch,R=this.fragmentTracker.getPartialFragment(a);if(A>0&&(A<=F||R)){this._trySkipBufferHole(R);return}}let g=self.performance.now();if(n===null){this.stalled=g;return}let E=g-n;if(!o&&E>=U1&&(this._reportStall(c),!this.media))return;let T=Xe.bufferInfo(s,a,r.maxBufferHole);this._tryFixBufferStall(T,E)}_tryFixBufferStall(e,t){let{config:r,fragmentTracker:s,media:n}=this;if(n===null)return;let a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(M.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;let n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);M.warn(n.message),t.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:r,media:s}=this;if(s===null)return 0;let n=s.currentTime,a=Xe.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){let l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&s.readyState<3,c=o-n;if(c>0&&(l||d)){if(c>t.maxBufferHole){let{fragmentTracker:h}=this,f=!1;if(n===0){let g=h.getAppendedFrag(0,he.MAIN);g&&o<g.end&&(f=!0)}if(!f){let g=e||h.getAppendedFrag(n,he.MAIN);if(g){let E=!1,T=g.end;for(;T<o;){let A=h.getPartialFragment(T);if(A)T+=A.duration;else{E=!0;break}}if(E)return 0}}}let u=Math.max(o+B1,n+F1);if(M.warn(`skipping hole, adjusting currentTime from ${n} to ${u}`),this.moved=!0,this.stalled=null,s.currentTime=u,e&&!e.gap){let h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${u}`);r.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return u}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;let n=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){let a=n+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);M.warn(o.message),r.currentTime=a,t.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{let a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);M.error(a.message),t.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},$1=100,Xh=class extends ma{constructor(e,t,r){super(e,t,r,"[stream-controller]",he.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(b.ERROR,this.onError,this),e.on(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this),e.on(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(b.ERROR,this.onError,this),e.off(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this),e.off(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval($1),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.nextAutoLevel),this.level=r.nextLoadLevel=s,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=V.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=V.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case V.WAITING_LEVEL:{var e;let{levels:r,level:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=V.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=V.IDLE;break}break}case V.FRAG_LOADING_WAITING_RETRY:{var t;let r=self.performance.now(),s=this.retryDate;(!s||r>=s||(t=this.media)!=null&&t.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=V.IDLE)}break}this.state===V.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:r,media:s}=this,{config:n,nextLoadLevel:a}=e;if(t===null||!s&&(this.startFragRequested||!n.startFragPrefetch)||this.altAudio&&this.audioOnly||!(r!=null&&r[a]))return;let o=r[a],l=this.getMainFwdBufferInfo();if(l===null)return;let d=this.getLevelDetails();if(d&&this._streamEnded(l,d)){let T={};this.altAudio&&(T.type="video"),this.hls.trigger(b.BUFFER_EOS,T),this.state=V.ENDED;return}e.loadLevel!==a&&e.manualLevel===-1&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;let c=o.details;if(!c||this.state===V.WAITING_LEVEL||c.live&&this.levelLastLoaded!==a){this.level=a,this.state=V.WAITING_LEVEL;return}let u=l.len,h=this.getMaxBufferLength(o.maxBitrate);if(u>=h)return;this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);let f=this.backtrackFragment?this.backtrackFragment.start:l.end,g=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&g&&g.sn!=="initSegment"&&this.fragmentTracker.getState(g)!==Et.OK){var E;let A=((E=this.backtrackFragment)!=null?E:g).sn-c.startSN,k=c.fragments[A-1];k&&g.cc===k.cc&&(g=k,this.fragmentTracker.removeFragment(k))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,f)){if(!g.gap){let A=this.audioOnly&&!this.altAudio?Ve.AUDIO:Ve.VIDEO,k=(A===Ve.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;k&&this.afterBufferFlushed(k,A,he.MAIN)}g=this.getNextFragmentLoopLoading(g,c,l,he.MAIN,h)}g&&(g.initSegment&&!g.initSegment.data&&!this.bitrateTest&&(g=g.initSegment),this.loadFragment(g,o,f))}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===Et.NOT_LOADED||s===Et.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,he.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){let{levels:e,media:t}=this;if(t!=null&&t.readyState){let r,s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);let n=this.getLevelDetails();if(n!=null&&n.live){let o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){let o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:r=0}else r=0;let a=this.getBufferedFrag(t.currentTime+r);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,c=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*.5),d*.75));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case V.KEY_LOADING:case V.FRAG_LOADING:case V.FRAG_LOADING_WAITING_RETRY:case V.PARSING:case V.PARSED:this.state=V.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new zh(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;oe(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(b.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(e,t){let r=!1,s=!1,n;t.levels.forEach(a=>{n=a.audioCodec,n&&(n.indexOf("mp4a.40.2")!==-1&&(r=!0),n.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=r&&s&&!c1(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:r}=this;if(!r||this.state!==V.IDLE)return;let s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(s.details))&&(this.state=V.WAITING_LEVEL)}onLevelLoaded(e,t){var r;let{levels:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);let l=s[n],d=this.fragCurrent;d&&(this.state===V.FRAG_LOADING||this.state===V.FRAG_LOADING_WAITING_RETRY)&&(d.level!==t.level||d.urlId!==l.urlId)&&d.loader&&this.abortCurrentFrag();let c=0;if(a.live||(r=l.details)!=null&&r.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;c=this.alignPlaylists(a,l.details)}if(l.details=a,this.levelLastLoaded=n,this.hls.trigger(b.LEVEL_UPDATED,{details:a,level:n}),this.state===V.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=V.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,c),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let o=a[r.level],l=o.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}let d=o.videoCodec,c=l.PTSKnown||!l.live,u=(t=r.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new id(this.hls,he.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=s?s.index:-1,E=g!==-1,T=new ha(r.level,r.sn,r.stats.chunkCount,n.byteLength,g,E),A=this.initPTS[r.cc];f.push(n,u,h,d,r,s,l.totalduration,c,T,A)}onAudioTrackSwitching(e,t){let r=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let 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();let n=this.hls;r&&(n.trigger(b.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(b.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let r=t.id,s=!!this.hls.audioTracks[r].url;if(s){let n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(e,t){let r=t.tracks,s,n,a=!1;for(let o in r){let l=r[o];if(l.id==="main"){if(n=o,s=l,o==="video"){let d=r[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r&&r.type!==he.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===V.PARSED&&(this.state=V.IDLE);return}let n=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=V.ERROR;return}switch(t.details){case $.FRAG_GAP:case $.FRAG_PARSING_ERROR:case $.FRAG_DECRYPT_ERROR:case $.FRAG_LOAD_ERROR:case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_ERROR:case $.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(he.MAIN,t);break;case $.LEVEL_LOAD_ERROR:case $.LEVEL_LOAD_TIMEOUT:case $.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===V.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===Me.LEVEL&&(this.state=V.IDLE);break;case $.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case $.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){let{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Xe.getBuffered(e).length){let r=this.state!==V.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=V.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Ve.AUDIO||this.audioOnly&&!this.altAudio){let r=(t===Ve.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,he.MAIN)}}onLevelsUpdated(e,t){this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}let s=Xe.getBuffered(e),a=(s.length?s.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),r+=a,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{let{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=V.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;let n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(b.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let r="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:c}=o,{video:u,text:h,id3:f,initSegment:g}=n,{details:E}=c,T=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=V.PARSING,g){if(g!=null&&g.tracks){let L=l.initSegment||l;this._bufferInitSegment(c,g.tracks,L,a),s.trigger(b.FRAG_PARSING_INIT_SEGMENT,{frag:L,id:r,tracks:g.tracks})}let A=g.initPTS,k=g.timescale;oe(A)&&(this.initPTS[l.cc]={baseTime:A,timescale:k},s.trigger(b.INIT_PTS_FOUND,{frag:l,id:r,initPTS:A,timescale:k}))}if(u&&E&&l.sn!=="initSegment"){let A=E.fragments[l.sn-1-E.startSN],k=l.sn===E.startSN,L=!A||l.cc>A.cc;if(n.independent!==!1){let{startPTS:F,endPTS:R,startDTS:B,endDTS:P}=u;if(d)d.elementaryStreams[u.type]={startPTS:F,endPTS:R,startDTS:B,endDTS:P};else if(u.firstKeyFrame&&u.independent&&a.id===1&&!L&&(this.couldBacktrack=!0),u.dropped&&u.independent){let G=this.getMainFwdBufferInfo(),K=(G?G.end:this.getLoadPosition())+this.config.maxBufferHole,N=u.firstKeyFramePTS?u.firstKeyFramePTS:F;if(!k&&K<N-this.config.maxBufferHole&&!L){this.backtrack(l);return}else L&&(l.gap=!0);l.setElementaryStreamInfo(u.type,l.start,R,l.start,P,!0)}l.setElementaryStreamInfo(u.type,F,R,B,P),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(u,l,d,a,k||L)}else if(k||L)l.gap=!0;else{this.backtrack(l);return}}if(T){let{startPTS:A,endPTS:k,startDTS:L,endDTS:F}=T;d&&(d.elementaryStreams[Ve.AUDIO]={startPTS:A,endPTS:k,startDTS:L,endDTS:F}),l.setElementaryStreamInfo(Ve.AUDIO,A,k,L,F),this.bufferFragmentData(T,l,d,a)}if(E&&f!=null&&(t=f.samples)!=null&&t.length){let A={id:r,frag:l,details:E,samples:f.samples};s.trigger(b.FRAG_PARSING_METADATA,A)}if(E&&h){let A={id:r,frag:l,details:E,samples:h.samples};s.trigger(b.FRAG_PARSING_USERDATA,A)}}_bufferInitSegment(e,t,r,s){if(this.state!==V.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,d=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),n.metadata.channelCount!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")),d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.attrs.CODECS||""}/${o.codec}]`),this.hls.trigger(b.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let c=t[l].initSegment;c!=null&&c.byteLength&&this.hls.trigger(b.BUFFER_APPENDING,{type:l,data:c,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,he.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=V.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===!1){let r=e.currentTime;if(Xe.isBuffered(e,r)?t=this.getAppendedFrag(r):Xe.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;let s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n||t.urlId!==s.urlId)&&(this.fragPlaying=t,this.hls.trigger(b.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(b.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,r=this.currentFrag;if(r&&oe(t)&&oe(r.programDateTime)){let s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},vr=class{constructor(e,t=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}sample(e,t){let r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}},Qh=class{constructor(e,t,r,s=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 vr(e),this.fast_=new vr(t),this.defaultTTFB_=s,this.ttfb_=new vr(e)}update(e,t){let{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new vr(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new vr(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new vr(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);let r=8*t,s=e/1e3,n=r/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){let t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}},Zh=class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;let t=e.config;this.bwEstimator=new Qh(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(b.FRAG_LOADING,this.onFragLoading,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){let{hls:e}=this;e.off(b.FRAG_LOADING,this.onFragLoading,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var r;let s=t.frag;this.ignoreFragment(s)||(this.fragCurrent=s,this.partCurrent=(r=t.part)!=null?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,r,s){let n=e+r/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let r=this.hls.config,{total:s,bwEstimate:n}=t.stats;oe(s)&&oe(n)&&(this.lastLevelLoadSec=8*s/n),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}_abandonRulesCheck(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{autoLevelEnabled:s,media:n}=r;if(!e||!n)return;let a=performance.now(),o=t?t.stats:e.stats,l=t?t.duration:e.duration,d=a-o.loading.start;if(o.aborted||o.loaded&&o.loaded===o.total||e.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!s||n.paused||!n.playbackRate||!n.readyState)return;let c=r.mainForwardBufferInfo;if(c===null)return;let u=this.bwEstimator.getEstimateTTFB(),h=Math.abs(n.playbackRate);if(d<=Math.max(u,1e3*(l/(h*2))))return;let f=c.len/h;if(f>=2*l/h)return;let g=o.loading.first?o.loading.first-o.loading.start:-1,E=o.loaded&&g>-1,T=this.bwEstimator.getEstimate(),{levels:A,minAutoLevel:k}=r,L=A[e.level],F=o.total||Math.max(o.loaded,Math.round(l*L.maxBitrate/8)),R=d-g;R<1&&E&&(R=Math.min(d,o.loaded*8/T));let B=E?o.loaded*1e3/R:0,P=B?(F-o.loaded)/B:F*8/T+u/1e3;if(P<=f)return;let G=B?B*8:T,K=Number.POSITIVE_INFINITY,N;for(N=e.level-1;N>k;N--){let j=A[N].maxBitrate;if(K=this.getTimeToLoadFrag(u/1e3,G,l*j,!A[N].details),K<f)break}K>=P||K>l*10||(r.nextLoadLevel=N,E?this.bwEstimator.sample(d-Math.min(u,g),o.loaded):this.bwEstimator.sampleTTFB(d),this.clearTimer(),M.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;
1137
+ initSegmentChange: ${H}`);let N=new tf(r,s,t,o,c);this.configureTransmuxer(N)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:E,chunkMeta:d,state:V},e instanceof ArrayBuffer?[e]:[]);else if(f){let N=f.push(e,E,d,V);jl(N)?(f.async=!0,N.then(j=>{this.handleTransmuxComplete(j)}).catch(j=>{this.transmuxerError(j,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(N))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);jl(r)||t.async?(jl(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data,r=this.hls;switch(t.event){case"init":{var s;let n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":M[t.data.logType]&&M[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);break}}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}},tS=250,Eh=2,iS=.1,rS=.05,sf=class{constructor(e,t,r,s){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=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:r,media:s,stalled:n}=this;if(s===null)return;let{currentTime:a,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,n!==null){if(this.stallReported){let S=self.performance.now()-n;M.warn(`playback not stuck anymore @${a}, after ${Math.round(S)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!Xe.getBuffered(s).length)return;let c=Xe.bufferInfo(s,a,0),u=c.len>0,h=c.nextStart||0;if(!u&&!h)return;if(o){let S=c.len>Eh,k=!h||t&&t.start<=a||h-a>Eh&&!this.fragmentTracker.getPartialFragment(a);if(S||k)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f;let S=Math.max(h,c.start||0)-a,k=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,F=(k==null||(f=k.details)==null?void 0:f.live)?k.details.targetduration*2:Eh,R=this.fragmentTracker.getPartialFragment(a);if(S>0&&(S<=F||R)){this._trySkipBufferHole(R);return}}let g=self.performance.now();if(n===null){this.stalled=g;return}let E=g-n;if(!o&&E>=tS&&(this._reportStall(c),!this.media))return;let T=Xe.bufferInfo(s,a,r.maxBufferHole);this._tryFixBufferStall(T,E)}_tryFixBufferStall(e,t){let{config:r,fragmentTracker:s,media:n}=this;if(n===null)return;let a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(M.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;let n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);M.warn(n.message),t.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:r,media:s}=this;if(s===null)return 0;let n=s.currentTime,a=Xe.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){let l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&s.readyState<3,c=o-n;if(c>0&&(l||d)){if(c>t.maxBufferHole){let{fragmentTracker:h}=this,f=!1;if(n===0){let g=h.getAppendedFrag(0,he.MAIN);g&&o<g.end&&(f=!0)}if(!f){let g=e||h.getAppendedFrag(n,he.MAIN);if(g){let E=!1,T=g.end;for(;T<o;){let S=h.getPartialFragment(T);if(S)T+=S.duration;else{E=!0;break}}if(E)return 0}}}let u=Math.max(o+rS,n+iS);if(M.warn(`skipping hole, adjusting currentTime from ${n} to ${u}`),this.moved=!0,this.stalled=null,s.currentTime=u,e&&!e.gap){let h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${u}`);r.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return u}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;let n=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){let a=n+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);M.warn(o.message),r.currentTime=a,t.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{let a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);M.error(a.message),t.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},sS=100,nf=class extends ba{constructor(e,t,r){super(e,t,r,"[stream-controller]",he.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(b.ERROR,this.onError,this),e.on(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this),e.on(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(b.ERROR,this.onError,this),e.off(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this),e.off(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(sS),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.nextAutoLevel),this.level=r.nextLoadLevel=s,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=W.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=W.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case W.WAITING_LEVEL:{var e;let{levels:r,level:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=W.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=W.IDLE;break}break}case W.FRAG_LOADING_WAITING_RETRY:{var t;let r=self.performance.now(),s=this.retryDate;(!s||r>=s||(t=this.media)!=null&&t.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=W.IDLE)}break}this.state===W.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:r,media:s}=this,{config:n,nextLoadLevel:a}=e;if(t===null||!s&&(this.startFragRequested||!n.startFragPrefetch)||this.altAudio&&this.audioOnly||!(r!=null&&r[a]))return;let o=r[a],l=this.getMainFwdBufferInfo();if(l===null)return;let d=this.getLevelDetails();if(d&&this._streamEnded(l,d)){let T={};this.altAudio&&(T.type="video"),this.hls.trigger(b.BUFFER_EOS,T),this.state=W.ENDED;return}e.loadLevel!==a&&e.manualLevel===-1&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;let c=o.details;if(!c||this.state===W.WAITING_LEVEL||c.live&&this.levelLastLoaded!==a){this.level=a,this.state=W.WAITING_LEVEL;return}let u=l.len,h=this.getMaxBufferLength(o.maxBitrate);if(u>=h)return;this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);let f=this.backtrackFragment?this.backtrackFragment.start:l.end,g=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&g&&g.sn!=="initSegment"&&this.fragmentTracker.getState(g)!==yt.OK){var E;let S=((E=this.backtrackFragment)!=null?E:g).sn-c.startSN,k=c.fragments[S-1];k&&g.cc===k.cc&&(g=k,this.fragmentTracker.removeFragment(k))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,f)){if(!g.gap){let S=this.audioOnly&&!this.altAudio?Ve.AUDIO:Ve.VIDEO,k=(S===Ve.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;k&&this.afterBufferFlushed(k,S,he.MAIN)}g=this.getNextFragmentLoopLoading(g,c,l,he.MAIN,h)}g&&(g.initSegment&&!g.initSegment.data&&!this.bitrateTest&&(g=g.initSegment),this.loadFragment(g,o,f))}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===yt.NOT_LOADED||s===yt.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,he.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){let{levels:e,media:t}=this;if(t!=null&&t.readyState){let r,s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);let n=this.getLevelDetails();if(n!=null&&n.live){let o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){let o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:r=0}else r=0;let a=this.getBufferedFrag(t.currentTime+r);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,c=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*.5),d*.75));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case W.KEY_LOADING:case W.FRAG_LOADING:case W.FRAG_LOADING_WAITING_RETRY:case W.PARSING:case W.PARSED:this.state=W.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new sf(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;oe(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(b.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(e,t){let r=!1,s=!1,n;t.levels.forEach(a=>{n=a.audioCodec,n&&(n.indexOf("mp4a.40.2")!==-1&&(r=!0),n.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=r&&s&&!R1(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:r}=this;if(!r||this.state!==W.IDLE)return;let s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(s.details))&&(this.state=W.WAITING_LEVEL)}onLevelLoaded(e,t){var r;let{levels:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);let l=s[n],d=this.fragCurrent;d&&(this.state===W.FRAG_LOADING||this.state===W.FRAG_LOADING_WAITING_RETRY)&&(d.level!==t.level||d.urlId!==l.urlId)&&d.loader&&this.abortCurrentFrag();let c=0;if(a.live||(r=l.details)!=null&&r.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;c=this.alignPlaylists(a,l.details)}if(l.details=a,this.levelLastLoaded=n,this.hls.trigger(b.LEVEL_UPDATED,{details:a,level:n}),this.state===W.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=W.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,c),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let o=a[r.level],l=o.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}let d=o.videoCodec,c=l.PTSKnown||!l.live,u=(t=r.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new dd(this.hls,he.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=s?s.index:-1,E=g!==-1,T=new va(r.level,r.sn,r.stats.chunkCount,n.byteLength,g,E),S=this.initPTS[r.cc];f.push(n,u,h,d,r,s,l.totalduration,c,T,S)}onAudioTrackSwitching(e,t){let r=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let 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();let n=this.hls;r&&(n.trigger(b.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(b.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let r=t.id,s=!!this.hls.audioTracks[r].url;if(s){let n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(e,t){let r=t.tracks,s,n,a=!1;for(let o in r){let l=r[o];if(l.id==="main"){if(n=o,s=l,o==="video"){let d=r[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r&&r.type!==he.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===W.PARSED&&(this.state=W.IDLE);return}let n=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=W.ERROR;return}switch(t.details){case $.FRAG_GAP:case $.FRAG_PARSING_ERROR:case $.FRAG_DECRYPT_ERROR:case $.FRAG_LOAD_ERROR:case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_ERROR:case $.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(he.MAIN,t);break;case $.LEVEL_LOAD_ERROR:case $.LEVEL_LOAD_TIMEOUT:case $.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===W.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===Me.LEVEL&&(this.state=W.IDLE);break;case $.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case $.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){let{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Xe.getBuffered(e).length){let r=this.state!==W.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=W.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Ve.AUDIO||this.audioOnly&&!this.altAudio){let r=(t===Ve.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,he.MAIN)}}onLevelsUpdated(e,t){this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}let s=Xe.getBuffered(e),a=(s.length?s.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),r+=a,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{let{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=W.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;let n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(b.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let r="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:c}=o,{video:u,text:h,id3:f,initSegment:g}=n,{details:E}=c,T=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=W.PARSING,g){if(g!=null&&g.tracks){let L=l.initSegment||l;this._bufferInitSegment(c,g.tracks,L,a),s.trigger(b.FRAG_PARSING_INIT_SEGMENT,{frag:L,id:r,tracks:g.tracks})}let S=g.initPTS,k=g.timescale;oe(S)&&(this.initPTS[l.cc]={baseTime:S,timescale:k},s.trigger(b.INIT_PTS_FOUND,{frag:l,id:r,initPTS:S,timescale:k}))}if(u&&E&&l.sn!=="initSegment"){let S=E.fragments[l.sn-1-E.startSN],k=l.sn===E.startSN,L=!S||l.cc>S.cc;if(n.independent!==!1){let{startPTS:F,endPTS:R,startDTS:B,endDTS:P}=u;if(d)d.elementaryStreams[u.type]={startPTS:F,endPTS:R,startDTS:B,endDTS:P};else if(u.firstKeyFrame&&u.independent&&a.id===1&&!L&&(this.couldBacktrack=!0),u.dropped&&u.independent){let H=this.getMainFwdBufferInfo(),V=(H?H.end:this.getLoadPosition())+this.config.maxBufferHole,N=u.firstKeyFramePTS?u.firstKeyFramePTS:F;if(!k&&V<N-this.config.maxBufferHole&&!L){this.backtrack(l);return}else L&&(l.gap=!0);l.setElementaryStreamInfo(u.type,l.start,R,l.start,P,!0)}l.setElementaryStreamInfo(u.type,F,R,B,P),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(u,l,d,a,k||L)}else if(k||L)l.gap=!0;else{this.backtrack(l);return}}if(T){let{startPTS:S,endPTS:k,startDTS:L,endDTS:F}=T;d&&(d.elementaryStreams[Ve.AUDIO]={startPTS:S,endPTS:k,startDTS:L,endDTS:F}),l.setElementaryStreamInfo(Ve.AUDIO,S,k,L,F),this.bufferFragmentData(T,l,d,a)}if(E&&f!=null&&(t=f.samples)!=null&&t.length){let S={id:r,frag:l,details:E,samples:f.samples};s.trigger(b.FRAG_PARSING_METADATA,S)}if(E&&h){let S={id:r,frag:l,details:E,samples:h.samples};s.trigger(b.FRAG_PARSING_USERDATA,S)}}_bufferInitSegment(e,t,r,s){if(this.state!==W.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,d=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),n.metadata.channelCount!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")),d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.attrs.CODECS||""}/${o.codec}]`),this.hls.trigger(b.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let c=t[l].initSegment;c!=null&&c.byteLength&&this.hls.trigger(b.BUFFER_APPENDING,{type:l,data:c,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,he.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=W.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===!1){let r=e.currentTime;if(Xe.isBuffered(e,r)?t=this.getAppendedFrag(r):Xe.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;let s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n||t.urlId!==s.urlId)&&(this.fragPlaying=t,this.hls.trigger(b.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(b.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,r=this.currentFrag;if(r&&oe(t)&&oe(r.programDateTime)){let s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},Er=class{constructor(e,t=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}sample(e,t){let r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}},af=class{constructor(e,t,r,s=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 Er(e),this.fast_=new Er(t),this.defaultTTFB_=s,this.ttfb_=new Er(e)}update(e,t){let{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new Er(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Er(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Er(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);let r=8*t,s=e/1e3,n=r/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){let t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}},of=class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;let t=e.config;this.bwEstimator=new af(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(b.FRAG_LOADING,this.onFragLoading,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){let{hls:e}=this;e.off(b.FRAG_LOADING,this.onFragLoading,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var r;let s=t.frag;this.ignoreFragment(s)||(this.fragCurrent=s,this.partCurrent=(r=t.part)!=null?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,r,s){let n=e+r/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let r=this.hls.config,{total:s,bwEstimate:n}=t.stats;oe(s)&&oe(n)&&(this.lastLevelLoadSec=8*s/n),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}_abandonRulesCheck(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{autoLevelEnabled:s,media:n}=r;if(!e||!n)return;let a=performance.now(),o=t?t.stats:e.stats,l=t?t.duration:e.duration,d=a-o.loading.start;if(o.aborted||o.loaded&&o.loaded===o.total||e.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!s||n.paused||!n.playbackRate||!n.readyState)return;let c=r.mainForwardBufferInfo;if(c===null)return;let u=this.bwEstimator.getEstimateTTFB(),h=Math.abs(n.playbackRate);if(d<=Math.max(u,1e3*(l/(h*2))))return;let f=c.len/h;if(f>=2*l/h)return;let g=o.loading.first?o.loading.first-o.loading.start:-1,E=o.loaded&&g>-1,T=this.bwEstimator.getEstimate(),{levels:S,minAutoLevel:k}=r,L=S[e.level],F=o.total||Math.max(o.loaded,Math.round(l*L.maxBitrate/8)),R=d-g;R<1&&E&&(R=Math.min(d,o.loaded*8/T));let B=E?o.loaded*1e3/R:0,P=B?(F-o.loaded)/B:F*8/T+u/1e3;if(P<=f)return;let H=B?B*8:T,V=Number.POSITIVE_INFINITY,N;for(N=e.level-1;N>k;N--){let j=S[N].maxBitrate;if(V=this.getTimeToLoadFrag(u/1e3,H,l*j,!S[N].details),V<f)break}V>=P||V>l*10||(r.nextLoadLevel=N,E?this.bwEstimator.sample(d-Math.min(u,g),o.loaded):this.bwEstimator.sampleTTFB(d),this.clearTimer(),M.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;
1063
1138
  Time to underbuffer: ${f.toFixed(3)} s
1064
1139
  Estimated load time for current fragment: ${P.toFixed(3)} s
1065
- Estimated load time for down switch fragment: ${K.toFixed(3)} s
1140
+ Estimated load time for down switch fragment: ${V.toFixed(3)} s
1066
1141
  TTFB estimate: ${g}
1067
1142
  Current BW estimate: ${oe(T)?(T/1024).toFixed(3):"Unknown"} Kb/s
1068
1143
  New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
1069
- Aborting and switching to level ${N}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),r.trigger(b.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}onFragLoaded(e,{frag:t,part:r}){let s=r?r.stats:t.stats;if(t.type===he.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){let n=r?r.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+s.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){let n={stats:s,frag:t,part:r,id:t.type};this.onFragBuffered(b.FRAG_BUFFERED,n),t.bitrateTest=!1}}}onFragBuffered(e,t){let{frag:r,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:r.stats;if(n.aborted||this.ignoreFragment(r))return;let a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==he.MAIN||e.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){let e=this._nextAutoLevel,t=this.bwEstimator;if(e!==-1&&!t.canEstimate())return e;let r=this.getNextABRAutoLevel();if(e!==-1){let s=this.hls.levels;if(s.length>Math.max(e,r)&&s[e].loadError<=s[r].loadError)return e}return e!==-1&&(r=Math.min(e,r)),r}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:s,config:n,minAutoLevel:a,media:o}=r,l=t?t.duration:e?e.duration:0,d=o&&o.playbackRate!==0?Math.abs(o.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,u=r.mainForwardBufferInfo,h=(u?u.len:0)/d,f=this.findBestLevel(c,a,s,h,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(f>=0)return f;M.trace(`[abr] ${h?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let g=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,E=n.abrBandWidthFactor,T=n.abrBandWidthUpFactor;if(!h){let A=this.bitrateTestDelay;A&&(g=(l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay)-A,M.trace(`[abr] bitrate test took ${Math.round(1e3*A)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),E=T=1)}return f=this.findBestLevel(c,a,s,h+g,E,T),Math.max(f,0)}findBestLevel(e,t,r,s,n,a){var o;let{fragCurrent:l,partCurrent:d,lastLoadedFragLevel:c}=this,{levels:u}=this.hls,h=u[c],f=!!(h!=null&&(o=h.details)!=null&&o.live),g=h==null?void 0:h.codecSet,E=d?d.duration:l?l.duration:0,T=this.bwEstimator.getEstimateTTFB()/1e3,A=t,k=-1;for(let L=r;L>=t;L--){let F=u[L];if(!F||g&&F.codecSet!==g){F&&(A=Math.min(L,A),k=Math.max(L,k));continue}k!==-1&&M.trace(`[abr] Skipped level(s) ${A}-${k} with CODECS:"${u[k].attrs.CODECS}"; not compatible with "${h.attrs.CODECS}"`);let R=F.details,B=(d?R==null?void 0:R.partTarget:R==null?void 0:R.averagetargetduration)||E,P;L<=c?P=n*e:P=a*e;let G=u[L].maxBitrate,K=this.getTimeToLoadFrag(T,P,G*B,R===void 0);if(M.trace(`[abr] level:${L} adjustedbw-bitrate:${Math.round(P-G)} avgDuration:${B.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${K.toFixed(1)}`),P>G&&(K===0||!oe(K)||f&&!this.bitrateTestDelay||K<s))return L}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}},rd=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,r;if(e.length)e.length===1?r=e[0]:r=G1(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}};function G1(i,e){let t=new Uint8Array(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return t}var iv=100,Jh=class extends ma{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",he.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(b.ERROR,this.onError,this),e.on(b.BUFFER_RESET,this.onBufferReset,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this),e.on(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(b.ERROR,this.onError,this),e.off(b.BUFFER_RESET,this.onBufferReset,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this),e.off(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){if(r==="main"){let a=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===V.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=V.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(iv),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=V.IDLE):(this.loadedmetadata=!1,this.state=V.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case V.IDLE:this.doTickIdle();break;case V.WAITING_TRACK:{var e;let{levels:r,trackId:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=V.WAITING_INIT_PTS}break}case V.FRAG_LOADING_WAITING_RETRY:{var t;let r=performance.now(),s=this.retryDate;(!s||r>=s||(t=this.media)!=null&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=V.IDLE);break}case V.WAITING_INIT_PTS:{let r=this.waitingData;if(r){let{frag:s,part:n,cache:a,complete:o}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=V.FRAG_LOADING;let l=a.flush(),d={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{let l=this.getLoadPosition(),d=Xe.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);kh(d.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=V.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=V.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){let{hls:e,levels:t,media:r,trackId:s}=this,n=e.config;if(!(t!=null&&t[s])||!r&&(this.startFragRequested||!n.startFragPrefetch))return;let a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(o)){this.state=V.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Ve.AUDIO,he.AUDIO));let d=this.getFwdBufferInfo(l,he.AUDIO);if(d===null)return;let{bufferedTrack:c,switchingTrack:u}=this;if(!u&&this._streamEnded(d,o)){e.trigger(b.BUFFER_EOS,{type:"audio"}),this.state=V.ENDED;return}let h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,he.MAIN),f=d.len,g=this.getMaxBufferLength(h==null?void 0:h.len);if(f>=g&&!u)return;let T=o.fragments[0].start,A=d.end;if(u&&r){let R=this.getLoadPosition();c&&u.attrs!==c.attrs&&(A=R),o.PTSKnown&&R<T&&(d.end>T||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=T+.05)}let k=this.getNextFragment(A,o),L=!1;if(k&&this.isLoopLoading(k,A)&&(L=!!k.gap,k=this.getNextFragmentLoopLoading(k,o,d,he.MAIN,g)),!k){this.bufferFlushed=!0;return}let F=h&&k.start>h.end+o.targetduration;if(F||!(h!=null&&h.len)&&d.len){let R=this.getAppendedFrag(k.start,he.MAIN);if(R===null||(L||(L=!!R.gap||!!F&&h.len===0),F&&!L||L&&d.nextStart&&d.nextStart<R.end))return}this.loadFragment(k,a,A)}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new Qr(r))}onAudioTrackSwitching(e,t){let r=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(iv):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=V.IDLE):(this.switchingTrack=null,this.bufferedTrack=t,this.state=V.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(b.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}let{levels:s}=this,{details:n,id:a}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let o=s[a],l=0;if(n.live||(r=o.details)!=null&&r.live){this.checkLiveUpdate(n);let d=this.mainDetails;if(n.deltaUpdateFailed||!d)return;!o.details&&n.hasProgramDateTime&&d.hasProgramDateTime?(Nv(n,d),l=n.fragments[0].start):l=this.alignPlaylists(n,o.details)}o.details=n,this.levelLastLoaded=a,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(o.details,l),this.state===V.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=V.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}let c=d.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}let u=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new id(this.hls,he.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[r.cc],g=(t=r.initSegment)==null?void 0:t.data;if(f!==void 0){let T=s?s.index:-1,A=T!==-1,k=new ha(r.level,r.sn,r.stats.chunkCount,n.byteLength,T,A);h.push(n,g,u,"",r,s,c.totalduration,!1,k,f)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);let{cache:E}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new rd,complete:!1};E.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=V.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){let r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r.type!==he.AUDIO){if(!this.loadedmetadata&&r.type===he.MAIN){let n=this.videoBuffer||this.media;n&&Xe.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(b.AUDIO_TRACK_SWITCHED,Ct({},n)))}this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=V.ERROR;return}switch(t.details){case $.FRAG_GAP:case $.FRAG_PARSING_ERROR:case $.FRAG_DECRYPT_ERROR:case $.FRAG_LOAD_ERROR:case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_ERROR:case $.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(he.AUDIO,t);break;case $.AUDIO_TRACK_LOAD_ERROR:case $.AUDIO_TRACK_LOAD_TIMEOUT:case $.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===V.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===Me.AUDIO_TRACK&&(this.state=V.IDLE);break;case $.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case $.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushed(e,{type:t}){t===Ve.AUDIO&&(this.bufferFlushed=!0,this.state===V.ENDED&&(this.state=V.IDLE))}_handleTransmuxComplete(e){var t;let r="audio",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:c}=o,{details:u}=c,{audio:h,text:f,id3:g,initSegment:E}=n;if(this.fragContextChanged(l)||!u){this.fragmentTracker.removeFragment(l);return}if(this.state=V.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),E!=null&&E.tracks){let T=l.initSegment||l;this._bufferInitSegment(E.tracks,T,a),s.trigger(b.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:r,tracks:E.tracks})}if(h){let{startPTS:T,endPTS:A,startDTS:k,endDTS:L}=h;d&&(d.elementaryStreams[Ve.AUDIO]={startPTS:T,endPTS:A,startDTS:k,endDTS:L}),l.setElementaryStreamInfo(Ve.AUDIO,T,A,k,L),this.bufferFragmentData(h,l,d,a)}if(g!=null&&(t=g.samples)!=null&&t.length){let T=ht({id:r,frag:l,details:u},g);s.trigger(b.FRAG_PARSING_METADATA,T)}if(f){let T=ht({id:r,frag:l,details:u},f);s.trigger(b.FRAG_PARSING_USERDATA,T)}}_bufferInitSegment(e,t,r){if(this.state!==V.PARSING)return;e.video&&delete e.video;let s=e.audio;if(!s)return;s.levelCodec=s.codec,s.id="audio",this.log(`Init audio buffer, container:${s.container}, codecs[parsed]=[${s.codec}]`),this.hls.trigger(b.BUFFER_CODECS,e);let n=s.initSegment;if(n!=null&&n.byteLength){let a={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:n};this.hls.trigger(b.BUFFER_APPENDING,a)}this.tick()}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===Et.NOT_LOADED||s===Et.PARTIAL){var n;e.sn==="initSegment"?this._loadInitSegment(e,t):(n=t.details)!=null&&n.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=V.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(e,t,r))}else this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){let{hls:t,media:r,bufferedTrack:s}=this,n=s==null?void 0:s.attrs,a=e.attrs;r&&n&&(n.CHANNELS!==a.CHANNELS||n.NAME!==a.NAME||n.LANGUAGE!==a.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(b.AUDIO_TRACK_SWITCHED,Ct({},e))}},ef=class extends ua{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(b.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(b.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Track with id:${r} and group:${s} not found in active group ${a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`audio-track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!(t!=null&&t.audioGroupIds))return;let r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r||null;let s=this.tracks.filter(a=>!r||a.groupId===r);this.selectDefaultTrack&&!s.some(a=>a.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=s;let n={audioTracks:s};this.log(`Updating audio tracks, ${s.length} track(s) found in group:${r}`),this.hls.trigger(b.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===Me.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();let r=this.currentTrack;t[this.trackId];let s=t[e],{groupId:n,name:a}=s;if(this.log(`Switching to audio-track ${e} "${a}" lang:${s.lang} group:${n}`),this.trackId=e,this.currentTrack=s,this.selectDefaultTrack=!1,this.hls.trigger(b.AUDIO_TRACK_SWITCHING,Ct({},s)),s.details&&!s.details.live)return;let o=this.switchParams(s.url,r==null?void 0:r.details);this.loadPlaylist(o)}selectInitialTrack(){let e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(t!==-1)this.setAudioTrack(t);else{let r=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(r.message),this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:r})}}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if((!this.selectDefaultTrack||s.default)&&(!e||e.attrs["STABLE-RENDITION-ID"]!==void 0&&e.attrs["STABLE-RENDITION-ID"]===s.attrs["STABLE-RENDITION-ID"]||e.name===s.name&&e.lang===s.lang))return s.id}return-1}loadPlaylist(e){super.loadPlaylist();let t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(b.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}};function Xv(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!H1(i[t].attrs,e[t].attrs))return!1;return!0}function H1(i,e){let t=i["STABLE-RENDITION-ID"];return t?t===e["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(r=>i[r]!==e[r])}var rv=500,tf=class extends ma{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",he.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.ERROR,this.onError,this),e.on(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(b.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(b.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.ERROR,this.onError,this),e.off(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(b.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(b.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=V.IDLE,this.setInterval(rv),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=V.IDLE,!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=r.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=r.start+r.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r)}onBufferFlushing(e,t){let{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){let n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(r,n,he.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===he.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let r=t.frag;(r==null?void 0:r.type)===he.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==V.STOPPED&&(this.state=V.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(Xv(this.levels,t)){this.levels=t.map(r=>new Qr(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{let s=new Qr(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,he.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){if(this.currentTrackId=t.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}let r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(rv)}onSubtitleTrackLoaded(e,t){var r;let{details:s,id:n}=t,{currentTrackId:a,levels:o}=this;if(!o.length)return;let l=o[a];if(n>=o.length||n!==a||!l)return;this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(s.live||(r=l.details)!=null&&r.live){let c=this.mainDetails;if(s.deltaUpdateFailed||!c)return;let u=c.fragments[0];l.details?(d=this.alignPlaylists(s,l.details),d===0&&u&&(d=u.start,Rh(s,d))):s.hasProgramDateTime&&c.hasProgramDateTime?(Nv(s,c),d=s.fragments[0].start):u&&(d=u.start,Rh(s,d))}l.details=s,this.levelLastLoaded=n,!this.startFragRequested&&(this.mainDetails||!s.live)&&this.setStartPosition(l.details,d),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===V.IDLE&&(ca(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0))}_handleFragmentLoadComplete(e){let{frag:t,payload:r}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{let l=performance.now();n.trigger(b.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=V.IDLE})}}doTick(){if(!this.media){this.state=V.IDLE;return}if(this.state===V.IDLE){let{currentTrackId:e,levels:t}=this,r=t[e];if(!t.length||!r||!r.details)return;let{config:s}=this,n=this.getLoadPosition(),a=Xe.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,he.MAIN),c=r.details,u=this.getMaxBufferLength(d==null?void 0:d.len)+c.levelTargetDuration;if(l>u)return;let h=c.fragments,f=h.length,g=c.edge,E=null,T=this.fragPrevious;if(o<g){let A=s.maxFragLookUpTolerance,k=o>g-A?0:A;E=ca(T,h,Math.max(h[0].start,o),k),!E&&T&&T.start<h[0].start&&(E=h[0])}else E=h[f-1];if(!E)return;if(E=this.mapToInitFragWhenRequired(E),E.sn!=="initSegment"){let A=E.sn-c.startSN,k=h[A-1];k&&k.cc===E.cc&&this.fragmentTracker.getState(k)===Et.NOT_LOADED&&(E=k)}this.fragmentTracker.getState(E)===Et.NOT_LOADED&&this.loadFragment(E,r,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new rf(this.tracksBuffered[this.currentTrackId]||[])}},rf=class{constructor(e){this.buffered=void 0;let t=(r,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}},sf=class extends ua{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(b.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(b.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),uh(this.media.textTracks).forEach(t=>{nn(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:r,details:s}=t,{trackId:n}=this,a=this.tracksInGroup[n];if(!a){this.warn(`Invalid subtitle track id ${r}`);return}let o=a.details;a.details=t.details,this.log(`subtitle track ${r} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!(t!=null&&t.textGroupIds))return;let r=t.textGroupIds[t.urlId],s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==r){let n=this.tracks.filter(l=>!r||l.groupId===r);this.tracksInGroup=n;let a=this.findTrackId(s==null?void 0:s.name)||this.findTrackId();this.groupId=r||null;let o={subtitleTracks:n};this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${r}" group-id`),this.hls.trigger(b.SUBTITLE_TRACKS_UPDATED,o),a!==-1&&this.setSubtitleTrack(a,s)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId,s)}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if((!this.selectDefaultTrack||s.default)&&(!e||e===s.name))return s.id}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Me.SUBTITLE_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.checkRetry(t)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;let t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}loadPlaylist(e){super.loadPlaylist();let t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(b.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(e){let{media:t,trackId:r}=this;if(!t)return;let s=uh(t.textTracks),n=s.filter(o=>o.groupId===this.groupId);if(e===-1)[].slice.call(s).forEach(o=>{o.mode="disabled"});else{let o=n[r];o&&(o.mode="disabled")}let a=n[e];a&&(a.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var r;let s=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(r=s[e])!=null&&r.details)||e<-1||e>=s.length)return;this.clearTimer();let n=s[e];if(this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:"")),this.trackId=e,n){let{id:a,groupId:o="",name:l,type:d,url:c}=n;this.hls.trigger(b.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:c});let u=this.switchParams(n.url,t==null?void 0:t.details);this.loadPlaylist(u)}else this.hls.trigger(b.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1,t=uh(this.media.textTracks);for(let r=0;r<t.length;r++)if(t[r].mode==="hidden")e=r;else if(t[r].mode==="showing"){e=r;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}};function uh(i){let e=[];for(let t=0;t<i.length;t++){let r=i[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(i[t])}return e}var nf=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t){let r=this.queues[t];r.push(e),r.length===1&&this.buffers[t]&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,r=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){let{buffers:t,queues:r}=this,s=t[e],n=r[e];if(n.length){let a=n[0];try{a.execute()}catch(o){M.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),a.onError(o),s!=null&&s.updating||(n.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}},sv=ud(),nv=/([ha]vc.)(?:\.[^.,]+)+/,af=class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{let{media:t,mediaSource:r}=this;M.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(b.MEDIA_ATTACHED,{media:t})),r&&r.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{M.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{M.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{let{media:t,_objectUrl:r}=this;t&&t.src!==r&&M.error(`Media element src was set while attaching MediaSource (${r} > ${t.src})`)},this.hls=e,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.BUFFER_RESET,this.onBufferReset,this),e.on(b.BUFFER_APPENDING,this.onBufferAppending,this),e.on(b.BUFFER_CODECS,this.onBufferCodecs,this),e.on(b.BUFFER_EOS,this.onBufferEos,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(b.FRAG_PARSED,this.onFragParsed,this),e.on(b.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.BUFFER_RESET,this.onBufferReset,this),e.off(b.BUFFER_APPENDING,this.onBufferAppending,this),e.off(b.BUFFER_CODECS,this.onBufferCodecs,this),e.off(b.BUFFER_EOS,this.onBufferEos,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(b.FRAG_PARSED,this.onFragParsed,this),e.off(b.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new nf(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,M.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let r=this.media=t.media;if(r&&sv){let s=this.mediaSource=new sv;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(s),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(M.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){M.warn(`[buffer-controller]: onMediaDetaching: ${s.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()):M.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(b.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{let t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(r){M.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,r)}}),this._initSourceBuffer()}onBufferCodecs(e,t){let r=this.getSourceBufferTypes().length;Object.keys(t).forEach(s=>{if(r){let n=this.tracks[s];if(n&&typeof n.buffer.changeType=="function"){let{id:a,codec:o,levelCodec:l,container:d,metadata:c}=t[s],u=(n.levelCodec||n.codec).replace(nv,"$1"),h=(l||o).replace(nv,"$1");if(u!==h){let f=`${d};codecs=${l||o}`;this.appendChangeType(s,f),M.log(`[buffer-controller]: switching codec ${u} to ${h}`),this.tracks[s]={buffer:n.buffer,codec:o,container:d,levelCodec:l,metadata:c,id:a}}}}else this.pendingTracks[s]=t[s]}),!r&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(e,t){let{operationQueue:r}=this,s={execute:()=>{let n=this.sourceBuffer[e];n&&(M.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{M.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,n)}};r.append(s,e)}onBufferAppending(e,t){let{hls:r,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:c}=t,u=c.buffering[o],h=self.performance.now();u.start=h;let f=l.stats.buffering,g=d?d.stats.buffering:null;f.start===0&&(f.start=h),g&&g.start===0&&(g.start=h);let E=n.audio,T=!1;o==="audio"&&(E==null?void 0:E.container)==="audio/mpeg"&&(T=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);let A=l.start,k={execute:()=>{if(u.executeStart=self.performance.now(),T){let L=this.sourceBuffer[o];if(L){let F=A-L.timestampOffset;Math.abs(F)>=.1&&(M.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${A} (delta: ${F}) sn: ${l.sn})`),L.timestampOffset=A)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let L=self.performance.now();u.executeEnd=u.end=L,f.first===0&&(f.first=L),g&&g.first===0&&(g.first=L);let{sourceBuffer:F}=this,R={};for(let B in F)R[B]=Xe.getBuffered(F[B]);this.appendError=0,this.hls.trigger(b.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:c,parent:l.type,timeRanges:R})},onError:L=>{M.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,L);let F={type:ue.MEDIA_ERROR,parent:l.type,details:$.BUFFER_APPEND_ERROR,frag:l,part:d,chunkMeta:c,error:L,err:L,fatal:!1};L.code===DOMException.QUOTA_EXCEEDED_ERR?F.details=$.BUFFER_FULL_ERROR:(this.appendError++,F.details=$.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(M.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),F.fatal=!0)),r.trigger(b.ERROR,F)}};s.append(k,o)}onBufferFlushing(e,t){let{operationQueue:r}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(b.BUFFER_FLUSHED,{type:n})},onError:a=>{M.warn(`[buffer-controller]: Failed to remove from ${n} SourceBuffer`,a)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{r.append(s(n),n)})}onFragParsed(e,t){let{frag:r,part:s}=t,n=[],a=s?s.elementaryStreams:r.elementaryStreams;a[Ve.AUDIOVIDEO]?n.push("audiovideo"):(a[Ve.AUDIO]&&n.push("audio"),a[Ve.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);let d=s?s.stats:r.stats;this.hls.trigger(b.FRAG_BUFFERED,{frag:r,part:s,stats:d,id:r.type})};n.length===0&&M.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,n)=>{let a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,M.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(M.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{let a=this.sourceBuffer[n];a&&(a.ending=!1)});let{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&M.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}M.log("[buffer-controller]: Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){let{hls:e,details:t,media:r,sourceBuffer:s}=this;if(!r||t===null)return;let n=this.getSourceBufferTypes();if(!n.length)return;let a=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!oe(a)||a<0)return;let o=r.currentTime,l=t.levelTargetDuration,d=Math.max(a,l),c=Math.floor(o/l)*l-d;n.forEach(u=>{let h=s[u];if(h){let f=Xe.getBuffered(h);if(f.length>0&&c>f.start(0)){if(e.trigger(b.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(b.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(h.ended&&f.end(f.length-1)-o<l*2){M.info(`[buffer-controller]: Cannot flush ${u} back buffer while SourceBuffer is in ended state`);return}e.trigger(b.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:u})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;let{details:e,hls:t,media:r,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=r.duration,o=oe(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(M.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!oe(a))&&(M.log(`[buffer-controller]: Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(e){let t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,a)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&!e||s===2){this.createSourceBuffers(r),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(b.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{let a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(let s in e)if(!t[s]){let n=e[s];if(!n)throw Error(`source buffer exists for track ${s}, however track does not`);let a=n.levelCodec||n.codec,o=`${n.container};codecs=${a}`;M.log(`[buffer-controller]: creating sourceBuffer(${o})`);try{let l=t[s]=r.addSourceBuffer(o),d=s;this.addBufferListener(d,"updatestart",this._onSBUpdateStart),this.addBufferListener(d,"updateend",this._onSBUpdateEnd),this.addBufferListener(d,"error",this._onSBUpdateError),this.tracks[s]={buffer:l,codec:a,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(l){M.error(`[buffer-controller]: error while trying to add sourceBuffer: ${l.message}`),this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:o})}}}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){let{operationQueue:t}=this;t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){let r=new Error(`${e} SourceBuffer error`);M.error(`[buffer-controller]: ${r}`,t),this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_APPENDING_ERROR,error:r,fatal:!1});let s=this.operationQueue.current(e);s&&s.onError(t)}removeExecutor(e,t,r){let{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!s||!n||!l){M.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let d=oe(s.duration)?s.duration:1/0,c=oe(n.duration)?n.duration:1/0,u=Math.max(0,t),h=Math.min(r,d,c);h>u&&!l.ending?(l.ended=!1,M.log(`[buffer-controller]: Removing [${u},${h}] from the ${e} SourceBuffer`),l.remove(u,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){let{operationQueue:r,sourceBuffer:s}=this,n=s[t];if(!n){M.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),r.shiftAndExecuteNext(t);return}n.ended=!1,n.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){M.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:r}=this,s=t.map(n=>r.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||r.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){let s=this.sourceBuffer[e];if(!s)return;let n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){let t=this.sourceBuffer[e];t&&this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}},av={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},Qv=function(e){let t=e;return av.hasOwnProperty(e)&&(t=av[e]),String.fromCharCode(t)},vi=15,Xi=100,V1={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},W1={17:2,18:4,21:6,22:8,23:10,19:13,20:15},K1={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},q1={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Y1=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],of=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let r=typeof t=="function"?t():t;M.log(`${this.time} [${e}] ${r}`)}}},qr=function(e){let t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t},sd=class{constructor(e,t,r,s,n){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=s||"black",this.flash=n||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){let s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},lf=class{constructor(e,t,r,s,n,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new sd(t,r,s,n,a)}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}},df=class{constructor(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let t=0;t<Xi;t++)this.chars.push(new lf);this.logger=e,this.pos=0,this.currPenState=new sd}equals(e){let t=!0;for(let r=0;r<Xi;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t}copy(e){for(let t=0;t<Xi;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Xi;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Xi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Xi)}moveCursor(e){let t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=Qv(e);if(this.pos>=Xi){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Xi;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let r=0;r<Xi;r++){let s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},la=class{constructor(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let t=0;t<vi;t++)this.rows.push(new df(e));this.logger=e,this.currRow=vi-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<vi;e++)this.rows[e].clear();this.currRow=vi-1}equals(e){let t=!0;for(let r=0;r<vi;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<vi;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<vi;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<vi;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,l=this.logger.time;if(o&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;let r=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);r.setCursor(e.indent),e.color=r.chars[a].penState.foreground}let s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],r="",s=-1;for(let n=0;n<vi;n++){let a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
1070
- `)),r}getTextAndFormat(){return this.rows}},nd=class{constructor(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 la(r),this.nonDisplayedMemory=new la(r),this.lastOutputScreen=new la(r),this.currRollUpRow=this.displayedMemory.rows[vi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[vi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{let r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}},ad=class{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;let s=new of;this.channels=[null,new nd(e,t,s),new nd(e+1,r,s)],this.cmdHistory=lv(),this.logger=s}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let r,s,n,a=!1;this.logger.time=e;for(let o=0;o<t.length;o+=2)if(s=t[o]&127,n=t[o+1]&127,!(s===0&&n===0)){if(this.logger.log(3,"["+qr([t[o],t[o+1]])+"] -> ("+qr([s,n])+")"),r=this.parseCmd(s,n),r||(r=this.parseMidrow(s,n)),r||(r=this.parsePAC(s,n)),r||(r=this.parseBackgroundAttributes(s,n)),!r&&(a=this.parseChars(s,n),a)){let l=this.currentChannel;l&&l>0?this.channels[l].insertChars(a):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!r&&!a&&this.logger.log(2,"Couldn't parse cleaned data "+qr([s,n])+" orig: "+qr([t[o],t[o+1]]))}}parseCmd(e,t){let{cmdHistory:r}=this,s=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,n=(e===23||e===31)&&t>=33&&t<=35;if(!(s||n))return!1;if(ov(e,t,r))return sn(null,null,r),this.logger.log(3,"Repeated command ("+qr([e,t])+") is dropped"),!0;let a=e===20||e===21||e===23?1:2,o=this.channels[a];return e===20||e===21||e===28||e===29?t===32?o.ccRCL():t===33?o.ccBS():t===34?o.ccAOF():t===35?o.ccAON():t===36?o.ccDER():t===37?o.ccRU(2):t===38?o.ccRU(3):t===39?o.ccRU(4):t===40?o.ccFON():t===41?o.ccRDC():t===42?o.ccTR():t===43?o.ccRTD():t===44?o.ccEDM():t===45?o.ccCR():t===46?o.ccENM():t===47&&o.ccEOC():o.ccTO(t-32),sn(e,t,r),this.currentChannel=a,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,"MIDROW ("+qr([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r,s=this.cmdHistory,n=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,a=(e===16||e===24)&&t>=64&&t<=95;if(!(n||a))return!1;if(ov(e,t,s))return sn(null,null,s),!0;let o=e<=23?1:2;t>=64&&t<=95?r=o===1?V1[e]:K1[e]:r=o===1?W1[e]:q1[e];let l=this.channels[o];return l?(l.setPAC(this.interpretPAC(r,t)),sn(e,t,s),this.currentChannel=o,!0):!1}interpretPAC(e,t){let r,s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,"Special char '"+Qv(a)+"' in channel "+r),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);if(s){let a=qr(s);this.logger.log(3,"Char codes = "+a.join(",")),sn(e,t,this.cmdHistory)}return s}parseBackgroundAttributes(e,t){let r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=Y1[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));let o=e<=23?1:2;return this.channels[o].setBkgData(a),sn(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}this.cmdHistory=lv()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let r=this.channels[t];r&&r.cueSplitAtTime(e)}}};function sn(i,e,t){t.a=i,t.b=e}function ov(i,e,t){return t.a===i&&t.b===e}function lv(){return{a:null,b:null}}var an=class{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},wf=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;let i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;let d=l.toLowerCase();return~o.indexOf(d)?d:!1}function r(o){return t(i,o)}function s(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){let c=arguments[d];for(let u in c)o[u]=c[u]}return o}function a(o,l,d){let c=this,u={enumerable:!0};c.hasBeenReset=!1;let h="",f=!1,g=o,E=l,T=d,A=null,k="",L=!0,F="auto",R="start",B=50,P="middle",G=50,K="middle";Object.defineProperty(c,"id",n({},u,{get:function(){return h},set:function(N){h=""+N}})),Object.defineProperty(c,"pauseOnExit",n({},u,{get:function(){return f},set:function(N){f=!!N}})),Object.defineProperty(c,"startTime",n({},u,{get:function(){return g},set:function(N){if(typeof N!="number")throw new TypeError("Start time must be set to a number.");g=N,this.hasBeenReset=!0}})),Object.defineProperty(c,"endTime",n({},u,{get:function(){return E},set:function(N){if(typeof N!="number")throw new TypeError("End time must be set to a number.");E=N,this.hasBeenReset=!0}})),Object.defineProperty(c,"text",n({},u,{get:function(){return T},set:function(N){T=""+N,this.hasBeenReset=!0}})),Object.defineProperty(c,"region",n({},u,{get:function(){return A},set:function(N){A=N,this.hasBeenReset=!0}})),Object.defineProperty(c,"vertical",n({},u,{get:function(){return k},set:function(N){let j=r(N);if(j===!1)throw new SyntaxError("An invalid or illegal string was specified.");k=j,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",n({},u,{get:function(){return L},set:function(N){L=!!N,this.hasBeenReset=!0}})),Object.defineProperty(c,"line",n({},u,{get:function(){return F},set:function(N){if(typeof N!="number"&&N!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");F=N,this.hasBeenReset=!0}})),Object.defineProperty(c,"lineAlign",n({},u,{get:function(){return R},set:function(N){let j=s(N);if(!j)throw new SyntaxError("An invalid or illegal string was specified.");R=j,this.hasBeenReset=!0}})),Object.defineProperty(c,"position",n({},u,{get:function(){return B},set:function(N){if(N<0||N>100)throw new Error("Position must be between 0 and 100.");B=N,this.hasBeenReset=!0}})),Object.defineProperty(c,"positionAlign",n({},u,{get:function(){return P},set:function(N){let j=s(N);if(!j)throw new SyntaxError("An invalid or illegal string was specified.");P=j,this.hasBeenReset=!0}})),Object.defineProperty(c,"size",n({},u,{get:function(){return G},set:function(N){if(N<0||N>100)throw new Error("Size must be between 0 and 100.");G=N,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",n({},u,{get:function(){return K},set:function(N){let j=s(N);if(!j)throw new SyntaxError("An invalid or illegal string was specified.");K=j,this.hasBeenReset=!0}})),c.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),cf=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function Zv(i){function e(r,s,n,a){return(r|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}let t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}var uf=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}};function Jv(i,e,t,r){let s=r?i.split(r):[i];for(let n in s){if(typeof s[n]!="string")continue;let a=s[n].split(t);if(a.length!==2)continue;let o=a[0],l=a[1];e(o,l)}}var hf=new wf(0,0,""),Bl=hf.align==="middle"?"middle":"center";function j1(i,e,t){let r=i;function s(){let o=Zv(i);if(o===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new uf;Jv(o,function(h,f){let g;switch(h){case"region":for(let E=t.length-1;E>=0;E--)if(t[E].id===f){d.set(h,t[E].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":g=f.split(","),d.integer(h,g[0]),d.percent(h,g[0])&&d.set("snapToLines",!1),d.alt(h,g[0],["auto"]),g.length===2&&d.alt("lineAlign",g[1],["start",Bl,"end"]);break;case"position":g=f.split(","),d.percent(h,g[0]),g.length===2&&d.alt("positionAlign",g[1],["start",Bl,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",Bl,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let c=d.get("line","auto");c==="auto"&&hf.line===-1&&(c=-1),l.line=c,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",Bl);let u=d.get("position","auto");u==="auto"&&hf.position===50&&(u=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=u}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),a(),e.endTime=s(),a(),n(i,e)}function eE(i){return i.replace(/<br(?: \/)?>/gi,`
1071
- `)}var ff=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new cf,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){let t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function r(){let n=t.buffer,a=0;for(n=eE(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
1144
+ Aborting and switching to level ${N}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),r.trigger(b.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}onFragLoaded(e,{frag:t,part:r}){let s=r?r.stats:t.stats;if(t.type===he.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){let n=r?r.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+s.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){let n={stats:s,frag:t,part:r,id:t.type};this.onFragBuffered(b.FRAG_BUFFERED,n),t.bitrateTest=!1}}}onFragBuffered(e,t){let{frag:r,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:r.stats;if(n.aborted||this.ignoreFragment(r))return;let a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==he.MAIN||e.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){let e=this._nextAutoLevel,t=this.bwEstimator;if(e!==-1&&!t.canEstimate())return e;let r=this.getNextABRAutoLevel();if(e!==-1){let s=this.hls.levels;if(s.length>Math.max(e,r)&&s[e].loadError<=s[r].loadError)return e}return e!==-1&&(r=Math.min(e,r)),r}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:s,config:n,minAutoLevel:a,media:o}=r,l=t?t.duration:e?e.duration:0,d=o&&o.playbackRate!==0?Math.abs(o.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,u=r.mainForwardBufferInfo,h=(u?u.len:0)/d,f=this.findBestLevel(c,a,s,h,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(f>=0)return f;M.trace(`[abr] ${h?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let g=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,E=n.abrBandWidthFactor,T=n.abrBandWidthUpFactor;if(!h){let S=this.bitrateTestDelay;S&&(g=(l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay)-S,M.trace(`[abr] bitrate test took ${Math.round(1e3*S)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),E=T=1)}return f=this.findBestLevel(c,a,s,h+g,E,T),Math.max(f,0)}findBestLevel(e,t,r,s,n,a){var o;let{fragCurrent:l,partCurrent:d,lastLoadedFragLevel:c}=this,{levels:u}=this.hls,h=u[c],f=!!(h!=null&&(o=h.details)!=null&&o.live),g=h==null?void 0:h.codecSet,E=d?d.duration:l?l.duration:0,T=this.bwEstimator.getEstimateTTFB()/1e3,S=t,k=-1;for(let L=r;L>=t;L--){let F=u[L];if(!F||g&&F.codecSet!==g){F&&(S=Math.min(L,S),k=Math.max(L,k));continue}k!==-1&&M.trace(`[abr] Skipped level(s) ${S}-${k} with CODECS:"${u[k].attrs.CODECS}"; not compatible with "${h.attrs.CODECS}"`);let R=F.details,B=(d?R==null?void 0:R.partTarget:R==null?void 0:R.averagetargetduration)||E,P;L<=c?P=n*e:P=a*e;let H=u[L].maxBitrate,V=this.getTimeToLoadFrag(T,P,H*B,R===void 0);if(M.trace(`[abr] level:${L} adjustedbw-bitrate:${Math.round(P-H)} avgDuration:${B.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${V.toFixed(1)}`),P>H&&(V===0||!oe(V)||f&&!this.bitrateTestDelay||V<s))return L}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}},cd=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,r;if(e.length)e.length===1?r=e[0]:r=nS(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}};function nS(i,e){let t=new Uint8Array(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return t}var pv=100,lf=class extends ba{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",he.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(b.ERROR,this.onError,this),e.on(b.BUFFER_RESET,this.onBufferReset,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this),e.on(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(b.ERROR,this.onError,this),e.off(b.BUFFER_RESET,this.onBufferReset,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this),e.off(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){if(r==="main"){let a=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===W.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=W.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(pv),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=W.IDLE):(this.loadedmetadata=!1,this.state=W.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case W.IDLE:this.doTickIdle();break;case W.WAITING_TRACK:{var e;let{levels:r,trackId:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=W.WAITING_INIT_PTS}break}case W.FRAG_LOADING_WAITING_RETRY:{var t;let r=performance.now(),s=this.retryDate;(!s||r>=s||(t=this.media)!=null&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=W.IDLE);break}case W.WAITING_INIT_PTS:{let r=this.waitingData;if(r){let{frag:s,part:n,cache:a,complete:o}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=W.FRAG_LOADING;let l=a.flush(),d={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{let l=this.getLoadPosition(),d=Xe.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);Uh(d.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=W.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=W.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){let{hls:e,levels:t,media:r,trackId:s}=this,n=e.config;if(!(t!=null&&t[s])||!r&&(this.startFragRequested||!n.startFragPrefetch))return;let a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(o)){this.state=W.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Ve.AUDIO,he.AUDIO));let d=this.getFwdBufferInfo(l,he.AUDIO);if(d===null)return;let{bufferedTrack:c,switchingTrack:u}=this;if(!u&&this._streamEnded(d,o)){e.trigger(b.BUFFER_EOS,{type:"audio"}),this.state=W.ENDED;return}let h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,he.MAIN),f=d.len,g=this.getMaxBufferLength(h==null?void 0:h.len);if(f>=g&&!u)return;let T=o.fragments[0].start,S=d.end;if(u&&r){let R=this.getLoadPosition();c&&u.attrs!==c.attrs&&(S=R),o.PTSKnown&&R<T&&(d.end>T||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=T+.05)}let k=this.getNextFragment(S,o),L=!1;if(k&&this.isLoopLoading(k,S)&&(L=!!k.gap,k=this.getNextFragmentLoopLoading(k,o,d,he.MAIN,g)),!k){this.bufferFlushed=!0;return}let F=h&&k.start>h.end+o.targetduration;if(F||!(h!=null&&h.len)&&d.len){let R=this.getAppendedFrag(k.start,he.MAIN);if(R===null||(L||(L=!!R.gap||!!F&&h.len===0),F&&!L||L&&d.nextStart&&d.nextStart<R.end))return}this.loadFragment(k,a,S)}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new Zr(r))}onAudioTrackSwitching(e,t){let r=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(pv):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=W.IDLE):(this.switchingTrack=null,this.bufferedTrack=t,this.state=W.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(b.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}let{levels:s}=this,{details:n,id:a}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let o=s[a],l=0;if(n.live||(r=o.details)!=null&&r.live){this.checkLiveUpdate(n);let d=this.mainDetails;if(n.deltaUpdateFailed||!d)return;!o.details&&n.hasProgramDateTime&&d.hasProgramDateTime?(zv(n,d),l=n.fragments[0].start):l=this.alignPlaylists(n,o.details)}o.details=n,this.levelLastLoaded=a,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(o.details,l),this.state===W.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=W.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}let c=d.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}let u=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new dd(this.hls,he.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[r.cc],g=(t=r.initSegment)==null?void 0:t.data;if(f!==void 0){let T=s?s.index:-1,S=T!==-1,k=new va(r.level,r.sn,r.stats.chunkCount,n.byteLength,T,S);h.push(n,g,u,"",r,s,c.totalduration,!1,k,f)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);let{cache:E}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new cd,complete:!1};E.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=W.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){let r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r.type!==he.AUDIO){if(!this.loadedmetadata&&r.type===he.MAIN){let n=this.videoBuffer||this.media;n&&Xe.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(b.AUDIO_TRACK_SWITCHED,Nt({},n)))}this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=W.ERROR;return}switch(t.details){case $.FRAG_GAP:case $.FRAG_PARSING_ERROR:case $.FRAG_DECRYPT_ERROR:case $.FRAG_LOAD_ERROR:case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_ERROR:case $.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(he.AUDIO,t);break;case $.AUDIO_TRACK_LOAD_ERROR:case $.AUDIO_TRACK_LOAD_TIMEOUT:case $.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===W.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===Me.AUDIO_TRACK&&(this.state=W.IDLE);break;case $.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case $.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushed(e,{type:t}){t===Ve.AUDIO&&(this.bufferFlushed=!0,this.state===W.ENDED&&(this.state=W.IDLE))}_handleTransmuxComplete(e){var t;let r="audio",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:c}=o,{details:u}=c,{audio:h,text:f,id3:g,initSegment:E}=n;if(this.fragContextChanged(l)||!u){this.fragmentTracker.removeFragment(l);return}if(this.state=W.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),E!=null&&E.tracks){let T=l.initSegment||l;this._bufferInitSegment(E.tracks,T,a),s.trigger(b.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:r,tracks:E.tracks})}if(h){let{startPTS:T,endPTS:S,startDTS:k,endDTS:L}=h;d&&(d.elementaryStreams[Ve.AUDIO]={startPTS:T,endPTS:S,startDTS:k,endDTS:L}),l.setElementaryStreamInfo(Ve.AUDIO,T,S,k,L),this.bufferFragmentData(h,l,d,a)}if(g!=null&&(t=g.samples)!=null&&t.length){let T=ft({id:r,frag:l,details:u},g);s.trigger(b.FRAG_PARSING_METADATA,T)}if(f){let T=ft({id:r,frag:l,details:u},f);s.trigger(b.FRAG_PARSING_USERDATA,T)}}_bufferInitSegment(e,t,r){if(this.state!==W.PARSING)return;e.video&&delete e.video;let s=e.audio;if(!s)return;s.levelCodec=s.codec,s.id="audio",this.log(`Init audio buffer, container:${s.container}, codecs[parsed]=[${s.codec}]`),this.hls.trigger(b.BUFFER_CODECS,e);let n=s.initSegment;if(n!=null&&n.byteLength){let a={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:n};this.hls.trigger(b.BUFFER_APPENDING,a)}this.tick()}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===yt.NOT_LOADED||s===yt.PARTIAL){var n;e.sn==="initSegment"?this._loadInitSegment(e,t):(n=t.details)!=null&&n.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=W.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(e,t,r))}else this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){let{hls:t,media:r,bufferedTrack:s}=this,n=s==null?void 0:s.attrs,a=e.attrs;r&&n&&(n.CHANNELS!==a.CHANNELS||n.NAME!==a.NAME||n.LANGUAGE!==a.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(b.AUDIO_TRACK_SWITCHED,Nt({},e))}},df=class extends ga{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(b.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(b.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Track with id:${r} and group:${s} not found in active group ${a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`audio-track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!(t!=null&&t.audioGroupIds))return;let r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r||null;let s=this.tracks.filter(a=>!r||a.groupId===r);this.selectDefaultTrack&&!s.some(a=>a.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=s;let n={audioTracks:s};this.log(`Updating audio tracks, ${s.length} track(s) found in group:${r}`),this.hls.trigger(b.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===Me.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();let r=this.currentTrack;t[this.trackId];let s=t[e],{groupId:n,name:a}=s;if(this.log(`Switching to audio-track ${e} "${a}" lang:${s.lang} group:${n}`),this.trackId=e,this.currentTrack=s,this.selectDefaultTrack=!1,this.hls.trigger(b.AUDIO_TRACK_SWITCHING,Nt({},s)),s.details&&!s.details.live)return;let o=this.switchParams(s.url,r==null?void 0:r.details);this.loadPlaylist(o)}selectInitialTrack(){let e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(t!==-1)this.setAudioTrack(t);else{let r=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(r.message),this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:r})}}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if((!this.selectDefaultTrack||s.default)&&(!e||e.attrs["STABLE-RENDITION-ID"]!==void 0&&e.attrs["STABLE-RENDITION-ID"]===s.attrs["STABLE-RENDITION-ID"]||e.name===s.name&&e.lang===s.lang))return s.id}return-1}loadPlaylist(e){super.loadPlaylist();let t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(b.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}};function dE(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!aS(i[t].attrs,e[t].attrs))return!1;return!0}function aS(i,e){let t=i["STABLE-RENDITION-ID"];return t?t===e["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(r=>i[r]!==e[r])}var gv=500,cf=class extends ba{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",he.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.ERROR,this.onError,this),e.on(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(b.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(b.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.ERROR,this.onError,this),e.off(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(b.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(b.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=W.IDLE,this.setInterval(gv),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=W.IDLE,!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=r.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=r.start+r.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r)}onBufferFlushing(e,t){let{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){let n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(r,n,he.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===he.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let r=t.frag;(r==null?void 0:r.type)===he.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==W.STOPPED&&(this.state=W.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(dE(this.levels,t)){this.levels=t.map(r=>new Zr(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{let s=new Zr(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,he.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){if(this.currentTrackId=t.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}let r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(gv)}onSubtitleTrackLoaded(e,t){var r;let{details:s,id:n}=t,{currentTrackId:a,levels:o}=this;if(!o.length)return;let l=o[a];if(n>=o.length||n!==a||!l)return;this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(s.live||(r=l.details)!=null&&r.live){let c=this.mainDetails;if(s.deltaUpdateFailed||!c)return;let u=c.fragments[0];l.details?(d=this.alignPlaylists(s,l.details),d===0&&u&&(d=u.start,Nh(s,d))):s.hasProgramDateTime&&c.hasProgramDateTime?(zv(s,c),d=s.fragments[0].start):u&&(d=u.start,Nh(s,d))}l.details=s,this.levelLastLoaded=n,!this.startFragRequested&&(this.mainDetails||!s.live)&&this.setStartPosition(l.details,d),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===W.IDLE&&(pa(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0))}_handleFragmentLoadComplete(e){let{frag:t,payload:r}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{let l=performance.now();n.trigger(b.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=W.IDLE})}}doTick(){if(!this.media){this.state=W.IDLE;return}if(this.state===W.IDLE){let{currentTrackId:e,levels:t}=this,r=t[e];if(!t.length||!r||!r.details)return;let{config:s}=this,n=this.getLoadPosition(),a=Xe.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,he.MAIN),c=r.details,u=this.getMaxBufferLength(d==null?void 0:d.len)+c.levelTargetDuration;if(l>u)return;let h=c.fragments,f=h.length,g=c.edge,E=null,T=this.fragPrevious;if(o<g){let S=s.maxFragLookUpTolerance,k=o>g-S?0:S;E=pa(T,h,Math.max(h[0].start,o),k),!E&&T&&T.start<h[0].start&&(E=h[0])}else E=h[f-1];if(!E)return;if(E=this.mapToInitFragWhenRequired(E),E.sn!=="initSegment"){let S=E.sn-c.startSN,k=h[S-1];k&&k.cc===E.cc&&this.fragmentTracker.getState(k)===yt.NOT_LOADED&&(E=k)}this.fragmentTracker.getState(E)===yt.NOT_LOADED&&this.loadFragment(E,r,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new uf(this.tracksBuffered[this.currentTrackId]||[])}},uf=class{constructor(e){this.buffered=void 0;let t=(r,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}},hf=class extends ga{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(b.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(b.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),bh(this.media.textTracks).forEach(t=>{an(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:r,details:s}=t,{trackId:n}=this,a=this.tracksInGroup[n];if(!a){this.warn(`Invalid subtitle track id ${r}`);return}let o=a.details;a.details=t.details,this.log(`subtitle track ${r} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!(t!=null&&t.textGroupIds))return;let r=t.textGroupIds[t.urlId],s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==r){let n=this.tracks.filter(l=>!r||l.groupId===r);this.tracksInGroup=n;let a=this.findTrackId(s==null?void 0:s.name)||this.findTrackId();this.groupId=r||null;let o={subtitleTracks:n};this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${r}" group-id`),this.hls.trigger(b.SUBTITLE_TRACKS_UPDATED,o),a!==-1&&this.setSubtitleTrack(a,s)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId,s)}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if((!this.selectDefaultTrack||s.default)&&(!e||e===s.name))return s.id}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Me.SUBTITLE_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.checkRetry(t)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;let t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}loadPlaylist(e){super.loadPlaylist();let t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(b.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(e){let{media:t,trackId:r}=this;if(!t)return;let s=bh(t.textTracks),n=s.filter(o=>o.groupId===this.groupId);if(e===-1)[].slice.call(s).forEach(o=>{o.mode="disabled"});else{let o=n[r];o&&(o.mode="disabled")}let a=n[e];a&&(a.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var r;let s=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(r=s[e])!=null&&r.details)||e<-1||e>=s.length)return;this.clearTimer();let n=s[e];if(this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:"")),this.trackId=e,n){let{id:a,groupId:o="",name:l,type:d,url:c}=n;this.hls.trigger(b.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:c});let u=this.switchParams(n.url,t==null?void 0:t.details);this.loadPlaylist(u)}else this.hls.trigger(b.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1,t=bh(this.media.textTracks);for(let r=0;r<t.length;r++)if(t[r].mode==="hidden")e=r;else if(t[r].mode==="showing"){e=r;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}};function bh(i){let e=[];for(let t=0;t<i.length;t++){let r=i[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(i[t])}return e}var ff=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t){let r=this.queues[t];r.push(e),r.length===1&&this.buffers[t]&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,r=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){let{buffers:t,queues:r}=this,s=t[e],n=r[e];if(n.length){let a=n[0];try{a.execute()}catch(o){M.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),a.onError(o),s!=null&&s.updating||(n.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}},vv=Ed(),Ev=/([ha]vc.)(?:\.[^.,]+)+/,mf=class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{let{media:t,mediaSource:r}=this;M.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(b.MEDIA_ATTACHED,{media:t})),r&&r.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{M.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{M.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{let{media:t,_objectUrl:r}=this;t&&t.src!==r&&M.error(`Media element src was set while attaching MediaSource (${r} > ${t.src})`)},this.hls=e,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.BUFFER_RESET,this.onBufferReset,this),e.on(b.BUFFER_APPENDING,this.onBufferAppending,this),e.on(b.BUFFER_CODECS,this.onBufferCodecs,this),e.on(b.BUFFER_EOS,this.onBufferEos,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(b.FRAG_PARSED,this.onFragParsed,this),e.on(b.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.BUFFER_RESET,this.onBufferReset,this),e.off(b.BUFFER_APPENDING,this.onBufferAppending,this),e.off(b.BUFFER_CODECS,this.onBufferCodecs,this),e.off(b.BUFFER_EOS,this.onBufferEos,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(b.FRAG_PARSED,this.onFragParsed,this),e.off(b.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new ff(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,M.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let r=this.media=t.media;if(r&&vv){let s=this.mediaSource=new vv;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(s),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(M.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){M.warn(`[buffer-controller]: onMediaDetaching: ${s.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()):M.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(b.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{let t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(r){M.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,r)}}),this._initSourceBuffer()}onBufferCodecs(e,t){let r=this.getSourceBufferTypes().length;Object.keys(t).forEach(s=>{if(r){let n=this.tracks[s];if(n&&typeof n.buffer.changeType=="function"){let{id:a,codec:o,levelCodec:l,container:d,metadata:c}=t[s],u=(n.levelCodec||n.codec).replace(Ev,"$1"),h=(l||o).replace(Ev,"$1");if(u!==h){let f=`${d};codecs=${l||o}`;this.appendChangeType(s,f),M.log(`[buffer-controller]: switching codec ${u} to ${h}`),this.tracks[s]={buffer:n.buffer,codec:o,container:d,levelCodec:l,metadata:c,id:a}}}}else this.pendingTracks[s]=t[s]}),!r&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(e,t){let{operationQueue:r}=this,s={execute:()=>{let n=this.sourceBuffer[e];n&&(M.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{M.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,n)}};r.append(s,e)}onBufferAppending(e,t){let{hls:r,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:c}=t,u=c.buffering[o],h=self.performance.now();u.start=h;let f=l.stats.buffering,g=d?d.stats.buffering:null;f.start===0&&(f.start=h),g&&g.start===0&&(g.start=h);let E=n.audio,T=!1;o==="audio"&&(E==null?void 0:E.container)==="audio/mpeg"&&(T=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);let S=l.start,k={execute:()=>{if(u.executeStart=self.performance.now(),T){let L=this.sourceBuffer[o];if(L){let F=S-L.timestampOffset;Math.abs(F)>=.1&&(M.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${S} (delta: ${F}) sn: ${l.sn})`),L.timestampOffset=S)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let L=self.performance.now();u.executeEnd=u.end=L,f.first===0&&(f.first=L),g&&g.first===0&&(g.first=L);let{sourceBuffer:F}=this,R={};for(let B in F)R[B]=Xe.getBuffered(F[B]);this.appendError=0,this.hls.trigger(b.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:c,parent:l.type,timeRanges:R})},onError:L=>{M.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,L);let F={type:ue.MEDIA_ERROR,parent:l.type,details:$.BUFFER_APPEND_ERROR,frag:l,part:d,chunkMeta:c,error:L,err:L,fatal:!1};L.code===DOMException.QUOTA_EXCEEDED_ERR?F.details=$.BUFFER_FULL_ERROR:(this.appendError++,F.details=$.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(M.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),F.fatal=!0)),r.trigger(b.ERROR,F)}};s.append(k,o)}onBufferFlushing(e,t){let{operationQueue:r}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(b.BUFFER_FLUSHED,{type:n})},onError:a=>{M.warn(`[buffer-controller]: Failed to remove from ${n} SourceBuffer`,a)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{r.append(s(n),n)})}onFragParsed(e,t){let{frag:r,part:s}=t,n=[],a=s?s.elementaryStreams:r.elementaryStreams;a[Ve.AUDIOVIDEO]?n.push("audiovideo"):(a[Ve.AUDIO]&&n.push("audio"),a[Ve.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);let d=s?s.stats:r.stats;this.hls.trigger(b.FRAG_BUFFERED,{frag:r,part:s,stats:d,id:r.type})};n.length===0&&M.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,n)=>{let a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,M.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(M.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{let a=this.sourceBuffer[n];a&&(a.ending=!1)});let{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&M.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}M.log("[buffer-controller]: Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){let{hls:e,details:t,media:r,sourceBuffer:s}=this;if(!r||t===null)return;let n=this.getSourceBufferTypes();if(!n.length)return;let a=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!oe(a)||a<0)return;let o=r.currentTime,l=t.levelTargetDuration,d=Math.max(a,l),c=Math.floor(o/l)*l-d;n.forEach(u=>{let h=s[u];if(h){let f=Xe.getBuffered(h);if(f.length>0&&c>f.start(0)){if(e.trigger(b.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(b.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(h.ended&&f.end(f.length-1)-o<l*2){M.info(`[buffer-controller]: Cannot flush ${u} back buffer while SourceBuffer is in ended state`);return}e.trigger(b.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:u})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;let{details:e,hls:t,media:r,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=r.duration,o=oe(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(M.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!oe(a))&&(M.log(`[buffer-controller]: Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(e){let t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,a)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&!e||s===2){this.createSourceBuffers(r),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(b.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{let a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(let s in e)if(!t[s]){let n=e[s];if(!n)throw Error(`source buffer exists for track ${s}, however track does not`);let a=n.levelCodec||n.codec,o=`${n.container};codecs=${a}`;M.log(`[buffer-controller]: creating sourceBuffer(${o})`);try{let l=t[s]=r.addSourceBuffer(o),d=s;this.addBufferListener(d,"updatestart",this._onSBUpdateStart),this.addBufferListener(d,"updateend",this._onSBUpdateEnd),this.addBufferListener(d,"error",this._onSBUpdateError),this.tracks[s]={buffer:l,codec:a,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(l){M.error(`[buffer-controller]: error while trying to add sourceBuffer: ${l.message}`),this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:o})}}}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){let{operationQueue:t}=this;t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){let r=new Error(`${e} SourceBuffer error`);M.error(`[buffer-controller]: ${r}`,t),this.hls.trigger(b.ERROR,{type:ue.MEDIA_ERROR,details:$.BUFFER_APPENDING_ERROR,error:r,fatal:!1});let s=this.operationQueue.current(e);s&&s.onError(t)}removeExecutor(e,t,r){let{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!s||!n||!l){M.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let d=oe(s.duration)?s.duration:1/0,c=oe(n.duration)?n.duration:1/0,u=Math.max(0,t),h=Math.min(r,d,c);h>u&&!l.ending?(l.ended=!1,M.log(`[buffer-controller]: Removing [${u},${h}] from the ${e} SourceBuffer`),l.remove(u,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){let{operationQueue:r,sourceBuffer:s}=this,n=s[t];if(!n){M.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),r.shiftAndExecuteNext(t);return}n.ended=!1,n.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){M.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:r}=this,s=t.map(n=>r.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||r.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){let s=this.sourceBuffer[e];if(!s)return;let n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){let t=this.sourceBuffer[e];t&&this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}},bv={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},cE=function(e){let t=e;return bv.hasOwnProperty(e)&&(t=bv[e]),String.fromCharCode(t)},yi=15,Zi=100,oS={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},lS={17:2,18:4,21:6,22:8,23:10,19:13,20:15},dS={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},cS={25:2,26:4,29:6,30:8,31:10,27:13,28:15},uS=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],pf=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let r=typeof t=="function"?t():t;M.log(`${this.time} [${e}] ${r}`)}}},Yr=function(e){let t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t},ud=class{constructor(e,t,r,s,n){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=s||"black",this.flash=n||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){let s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},gf=class{constructor(e,t,r,s,n,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new ud(t,r,s,n,a)}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}},vf=class{constructor(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let t=0;t<Zi;t++)this.chars.push(new gf);this.logger=e,this.pos=0,this.currPenState=new ud}equals(e){let t=!0;for(let r=0;r<Zi;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t}copy(e){for(let t=0;t<Zi;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Zi;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Zi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Zi)}moveCursor(e){let t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=cE(e);if(this.pos>=Zi){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Zi;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let r=0;r<Zi;r++){let s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},fa=class{constructor(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let t=0;t<yi;t++)this.rows.push(new vf(e));this.logger=e,this.currRow=yi-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<yi;e++)this.rows[e].clear();this.currRow=yi-1}equals(e){let t=!0;for(let r=0;r<yi;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<yi;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<yi;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<yi;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,l=this.logger.time;if(o&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;let r=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);r.setCursor(e.indent),e.color=r.chars[a].penState.foreground}let s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],r="",s=-1;for(let n=0;n<yi;n++){let a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
1145
+ `)),r}getTextAndFormat(){return this.rows}},hd=class{constructor(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 fa(r),this.nonDisplayedMemory=new fa(r),this.lastOutputScreen=new fa(r),this.currRollUpRow=this.displayedMemory.rows[yi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[yi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{let r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}},fd=class{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;let s=new pf;this.channels=[null,new hd(e,t,s),new hd(e+1,r,s)],this.cmdHistory=Tv(),this.logger=s}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let r,s,n,a=!1;this.logger.time=e;for(let o=0;o<t.length;o+=2)if(s=t[o]&127,n=t[o+1]&127,!(s===0&&n===0)){if(this.logger.log(3,"["+Yr([t[o],t[o+1]])+"] -> ("+Yr([s,n])+")"),r=this.parseCmd(s,n),r||(r=this.parseMidrow(s,n)),r||(r=this.parsePAC(s,n)),r||(r=this.parseBackgroundAttributes(s,n)),!r&&(a=this.parseChars(s,n),a)){let l=this.currentChannel;l&&l>0?this.channels[l].insertChars(a):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!r&&!a&&this.logger.log(2,"Couldn't parse cleaned data "+Yr([s,n])+" orig: "+Yr([t[o],t[o+1]]))}}parseCmd(e,t){let{cmdHistory:r}=this,s=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,n=(e===23||e===31)&&t>=33&&t<=35;if(!(s||n))return!1;if(yv(e,t,r))return nn(null,null,r),this.logger.log(3,"Repeated command ("+Yr([e,t])+") is dropped"),!0;let a=e===20||e===21||e===23?1:2,o=this.channels[a];return e===20||e===21||e===28||e===29?t===32?o.ccRCL():t===33?o.ccBS():t===34?o.ccAOF():t===35?o.ccAON():t===36?o.ccDER():t===37?o.ccRU(2):t===38?o.ccRU(3):t===39?o.ccRU(4):t===40?o.ccFON():t===41?o.ccRDC():t===42?o.ccTR():t===43?o.ccRTD():t===44?o.ccEDM():t===45?o.ccCR():t===46?o.ccENM():t===47&&o.ccEOC():o.ccTO(t-32),nn(e,t,r),this.currentChannel=a,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,"MIDROW ("+Yr([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r,s=this.cmdHistory,n=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,a=(e===16||e===24)&&t>=64&&t<=95;if(!(n||a))return!1;if(yv(e,t,s))return nn(null,null,s),!0;let o=e<=23?1:2;t>=64&&t<=95?r=o===1?oS[e]:dS[e]:r=o===1?lS[e]:cS[e];let l=this.channels[o];return l?(l.setPAC(this.interpretPAC(r,t)),nn(e,t,s),this.currentChannel=o,!0):!1}interpretPAC(e,t){let r,s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,"Special char '"+cE(a)+"' in channel "+r),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);if(s){let a=Yr(s);this.logger.log(3,"Char codes = "+a.join(",")),nn(e,t,this.cmdHistory)}return s}parseBackgroundAttributes(e,t){let r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=uS[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));let o=e<=23?1:2;return this.channels[o].setBkgData(a),nn(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}this.cmdHistory=Tv()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let r=this.channels[t];r&&r.cueSplitAtTime(e)}}};function nn(i,e,t){t.a=i,t.b=e}function yv(i,e,t){return t.a===i&&t.b===e}function Tv(){return{a:null,b:null}}var on=class{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},Ff=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;let i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;let d=l.toLowerCase();return~o.indexOf(d)?d:!1}function r(o){return t(i,o)}function s(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){let c=arguments[d];for(let u in c)o[u]=c[u]}return o}function a(o,l,d){let c=this,u={enumerable:!0};c.hasBeenReset=!1;let h="",f=!1,g=o,E=l,T=d,S=null,k="",L=!0,F="auto",R="start",B=50,P="middle",H=50,V="middle";Object.defineProperty(c,"id",n({},u,{get:function(){return h},set:function(N){h=""+N}})),Object.defineProperty(c,"pauseOnExit",n({},u,{get:function(){return f},set:function(N){f=!!N}})),Object.defineProperty(c,"startTime",n({},u,{get:function(){return g},set:function(N){if(typeof N!="number")throw new TypeError("Start time must be set to a number.");g=N,this.hasBeenReset=!0}})),Object.defineProperty(c,"endTime",n({},u,{get:function(){return E},set:function(N){if(typeof N!="number")throw new TypeError("End time must be set to a number.");E=N,this.hasBeenReset=!0}})),Object.defineProperty(c,"text",n({},u,{get:function(){return T},set:function(N){T=""+N,this.hasBeenReset=!0}})),Object.defineProperty(c,"region",n({},u,{get:function(){return S},set:function(N){S=N,this.hasBeenReset=!0}})),Object.defineProperty(c,"vertical",n({},u,{get:function(){return k},set:function(N){let j=r(N);if(j===!1)throw new SyntaxError("An invalid or illegal string was specified.");k=j,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",n({},u,{get:function(){return L},set:function(N){L=!!N,this.hasBeenReset=!0}})),Object.defineProperty(c,"line",n({},u,{get:function(){return F},set:function(N){if(typeof N!="number"&&N!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");F=N,this.hasBeenReset=!0}})),Object.defineProperty(c,"lineAlign",n({},u,{get:function(){return R},set:function(N){let j=s(N);if(!j)throw new SyntaxError("An invalid or illegal string was specified.");R=j,this.hasBeenReset=!0}})),Object.defineProperty(c,"position",n({},u,{get:function(){return B},set:function(N){if(N<0||N>100)throw new Error("Position must be between 0 and 100.");B=N,this.hasBeenReset=!0}})),Object.defineProperty(c,"positionAlign",n({},u,{get:function(){return P},set:function(N){let j=s(N);if(!j)throw new SyntaxError("An invalid or illegal string was specified.");P=j,this.hasBeenReset=!0}})),Object.defineProperty(c,"size",n({},u,{get:function(){return H},set:function(N){if(N<0||N>100)throw new Error("Size must be between 0 and 100.");H=N,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",n({},u,{get:function(){return V},set:function(N){let j=s(N);if(!j)throw new SyntaxError("An invalid or illegal string was specified.");V=j,this.hasBeenReset=!0}})),c.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),Ef=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function uE(i){function e(r,s,n,a){return(r|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}let t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}var bf=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}};function hE(i,e,t,r){let s=r?i.split(r):[i];for(let n in s){if(typeof s[n]!="string")continue;let a=s[n].split(t);if(a.length!==2)continue;let o=a[0],l=a[1];e(o,l)}}var yf=new Ff(0,0,""),ql=yf.align==="middle"?"middle":"center";function hS(i,e,t){let r=i;function s(){let o=uE(i);if(o===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new bf;hE(o,function(h,f){let g;switch(h){case"region":for(let E=t.length-1;E>=0;E--)if(t[E].id===f){d.set(h,t[E].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":g=f.split(","),d.integer(h,g[0]),d.percent(h,g[0])&&d.set("snapToLines",!1),d.alt(h,g[0],["auto"]),g.length===2&&d.alt("lineAlign",g[1],["start",ql,"end"]);break;case"position":g=f.split(","),d.percent(h,g[0]),g.length===2&&d.alt("positionAlign",g[1],["start",ql,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",ql,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let c=d.get("line","auto");c==="auto"&&yf.line===-1&&(c=-1),l.line=c,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",ql);let u=d.get("position","auto");u==="auto"&&yf.position===50&&(u=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=u}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),a(),e.endTime=s(),a(),n(i,e)}function fE(i){return i.replace(/<br(?: \/)?>/gi,`
1146
+ `)}var Tf=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Ef,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){let t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function r(){let n=t.buffer,a=0;for(n=fE(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
1072
1147
  `;)++a;let o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
1073
- `&&++a,t.buffer=n.slice(a),o}function s(n){Jv(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=r();let o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=r(),t.state){case"HEADER":/:/.test(n)?s(n):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 wf(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{j1(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let o=n.indexOf("-->")!==-1;if(!n||o&&(a=!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+=`
1148
+ `&&++a,t.buffer=n.slice(a),o}function s(n){hE(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=r();let o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=r(),t.state){case"HEADER":/:/.test(n)?s(n):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 Ff(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{hS(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let o=n.indexOf("-->")!==-1;if(!n||o&&(a=!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+=`
1074
1149
  `),t.cue.text+=n}continue;case"BADCUE":n||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){let e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
1075
1150
 
1076
- `,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}},z1=/\r\n|\n\r|\n|\r/g,hh=function(e,t,r=0){return e.slice(r,r+t.length)===t},X1=function(e){let t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!oe(t)||!oe(r)||!oe(s)||!oe(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=60*1e3*s,t+=60*60*1e3*n,t},fh=function(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0).toString()};function Df(i,e,t){return fh(i.toString())+fh(e.toString())+fh(t)}var Q1=function(e,t,r){let s=e[t],n=e[s.prevCC];if(!n||!n.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=s.start-n.start,s.new=!1,s=n,n=e[s.prevCC]}e.presentationOffset=r};function Z1(i,e,t,r,s,n,a){let o=new ff,l=$i(new Uint8Array(i)).trim().replace(z1,`
1151
+ `,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}},fS=/\r\n|\n\r|\n|\r/g,yh=function(e,t,r=0){return e.slice(r,r+t.length)===t},mS=function(e){let t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!oe(t)||!oe(r)||!oe(s)||!oe(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=60*1e3*s,t+=60*60*1e3*n,t},Th=function(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0).toString()};function Bf(i,e,t){return Th(i.toString())+Th(e.toString())+Th(t)}var pS=function(e,t,r){let s=e[t],n=e[s.prevCC];if(!n||!n.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=s.start-n.start,s.new=!1,s=n,n=e[s.prevCC]}e.presentationOffset=r};function gS(i,e,t,r,s,n,a){let o=new Tf,l=Wi(new Uint8Array(i)).trim().replace(fS,`
1077
1152
  `).split(`
1078
- `),d=[],c=e?w1(e.baseTime,e.timescale):0,u="00:00.000",h=0,f=0,g,E=!0;o.oncue=function(T){let A=t[r],k=t.ccOffset,L=(h-c)/9e4;if(A!=null&&A.new&&(f!==void 0?k=t.ccOffset=A.start:Q1(t,r,L)),L){if(!e){g=new Error("Missing initPTS for VTT MPEGTS");return}k=L-t.presentationOffset}let F=T.endTime-T.startTime,R=ni((T.startTime+k-f)*9e4,s*9e4)/9e4;T.startTime=Math.max(R,0),T.endTime=Math.max(R+F,0);let B=T.text.trim();T.text=decodeURIComponent(encodeURIComponent(B)),T.id||(T.id=Df(T.startTime,T.endTime,B)),T.endTime>0&&d.push(T)},o.onparsingerror=function(T){g=T},o.onflush=function(){if(g){a(g);return}n(d)},l.forEach(T=>{if(E)if(hh(T,"X-TIMESTAMP-MAP=")){E=!1,T.slice(16).split(",").forEach(A=>{hh(A,"LOCAL:")?u=A.slice(6):hh(A,"MPEGTS:")&&(h=parseInt(A.slice(7)))});try{f=X1(u)/1e3}catch(A){g=A}return}else T===""&&(E=!1);o.parse(T+`
1079
- `)}),o.flush()}var mh="stpp.ttml.im1t",tE=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,iE=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,J1={left:"start",center:"center",right:"end",start:"start",end:"end"};function dv(i,e,t,r){let s=Ce(new Uint8Array(i),["mdat"]);if(s.length===0){r(new Error("Could not parse IMSC1 mdat"));return}let n=s.map(o=>$i(o)),a=k1(e.baseTime,1,e.timescale);try{n.forEach(o=>t(eS(o,a)))}catch(o){r(o)}}function eS(i,e){let s=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");let n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((u,h)=>(u[h]=s.getAttribute(`ttp:${h}`)||n[h],u),{}),o=s.getAttribute("xml:space")!=="preserve",l=cv(ph(s,"styling","style")),d=cv(ph(s,"layout","region")),c=ph(s,"body","[begin]");return[].map.call(c,u=>{let h=rE(u,o);if(!h||!u.hasAttribute("begin"))return null;let f=vh(u.getAttribute("begin"),a),g=vh(u.getAttribute("dur"),a),E=vh(u.getAttribute("end"),a);if(f===null)throw uv(u);if(E===null){if(g===null)throw uv(u);E=f+g}let T=new wf(f-e,E-e,h);T.id=Df(T.startTime,T.endTime,T.text);let A=d[u.getAttribute("region")],k=l[u.getAttribute("style")],L=tS(A,k,l),{textAlign:F}=L;if(F){let R=J1[F];R&&(T.lineAlign=R),T.align=F}return ht(T,L),T}).filter(u=>u!==null)}function ph(i,e,t){let r=i.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function cv(i){return i.reduce((e,t)=>{let r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function rE(i,e){return[].slice.call(i.childNodes).reduce((t,r,s)=>{var n;return r.nodeName==="br"&&s?t+`
1080
- `:(n=r.childNodes)!=null&&n.length?rE(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function tS(i,e,t){let r="http://www.w3.org/ns/ttml#styling",s=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{let d=gh(e,r,l)||gh(i,r,l)||gh(s,r,l);return d&&(o[l]=d),o},{})}function gh(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function uv(i){return new Error(`Could not parse ttml timestamp ${i}`)}function vh(i,e){if(!i)return null;let t=Zv(i);return t===null&&(tE.test(i)?t=iS(i,e):iE.test(i)&&(t=rS(i,e))),t}function iS(i,e){let t=tE.exec(i),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function rS(i,e){let t=iE.exec(i),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}var mf=class{constructor(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=hv(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){let t=new an(this,"textTrack1"),r=new an(this,"textTrack2"),s=new an(this,"textTrack3"),n=new an(this,"textTrack4");this.cea608Parser1=new ad(1,t,r),this.cea608Parser2=new ad(3,s,n)}e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(b.FRAG_LOADING,this.onFragLoading,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(b.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(b.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(b.FRAG_LOADING,this.onFragLoading,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(b.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(b.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,r,s,n){let a=!1;for(let o=n.length;o--;){let l=n[o],d=nS(l[0],l[1],t,r);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),a=!0,d/(r-t)>.5))return}if(a||n.push([t,r]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,r,s)}else{let o=this.Cues.newCue(null,t,r,s);this.hls.trigger(b.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){let{unparsedVttFrags:a}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(b.FRAG_LOADED,o)}))}getExistingTrack(e){let{media:t}=this;if(t)for(let r=0;r<t.textTracks.length;r++){let s=t.textTracks[r];if(s[e])return s}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:r,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(e);if(o)r[e]=o,nn(r[e]),kv(r[e],s);else{let l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(b.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){let s=this.media;if(s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{nn(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=hv(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let r=0;r<t.length;r++)nn(t[r])}onSubtitleTracksUpdated(e,t){let r=t.subtitleTracks||[],s=r.some(n=>n.textCodec===mh);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(Xv(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){let a=this.media?this.media.textTracks:null;this.tracks.forEach((o,l)=>{let d;if(a&&l<a.length){let c=null;for(let u=0;u<a.length;u++)if(sS(a[u],o)){c=a[u];break}c&&(d=c)}if(d)nn(d);else{let c=this._captionsOrSubtitlesFromCharacteristics(o);d=this.createTextTrack(c,o.name,o.lang),d&&(d.mode="disabled")}d&&(d.groupId=o.groupId,this.textTracks.push(d))})}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(b.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){let 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"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{let s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;let n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=r.name,r.lang&&(a.languageCode=r.lang),a.media=r)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){let{cea608Parser1:r,cea608Parser2:s,lastSn:n,lastPartIndex:a}=this;if(!(!this.enabled||!(r&&s))&&t.frag.type===he.MAIN){var o,l;let d=t.frag.sn,c=(o=t==null||(l=t.part)==null?void 0:l.index)!=null?o:-1;d===n+1||d===n&&c===a+1||(r.reset(),s.reset()),this.lastSn=d,this.lastPartIndex=c}}onFragLoaded(e,t){let{frag:r,payload:s}=t;if(r.type===he.SUBTITLE)if(s.byteLength){let n=r.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),o&&o.textCodec===mh?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let r=this.hls;dv(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{M.log(`Failed to parse IMSC1: ${s}`),r.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;let{frag:r,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[r.cc]&&o===-1){a.push(e);return}let l=this.hls,d=(t=r.initSegment)!=null&&t.data?Xr(r.initSegment.data,new Uint8Array(s)):s;Z1(d,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,c=>{this._appendCues(c,r.level),l.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},c=>{let u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(r,s),M.log(`Failed to parse VTT cue: ${c}`),!(u&&o>r.cc)&&l.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:c})})}_fallbackToIMSC1(e,t){let r=this.tracks[e.level];r.textCodec||dv(t,this.initPTS[e.cc],()=>{r.textCodec=mh,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){let r=this.hls;if(this.config.renderTextTracksNatively){let s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>wv(s,n))}else{let s=this.tracks[t];if(!s)return;let n=s.default?"default":"subtitles"+t;r.trigger(b.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){let{frag:r}=t;r.type===he.SUBTITLE&&this.onFragLoaded(b.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){let{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!(r&&s))return;let{frag:n,samples:a}=t;if(!(n.type===he.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){let l=a[o].bytes;if(l){let d=this.extractCea608Data(l);r.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:n}){let{media:a}=this;if(!(!a||a.currentTime<r)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>Ah(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>Ah(o[l],t,s))}}}extractCea608Data(e){let t=[[],[]],r=e[0]&31,s=2;for(let n=0;n<r;n++){let a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){let c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(l))}}return t}};function sS(i,e){return!!i&&i.label===e.name&&!(i.textTrack1||i.textTrack2)}function nS(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function hv(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var pf=class i{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(b.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.BUFFER_CODECS,this.onBufferCodecs,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(b.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.BUFFER_CODECS,this.onBufferCodecs,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){let r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){let e=this.hls.levels;if(e.length){let t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return-1;let r=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,i.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let 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}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;let s=(a,o)=>o?a.width!==o.width||a.height!==o.height:!0,n=e.length-1;for(let a=0;a<e.length;a+=1){let o=e[a];if((o.width>=t||o.height>=r)&&s(o,e[a+1])){n=a;break}}return n}},gf=class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let r=this.hls.config;if(r.capLevelOnFPSDrop){let s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){let s=performance.now();if(t){if(this.lastTime){let n=s-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(b.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let c=d.currentLevel;M.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=c)&&(c=c-1,d.trigger(b.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},$l="[eme]",od=class i{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=M.debug.bind(M,$l),this.log=M.log.bind(M,$l),this.warn=M.warn.bind(M,$l),this.error=M.error.bind(M,$l),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(b.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(b.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(b.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(b.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===tt.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){let{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,r=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(r),n=t.map(a=>a.videoCodec).filter(r);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let l=d=>{let c=d.shift();this.getMediaKeysPromise(c,s,n).then(u=>a({keySystem:c,mediaKeys:u})).catch(u=>{d.length?l(d):u instanceof Vt?o(u):o(new Vt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_ACCESS,error:u,fatal:!0},u.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return vv===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){let s=sA(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);let o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(c=>(this.log(`Media-keys created for "${e}"`),d.then(u=>u?this.setMediaKeysServerCertificate(c,e,u):c))),o.mediaKeys.catch(c=>{this.error(`Failed to create media-keys for "${e}"}: ${c}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${Fi.hexDump(e.keyId||[])}`);let s=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Fi.hexDump(e.keyId)}updateKeySession(e,t){var r;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Fi.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
1081
- } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{let s=Zu(this.config),n=e.map(k0).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=w0(a);o?t(o):r(new Error(`Unable to find format for key-system "${a}"`))}).catch(r)})}loadKey(e){let t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();let l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t}),d="cenc";return this.generateRequestWithPreferredKeySession(l,d,t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Vt?this.hls.trigger(b.ERROR,e.data):this.hls.trigger(b.ERROR,{type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){let s=k0(e.keyFormat),n=s?[s]:Zu(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=Zu(this.config)),e.length===0)throw new Vt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){let{initDataType:t,initData:r}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),r===null)return;let s,n;if(t==="sinf"&&this.config.drmSystems[tt.FAIRPLAY]){let c=yt(new Uint8Array(r));try{let u=_f(JSON.parse(c).sinf),h=xv(new Uint8Array(u));if(!h)return;s=h.subarray(8,24),n=tt.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{let c=RA(r);if(c===null)return;c.version===0&&c.systemId===gv.WIDEVINE&&c.data&&(s=c.data.subarray(8,24)),n=rA(c.systemId)}if(!n||!s)return;let a=Fi.hexDump(s),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this,d=o[a];for(let c=0;c<l.length;c++){let u=l[c],h=u.decryptdata;if(h.pssh||!h.keyId)continue;let f=Fi.hexDump(h.keyId);if(a===f||h.uri.replace(/-/g,"").indexOf(a)!==-1){d=o[f],delete o[f],h.pssh=new Uint8Array(r),h.keyId=s,d=o[a]=d.then(()=>this.generateRequestWithPreferredKeySession(u,t,r,"encrypted-event-key-match"));break}}d||(d=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:c,mediaKeys:u})=>{var h;this.throwIfDestroyed();let f=new da("ISO-23001-7",a,(h=w0(c))!=null?h:"");return f.pssh=new Uint8Array(r),f.keyId=s,this.attemptSetMediaKeys(c,u).then(()=>{this.throwIfDestroyed();let g=this.createMediaKeySessionContext({decryptdata:f,keySystem:c,mediaKeys:u});return this.generateRequestWithPreferredKeySession(g,t,r,"encrypted-event-no-match")})})),d.catch(c=>this.handleError(c))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){let r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>r.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var n,a;let o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{let h=o.call(this.hls,t,r,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,r=e.decryptdata.pssh=h.initData?new Uint8Array(h.initData):null}catch(h){var l;if(this.warn(h.message),(l=this.hls)!=null&&l.config.debug)throw h}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);let d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${d} (init data type: ${t} length: ${r?r.byteLength:null})`);let c=new kf;e.mediaKeysSession.onmessage=h=>{let f=e.mediaKeysSession;if(!f){c.emit("error",new Error("invalid state"));return}let{messageType:g,message:E}=h;this.log(`"${g}" message event for session "${f.sessionId}" message size: ${E.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,E).catch(T=>{this.handleError(T),c.emit("error",T)}):g==="license-release"?e.keySystem===tt.FAIRPLAY&&(this.updateKeySession(e,pv("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},e.mediaKeysSession.onkeystatuseschange=h=>{if(!e.mediaKeysSession){c.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let g=e.keyStatus;c.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};let u=new Promise((h,f)=>{c.on("error",f),c.on("keyStatus",g=>{g.startsWith("usable")?h():g==="output-restricted"?f(new Vt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?f(new Vt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?f(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var h;this.log(`Request generated for key-session "${(h=e.mediaKeysSession)==null?void 0:h.sessionId}" keyId: ${d}`)}).catch(h=>{throw new Vt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_SESSION,error:h,fatal:!1},`Error generating key-session request: ${h}`)}).then(()=>u).catch(h=>{throw c.removeAllListeners(),this.removeSession(e),h}).then(()=>(c.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Fi.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${Fi.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,r=t.loader,s=new r(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching serverCertificate for "${e}"`),new Promise((a,o)=>{let l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,E)=>{a(h.data)},onError:(h,f,g,E)=>{o(new Vt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:Ct({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,g)=>{o(new Vt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,g)=>{o(new Error("aborted"))}};s.load(l,c,u)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,n)=>{e.setServerCertificate(r).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new Vt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new Vt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}setupLicenseXHR(e,t,r,s){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,s)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,r,s)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){let r=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{let a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(c){this.error(c)}s(l)}else{let l=r.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new Vt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{let c=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},da.clearKeyUriToKeyIdMap();let r=t.length;i.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}. media.src: ${e==null?void 0:e.src}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}. media.src: ${e==null?void 0:e.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let r=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),t.onmessage=null,t.onkeystatuseschange=null,r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}};od.CDMCleanupPromise=void 0;var Vt=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},aS=1,Gt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},oS="h",vf=class i{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:Gt.MANIFEST,su:!this.initialized})}catch(n){M.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{let n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===Gt.VIDEO||o===Gt.AUDIO||o==Gt.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){M.warn("Could not generate segment CMCD data.",n)}},this.hls=e;let t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||i.uuid(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.registerListeners())}registerListeners(){let e=this.hls;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHED,this.onMediaDetached,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHED,this.onMediaDetached,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:aS,sf:oS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ht(t,this.createData());let r=t.ot===Gt.INIT||t.ot===Gt.VIDEO||t.ot===Gt.MUXED;if(this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){let s=i.toHeaders(t);if(!Object.keys(s).length)return;e.headers||(e.headers={}),ht(e.headers,s)}else{let s=i.toQuery(t);if(!s)return;e.url=i.appendQueryToUri(e.url,s)}}getObjectType(e){let{type:t}=e;if(t==="subtitle")return Gt.TIMED_TEXT;if(e.sn==="initSegment")return Gt.INIT;if(t==="audio")return Gt.AUDIO;if(t==="main")return this.hls.audioTracks.length?Gt.VIDEO:Gt.MUXED}getTopBandwidth(e){let t=0,r,s=this.hls;if(e===Gt.AUDIO)r=s.audioTracks;else{let n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;r=s.levels.slice(0,a)}for(let n of r)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,r=e===Gt.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:Xe.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}static uuid(){let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}static serialize(e){let t=[],r=d=>!Number.isNaN(d)&&d!=null&&d!==""&&d!==!1,s=d=>Math.round(d),n=d=>s(d/100)*100,o={br:s,d:s,bl:n,dl:n,mtp:n,nor:d=>encodeURIComponent(d),rtp:n,tb:s},l=Object.keys(e||{}).sort();for(let d of l){let c=e[d];if(!r(c)||d==="v"&&c===1||d=="pr"&&c===1)continue;let u=o[d];u&&(c=u(c));let h=typeof c,f;d==="ot"||d==="sf"||d==="st"?f=`${d}=${c}`:h==="boolean"?f=d:h==="number"?f=`${d}=${c}`:f=`${d}=${JSON.stringify(c)}`,t.push(f)}return t.join(",")}static toHeaders(e){let t=Object.keys(e),r={},s=["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};for(let o of t){let l=a[o]!=null?a[o]:1;n[l][o]=e[o]}for(let o=0;o<n.length;o++){let l=i.serialize(n[o]);l&&(r[`CMCD-${s[o]}`]=l)}return r}static toQuery(e){return`CMCD=${encodeURIComponent(i.serialize(e))}`}static appendQueryToUri(e,t){if(!t)return e;let r=e.includes("?")?"&":"?";return`${e}${r}${t}`}},lS=3e5,Ef=class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=M.log.bind(M,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){let e=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:r}=t;if((r==null?void 0:r.action)===Lt.SendAlternateToPenaltyBox&&r.flags===si.MoveAllAlternatesMatchingHost){let s=this.pathwayPriority,n=this.pathwayId;this.penalizedPathways[n]||(this.penalizedPathways[n]=performance.now()),!s&&this.levels&&(s=this.levels.reduce((a,o)=>(a.indexOf(o.pathwayId)===-1&&a.push(o.pathwayId),a),[])),s&&s.length>1&&(this.updatePathwayPriority(s),r.resolved=this.pathwayId!==n)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let 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}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(n=>{s-r[n]>lS&&delete r[n]});for(let n=0;n<e.length;n++){let a=e[n];if(r[a])continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,this.hls.trigger(b.LEVELS_UPDATED,{levels:t});let d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}clonePathways(e){let t=this.levels;if(!t)return;let r={},s={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(c=>c.pathwayId===a))return;let d=this.getLevelsForPathway(o).map(c=>{let u=ht({},c);u.details=void 0,u.url=sE(c.uri,c.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);let h=new et(c.attrs);h["PATHWAY-ID"]=a;let f=h.AUDIO&&`${h.AUDIO}_clone_${a}`,g=h.SUBTITLES&&`${h.SUBTITLES}_clone_${a}`;f&&(r[h.AUDIO]=f,h.AUDIO=f),g&&(s[h.SUBTITLES]=g,h.SUBTITLES=g),u.attrs=h;let E=new Qr(u);return zl(E,"audio",f),zl(E,"text",g),E});t.push(...d),fv(this.audioTracks,r,l,a),fv(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){let t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){let c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+c)}let n={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(c,u,h,f)=>{this.log(`Loaded steering manifest: "${s}"`);let g=c.data;if(g.VERSION!==1){this.log(`Steering VERSION ${g.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=g.TTL;let{"RELOAD-URI":E,"PATHWAY-CLONES":T,"PATHWAY-PRIORITY":A}=g;if(E)try{this.uri=new self.URL(E,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${E}`);return}this.scheduleRefresh(this.uri||h.url),T&&this.clonePathways(T),A&&this.updatePathwayPriority(A)},onError:(c,u,h,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${u.url})`),this.stopLoad(),c.code===410){this.enabled=!1,this.log(`Steering manifest ${u.url} no longer available`);return}let g=this.timeToLoad*1e3;if(c.code===429){let E=this.loader;if(typeof(E==null?void 0:E.getResponseHeader)=="function"){let T=E.getResponseHeader("Retry-After");T&&(g=parseFloat(T)*1e3)}this.log(`Steering manifest ${u.url} rate limited`);return}this.scheduleRefresh(this.uri||u.url,g)},onTimeout:(c,u,h)=>{this.log(`Timeout loading steering manifest (${u.url})`),this.scheduleRefresh(this.uri||u.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}};function fv(i,e,t,r){i&&Object.keys(e).forEach(s=>{let n=i.filter(a=>a.groupId===s).map(a=>{let o=ht({},a);return o.details=void 0,o.attrs=new et(o.attrs),o.url=o.attrs.URI=sE(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=r,o});i.push(...n)})}function sE(i,e,t,r){let{HOST:s,PARAMS:n,[t]:a}=r,o;e&&(o=a==null?void 0:a[e],o&&(i=o));let l=new self.URL(i);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}var dS=/^age:\s*[\d.]+\s*$/im,ld=class{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new on,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,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()}loadInternal(){let{config:e,context:t}=this;if(!e)return;let r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!this.stats.aborted)return n(r,t.url)}).catch(a=>(r.open("GET",t.url,!0),n(r,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(a=>{this.callbacks.onError({code:r.status,text:a.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);let s=this.context.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=r.loadPolicy;if(s)for(let o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&oe(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:r}=this;if(!e||!t)return;let s=t.readyState,n=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);let l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(r.loaded=r.total=d,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;let c=this.callbacks.onProgress;if(c&&c(r,e,l,t),!this.callbacks)return;let u={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(u,r,e,t)}else{let l=n.loadPolicy.errorRetry,d=r.retry;jl(l,d,!1,a)?this.retry(l):(M.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}}loadtimeout(){var e;let t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,r=this.stats.retry;if(jl(t,r,!0))this.retry(t);else{M.warn(`timeout while loading ${this.context.url}`);let s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:r}=this;this.retryDelay=Sf(e,r.retry),r.retry++,M.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)}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&dS.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}};function cS(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var uS=/(\d+)-(\d+)\/(\d+)/,dd=class{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||pS,this.controller=new self.AbortController,this.stats=new on}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){let e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){let s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();let n=hS(e,this.controller.signal),a=r.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:c}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&oe(d)?d:c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(u=>{this.response=this.loader=u;let h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},c-(h-s.loading.start)),!u.ok){let{status:f,statusText:g}=u;throw new bf(g||"fetch, bad network response",f,u)}return s.loading.first=h,s.total=mS(u.headers)||s.total,a&&oe(t.highWaterMark)?this.loadProgressively(u,s,e,t.highWaterMark,a):o?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{let{response:h}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);let f=u[l];f&&(s.loaded=s.total=f);let g={url:h.url,data:u,code:h.status};a&&!oe(t.highWaterMark)&&a(s,e,u,h),r.onSuccess(g,s,e,h)}).catch(u=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;let h=u&&u.code||0,f=u?u.message:null;r.onError({code:h,text:f},e,u?u.details:null,s)})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,s=0,n){let a=new rd,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));let c=d.value,u=c.length;return t.loaded+=u,u<s||a.dataLength?(a.push(c),a.dataLength>=s&&n(t,r,a.flush(),e)):n(t,r,c,e),l()}).catch(()=>Promise.reject());return l()}};function hS(i,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ht({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function fS(i){let e=uS.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function mS(i){let e=i.get("Content-Range");if(e){let r=fS(e);if(oe(r))return r}let t=i.get("Content-Length");if(t)return parseInt(t)}function pS(i,e){return new self.Request(i.url,e)}var bf=class extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}},gS=/\s/,vS={newCue(i,e,t,r){let s=[],n,a,o,l,d,c=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(n=r.rows[h],o=!0,l=0,d="",!n.isEmpty()){var u;for(let E=0;E<n.chars.length;E++)gS.test(n.chars[E].uchar)&&o?l++:(d+=n.chars[E].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;let f=eE(d.trim()),g=Df(e,t,f);i!=null&&(u=i.cues)!=null&&u.getCueById(g)||(a=new c(e,t,f),a.id=g,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return i&&s.length&&(s.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),s.forEach(h=>wv(i,h))),s}},ES={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},bS=Ct(Ct({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:ld,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Zh,bufferController:af,capLevelController:pf,errorController:wh,fpsController:gf,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:vv,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:ES},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},yS()),{},{subtitleStreamController:tf,subtitleTrackController:sf,timelineController:mf,audioStreamController:Jh,audioTrackController:ef,emeController:od,cmcdController:vf,contentSteeringController:Ef});function yS(){return{cueHandler:vS,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function TS(i,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let t=yf(i),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(n=>{let a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];s.forEach(d=>{let c=`${n}Loading${d}`,u=e[c];if(u!==void 0&&o){l.push(c);let h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=u,h.maxTimeToFirstByteMs=u;break;case"MaxRetry":h.errorRetry.maxNumRetry=u,h.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":h.errorRetry.retryDelayMs=u,h.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=u,h.timeoutRetry.maxRetryDelayMs=u;break}}}),l.length&&M.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),Ct(Ct({},t),e)}function yf(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(yf):Object.keys(i).reduce((e,t)=>(e[t]=yf(i[t]),e),{}):i}function _S(i){let e=i.loader;e!==dd&&e!==ld?(M.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):cS()&&(i.loader=dd,i.progressive=!0,i.enableSoftwareAES=!0,M.log("[config]: Progressive streaming enabled, using FetchLoader"))}var pa=class i{static get version(){return"1.4.13"}static isSupported(){return d1()}static get Events(){return b}static get ErrorTypes(){return ue}static get ErrorDetails(){return $}static get DefaultConfig(){return i.defaultConfig?i.defaultConfig:bS}static set DefaultConfig(e){i.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new kf,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,z_(e.debug||!1,"Hls instance");let t=this.config=TS(i.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&_S(t);let{abrController:r,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new r(this),c=this.bufferController=new s(this),u=this.capLevelController=new n(this),h=new o(this),f=new _h(this),g=new xh(this),E=t.contentSteeringController,T=E?new E(this):null,A=this.levelController=new Dh(this,T),k=new Ch(this),L=new Ph(this.config),F=this.streamController=new Xh(this,k,L);u.setStreamController(F),h.setStreamController(F);let R=[f,A,F];T&&R.splice(1,0,T),this.networkControllers=R;let B=[d,c,u,h,g,k];this.audioTrackController=this.createController(t.audioTrackController,R);let P=t.audioStreamController;P&&R.push(new P(this,k,L)),this.subtitleTrackController=this.createController(t.subtitleTrackController,R);let G=t.subtitleStreamController;G&&R.push(new G(this,k,L)),this.createController(t.timelineController,B),L.emeController=this.emeController=this.createController(t.emeController,B),this.cmcdController=this.createController(t.cmcdController,B),this.latencyController=this.createController(Ih,B),this.coreComponents=B,R.push(l);let K=l.onErrorOut;typeof K=="function"&&this.on(b.ERROR,K,l)}createController(e,t){if(e){let r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){M.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(b.ERROR,{type:ue.OTHER_ERROR,details:$.INTERNAL_EXCEPTION,fatal:!1,event:e,error:r})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){M.log("destroy"),this.trigger(b.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){M.log("attachMedia"),this._media=e,this.trigger(b.MEDIA_ATTACHING,{media:e})}detachMedia(){M.log("detachMedia"),this.trigger(b.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,r=this.url,s=this.url=Tf.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});M.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(b.MANIFEST_LOADING,{url:e})}startLoad(e=-1){M.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){M.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){M.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){M.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){M.log(`set currentLevel:${e}`),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){M.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){M.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){M.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){M.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(M.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){Lh.indexOf(e)>-1&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this,s;if(t===-1&&e&&e.length?s=e.length-1:s=t,r)for(let n=s;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return s}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}};pa.defaultConfig=void 0;var lt=pa,Er=class ga extends Error{constructor(e,t=ga.MEDIA_ERR_CUSTOM,r,s){var n;super(e),this.name="MediaError",this.code=t,this.context=s,this.fatal=r!=null?r:t>=ga.MEDIA_ERR_NETWORK&&t<=ga.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(n=ga.defaultMessages[this.code])!=null?n:"")}};Er.MEDIA_ERR_ABORTED=1,Er.MEDIA_ERR_NETWORK=2,Er.MEDIA_ERR_DECODE=3,Er.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Er.MEDIA_ERR_ENCRYPTED=5,Er.MEDIA_ERR_CUSTOM=100,Er.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 _t=Er,AS=i=>i==null,uE=(i,e)=>AS(e)?!1:i in e,Mf={ANY:"any",MUTED:"muted"},Ye={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},ai={MSE:"mse",NATIVE:"native"},hd={HEADER:"header",QUERY:"query",NONE:"none"},ln=Object.values(hd),br={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Pf={HLS:br.M3U8},SC=Object.keys(Pf),xC=[...Object.values(br),"hls","HLS"];var yi=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function SS(i,e,t){e&&t>e&&(t=e);for(let r=0;r<i.length;r++)if(i.start(r)<=t&&i.end(r)>=t)return!0;return!1}var xS=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},md=i=>{let e=i.type;if(e){let r=e.toUpperCase();return uE(r,Pf)?Pf[r]:e}let{src:t}=i;return t?IS(t):""},hE=i=>i==="VOD"?Ye.ON_DEMAND:Ye.LIVE,fE=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,IS=i=>{let e="";try{e=new URL(i).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let r=e.slice(t+1).toUpperCase();return uE(r,br)?br[r]:""},LS=Object.values(Mf),nE=i=>typeof i=="boolean"||typeof i=="string"&&LS.includes(i),RS=({autoplay:i},e,t)=>{let r=!1,s=!1,n=nE(i)?i:!!i,a=()=>{r||yi(e,"playing",()=>{r=!0},{once:!0})};if(a(),yi(e,"loadstart",()=>{r=!1,a(),Cf(e,n)},{once:!0}),yi(e,"loadstart",()=>{t||(s=!Number.isFinite(e.duration)),Cf(e,n)},{once:!0}),t&&t.once(lt.Events.LEVEL_LOADED,(o,l)=>{var d;s=(d=l.details.live)!=null?d:!1}),!n){let o=()=>{s&&(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&yi(e,"play",()=>{e.preload==="metadata"?t.once(lt.Events.LEVEL_UPDATED,o):o()},{once:!0})}return o=>{r||(n=nE(o)?o:!!o,Cf(e,n))}},Cf=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case Mf.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case Mf.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},kS=({preload:i,src:e},t,r)=>{let s=u=>{u!=null&&["","none","metadata","auto"].includes(u)?t.setAttribute("preload",u):t.removeAttribute("preload")};if(!r)return s(i),s;let n=!1,a=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=u=>{s(u);let h=u!=null?u:t.preload;a||h==="none"||(h==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),c())},c=()=>{!n&&e&&(n=!0,r.loadSource(e))};return yi(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,c()},{once:!0}),d(i),d};function wS(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(lt.Events.MANIFEST_PARSED,function(d,c){l();let u=i.addVideoTrack("main");u.selected=!0;for(let[h,f]of c.levels.entries()){let g=u.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),g.id=`${h}`}}),e.on(lt.Events.AUDIO_TRACKS_UPDATED,function(d,c){o();for(let u of c.audioTracks){let h=u.default?"main":"alternative",f=i.addAudioTrack(h,u.name,u.lang);f.id=`${u.id}`,u.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let c=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),u=e.audioTracks.map(h=>h.id);c!=e.audioTrack&&u.includes(c)&&(e.audioTrack=c)}),e.on(lt.Events.LEVELS_UPDATED,function(d,c){var u;let h=i.videoTracks[(u=i.videoTracks.selectedIndex)!=null?u:0];if(!h)return;let f=c.levels.map(g=>r.get(g));for(let g of i.videoRenditions)g.id&&!f.includes(g.id)&&h.removeRendition(g)});let s=d=>{let c=d.target.selectedIndex;c!=e.nextLevel&&n(c)},n=d=>{let c=i.currentTime,u=!1,h=(f,g)=>{u||(u=!Number.isFinite(g.endOffset))};e.on(lt.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(lt.Events.BUFFER_FLUSHING,h),u||e.trigger(lt.Events.BUFFER_FLUSHING,{startOffset:c+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",s);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(lt.Events.DESTROYING,l)}function DS(i,e){e.on(lt.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:n})=>{n.forEach(a=>{var o;let l=(o=a.subtitleTrack)!=null?o:a.closedCaptions,d=e.subtitleTracks.findIndex(({lang:c,name:u,type:h})=>c==(l==null?void 0:l.lang)&&u===a.label&&h.toLowerCase()===a.kind);pd(i,a.kind,a.label,l==null?void 0:l.lang,`${a.kind}${d}`)})});let t=()=>{var s;if(!e.subtitleTracks.length)return;let n=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind)),a=`${(s=e.subtitleTracks[e.subtitleTrack])==null?void 0:s.type.toLowerCase()}${e.subtitleTrack}`;if(n&&(e.subtitleTrack<0||(n==null?void 0:n.id)!==a)){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:c})=>l==n.language&&d===n.label&&c.toLowerCase()===n.kind);e.subtitleTrack=o}n&&(n==null?void 0:n.id)===a&&n.cues&&Array.from(n.cues).forEach(o=>{n.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(lt.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var c;(c=o.cues)!=null&&c.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(lt.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let r=()=>{Array.from(i.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&s.label==="thumbnails"){if(!((n=s.cues)!=null&&n.length)){let o=i.querySelector('track[label="thumbnails"]'),l=(a=o==null?void 0:o.getAttribute("src"))!=null?a:"";o==null||o.removeAttribute("src"),setTimeout(()=>{o==null||o.setAttribute("src",l)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};e.once(lt.Events.MANIFEST_LOADED,r),e.once(lt.Events.MEDIA_ATTACHED,r)}function pd(i,e,t,r,s){let n=document.createElement("track");return n.kind=e,n.label=t,r&&(n.srclang=r),s&&(n.id=s),n.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),i.append(n),n.track}function mE(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),r=>r.track===e);t==null||t.remove()}var va="cuepoints",Nf=Object.freeze({label:va}),Uf=(i,{label:e=va}=Nf)=>{var t;return(t=Array.from(i.querySelectorAll("track")).find(r=>r.track.label===e&&r.track.kind==="metadata"))==null?void 0:t.track};async function Ff(i,e,t=Nf){let r=Uf(i,t);if(!r){let{label:s=va}=t;r=pd(i,"metadata",s),r.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))}return r.mode!=="hidden"&&(r.mode="hidden"),[...e].sort(({time:s},{time:n})=>n-s).forEach(({time:s,value:n})=>{var a,o;let l=Array.prototype.findIndex.call(r==null?void 0:r.cues,f=>f.startTime>=s),d=(a=r==null?void 0:r.cues)==null?void 0:a[l],c=d?d.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,u=(o=r==null?void 0:r.cues)==null?void 0:o[l-1];u&&(u.endTime=s);let h=new VTTCue(s,c,JSON.stringify(n!=null?n:null));r.addCue(h)}),r}var pE=i=>({time:i.startTime,value:JSON.parse(i.text)});function gE(i,e={label:va}){let t=Uf(i,e);return t!=null&&t.cues?Array.from(t.cues,r=>pE(r)):[]}function Bf(i,e={label:va}){var t,r;let s=Uf(i,e);if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return pE(a)}async function CS(i,e=Nf){return new Promise(t=>{yi(i,"loadstart",async()=>{let r=await Ff(i,[],e);yi(i,"cuechange",()=>{let s=Bf(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function vE(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function EE(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var MS=async i=>fetch(i).then(e=>e.text()).then(e=>{let t=e.split(`
1153
+ `),d=[],c=e?j1(e.baseTime,e.timescale):0,u="00:00.000",h=0,f=0,g,E=!0;o.oncue=function(T){let S=t[r],k=t.ccOffset,L=(h-c)/9e4;if(S!=null&&S.new&&(f!==void 0?k=t.ccOffset=S.start:pS(t,r,L)),L){if(!e){g=new Error("Missing initPTS for VTT MPEGTS");return}k=L-t.presentationOffset}let F=T.endTime-T.startTime,R=ai((T.startTime+k-f)*9e4,s*9e4)/9e4;T.startTime=Math.max(R,0),T.endTime=Math.max(R+F,0);let B=T.text.trim();T.text=decodeURIComponent(encodeURIComponent(B)),T.id||(T.id=Bf(T.startTime,T.endTime,B)),T.endTime>0&&d.push(T)},o.onparsingerror=function(T){g=T},o.onflush=function(){if(g){a(g);return}n(d)},l.forEach(T=>{if(E)if(yh(T,"X-TIMESTAMP-MAP=")){E=!1,T.slice(16).split(",").forEach(S=>{yh(S,"LOCAL:")?u=S.slice(6):yh(S,"MPEGTS:")&&(h=parseInt(S.slice(7)))});try{f=mS(u)/1e3}catch(S){g=S}return}else T===""&&(E=!1);o.parse(T+`
1154
+ `)}),o.flush()}var _h="stpp.ttml.im1t",mE=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,pE=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,vS={left:"start",center:"center",right:"end",start:"start",end:"end"};function _v(i,e,t,r){let s=Ce(new Uint8Array(i),["mdat"]);if(s.length===0){r(new Error("Could not parse IMSC1 mdat"));return}let n=s.map(o=>Wi(o)),a=Y1(e.baseTime,1,e.timescale);try{n.forEach(o=>t(ES(o,a)))}catch(o){r(o)}}function ES(i,e){let s=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");let n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((u,h)=>(u[h]=s.getAttribute(`ttp:${h}`)||n[h],u),{}),o=s.getAttribute("xml:space")!=="preserve",l=Av(Ah(s,"styling","style")),d=Av(Ah(s,"layout","region")),c=Ah(s,"body","[begin]");return[].map.call(c,u=>{let h=gE(u,o);if(!h||!u.hasAttribute("begin"))return null;let f=xh(u.getAttribute("begin"),a),g=xh(u.getAttribute("dur"),a),E=xh(u.getAttribute("end"),a);if(f===null)throw Sv(u);if(E===null){if(g===null)throw Sv(u);E=f+g}let T=new Ff(f-e,E-e,h);T.id=Bf(T.startTime,T.endTime,T.text);let S=d[u.getAttribute("region")],k=l[u.getAttribute("style")],L=bS(S,k,l),{textAlign:F}=L;if(F){let R=vS[F];R&&(T.lineAlign=R),T.align=F}return ft(T,L),T}).filter(u=>u!==null)}function Ah(i,e,t){let r=i.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function Av(i){return i.reduce((e,t)=>{let r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function gE(i,e){return[].slice.call(i.childNodes).reduce((t,r,s)=>{var n;return r.nodeName==="br"&&s?t+`
1155
+ `:(n=r.childNodes)!=null&&n.length?gE(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function bS(i,e,t){let r="http://www.w3.org/ns/ttml#styling",s=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{let d=Sh(e,r,l)||Sh(i,r,l)||Sh(s,r,l);return d&&(o[l]=d),o},{})}function Sh(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function Sv(i){return new Error(`Could not parse ttml timestamp ${i}`)}function xh(i,e){if(!i)return null;let t=uE(i);return t===null&&(mE.test(i)?t=yS(i,e):pE.test(i)&&(t=TS(i,e))),t}function yS(i,e){let t=mE.exec(i),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function TS(i,e){let t=pE.exec(i),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}var _f=class{constructor(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=xv(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){let t=new on(this,"textTrack1"),r=new on(this,"textTrack2"),s=new on(this,"textTrack3"),n=new on(this,"textTrack4");this.cea608Parser1=new fd(1,t,r),this.cea608Parser2=new fd(3,s,n)}e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(b.FRAG_LOADING,this.onFragLoading,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(b.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(b.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(b.FRAG_LOADING,this.onFragLoading,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(b.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(b.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,r,s,n){let a=!1;for(let o=n.length;o--;){let l=n[o],d=AS(l[0],l[1],t,r);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),a=!0,d/(r-t)>.5))return}if(a||n.push([t,r]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,r,s)}else{let o=this.Cues.newCue(null,t,r,s);this.hls.trigger(b.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){let{unparsedVttFrags:a}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(b.FRAG_LOADED,o)}))}getExistingTrack(e){let{media:t}=this;if(t)for(let r=0;r<t.textTracks.length;r++){let s=t.textTracks[r];if(s[e])return s}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:r,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(e);if(o)r[e]=o,an(r[e]),Gv(r[e],s);else{let l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(b.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){let s=this.media;if(s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{an(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=xv(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let r=0;r<t.length;r++)an(t[r])}onSubtitleTracksUpdated(e,t){let r=t.subtitleTracks||[],s=r.some(n=>n.textCodec===_h);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(dE(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){let a=this.media?this.media.textTracks:null;this.tracks.forEach((o,l)=>{let d;if(a&&l<a.length){let c=null;for(let u=0;u<a.length;u++)if(_S(a[u],o)){c=a[u];break}c&&(d=c)}if(d)an(d);else{let c=this._captionsOrSubtitlesFromCharacteristics(o);d=this.createTextTrack(c,o.name,o.lang),d&&(d.mode="disabled")}d&&(d.groupId=o.groupId,this.textTracks.push(d))})}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(b.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){let 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"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{let s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;let n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=r.name,r.lang&&(a.languageCode=r.lang),a.media=r)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){let{cea608Parser1:r,cea608Parser2:s,lastSn:n,lastPartIndex:a}=this;if(!(!this.enabled||!(r&&s))&&t.frag.type===he.MAIN){var o,l;let d=t.frag.sn,c=(o=t==null||(l=t.part)==null?void 0:l.index)!=null?o:-1;d===n+1||d===n&&c===a+1||(r.reset(),s.reset()),this.lastSn=d,this.lastPartIndex=c}}onFragLoaded(e,t){let{frag:r,payload:s}=t;if(r.type===he.SUBTITLE)if(s.byteLength){let n=r.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),o&&o.textCodec===_h?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let r=this.hls;_v(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{M.log(`Failed to parse IMSC1: ${s}`),r.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;let{frag:r,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[r.cc]&&o===-1){a.push(e);return}let l=this.hls,d=(t=r.initSegment)!=null&&t.data?Qr(r.initSegment.data,new Uint8Array(s)):s;gS(d,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,c=>{this._appendCues(c,r.level),l.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},c=>{let u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(r,s),M.log(`Failed to parse VTT cue: ${c}`),!(u&&o>r.cc)&&l.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:c})})}_fallbackToIMSC1(e,t){let r=this.tracks[e.level];r.textCodec||_v(t,this.initPTS[e.cc],()=>{r.textCodec=_h,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){let r=this.hls;if(this.config.renderTextTracksNatively){let s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>Vv(s,n))}else{let s=this.tracks[t];if(!s)return;let n=s.default?"default":"subtitles"+t;r.trigger(b.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){let{frag:r}=t;r.type===he.SUBTITLE&&this.onFragLoaded(b.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){let{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!(r&&s))return;let{frag:n,samples:a}=t;if(!(n.type===he.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){let l=a[o].bytes;if(l){let d=this.extractCea608Data(l);r.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:n}){let{media:a}=this;if(!(!a||a.currentTime<r)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>Dh(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>Dh(o[l],t,s))}}}extractCea608Data(e){let t=[[],[]],r=e[0]&31,s=2;for(let n=0;n<r;n++){let a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){let c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(l))}}return t}};function _S(i,e){return!!i&&i.label===e.name&&!(i.textTrack1||i.textTrack2)}function AS(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function xv(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var Af=class i{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(b.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.BUFFER_CODECS,this.onBufferCodecs,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(b.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.BUFFER_CODECS,this.onBufferCodecs,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){let r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){let e=this.hls.levels;if(e.length){let t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return-1;let r=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,i.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let 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}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;let s=(a,o)=>o?a.width!==o.width||a.height!==o.height:!0,n=e.length-1;for(let a=0;a<e.length;a+=1){let o=e[a];if((o.width>=t||o.height>=r)&&s(o,e[a+1])){n=a;break}}return n}},Sf=class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let r=this.hls.config;if(r.capLevelOnFPSDrop){let s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){let s=performance.now();if(t){if(this.lastTime){let n=s-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(b.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let c=d.currentLevel;M.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=c)&&(c=c-1,d.trigger(b.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},Yl="[eme]",md=class i{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=M.debug.bind(M,Yl),this.log=M.log.bind(M,Yl),this.warn=M.warn.bind(M,Yl),this.error=M.error.bind(M,Yl),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(b.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(b.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(b.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(b.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===it.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){let{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,r=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(r),n=t.map(a=>a.videoCodec).filter(r);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let l=d=>{let c=d.shift();this.getMediaKeysPromise(c,s,n).then(u=>a({keySystem:c,mediaKeys:u})).catch(u=>{d.length?l(d):u instanceof qt?o(u):o(new qt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_ACCESS,error:u,fatal:!0},u.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return wv===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){let s=_A(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);let o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(c=>(this.log(`Media-keys created for "${e}"`),d.then(u=>u?this.setMediaKeysServerCertificate(c,e,u):c))),o.mediaKeys.catch(c=>{this.error(`Failed to create media-keys for "${e}"}: ${c}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${Gi.hexDump(e.keyId||[])}`);let s=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Gi.hexDump(e.keyId)}updateKeySession(e,t){var r;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Gi.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
1156
+ } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{let s=ah(this.config),n=e.map(G0).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=V0(a);o?t(o):r(new Error(`Unable to find format for key-system "${a}"`))}).catch(r)})}loadKey(e){let t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();let l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t}),d="cenc";return this.generateRequestWithPreferredKeySession(l,d,t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof qt?this.hls.trigger(b.ERROR,e.data):this.hls.trigger(b.ERROR,{type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){let s=G0(e.keyFormat),n=s?[s]:ah(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=ah(this.config)),e.length===0)throw new qt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){let{initDataType:t,initData:r}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),r===null)return;let s,n;if(t==="sinf"&&this.config.drmSystems[it.FAIRPLAY]){let c=At(new Uint8Array(r));try{let u=wf(JSON.parse(c).sinf),h=Fv(new Uint8Array(u));if(!h)return;s=h.subarray(8,24),n=it.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{let c=qA(r);if(c===null)return;c.version===0&&c.systemId===kv.WIDEVINE&&c.data&&(s=c.data.subarray(8,24)),n=TA(c.systemId)}if(!n||!s)return;let a=Gi.hexDump(s),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this,d=o[a];for(let c=0;c<l.length;c++){let u=l[c],h=u.decryptdata;if(h.pssh||!h.keyId)continue;let f=Gi.hexDump(h.keyId);if(a===f||h.uri.replace(/-/g,"").indexOf(a)!==-1){d=o[f],delete o[f],h.pssh=new Uint8Array(r),h.keyId=s,d=o[a]=d.then(()=>this.generateRequestWithPreferredKeySession(u,t,r,"encrypted-event-key-match"));break}}d||(d=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:c,mediaKeys:u})=>{var h;this.throwIfDestroyed();let f=new ma("ISO-23001-7",a,(h=V0(c))!=null?h:"");return f.pssh=new Uint8Array(r),f.keyId=s,this.attemptSetMediaKeys(c,u).then(()=>{this.throwIfDestroyed();let g=this.createMediaKeySessionContext({decryptdata:f,keySystem:c,mediaKeys:u});return this.generateRequestWithPreferredKeySession(g,t,r,"encrypted-event-no-match")})})),d.catch(c=>this.handleError(c))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){let r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>r.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var n,a;let o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{let h=o.call(this.hls,t,r,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,r=e.decryptdata.pssh=h.initData?new Uint8Array(h.initData):null}catch(h){var l;if(this.warn(h.message),(l=this.hls)!=null&&l.config.debug)throw h}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);let d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${d} (init data type: ${t} length: ${r?r.byteLength:null})`);let c=new Uf;e.mediaKeysSession.onmessage=h=>{let f=e.mediaKeysSession;if(!f){c.emit("error",new Error("invalid state"));return}let{messageType:g,message:E}=h;this.log(`"${g}" message event for session "${f.sessionId}" message size: ${E.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,E).catch(T=>{this.handleError(T),c.emit("error",T)}):g==="license-release"?e.keySystem===it.FAIRPLAY&&(this.updateKeySession(e,Rv("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},e.mediaKeysSession.onkeystatuseschange=h=>{if(!e.mediaKeysSession){c.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let g=e.keyStatus;c.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};let u=new Promise((h,f)=>{c.on("error",f),c.on("keyStatus",g=>{g.startsWith("usable")?h():g==="output-restricted"?f(new qt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?f(new qt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?f(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var h;this.log(`Request generated for key-session "${(h=e.mediaKeysSession)==null?void 0:h.sessionId}" keyId: ${d}`)}).catch(h=>{throw new qt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_SESSION,error:h,fatal:!1},`Error generating key-session request: ${h}`)}).then(()=>u).catch(h=>{throw c.removeAllListeners(),this.removeSession(e),h}).then(()=>(c.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Gi.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${Gi.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,r=t.loader,s=new r(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching serverCertificate for "${e}"`),new Promise((a,o)=>{let l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,E)=>{a(h.data)},onError:(h,f,g,E)=>{o(new qt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:Nt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,g)=>{o(new qt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,g)=>{o(new Error("aborted"))}};s.load(l,c,u)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,n)=>{e.setServerCertificate(r).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new qt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new qt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}setupLicenseXHR(e,t,r,s){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,s)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,r,s)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){let r=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{let a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(c){this.error(c)}s(l)}else{let l=r.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new qt({type:ue.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{let c=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},ma.clearKeyUriToKeyIdMap();let r=t.length;i.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}. media.src: ${e==null?void 0:e.src}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}. media.src: ${e==null?void 0:e.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let r=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),t.onmessage=null,t.onkeystatuseschange=null,r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}};md.CDMCleanupPromise=void 0;var qt=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},SS=1,Wt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},xS="h",xf=class i{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:Wt.MANIFEST,su:!this.initialized})}catch(n){M.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{let n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===Wt.VIDEO||o===Wt.AUDIO||o==Wt.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){M.warn("Could not generate segment CMCD data.",n)}},this.hls=e;let t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||i.uuid(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.registerListeners())}registerListeners(){let e=this.hls;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHED,this.onMediaDetached,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHED,this.onMediaDetached,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:SS,sf:xS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ft(t,this.createData());let r=t.ot===Wt.INIT||t.ot===Wt.VIDEO||t.ot===Wt.MUXED;if(this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){let s=i.toHeaders(t);if(!Object.keys(s).length)return;e.headers||(e.headers={}),ft(e.headers,s)}else{let s=i.toQuery(t);if(!s)return;e.url=i.appendQueryToUri(e.url,s)}}getObjectType(e){let{type:t}=e;if(t==="subtitle")return Wt.TIMED_TEXT;if(e.sn==="initSegment")return Wt.INIT;if(t==="audio")return Wt.AUDIO;if(t==="main")return this.hls.audioTracks.length?Wt.VIDEO:Wt.MUXED}getTopBandwidth(e){let t=0,r,s=this.hls;if(e===Wt.AUDIO)r=s.audioTracks;else{let n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;r=s.levels.slice(0,a)}for(let n of r)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,r=e===Wt.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:Xe.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}static uuid(){let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}static serialize(e){let t=[],r=d=>!Number.isNaN(d)&&d!=null&&d!==""&&d!==!1,s=d=>Math.round(d),n=d=>s(d/100)*100,o={br:s,d:s,bl:n,dl:n,mtp:n,nor:d=>encodeURIComponent(d),rtp:n,tb:s},l=Object.keys(e||{}).sort();for(let d of l){let c=e[d];if(!r(c)||d==="v"&&c===1||d=="pr"&&c===1)continue;let u=o[d];u&&(c=u(c));let h=typeof c,f;d==="ot"||d==="sf"||d==="st"?f=`${d}=${c}`:h==="boolean"?f=d:h==="number"?f=`${d}=${c}`:f=`${d}=${JSON.stringify(c)}`,t.push(f)}return t.join(",")}static toHeaders(e){let t=Object.keys(e),r={},s=["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};for(let o of t){let l=a[o]!=null?a[o]:1;n[l][o]=e[o]}for(let o=0;o<n.length;o++){let l=i.serialize(n[o]);l&&(r[`CMCD-${s[o]}`]=l)}return r}static toQuery(e){return`CMCD=${encodeURIComponent(i.serialize(e))}`}static appendQueryToUri(e,t){if(!t)return e;let r=e.includes("?")?"&":"?";return`${e}${r}${t}`}},IS=3e5,If=class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=M.log.bind(M,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){let e=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:r}=t;if((r==null?void 0:r.action)===Dt.SendAlternateToPenaltyBox&&r.flags===ni.MoveAllAlternatesMatchingHost){let s=this.pathwayPriority,n=this.pathwayId;this.penalizedPathways[n]||(this.penalizedPathways[n]=performance.now()),!s&&this.levels&&(s=this.levels.reduce((a,o)=>(a.indexOf(o.pathwayId)===-1&&a.push(o.pathwayId),a),[])),s&&s.length>1&&(this.updatePathwayPriority(s),r.resolved=this.pathwayId!==n)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let 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}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(n=>{s-r[n]>IS&&delete r[n]});for(let n=0;n<e.length;n++){let a=e[n];if(r[a])continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,this.hls.trigger(b.LEVELS_UPDATED,{levels:t});let d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}clonePathways(e){let t=this.levels;if(!t)return;let r={},s={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(c=>c.pathwayId===a))return;let d=this.getLevelsForPathway(o).map(c=>{let u=ft({},c);u.details=void 0,u.url=vE(c.uri,c.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);let h=new tt(c.attrs);h["PATHWAY-ID"]=a;let f=h.AUDIO&&`${h.AUDIO}_clone_${a}`,g=h.SUBTITLES&&`${h.SUBTITLES}_clone_${a}`;f&&(r[h.AUDIO]=f,h.AUDIO=f),g&&(s[h.SUBTITLES]=g,h.SUBTITLES=g),u.attrs=h;let E=new Zr(u);return id(E,"audio",f),id(E,"text",g),E});t.push(...d),Iv(this.audioTracks,r,l,a),Iv(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){let t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){let c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+c)}let n={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(c,u,h,f)=>{this.log(`Loaded steering manifest: "${s}"`);let g=c.data;if(g.VERSION!==1){this.log(`Steering VERSION ${g.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=g.TTL;let{"RELOAD-URI":E,"PATHWAY-CLONES":T,"PATHWAY-PRIORITY":S}=g;if(E)try{this.uri=new self.URL(E,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${E}`);return}this.scheduleRefresh(this.uri||h.url),T&&this.clonePathways(T),S&&this.updatePathwayPriority(S)},onError:(c,u,h,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${u.url})`),this.stopLoad(),c.code===410){this.enabled=!1,this.log(`Steering manifest ${u.url} no longer available`);return}let g=this.timeToLoad*1e3;if(c.code===429){let E=this.loader;if(typeof(E==null?void 0:E.getResponseHeader)=="function"){let T=E.getResponseHeader("Retry-After");T&&(g=parseFloat(T)*1e3)}this.log(`Steering manifest ${u.url} rate limited`);return}this.scheduleRefresh(this.uri||u.url,g)},onTimeout:(c,u,h)=>{this.log(`Timeout loading steering manifest (${u.url})`),this.scheduleRefresh(this.uri||u.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}};function Iv(i,e,t,r){i&&Object.keys(e).forEach(s=>{let n=i.filter(a=>a.groupId===s).map(a=>{let o=ft({},a);return o.details=void 0,o.attrs=new tt(o.attrs),o.url=o.attrs.URI=vE(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=r,o});i.push(...n)})}function vE(i,e,t,r){let{HOST:s,PARAMS:n,[t]:a}=r,o;e&&(o=a==null?void 0:a[e],o&&(i=o));let l=new self.URL(i);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}var LS=/^age:\s*[\d.]+\s*$/im,pd=class{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new ln,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,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()}loadInternal(){let{config:e,context:t}=this;if(!e)return;let r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!this.stats.aborted)return n(r,t.url)}).catch(a=>(r.open("GET",t.url,!0),n(r,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(a=>{this.callbacks.onError({code:r.status,text:a.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);let s=this.context.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=r.loadPolicy;if(s)for(let o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&oe(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:r}=this;if(!e||!t)return;let s=t.readyState,n=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);let l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(r.loaded=r.total=d,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;let c=this.callbacks.onProgress;if(c&&c(r,e,l,t),!this.callbacks)return;let u={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(u,r,e,t)}else{let l=n.loadPolicy.errorRetry,d=r.retry;td(l,d,!1,a)?this.retry(l):(M.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}}loadtimeout(){var e;let t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,r=this.stats.retry;if(td(t,r,!0))this.retry(t);else{M.warn(`timeout while loading ${this.context.url}`);let s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:r}=this;this.retryDelay=Cf(e,r.retry),r.retry++,M.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)}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&LS.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}};function RS(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var kS=/(\d+)-(\d+)\/(\d+)/,gd=class{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||MS,this.controller=new self.AbortController,this.stats=new ln}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){let e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){let s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();let n=wS(e,this.controller.signal),a=r.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:c}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&oe(d)?d:c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(u=>{this.response=this.loader=u;let h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},c-(h-s.loading.start)),!u.ok){let{status:f,statusText:g}=u;throw new Lf(g||"fetch, bad network response",f,u)}return s.loading.first=h,s.total=CS(u.headers)||s.total,a&&oe(t.highWaterMark)?this.loadProgressively(u,s,e,t.highWaterMark,a):o?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{let{response:h}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);let f=u[l];f&&(s.loaded=s.total=f);let g={url:h.url,data:u,code:h.status};a&&!oe(t.highWaterMark)&&a(s,e,u,h),r.onSuccess(g,s,e,h)}).catch(u=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;let h=u&&u.code||0,f=u?u.message:null;r.onError({code:h,text:f},e,u?u.details:null,s)})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,s=0,n){let a=new cd,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));let c=d.value,u=c.length;return t.loaded+=u,u<s||a.dataLength?(a.push(c),a.dataLength>=s&&n(t,r,a.flush(),e)):n(t,r,c,e),l()}).catch(()=>Promise.reject());return l()}};function wS(i,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ft({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function DS(i){let e=kS.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function CS(i){let e=i.get("Content-Range");if(e){let r=DS(e);if(oe(r))return r}let t=i.get("Content-Length");if(t)return parseInt(t)}function MS(i,e){return new self.Request(i.url,e)}var Lf=class extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}},PS=/\s/,OS={newCue(i,e,t,r){let s=[],n,a,o,l,d,c=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(n=r.rows[h],o=!0,l=0,d="",!n.isEmpty()){var u;for(let E=0;E<n.chars.length;E++)PS.test(n.chars[E].uchar)&&o?l++:(d+=n.chars[E].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;let f=fE(d.trim()),g=Bf(e,t,f);i!=null&&(u=i.cues)!=null&&u.getCueById(g)||(a=new c(e,t,f),a.id=g,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return i&&s.length&&(s.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),s.forEach(h=>Vv(i,h))),s}},NS={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},US=Nt(Nt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:pd,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:of,bufferController:mf,capLevelController:Af,errorController:Fh,fpsController:Sf,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:wv,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:NS},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},FS()),{},{subtitleStreamController:cf,subtitleTrackController:hf,timelineController:_f,audioStreamController:lf,audioTrackController:df,emeController:md,cmcdController:xf,contentSteeringController:If});function FS(){return{cueHandler:OS,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function BS(i,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let t=Rf(i),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(n=>{let a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];s.forEach(d=>{let c=`${n}Loading${d}`,u=e[c];if(u!==void 0&&o){l.push(c);let h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=u,h.maxTimeToFirstByteMs=u;break;case"MaxRetry":h.errorRetry.maxNumRetry=u,h.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":h.errorRetry.retryDelayMs=u,h.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=u,h.timeoutRetry.maxRetryDelayMs=u;break}}}),l.length&&M.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),Nt(Nt({},t),e)}function Rf(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(Rf):Object.keys(i).reduce((e,t)=>(e[t]=Rf(i[t]),e),{}):i}function $S(i){let e=i.loader;e!==gd&&e!==pd?(M.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):RS()&&(i.loader=gd,i.progressive=!0,i.enableSoftwareAES=!0,M.log("[config]: Progressive streaming enabled, using FetchLoader"))}var ya=class i{static get version(){return"1.4.13"}static isSupported(){return L1()}static get Events(){return b}static get ErrorTypes(){return ue}static get ErrorDetails(){return $}static get DefaultConfig(){return i.defaultConfig?i.defaultConfig:US}static set DefaultConfig(e){i.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Uf,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,fA(e.debug||!1,"Hls instance");let t=this.config=BS(i.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&$S(t);let{abrController:r,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new r(this),c=this.bufferController=new s(this),u=this.capLevelController=new n(this),h=new o(this),f=new wh(this),g=new Mh(this),E=t.contentSteeringController,T=E?new E(this):null,S=this.levelController=new Bh(this,T),k=new $h(this),L=new Gh(this.config),F=this.streamController=new nf(this,k,L);u.setStreamController(F),h.setStreamController(F);let R=[f,S,F];T&&R.splice(1,0,T),this.networkControllers=R;let B=[d,c,u,h,g,k];this.audioTrackController=this.createController(t.audioTrackController,R);let P=t.audioStreamController;P&&R.push(new P(this,k,L)),this.subtitleTrackController=this.createController(t.subtitleTrackController,R);let H=t.subtitleStreamController;H&&R.push(new H(this,k,L)),this.createController(t.timelineController,B),L.emeController=this.emeController=this.createController(t.emeController,B),this.cmcdController=this.createController(t.cmcdController,B),this.latencyController=this.createController(Ph,B),this.coreComponents=B,R.push(l);let V=l.onErrorOut;typeof V=="function"&&this.on(b.ERROR,V,l)}createController(e,t){if(e){let r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){M.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(b.ERROR,{type:ue.OTHER_ERROR,details:$.INTERNAL_EXCEPTION,fatal:!1,event:e,error:r})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){M.log("destroy"),this.trigger(b.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){M.log("attachMedia"),this._media=e,this.trigger(b.MEDIA_ATTACHING,{media:e})}detachMedia(){M.log("detachMedia"),this.trigger(b.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,r=this.url,s=this.url=kf.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});M.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(b.MANIFEST_LOADING,{url:e})}startLoad(e=-1){M.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){M.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){M.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){M.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){M.log(`set currentLevel:${e}`),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){M.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){M.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){M.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){M.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(M.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){Oh.indexOf(e)>-1&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this,s;if(t===-1&&e&&e.length?s=e.length-1:s=t,r)for(let n=s;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return s}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}};ya.defaultConfig=void 0;var dt=ya,br=class Ta extends Error{constructor(e,t=Ta.MEDIA_ERR_CUSTOM,r,s){var n;super(e),this.name="MediaError",this.code=t,this.context=s,this.fatal=r!=null?r:t>=Ta.MEDIA_ERR_NETWORK&&t<=Ta.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(n=Ta.defaultMessages[this.code])!=null?n:"")}};br.MEDIA_ERR_ABORTED=1,br.MEDIA_ERR_NETWORK=2,br.MEDIA_ERR_DECODE=3,br.MEDIA_ERR_SRC_NOT_SUPPORTED=4,br.MEDIA_ERR_ENCRYPTED=5,br.MEDIA_ERR_CUSTOM=100,br.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 xt=br,HS=i=>i==null,SE=(i,e)=>HS(e)?!1:i in e,Hf={ANY:"any",MUTED:"muted"},je={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},li={MSE:"mse",NATIVE:"native"},bd={HEADER:"header",QUERY:"query",NONE:"none"},dn=Object.values(bd),yr={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Gf={HLS:yr.M3U8},JC=Object.keys(Gf),eM=[...Object.values(yr),"hls","HLS"];var oi=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function GS(i,e,t){e&&t>e&&(t=e);for(let r=0;r<i.length;r++)if(i.start(r)<=t&&i.end(r)>=t)return!0;return!1}var VS=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},Td=i=>{let e=i.type;if(e){let r=e.toUpperCase();return SE(r,Gf)?Gf[r]:e}let{src:t}=i;return t?WS(t):""},xE=i=>i==="VOD"?je.ON_DEMAND:je.LIVE,IE=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,WS=i=>{let e="";try{e=new URL(i).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let r=e.slice(t+1).toUpperCase();return SE(r,yr)?yr[r]:""},KS=Object.values(Hf),EE=i=>typeof i=="boolean"||typeof i=="string"&&KS.includes(i),qS=({autoplay:i},e,t)=>{let r=!1,s=!1,n=EE(i)?i:!!i,a=()=>{r||oi(e,"playing",()=>{r=!0},{once:!0})};if(a(),oi(e,"loadstart",()=>{r=!1,a(),$f(e,n)},{once:!0}),oi(e,"loadstart",()=>{t||(s=!Number.isFinite(e.duration)),$f(e,n)},{once:!0}),t&&t.once(dt.Events.LEVEL_LOADED,(o,l)=>{var d;s=(d=l.details.live)!=null?d:!1}),!n){let o=()=>{s&&(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&oi(e,"play",()=>{e.preload==="metadata"?t.once(dt.Events.LEVEL_UPDATED,o):o()},{once:!0})}return o=>{r||(n=EE(o)?o:!!o,$f(e,n))}},$f=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case Hf.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case Hf.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},YS=({preload:i,src:e},t,r)=>{let s=u=>{u!=null&&["","none","metadata","auto"].includes(u)?t.setAttribute("preload",u):t.removeAttribute("preload")};if(!r)return s(i),s;let n=!1,a=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=u=>{s(u);let h=u!=null?u:t.preload;a||h==="none"||(h==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),c())},c=()=>{!n&&e&&(n=!0,r.loadSource(e))};return oi(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,c()},{once:!0}),d(i),d};function jS(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(dt.Events.MANIFEST_PARSED,function(d,c){l();let u=i.addVideoTrack("main");u.selected=!0;for(let[h,f]of c.levels.entries()){let g=u.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),g.id=`${h}`}}),e.on(dt.Events.AUDIO_TRACKS_UPDATED,function(d,c){o();for(let u of c.audioTracks){let h=u.default?"main":"alternative",f=i.addAudioTrack(h,u.name,u.lang);f.id=`${u.id}`,u.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let c=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),u=e.audioTracks.map(h=>h.id);c!=e.audioTrack&&u.includes(c)&&(e.audioTrack=c)}),e.on(dt.Events.LEVELS_UPDATED,function(d,c){var u;let h=i.videoTracks[(u=i.videoTracks.selectedIndex)!=null?u:0];if(!h)return;let f=c.levels.map(g=>r.get(g));for(let g of i.videoRenditions)g.id&&!f.includes(g.id)&&h.removeRendition(g)});let s=d=>{let c=d.target.selectedIndex;c!=e.nextLevel&&n(c)},n=d=>{let c=i.currentTime,u=!1,h=(f,g)=>{u||(u=!Number.isFinite(g.endOffset))};e.on(dt.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(dt.Events.BUFFER_FLUSHING,h),u||e.trigger(dt.Events.BUFFER_FLUSHING,{startOffset:c+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",s);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(dt.Events.DESTROYING,l)}function zS(i,e){e.on(dt.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:n})=>{n.forEach(a=>{var o;let l=(o=a.subtitleTrack)!=null?o:a.closedCaptions,d=e.subtitleTracks.findIndex(({lang:c,name:u,type:h})=>c==(l==null?void 0:l.lang)&&u===a.label&&h.toLowerCase()===a.kind);_d(i,a.kind,a.label,l==null?void 0:l.lang,`${a.kind}${d}`)})});let t=()=>{var s;if(!e.subtitleTracks.length)return;let n=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind)),a=`${(s=e.subtitleTracks[e.subtitleTrack])==null?void 0:s.type.toLowerCase()}${e.subtitleTrack}`;if(n&&(e.subtitleTrack<0||(n==null?void 0:n.id)!==a)){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:c})=>l==n.language&&d===n.label&&c.toLowerCase()===n.kind);e.subtitleTrack=o}n&&(n==null?void 0:n.id)===a&&n.cues&&Array.from(n.cues).forEach(o=>{n.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(dt.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var c;(c=o.cues)!=null&&c.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(dt.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let r=()=>{Array.from(i.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&s.label==="thumbnails"){if(!((n=s.cues)!=null&&n.length)){let o=i.querySelector('track[label="thumbnails"]'),l=(a=o==null?void 0:o.getAttribute("src"))!=null?a:"";o==null||o.removeAttribute("src"),setTimeout(()=>{o==null||o.setAttribute("src",l)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};e.once(dt.Events.MANIFEST_LOADED,r),e.once(dt.Events.MEDIA_ATTACHED,r)}function _d(i,e,t,r,s){let n=document.createElement("track");return n.kind=e,n.label=t,r&&(n.srclang=r),s&&(n.id=s),n.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),i.append(n),n.track}function LE(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),r=>r.track===e);t==null||t.remove()}var _a="cuepoints",Wf=Object.freeze({label:_a}),Kf=(i,{label:e=_a}=Wf)=>{var t;return(t=Array.from(i.querySelectorAll("track")).find(r=>r.track.label===e&&r.track.kind==="metadata"))==null?void 0:t.track};async function qf(i,e,t=Wf){let r=Kf(i,t);if(!r){let{label:s=_a}=t;r=_d(i,"metadata",s),r.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))}return r.mode!=="hidden"&&(r.mode="hidden"),[...e].sort(({time:s},{time:n})=>n-s).forEach(({time:s,value:n})=>{var a,o;let l=Array.prototype.findIndex.call(r==null?void 0:r.cues,f=>f.startTime>=s),d=(a=r==null?void 0:r.cues)==null?void 0:a[l],c=d?d.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,u=(o=r==null?void 0:r.cues)==null?void 0:o[l-1];u&&(u.endTime=s);let h=new VTTCue(s,c,JSON.stringify(n!=null?n:null));r.addCue(h)}),r}var RE=i=>({time:i.startTime,value:JSON.parse(i.text)});function kE(i,e={label:_a}){let t=Kf(i,e);return t!=null&&t.cues?Array.from(t.cues,r=>RE(r)):[]}function Yf(i,e={label:_a}){var t,r;let s=Kf(i,e);if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return RE(a)}async function XS(i,e=Wf){return new Promise(t=>{oi(i,"loadstart",async()=>{let r=await qf(i,[],e);oi(i,"cuechange",()=>{let s=Yf(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function wE(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function DE(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var QS=async i=>fetch(i).then(e=>e.text()).then(e=>{let t=e.split(`
1082
1157
  `).find((r,s,n)=>s&&n[s-1].startsWith("#EXT-X-STREAM-INF"));return fetch(t).then(r=>r.text()).then(r=>r.split(`
1083
- `))}),PS=i=>{var e,t,r;let s=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=hE(s),a=fE(s),o;if(n===Ye.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(u=>u.startsWith("#EXT-X-TARGETDURATION")),c=(r=d==null?void 0:d.split(":"))==null?void 0:r[1];o=+(c!=null?c:6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},OS=async(i,e)=>{if(e===br.MP4)return{streamType:Ye.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===br.M3U8){let t=await MS(i);return PS(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},aE=async(i,e,t=md({src:i}))=>{var r,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await OS(i,t);((r=Tt.get(e))!=null?r:{}).liveEdgeStartOffset=l,((s=Tt.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=Tt.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},NS=i=>{var e;let t=i.type,r=hE(t),s=fE(t),n,a=!!((e=i.partList)!=null&&e.length);return r===Ye.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},US=(i,e,t)=>{var r,s,n,a,o,l,d,c;let{streamType:u,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:g}=NS(i);if(u===Ye.LIVE){g?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let E=Object.freeze({get length(){return e.seekable.length},start(T){return e.seekable.start(T)},end(T){var A;return T>this.length?e.seekable.end(T):(A=t.liveSyncPosition)!=null?A:e.seekable.end(T)}});((o=Tt.get(e))!=null?o:{}).seekable=E}((l=Tt.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=Tt.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((c=Tt.get(e))!=null?c:{}).streamType=u,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},oE,lE,FS=(lE=(oE=globalThis==null?void 0:globalThis.navigator)==null?void 0:oE.userAgent)!=null?lE:"",BS=FS.toLowerCase().indexOf("android")!==-1,Tt=new WeakMap,bE="mux.com",dE,cE,yE=(cE=(dE=lt).isSupported)==null?void 0:cE.call(dE),$S=BS,TE=()=>fd.default.utils.now(),GS=fd.default.utils.generateUUID,Ea=({playbackId:i,customDomain:e=bE,maxResolution:t,minResolution:r,renditionOrder:s,tokens:{playback:n}={},extraSourceParams:a={}}={})=>{if(!i)return;let[o,l=""]=xS(i),d=new URL(`https://stream.${e}/${o}.m3u8${l}`);return n||d.searchParams.has("token")?(d.searchParams.forEach((c,u)=>{u!="token"&&d.searchParams.delete(u)}),n&&d.searchParams.set("token",n)):(t&&d.searchParams.set("max_resolution",t),r&&(d.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&d.searchParams.set("rendition_order",s),Object.entries(a).forEach(([c,u])=>{u!=null&&d.searchParams.set(c,u)})),d.toString()},HS=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},VS=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},WS=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:kE(i)&&(r=(t=HS(i.playbackId))!=null?t:VS(i.src))!=null?r:i.src},_E=i=>{var e;return(e=Tt.get(i))==null?void 0:e.error},AE=i=>{var e,t;return(t=(e=Tt.get(i))==null?void 0:e.streamType)!=null?t:Ye.UNKNOWN},SE=i=>{var e,t;return(t=(e=Tt.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},$f=i=>{var e,t;return(t=(e=Tt.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},xE=i=>{var e;let t=(e=Tt.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=$f(i);return r.length?r.end(r.length-1)-t:Number.NaN},KS=(i,e,t=.001)=>Math.abs(i-e)<=t,IE=(i,e,t=.001)=>i>e||KS(i,e,t),qS=i=>i.paused&&IE(i.currentTime,i.duration),Gf=(i,e)=>i.loop||e?i.ended:i.ended||qS(i),LE=(i,e,t)=>{Hf(e,t);let{metadata:r={}}=i,{view_session_id:s=GS()}=r,n=WS(i);r.view_session_id=s,r.video_id=n,i.metadata=r,Tt.set(e,{});let a=YS(i,e);zS(i,e,a),XS(i,e,a),CS(e);let o=RS(i,e,a),l=kS(i,e,a);return{engine:a,setAutoplay:o,setPreload:l}},Hf=(i,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),i!=null&&i.mux&&!i.mux.deleted&&(i.mux.destroy(),delete i.mux),i&&(i.removeAttribute("src"),i.load(),i.removeEventListener("error",DE),i.removeEventListener("error",Of),i.removeEventListener("durationchange",wE),Tt.delete(i),i.dispatchEvent(new Event("teardown")))};function RE(i,e){var t;let r=md(i);if(r!==br.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===ai.MSE,o=n===ai.NATIVE;return s&&(o||!(yE&&(a||$S)))}var YS=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=md(i)===br.M3U8,d=RE(i,e);if(l&&!d&&yE){let c={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},u=jS(r),h=a!==hd.NONE?{useHeaders:a===hd.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new lt({debug:t,startPosition:s,cmcd:h,xhrSetup:(f,g)=>{var E,T;if(a&&a!==hd.QUERY)return;let A=new URL(g);if(!A.searchParams.has("CMCD"))return;let k=((T=(E=A.searchParams.get("CMCD"))==null?void 0:E.split(","))!=null?T:[]).filter(L=>L.startsWith("sid")||L.startsWith("cid")).join(",");A.searchParams.set("CMCD",k),f.open("GET",A)},...c,...u,...o})}},jS=i=>i===Ye.LIVE?{backBufferLength:8}:{},kE=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(bE)||!!t&&s.includes(t.toLocaleLowerCase())},zS=(i,e,t)=>{var r;let{envKey:s}=i,n=kE(i);if(s||n){let{playerInitTime:a,playerSoftwareName:o,playerSoftwareVersion:l,beaconCollectionDomain:d,debug:c,disableCookies:u}=i,h={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},f=g=>typeof g.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(g):g;fd.default.monitor(e,{debug:c,beaconCollectionDomain:d,hlsjs:t,Hls:t?lt:void 0,automaticErrorTracking:!1,errorTranslator:f,disableCookies:u,data:{...s?{env_key:s}:{},player_software_name:o,player_software:o,player_software_version:l,player_init_time:a,...h}})}},XS=(i,e,t)=>{var r;let s=RE(i,e),{src:n}=i;if(e&&s){let a=md(i);typeof n=="string"?(e.preload==="none"?yi(e,"loadstart",()=>aE(n,e,a)):aE(n,e,a),e.setAttribute("src",n),i.startTime&&(((r=Tt.get(e))!=null?r:{}).startTime=i.startTime,e.addEventListener("durationchange",wE,{once:!0}))):e.removeAttribute("src"),e.addEventListener("error",DE),e.addEventListener("error",Of),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(l=>{l.remove()})},{once:!0});let o=()=>{e.ended||Gf(e)&&e.dispatchEvent(new Event("ended"))};yi(e,"pause",o),yi(e,"seeked",o),yi(e,"play",()=>{e.ended||IE(e.currentTime,e.duration)&&(e.currentTime=e.seekable.start(0))})}else t&&n?(t.once(lt.Events.LEVEL_LOADED,(a,o)=>{US(o.details,e,t)}),t.on(lt.Events.ERROR,(a,o)=>{let l={[lt.ErrorTypes.NETWORK_ERROR]:_t.MEDIA_ERR_NETWORK,[lt.ErrorTypes.MEDIA_ERROR]:_t.MEDIA_ERR_DECODE},d=new _t("",l[o.type]);d.fatal=o.fatal,d.data=o,e.dispatchEvent(new CustomEvent("error",{detail:d}))}),e.addEventListener("error",Of),wS(i,t),DS(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function wE(i){var e;let t=i.target,r=(e=Tt.get(t))==null?void 0:e.startTime;if(r&&SS(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function DE(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new _t(t,r);if(e.src&&(r!==_t.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:s}))}function Of(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof _t))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=Tt.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var QS=Object.defineProperty,ZS=Object.getPrototypeOf,JS=Reflect.get,ex=(i,e,t)=>e in i?QS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,qe=(i,e,t)=>(ex(i,typeof e!="symbol"?e+"":e,t),t),hm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},O=(i,e,t)=>(hm(i,e,"read from private field"),t?t.call(i):e.get(i)),se=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},de=(i,e,t,r)=>(hm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),at=(i,e,t)=>(hm(i,e,"access private method"),t),Vf=(i,e,t)=>JS(ZS(i),t,e),wd=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment=="undefined"){class i extends wd{}globalThis.DocumentFragment=i}var fm=class extends wd{},tx=class extends wd{},ix={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(fm)}},gd,rx=class{constructor(i,e={}){se(this,gd,void 0),de(this,gd,e==null?void 0:e.detail)}get detail(){return O(this,gd)}initCustomEvent(){}};gd=new WeakMap;function sx(i,e){return new fm}var BE={document:{createElement:sx},DocumentFragment,customElements:ix,CustomEvent:rx,EventTarget:wd,HTMLElement:fm,HTMLVideoElement:tx},$E=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Wf=$E?BE:globalThis,LC=$E?BE.document:globalThis.document,nx=()=>{try{return"0.17.2"}catch{}return"UNKNOWN"},ax=nx(),ox=()=>ax,Dd=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],CE,jf=(CE=globalThis.document)==null?void 0:CE.createElement("template");jf&&(jf.innerHTML=`
1158
+ `))}),ZS=i=>{var e,t,r;let s=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=xE(s),a=IE(s),o;if(n===je.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(u=>u.startsWith("#EXT-X-TARGETDURATION")),c=(r=d==null?void 0:d.split(":"))==null?void 0:r[1];o=+(c!=null?c:6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},JS=async(i,e)=>{if(e===yr.MP4)return{streamType:je.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===yr.M3U8){let t=await QS(i);return ZS(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},bE=async(i,e,t=Td({src:i}))=>{var r,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await JS(i,t);((r=St.get(e))!=null?r:{}).liveEdgeStartOffset=l,((s=St.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=St.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},ex=i=>{var e;let t=i.type,r=xE(t),s=IE(t),n,a=!!((e=i.partList)!=null&&e.length);return r===je.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},tx=(i,e,t)=>{var r,s,n,a,o,l,d,c;let{streamType:u,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:g}=ex(i);if(u===je.LIVE){g?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let E=Object.freeze({get length(){return e.seekable.length},start(T){return e.seekable.start(T)},end(T){var S;return T>this.length?e.seekable.end(T):(S=t.liveSyncPosition)!=null?S:e.seekable.end(T)}});((o=St.get(e))!=null?o:{}).seekable=E}((l=St.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=St.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((c=St.get(e))!=null?c:{}).streamType=u,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},yE,TE,ix=(TE=(yE=globalThis==null?void 0:globalThis.navigator)==null?void 0:yE.userAgent)!=null?TE:"",rx=ix.toLowerCase().indexOf("android")!==-1,St=new WeakMap,CE="mux.com",_E,AE,ME=(AE=(_E=dt).isSupported)==null?void 0:AE.call(_E),sx=rx,PE=()=>yd.default.utils.now(),nx=yd.default.utils.generateUUID,Aa=({playbackId:i,customDomain:e=CE,maxResolution:t,minResolution:r,renditionOrder:s,tokens:{playback:n}={},extraSourceParams:a={}}={})=>{if(!i)return;let[o,l=""]=VS(i),d=new URL(`https://stream.${e}/${o}.m3u8${l}`);return n||d.searchParams.has("token")?(d.searchParams.forEach((c,u)=>{u!="token"&&d.searchParams.delete(u)}),n&&d.searchParams.set("token",n)):(t&&d.searchParams.set("max_resolution",t),r&&(d.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&d.searchParams.set("rendition_order",s),Object.entries(a).forEach(([c,u])=>{u!=null&&d.searchParams.set(c,u)})),d.toString()},ax=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},ox=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},lx=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:VE(i)&&(r=(t=ax(i.playbackId))!=null?t:ox(i.src))!=null?r:i.src},OE=i=>{var e;return(e=St.get(i))==null?void 0:e.error},NE=i=>{var e,t;return(t=(e=St.get(i))==null?void 0:e.streamType)!=null?t:je.UNKNOWN},UE=i=>{var e,t;return(t=(e=St.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},jf=i=>{var e,t;return(t=(e=St.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},FE=i=>{var e;let t=(e=St.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=jf(i);return r.length?r.end(r.length-1)-t:Number.NaN},zf=.034,dx=(i,e,t=zf)=>Math.abs(i-e)<=t,BE=(i,e,t=zf)=>i>e||dx(i,e,t),cx=(i,e=zf)=>i.paused&&BE(i.currentTime,i.duration,e),$E=(i,e)=>{var t,r,s;if(!e)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(r=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:r.details:(s=e.levels.find(u=>!!u.details))==null?void 0:s.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),c=i.buffered.end(i.buffered.length-1);return l>d&&l<c},Xf=(i,e)=>i.ended||i.loop?i.ended:e&&$E(i,e)?!0:cx(i),HE=(i,e,t)=>{Qf(e,t);let{metadata:r={}}=i,{view_session_id:s=nx()}=r,n=lx(i);r.view_session_id=s,r.video_id=n,i.metadata=r,St.set(e,{});let a=ux(i,e);fx(i,e,a),mx(i,e,a),XS(e);let o=qS(i,e,a),l=YS(i,e,a);return{engine:a,setAutoplay:o,setPreload:l}},Qf=(i,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),i!=null&&i.mux&&!i.mux.deleted&&(i.mux.destroy(),delete i.mux),i&&(i.removeAttribute("src"),i.load(),i.removeEventListener("error",KE),i.removeEventListener("error",Vf),i.removeEventListener("durationchange",WE),St.delete(i),i.dispatchEvent(new Event("teardown")))};function GE(i,e){var t;let r=Td(i);if(r!==yr.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===li.MSE,o=n===li.NATIVE;return s&&(o||!(ME&&(a||sx)))}var ux=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=Td(i)===yr.M3U8,d=GE(i,e);if(l&&!d&&ME){let c={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},u=hx(r),h=a!==bd.NONE?{useHeaders:a===bd.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new dt({debug:t,startPosition:s,cmcd:h,xhrSetup:(f,g)=>{var E,T;if(a&&a!==bd.QUERY)return;let S=new URL(g);if(!S.searchParams.has("CMCD"))return;let k=((T=(E=S.searchParams.get("CMCD"))==null?void 0:E.split(","))!=null?T:[]).filter(L=>L.startsWith("sid")||L.startsWith("cid")).join(",");S.searchParams.set("CMCD",k),f.open("GET",S)},...c,...u,...o})}},hx=i=>i===je.LIVE?{backBufferLength:8}:{},VE=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(CE)||!!t&&s.includes(t.toLocaleLowerCase())},fx=(i,e,t)=>{var r;let{envKey:s}=i,n=VE(i);if(s||n){let{playerInitTime:a,playerSoftwareName:o,playerSoftwareVersion:l,beaconCollectionDomain:d,debug:c,disableCookies:u}=i,h={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},f=g=>typeof g.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(g):g;yd.default.monitor(e,{debug:c,beaconCollectionDomain:d,hlsjs:t,Hls:t?dt:void 0,automaticErrorTracking:!1,errorTranslator:f,disableCookies:u,data:{...s?{env_key:s}:{},player_software_name:o,player_software:o,player_software_version:l,player_init_time:a,...h}})}},mx=(i,e,t)=>{var r;let s=GE(i,e),{src:n}=i,a=o=>{e.ended||!Xf(e,t)||($E(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))};if(e&&s){let o=Td(i);typeof n=="string"?(e.preload==="none"?oi(e,"loadstart",()=>bE(n,e,o)):bE(n,e,o),e.setAttribute("src",n),i.startTime&&(((r=St.get(e))!=null?r:{}).startTime=i.startTime,e.addEventListener("durationchange",WE,{once:!0}))):e.removeAttribute("src"),e.addEventListener("error",KE),e.addEventListener("error",Vf),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(l=>{l.remove()})},{once:!0}),oi(e,"pause",a),oi(e,"seeked",a),oi(e,"play",()=>{e.ended||BE(e.currentTime,e.duration)&&(e.currentTime=e.seekable.start(0))})}else t&&n?(t.once(dt.Events.LEVEL_LOADED,(o,l)=>{tx(l.details,e,t)}),t.on(dt.Events.ERROR,(o,l)=>{let d={[dt.ErrorTypes.NETWORK_ERROR]:xt.MEDIA_ERR_NETWORK,[dt.ErrorTypes.MEDIA_ERROR]:xt.MEDIA_ERR_DECODE},c=new xt("",d[l.type]);c.fatal=l.fatal,c.data=l,e.dispatchEvent(new CustomEvent("error",{detail:c}))}),e.addEventListener("error",Vf),oi(e,"waiting",a),jS(i,t),zS(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function WE(i){var e;let t=i.target,r=(e=St.get(t))==null?void 0:e.startTime;if(r&&GS(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function KE(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new xt(t,r);if(e.src&&(r!==xt.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:s}))}function Vf(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof xt))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=St.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var px=Object.defineProperty,gx=Object.getPrototypeOf,vx=Reflect.get,Ex=(i,e,t)=>e in i?px(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,qe=(i,e,t)=>(Ex(i,typeof e!="symbol"?e+"":e,t),t),Tm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},O=(i,e,t)=>(Tm(i,e,"read from private field"),t?t.call(i):e.get(i)),se=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},de=(i,e,t,r)=>(Tm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ot=(i,e,t)=>(Tm(i,e,"access private method"),t),Zf=(i,e,t)=>vx(gx(i),t,e),Ud=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment=="undefined"){class i extends Ud{}globalThis.DocumentFragment=i}var _m=class extends Ud{},bx=class extends Ud{},yx={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(_m)}},Ad,Tx=class{constructor(i,e={}){se(this,Ad,void 0),de(this,Ad,e==null?void 0:e.detail)}get detail(){return O(this,Ad)}initCustomEvent(){}};Ad=new WeakMap;function _x(i,e){return new _m}var JE={document:{createElement:_x},DocumentFragment,customElements:yx,CustomEvent:Tx,EventTarget:Ud,HTMLElement:_m,HTMLVideoElement:bx},eb=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Jf=eb?JE:globalThis,iM=eb?JE.document:globalThis.document,Ax=()=>{try{return"0.17.3"}catch{}return"UNKNOWN"},Sx=Ax(),xx=()=>Sx,Fd=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],qE,rm=(qE=globalThis.document)==null?void 0:qE.createElement("template");rm&&(rm.innerHTML=`
1084
1159
  <style>
1085
1160
  :host {
1086
1161
  display: inline-flex;
@@ -1095,7 +1170,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1095
1170
  </style>
1096
1171
  <slot name="media"></slot>
1097
1172
  <slot></slot>
1098
- `);var ME,zf=(ME=globalThis.document)==null?void 0:ME.createElement("template");zf&&(zf.innerHTML=`
1173
+ `);var YE,sm=(YE=globalThis.document)==null?void 0:YE.createElement("template");sm&&(sm.innerHTML=`
1099
1174
  <style>
1100
1175
  :host {
1101
1176
  display: inline-block;
@@ -1118,8 +1193,8 @@ svg, img, ::slotted(svg), ::slotted(img) {
1118
1193
  </style>
1119
1194
  <slot name="media"></slot>
1120
1195
  <slot></slot>
1121
- `);var GE=(i,{tag:e,is:t})=>{var r,s,n,a,o,l,d,c,u,h,f,g,E,T,A,k;let L=(r=globalThis.document)==null?void 0:r.createElement(e,{is:t}),F=L?lx(L):[];return s=class extends i{constructor(){super(),se(this,u),se(this,f),se(this,E),se(this,A),se(this,l,void 0),se(this,d,void 0),se(this,c,new Map),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var R,B,P;return at(R=s,a,o).call(R),[...(P=(B=L==null?void 0:L.constructor)==null?void 0:B.observedAttributes)!=null?P:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var R,B,P;return(P=(B=(R=O(this,d))!=null?R:this.shadowRoot.querySelector(e))!=null?B:this.querySelector(":scope > [slot=media]"))!=null?P:this.querySelector(e)}set nativeEl(R){de(this,d,R)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(R){this.toggleAttribute("muted",!!R)}get src(){return this.getAttribute("src")}set src(R){this.setAttribute("src",`${R}`)}get preload(){var R,B;return(B=this.getAttribute("preload"))!=null?B:(R=this.nativeEl)==null?void 0:R.preload}set preload(R){this.setAttribute("preload",`${R}`)}init(){var R,B;if(!this.nativeEl){let P=document.createElement(e,{is:t});P.part=e,this.shadowRoot.querySelector('slot[name="media"]').append(P)}this.nativeEl.muted=this.hasAttribute("muted");for(let P of F)at(this,E,T).call(this,P);this.shadowRoot.addEventListener("slotchange",this);for(let P of this.constructor.Events)(B=(R=this.shadowRoot).addEventListener)==null||B.call(R,P,this,!0)}handleEvent(R){if(R.type==="slotchange"){at(this,f,g).call(this);return}R.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(R.type,{detail:R.detail}))}attributeChangedCallback(R,B,P){at(this,u,h).call(this),at(this,A,k).call(this,R,B,P)}connectedCallback(){at(this,u,h).call(this)}},n=new WeakMap,a=new WeakSet,o=function(){if(O(this,n))return;de(this,n,!0);let R=new Set(this.observedAttributes);R.delete("muted");for(let B of F)if(!(B in this.prototype))if(typeof L[B]=="function")this.prototype[B]=function(...P){return at(this,u,h).call(this),this.call?this.call(B,...P):this.nativeEl[B].apply(this.nativeEl,P)};else{let P={get(){var G,K,N;at(this,u,h).call(this);let j=B.toLowerCase();if(R.has(j)){let Y=this.getAttribute(j);return Y===null?!1:Y===""?!0:Y}return(N=(G=this.get)==null?void 0:G.call(this,B))!=null?N:(K=this.nativeEl)==null?void 0:K[B]}};B!==B.toUpperCase()&&(P.set=function(G){at(this,u,h).call(this);let K=B.toLowerCase();if(R.has(K)){G===!0||G===!1||G==null?this.toggleAttribute(K,!!G):this.setAttribute(K,G);return}if(this.set){this.set(B,G);return}this.nativeEl[B]=G}),Object.defineProperty(this.prototype,B,P)}},l=new WeakMap,d=new WeakMap,c=new WeakMap,u=new WeakSet,h=function(){O(this,l)||(de(this,l,!0),this.init())},f=new WeakSet,g=function(){let R=new Map(O(this,c));this.shadowRoot.querySelector("slot:not([name])").assignedElements().filter(B=>["track","source"].includes(B.localName)).forEach(B=>{var P,G;R.delete(B);let K=O(this,c).get(B);K||(K=B.cloneNode(),O(this,c).set(B,K)),(G=(P=this.nativeEl).append)==null||G.call(P,K)}),R.forEach(B=>B.remove())},E=new WeakSet,T=function(R){if(Object.prototype.hasOwnProperty.call(this,R)){let B=this[R];delete this[R],this[R]=B}},A=new WeakSet,k=function(R,B,P){var G,K,N,j,Y,Ee;["id","class"].includes(R)||!s.observedAttributes.includes(R)&&this.constructor.observedAttributes.includes(R)||(P===null?(K=(G=this.nativeEl).removeAttribute)==null||K.call(G,R):((j=(N=this.nativeEl).getAttribute)==null?void 0:j.call(N,R))!=P&&((Ee=(Y=this.nativeEl).setAttribute)==null||Ee.call(Y,R,P)))},se(s,a),qe(s,"Events",Dd),qe(s,"template",e.endsWith("audio")?jf:zf),se(s,n,void 0),s};function lx(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}var Kf=globalThis.document?GE(HTMLElement,{tag:"video"}):class{},kC=globalThis.document?GE(HTMLElement,{tag:"audio"}):class{},hs=new WeakMap,qf=class extends Error{},dx=class extends Error{},cx=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function ux(i){HE()?VE()?i(chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>i(chrome.cast.isAvailable)):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>i(chrome.cast.isAvailable))}}function hx(){return globalThis.chrome}function fx(){let i="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if(globalThis.chrome.cast||document.querySelector(`script[src="${i}"]`))return;let e=document.createElement("script");e.src=i,document.head.append(e)}function HE(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable}function VE(){return typeof cast!="undefined"&&cast.framework}function fs(){if(VE())return cast.framework.CastContext.getInstance()}function mm(){var i;return(i=fs())==null?void 0:i.getCurrentSession()}function pm(){var i;return(i=mm())==null?void 0:i.getSessionObj().media[0]}function mx(i){return new Promise((e,t)=>{pm().editTracksInfo(i,e,t)})}function px(i){return new Promise((e,t)=>{pm().getStatus(i,e,t)})}function WE(i){return fs().setOptions({...KE(),...i})}function KE(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}var vd=new cx,_r=new WeakSet,ft;ux(i=>{i&&!ft&&(ft=cast.framework,fs().addEventListener(ft.CastContextEventType.CAST_STATE_CHANGED,e=>{vd.forEach(t=>{var r,s;return(s=(r=hs.get(t)).onCastStateChanged)==null?void 0:s.call(r,e)})}),fs().addEventListener(ft.CastContextEventType.SESSION_STATE_CHANGED,e=>{vd.forEach(t=>{var r,s;return(s=(r=hs.get(t)).onSessionStateChanged)==null?void 0:s.call(r,e)})}),vd.forEach(e=>{var t,r;return(r=(t=hs.get(e)).init)==null?void 0:r.call(t)}))});var PE=0,Ue,Ed,oi,yr,fn,dn,us,Xf,Tr,Zr,Qf,OE,Rd,Zf,Jf,qE,bd,em,tm,NE,yd,Yf,gx=class extends EventTarget{constructor(i){super(),se(this,Tr),se(this,Qf),se(this,Rd),se(this,Jf),se(this,bd),se(this,tm),se(this,yd),se(this,Ue,void 0),se(this,Ed,void 0),se(this,oi,void 0),se(this,yr,void 0),se(this,fn,"disconnected"),se(this,dn,!1),se(this,us,new Set),se(this,Xf,new WeakMap),de(this,Ue,i),vd.add(this),hs.set(this,{init:()=>at(this,bd,em).call(this),onCastStateChanged:()=>at(this,Rd,Zf).call(this),onSessionStateChanged:()=>at(this,Jf,qE).call(this),getCastPlayer:()=>O(this,Tr,Zr)}),at(this,bd,em).call(this)}get state(){return O(this,fn)}async watchAvailability(i){if(O(this,Ue).disableRemotePlayback)throw new qf("disableRemotePlayback attribute is present.");return O(this,Xf).set(i,++PE),O(this,us).add(i),PE}async cancelWatchAvailability(i){if(O(this,Ue).disableRemotePlayback)throw new qf("disableRemotePlayback attribute is present.");i?O(this,us).delete(i):O(this,us).clear()}async prompt(){var i,e;if(O(this,Ue).disableRemotePlayback)throw new qf("disableRemotePlayback attribute is present.");if(!HE())throw new dx("The RemotePlayback API is disabled on this platform.");let t=_r.has(O(this,Ue));_r.add(O(this,Ue)),WE(O(this,Ue).castOptions),Object.entries(O(this,yr)).forEach(([r,s])=>{O(this,oi).controller.addEventListener(r,s)});try{await fs().requestSession()}catch(r){if(r==="cancel"){t||_r.delete(O(this,Ue));return}throw new Error(r)}(e=(i=hs.get(O(this,Ue)))==null?void 0:i.loadOnPrompt)==null||e.call(i)}};Ue=new WeakMap,Ed=new WeakMap,oi=new WeakMap,yr=new WeakMap,fn=new WeakMap,dn=new WeakMap,us=new WeakMap,Xf=new WeakMap,Tr=new WeakSet,Zr=function(){if(_r.has(O(this,Ue)))return O(this,oi)},Qf=new WeakSet,OE=function(){_r.has(O(this,Ue))&&(Object.entries(O(this,yr)).forEach(([i,e])=>{O(this,oi).controller.removeEventListener(i,e)}),_r.delete(O(this,Ue)),O(this,Ue).muted=O(this,oi).isMuted,O(this,Ue).currentTime=O(this,oi).savedPlayerState.currentTime,O(this,oi).savedPlayerState.isPaused===!1&&O(this,Ue).play())},Rd=new WeakSet,Zf=function(){let i=fs().getCastState();if(_r.has(O(this,Ue))&&i==="CONNECTING"&&(de(this,fn,"connecting"),this.dispatchEvent(new Event("connecting"))),!O(this,dn)&&i!=null&&i.includes("CONNECT")){de(this,dn,!0);for(let e of O(this,us))e(!0)}else if(O(this,dn)&&(!i||i==="NO_DEVICES_AVAILABLE")){de(this,dn,!1);for(let e of O(this,us))e(!1)}},Jf=new WeakSet,qE=async function(){var i;let{SESSION_RESUMED:e}=ft.SessionState;if(fs().getSessionState()===e&&O(this,Ue).castSrc===((i=pm())==null?void 0:i.media.contentId)){_r.add(O(this,Ue)),Object.entries(O(this,yr)).forEach(([t,r])=>{O(this,oi).controller.addEventListener(t,r)});try{await px(new chrome.cast.media.GetStatusRequest)}catch(t){console.error(t)}O(this,yr)[ft.RemotePlayerEventType.IS_PAUSED_CHANGED](),O(this,yr)[ft.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},bd=new WeakSet,em=function(){!ft||O(this,Ed)||(de(this,Ed,!0),WE(O(this,Ue).castOptions),O(this,Ue).textTracks.addEventListener("change",()=>at(this,yd,Yf).call(this)),at(this,Rd,Zf).call(this),de(this,oi,new ft.RemotePlayer),new ft.RemotePlayerController(O(this,oi)),de(this,yr,{[ft.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:i})=>{i===!0?(de(this,fn,"connected"),this.dispatchEvent(new Event("connect"))):(at(this,Qf,OE).call(this),de(this,fn,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[ft.RemotePlayerEventType.DURATION_CHANGED]:()=>{O(this,Ue).dispatchEvent(new Event("durationchange"))},[ft.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{O(this,Ue).dispatchEvent(new Event("volumechange"))},[ft.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{O(this,Ue).dispatchEvent(new Event("volumechange"))},[ft.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var i;(i=O(this,Tr,Zr))!=null&&i.isMediaLoaded&&O(this,Ue).dispatchEvent(new Event("timeupdate"))},[ft.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{O(this,Ue).dispatchEvent(new Event("resize"))},[ft.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{O(this,Ue).dispatchEvent(new Event(this.paused?"pause":"play"))},[ft.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var i,e;((i=O(this,Tr,Zr))==null?void 0:i.playerState)!==chrome.cast.media.PlayerState.PAUSED&&O(this,Ue).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(e=O(this,Tr,Zr))==null?void 0:e.playerState]))},[ft.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var i;(i=O(this,Tr,Zr))!=null&&i.isMediaLoaded&&(await Promise.resolve(),at(this,tm,NE).call(this))}}))},tm=new WeakSet,NE=function(){at(this,yd,Yf).call(this)},yd=new WeakSet,Yf=async function(){var i,e,t,r,s;if(!O(this,Tr,Zr))return;let n=((e=(i=O(this,oi).mediaInfo)==null?void 0:i.tracks)!=null?e:[]).filter(({type:h})=>h===chrome.cast.media.TrackType.TEXT),a=[...O(this,Ue).textTracks].filter(({kind:h})=>h==="subtitles"||h==="captions"),o=n.map(({language:h,name:f,trackId:g})=>{var E;let{mode:T}=(E=a.find(A=>A.language===h&&A.label===f))!=null?E:{};return T?{mode:T,trackId:g}:!1}).filter(Boolean),l=o.filter(({mode:h})=>h!=="showing").map(({trackId:h})=>h),d=o.find(({mode:h})=>h==="showing"),c=(s=(r=(t=mm())==null?void 0:t.getSessionObj().media[0])==null?void 0:r.activeTrackIds)!=null?s:[],u=c;if(c.length&&(u=u.filter(h=>!l.includes(h))),d!=null&&d.trackId&&(u=[...u,d.trackId]),u=[...new Set(u)],!((h,f)=>h.length===f.length&&h.every(g=>f.includes(g)))(c,u))try{let h=new chrome.cast.media.EditTracksInfoRequest(u);await mx(h)}catch(h){console.error(h)}};var vx=i=>{var e,t,r,s,n,a,o,l,d;return t=class extends i{constructor(){super(...arguments),se(this,a),se(this,l),se(this,r,{paused:!1}),se(this,s,KE()),se(this,n,void 0)}get remote(){return O(this,n)?O(this,n):hx()?(fx(),hs.set(this,{loadOnPrompt:()=>at(this,l,d).call(this)}),de(this,n,new gx(this))):super.remote}attributeChangedCallback(c,u,h){if(super.attributeChangedCallback(c,u,h),c==="cast-receiver"&&h){O(this,s).receiverApplicationId=h;return}if(O(this,a,o))switch(c){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var c,u;if(!O(this,a,o))return super.load();let h=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),f=[...this.querySelectorAll("track")].filter(({kind:A,src:k})=>k&&(A==="subtitles"||A==="captions")),g=[],E=0;f.length&&(h.tracks=f.map(A=>{let k=++E;g.length===0&&A.track.mode==="showing"&&g.push(k);let L=new chrome.cast.media.Track(k,chrome.cast.media.TrackType.TEXT);return L.trackContentId=A.src,L.trackContentType="text/vtt",L.subtype=A.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,L.name=A.label,L.language=A.srclang,L})),this.castStreamType==="live"?h.streamType=chrome.cast.media.StreamType.LIVE:h.streamType=chrome.cast.media.StreamType.BUFFERED,h.metadata=new chrome.cast.media.GenericMediaMetadata,h.metadata.title=this.title,h.metadata.images=[{url:this.poster}];let T=new chrome.cast.media.LoadRequest(h);T.currentTime=(c=super.currentTime)!=null?c:0,T.autoplay=!O(this,r).paused,T.activeTrackIds=g,await((u=mm())==null?void 0:u.loadMedia(T)),this.dispatchEvent(new Event("volumechange"))}play(){var c;if(O(this,a,o)){O(this,a,o).isPaused&&((c=O(this,a,o).controller)==null||c.playOrPause());return}return super.play()}pause(){var c;if(O(this,a,o)){O(this,a,o).isPaused||(c=O(this,a,o).controller)==null||c.playOrPause();return}super.pause()}get castOptions(){return O(this,s)}get castReceiver(){var c;return(c=this.getAttribute("cast-receiver"))!=null?c:void 0}set castReceiver(c){this.castReceiver!=c&&this.setAttribute("cast-receiver",`${c}`)}get castSrc(){var c,u,h;return(h=(u=this.getAttribute("cast-src"))!=null?u:(c=this.querySelector("source"))==null?void 0:c.src)!=null?h:this.currentSrc}set castSrc(c){this.castSrc!=c&&this.setAttribute("cast-src",`${c}`)}get castContentType(){var c;return(c=this.getAttribute("cast-content-type"))!=null?c:void 0}set castContentType(c){this.setAttribute("cast-content-type",`${c}`)}get castStreamType(){var c,u;return(u=(c=this.getAttribute("cast-stream-type"))!=null?c:this.streamType)!=null?u:void 0}set castStreamType(c){this.setAttribute("cast-stream-type",`${c}`)}get readyState(){if(O(this,a,o))switch(O(this,a,o).playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return O(this,a,o)?O(this,a,o).isPaused:super.paused}get muted(){var c;return O(this,a,o)?(c=O(this,a,o))==null?void 0:c.isMuted:super.muted}set muted(c){var u;if(O(this,a,o)){(c&&!O(this,a,o).isMuted||!c&&O(this,a,o).isMuted)&&((u=O(this,a,o).controller)==null||u.muteOrUnmute());return}super.muted=c}get volume(){var c,u;return O(this,a,o)?(u=(c=O(this,a,o))==null?void 0:c.volumeLevel)!=null?u:1:super.volume}set volume(c){var u;if(O(this,a,o)){O(this,a,o).volumeLevel=+c,(u=O(this,a,o).controller)==null||u.setVolumeLevel();return}super.volume=c}get duration(){var c,u,h;return O(this,a,o)&&(c=O(this,a,o))!=null&&c.isMediaLoaded?(h=(u=O(this,a,o))==null?void 0:u.duration)!=null?h:NaN:super.duration}get currentTime(){var c,u,h;return O(this,a,o)&&(c=O(this,a,o))!=null&&c.isMediaLoaded?(h=(u=O(this,a,o))==null?void 0:u.currentTime)!=null?h:0:super.currentTime}set currentTime(c){var u;if(O(this,a,o)){O(this,a,o).currentTime=c,(u=O(this,a,o).controller)==null||u.seek();return}super.currentTime=c}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakSet,o=function(){var c,u;return(u=(c=hs.get(this.remote))==null?void 0:c.getCastPlayer)==null?void 0:u.call(c)},l=new WeakSet,d=async function(){O(this,r).paused=Vf(t.prototype,this,"paused"),Vf(t.prototype,this,"pause").call(this),this.muted=Vf(t.prototype,this,"muted");try{await this.load()}catch(c){console.error(c)}},qe(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t},Cd=class extends Event{constructor(i,e){super(i),qe(this,"track"),this.track=e.track}},im=new WeakMap;function J(i){var e;return(e=im.get(i))!=null?e:Ex(i,{})}function Ex(i,e){let t=im.get(i);return t||im.set(i,t={}),Object.assign(t,e)}function rm(i,e){let t=i.videoTracks;J(e).media=i,J(e).renditionSet||(J(e).renditionSet=new Set);let r=J(t).trackSet;r.add(e);let s=r.size-1;s in nm.prototype||Object.defineProperty(nm.prototype,s,{get(){return[...J(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Cd("addtrack",{track:e}))})}function sm(i){var e;let t=(e=J(i).media)==null?void 0:e.videoTracks;t&&(J(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Cd("removetrack",{track:i}))}))}function bx(i){var e;let t=(e=J(i).media.videoTracks)!=null?e:[],r=!1;for(let s of t)s!==i&&(s.selected=!1,r=!0);if(r){if(J(t).changeRequested)return;J(t).changeRequested=!0,queueMicrotask(()=>{delete J(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var Jr,es,ts,cn,ba,nm=class extends EventTarget{constructor(){super(),se(this,cn),se(this,Jr,void 0),se(this,es,void 0),se(this,ts,void 0),J(this).trackSet=new Set}[Symbol.iterator](){return O(this,cn,ba).values()}get length(){return O(this,cn,ba).size}getTrackById(i){var e;return(e=[...O(this,cn,ba)].find(t=>t.id===i))!=null?e:null}get selectedIndex(){return[...O(this,cn,ba)].findIndex(i=>i.selected)}get onaddtrack(){return O(this,Jr)}set onaddtrack(i){O(this,Jr)&&(this.removeEventListener("addtrack",O(this,Jr)),de(this,Jr,void 0)),typeof i=="function"&&(de(this,Jr,i),this.addEventListener("addtrack",i))}get onremovetrack(){return O(this,es)}set onremovetrack(i){O(this,es)&&(this.removeEventListener("removetrack",O(this,es)),de(this,es,void 0)),typeof i=="function"&&(de(this,es,i),this.addEventListener("removetrack",i))}get onchange(){return O(this,ts)}set onchange(i){O(this,ts)&&(this.removeEventListener("change",O(this,ts)),de(this,ts,void 0)),typeof i=="function"&&(de(this,ts,i),this.addEventListener("change",i))}};Jr=new WeakMap,es=new WeakMap,ts=new WeakMap,cn=new WeakSet,ba=function(){return J(this).trackSet};var Md=class extends Event{constructor(i,e){super(i),qe(this,"rendition"),this.rendition=e.rendition}};function yx(i,e){let t=J(i).media.videoRenditions;J(e).media=J(i).media,J(e).track=i;let r=J(i).renditionSet;r.add(e);let s=r.size-1;s in am.prototype||Object.defineProperty(am.prototype,s,{get(){return un(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new Md("addrendition",{rendition:e}))})}function Tx(i){let e=J(i).media.videoRenditions,t=J(i).track;J(t).renditionSet.delete(i),queueMicrotask(()=>{J(i).track.selected&&e.dispatchEvent(new Md("removerendition",{rendition:i}))})}function _x(i){let e=J(i).media.videoRenditions;!e||J(e).changeRequested||(J(e).changeRequested=!0,queueMicrotask(()=>{delete J(e).changeRequested,J(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function un(i){return[...J(i).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...J(e).renditionSet])}var is,rs,ss,am=class extends EventTarget{constructor(){super(...arguments),se(this,is,void 0),se(this,rs,void 0),se(this,ss,void 0)}[Symbol.iterator](){return un(this).values()}get length(){return un(this).length}getRenditionById(i){var e;return(e=un(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return un(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of un(this).entries())t.selected=e===i}get onaddrendition(){return O(this,is)}set onaddrendition(i){O(this,is)&&(this.removeEventListener("addrendition",O(this,is)),de(this,is,void 0)),typeof i=="function"&&(de(this,is,i),this.addEventListener("addrendition",i))}get onremoverendition(){return O(this,rs)}set onremoverendition(i){O(this,rs)&&(this.removeEventListener("removerendition",O(this,rs)),de(this,rs,void 0)),typeof i=="function"&&(de(this,rs,i),this.addEventListener("removerendition",i))}get onchange(){return O(this,ss)}set onchange(i){O(this,ss)&&(this.removeEventListener("change",O(this,ss)),de(this,ss,void 0)),typeof i=="function"&&(de(this,ss,i),this.addEventListener("change",i))}};is=new WeakMap,rs=new WeakMap,ss=new WeakMap;var ya,Ax=class{constructor(){qe(this,"src"),qe(this,"id"),qe(this,"width"),qe(this,"height"),qe(this,"bitrate"),qe(this,"frameRate"),qe(this,"codec"),se(this,ya,!1)}get selected(){return O(this,ya)}set selected(i){O(this,ya)!==i&&(de(this,ya,i),_x(this))}};ya=new WeakMap;var Ta,YE=class{constructor(){qe(this,"id"),qe(this,"kind"),qe(this,"label",""),qe(this,"language",""),qe(this,"sourceBuffer"),se(this,Ta,!1)}addRendition(i,e,t,r,s,n){let a=new Ax;return a.src=i,a.width=e,a.height=t,a.frameRate=n,a.bitrate=s,a.codec=r,yx(this,a),a}removeRendition(i){Tx(i)}get selected(){return O(this,Ta)}set selected(i){O(this,Ta)!==i&&(de(this,Ta,i),i===!0&&bx(this))}};Ta=new WeakMap;function Sx(i,e){let t=J(i).media.audioRenditions;J(e).media=J(i).media,J(e).track=i;let r=J(i).renditionSet;r.add(e);let s=r.size-1;s in om.prototype||Object.defineProperty(om.prototype,s,{get(){return hn(this)[s]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new Md("addrendition",{rendition:e}))})}function xx(i){let e=J(i).media.audioRenditions,t=J(i).track;J(t).renditionSet.delete(i),queueMicrotask(()=>{J(i).track.enabled&&e.dispatchEvent(new Md("removerendition",{rendition:i}))})}function Ix(i){let e=J(i).media.audioRenditions;!e||J(e).changeRequested||(J(e).changeRequested=!0,queueMicrotask(()=>{delete J(e).changeRequested,J(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function hn(i){return[...J(i).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...J(e).renditionSet])}var ns,as,os,om=class extends EventTarget{constructor(){super(...arguments),se(this,ns,void 0),se(this,as,void 0),se(this,os,void 0)}[Symbol.iterator](){return hn(this).values()}get length(){return hn(this).length}getRenditionById(i){var e;return(e=hn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return hn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of hn(this).entries())t.selected=e===i}get onaddrendition(){return O(this,ns)}set onaddrendition(i){O(this,ns)&&(this.removeEventListener("addrendition",O(this,ns)),de(this,ns,void 0)),typeof i=="function"&&(de(this,ns,i),this.addEventListener("addrendition",i))}get onremoverendition(){return O(this,as)}set onremoverendition(i){O(this,as)&&(this.removeEventListener("removerendition",O(this,as)),de(this,as,void 0)),typeof i=="function"&&(de(this,as,i),this.addEventListener("removerendition",i))}get onchange(){return O(this,os)}set onchange(i){O(this,os)&&(this.removeEventListener("change",O(this,os)),de(this,os,void 0)),typeof i=="function"&&(de(this,os,i),this.addEventListener("change",i))}};ns=new WeakMap,as=new WeakMap,os=new WeakMap;var _a,Lx=class{constructor(){qe(this,"src"),qe(this,"id"),qe(this,"bitrate"),qe(this,"codec"),se(this,_a,!1)}get selected(){return O(this,_a)}set selected(i){O(this,_a)!==i&&(de(this,_a,i),Ix(this))}};_a=new WeakMap;function lm(i,e){let t=i.audioTracks;J(e).media=i,J(e).renditionSet||(J(e).renditionSet=new Set);let r=J(t).trackSet;r.add(e);let s=r.size-1;s in cm.prototype||Object.defineProperty(cm.prototype,s,{get(){return[...J(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Cd("addtrack",{track:e}))})}function dm(i){var e;let t=(e=J(i).media)==null?void 0:e.audioTracks;t&&(J(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Cd("removetrack",{track:i}))}))}function Rx(i){let e=J(i).media.audioTracks;!e||J(e).changeRequested||(J(e).changeRequested=!0,queueMicrotask(()=>{delete J(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var ls,ds,cs,Aa,Td,cm=class extends EventTarget{constructor(){super(),se(this,Aa),se(this,ls,void 0),se(this,ds,void 0),se(this,cs,void 0),J(this).trackSet=new Set}[Symbol.iterator](){return O(this,Aa,Td).values()}get length(){return O(this,Aa,Td).size}getTrackById(i){var e;return(e=[...O(this,Aa,Td)].find(t=>t.id===i))!=null?e:null}get onaddtrack(){return O(this,ls)}set onaddtrack(i){O(this,ls)&&(this.removeEventListener("addtrack",O(this,ls)),de(this,ls,void 0)),typeof i=="function"&&(de(this,ls,i),this.addEventListener("addtrack",i))}get onremovetrack(){return O(this,ds)}set onremovetrack(i){O(this,ds)&&(this.removeEventListener("removetrack",O(this,ds)),de(this,ds,void 0)),typeof i=="function"&&(de(this,ds,i),this.addEventListener("removetrack",i))}get onchange(){return O(this,cs)}set onchange(i){O(this,cs)&&(this.removeEventListener("change",O(this,cs)),de(this,cs,void 0)),typeof i=="function"&&(de(this,cs,i),this.addEventListener("change",i))}};ls=new WeakMap,ds=new WeakMap,cs=new WeakMap,Aa=new WeakSet,Td=function(){return J(this).trackSet};var Sa,jE=class{constructor(){qe(this,"id"),qe(this,"kind"),qe(this,"label",""),qe(this,"language",""),qe(this,"sourceBuffer"),se(this,Sa,!1)}addRendition(i,e,t){let r=new Lx;return r.src=i,r.codec=e,r.bitrate=t,Sx(this,r),r}removeRendition(i){xx(i)}get enabled(){return O(this,Sa)}set enabled(i){O(this,Sa)!==i&&(de(this,Sa,i),Rx(this))}};Sa=new WeakMap;var UE=kd(globalThis.HTMLMediaElement,"video"),FE=kd(globalThis.HTMLMediaElement,"audio");function kx(i){if(!(i!=null&&i.prototype))return i;let e=kd(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return wx(this)}});let t=kd(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return Dx(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new YE;return l.kind=n,l.label=a,l.language=o,rm(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=sm),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new jE;return l.kind=n,l.label=a,l.language=o,lm(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=dm),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return r(this)}});let r=n=>{let a=J(n).videoRenditions;return a||(a=new am,J(a).media=n,J(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=J(n).audioRenditions;return a||(a=new om,J(a).media=n,J(n).audioRenditions=a),a};return i}function kd(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function wx(i){var e;let t=J(i).videoTracks;if(!t&&(t=new nm,J(i).videoTracks=t,UE)){let r=UE.call((e=i.nativeEl)!=null?e:i);for(let s of r)rm(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof YE)){for(let n of r)sm(n);return}rm(i,s.track)}),r.addEventListener("removetrack",s=>{sm(s.track)})}return t}function Dx(i){var e;let t=J(i).audioTracks;if(!t&&(t=new cm,J(i).audioTracks=t,FE)){let r=FE.call((e=i.nativeEl)!=null?e:i);for(let s of r)lm(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof jE)){for(let n of r)dm(n);return}lm(i,s.track)}),r.addEventListener("removetrack",s=>{dm(s.track)})}return t}Dd.push("castchange","entercast","leavecast");var W={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},Cx=Object.values(W),Mx=ox(),Px="mux-video",Gi,xa,_d,Ia,Ad,Sd,xd,Id,La,Ld,Ox=class extends Kf{constructor(){super(),se(this,La),se(this,Gi,void 0),se(this,xa,void 0),se(this,_d,void 0),se(this,Ia,{}),se(this,Ad,void 0),se(this,Sd,void 0),se(this,xd,void 0),se(this,Id,void 0),de(this,_d,TE())}static get observedAttributes(){var i;return[...Cx,...(i=Kf.observedAttributes)!=null?i:[]]}get preferCmcd(){var i;return(i=this.getAttribute(W.PREFER_CMCD))!=null?i:void 0}set preferCmcd(i){i!==this.preferCmcd&&(i?ln.includes(i)?this.setAttribute(W.PREFER_CMCD,i):console.warn(`Invalid value for preferCmcd. Must be one of ${ln.join()}`):this.removeAttribute(W.PREFER_CMCD))}get playerInitTime(){return O(this,_d)}get playerSoftwareName(){var i;return(i=O(this,xd))!=null?i:Px}set playerSoftwareName(i){de(this,xd,i)}get playerSoftwareVersion(){var i;return(i=O(this,Sd))!=null?i:Mx}set playerSoftwareVersion(i){de(this,Sd,i)}get _hls(){var i;return(i=O(this,Gi))==null?void 0:i.engine}get mux(){var i;return(i=this.nativeEl)==null?void 0:i.mux}get error(){var i;return(i=_E(this.nativeEl))!=null?i:null}get errorTranslator(){return O(this,Id)}set errorTranslator(i){de(this,Id,i)}get src(){return this.getAttribute("src")}set src(i){i!==this.src&&(i==null?this.removeAttribute("src"):this.setAttribute("src",i))}get type(){var i;return(i=this.getAttribute(W.TYPE))!=null?i:void 0}set type(i){i!==this.type&&(i?this.setAttribute(W.TYPE,i):this.removeAttribute(W.TYPE))}get autoplay(){let i=this.getAttribute("autoplay");return i===null?!1:i===""?!0:i}set autoplay(i){let e=this.autoplay;i!==e&&(i?this.setAttribute("autoplay",typeof i=="string"?i:""):this.removeAttribute("autoplay"))}get preload(){let i=this.getAttribute("preload");return i===""?"auto":["none","metadata","auto"].includes(i)?i:super.preload}set preload(i){i!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(i)?this.setAttribute("preload",i):this.removeAttribute("preload"))}get debug(){return this.getAttribute(W.DEBUG)!=null}set debug(i){i!==this.debug&&(i?this.setAttribute(W.DEBUG,""):this.removeAttribute(W.DEBUG))}get disableCookies(){return this.hasAttribute(W.DISABLE_COOKIES)}set disableCookies(i){i!==this.disableCookies&&(i?this.setAttribute(W.DISABLE_COOKIES,""):this.removeAttribute(W.DISABLE_COOKIES))}get startTime(){let i=this.getAttribute(W.START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set startTime(i){i!==this.startTime&&(i==null?this.removeAttribute(W.START_TIME):this.setAttribute(W.START_TIME,`${i}`))}get playbackId(){var i;return(i=this.getAttribute(W.PLAYBACK_ID))!=null?i:void 0}set playbackId(i){i!==this.playbackId&&(i?this.setAttribute(W.PLAYBACK_ID,i):this.removeAttribute(W.PLAYBACK_ID))}get maxResolution(){var i;return(i=this.getAttribute(W.MAX_RESOLUTION))!=null?i:void 0}set maxResolution(i){i!==this.maxResolution&&(i?this.setAttribute(W.MAX_RESOLUTION,i):this.removeAttribute(W.MAX_RESOLUTION))}get minResolution(){var i;return(i=this.getAttribute(W.MIN_RESOLUTION))!=null?i:void 0}set minResolution(i){i!==this.minResolution&&(i?this.setAttribute(W.MIN_RESOLUTION,i):this.removeAttribute(W.MIN_RESOLUTION))}get renditionOrder(){var i;return(i=this.getAttribute(W.RENDITION_ORDER))!=null?i:void 0}set renditionOrder(i){i!==this.renditionOrder&&(i?this.setAttribute(W.RENDITION_ORDER,i):this.removeAttribute(W.RENDITION_ORDER))}get customDomain(){var i;return(i=this.getAttribute(W.CUSTOM_DOMAIN))!=null?i:void 0}set customDomain(i){i!==this.customDomain&&(i?this.setAttribute(W.CUSTOM_DOMAIN,i):this.removeAttribute(W.CUSTOM_DOMAIN))}get ended(){return Gf(this.nativeEl,this._hls)}get envKey(){var i;return(i=this.getAttribute(W.ENV_KEY))!=null?i:void 0}set envKey(i){i!==this.envKey&&(i?this.setAttribute(W.ENV_KEY,i):this.removeAttribute(W.ENV_KEY))}get beaconCollectionDomain(){var i;return(i=this.getAttribute(W.BEACON_COLLECTION_DOMAIN))!=null?i:void 0}set beaconCollectionDomain(i){i!==this.beaconCollectionDomain&&(i?this.setAttribute(W.BEACON_COLLECTION_DOMAIN,i):this.removeAttribute(W.BEACON_COLLECTION_DOMAIN))}get streamType(){var i;return(i=this.getAttribute(W.STREAM_TYPE))!=null?i:AE(this.nativeEl)}set streamType(i){i!==this.streamType&&(i?this.setAttribute(W.STREAM_TYPE,i):this.removeAttribute(W.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(W.TARGET_LIVE_WINDOW)?+this.getAttribute(W.TARGET_LIVE_WINDOW):SE(this.nativeEl)}set targetLiveWindow(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(W.TARGET_LIVE_WINDOW):this.setAttribute(W.TARGET_LIVE_WINDOW,`${+i}`))}get liveEdgeStart(){var i,e;if(this.hasAttribute(W.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,r=(i=this.nativeEl.seekable.end(0))!=null?i:0,s=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(s,r-t)}return xE(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(W.LIVE_EDGE_OFFSET))return+this.getAttribute(W.LIVE_EDGE_OFFSET)}set liveEdgeOffset(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(W.LIVE_EDGE_OFFSET):this.setAttribute(W.LIVE_EDGE_OFFSET,`${+i}`))}get seekable(){return $f(this.nativeEl)}async addCuePoints(i){return Ff(this.nativeEl,i)}get activeCuePoint(){return Bf(this.nativeEl)}get cuePoints(){return gE(this.nativeEl)}getStartDate(){return vE(this.nativeEl,this._hls)}get currentPdt(){return EE(this.nativeEl,this._hls)}get preferPlayback(){let i=this.getAttribute(W.PREFER_PLAYBACK);if(i===ai.MSE||i===ai.NATIVE)return i}set preferPlayback(i){i!==this.preferPlayback&&(i===ai.MSE||i===ai.NATIVE?this.setAttribute(W.PREFER_PLAYBACK,i):this.removeAttribute(W.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(i=>i.startsWith("metadata-")&&![W.METADATA_URL].includes(i)).reduce((i,e)=>{let t=this.getAttribute(e);return t!=null&&(i[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),i},{}),...O(this,Ia)}}set metadata(i){de(this,Ia,i!=null?i:{}),this.mux&&this.mux.emit("hb",O(this,Ia))}get _hlsConfig(){return O(this,Ad)}set _hlsConfig(i){de(this,Ad,i)}load(){de(this,Gi,LE(this,this.nativeEl,O(this,Gi)))}unload(){Hf(this.nativeEl,O(this,Gi)),de(this,Gi,void 0)}attributeChangedCallback(i,e,t){var r,s;switch(Kf.observedAttributes.includes(i)&&!["src","autoplay","preload"].includes(i)&&super.attributeChangedCallback(i,e,t),i){case W.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case W.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?at(this,La,Ld).call(this):n&&!a?this.unload():n&&a&&(this.unload(),at(this,La,Ld).call(this));break}case"autoplay":if(t===e)break;(r=O(this,Gi))==null||r.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=O(this,Gi))==null||s.setPreload(t);break;case W.PLAYBACK_ID:this.src=Ea(this);break;case W.DEBUG:{let n=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=n);break}case W.METADATA_URL:t&&fetch(t).then(n=>n.json()).then(n=>this.metadata=n).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${t}!`));break;case W.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case W.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}connectedCallback(){var i;(i=super.connectedCallback)==null||i.call(this),this.nativeEl&&this.src&&!O(this,Gi)&&at(this,La,Ld).call(this)}disconnectedCallback(){this.unload()}};Gi=new WeakMap,xa=new WeakMap,_d=new WeakMap,Ia=new WeakMap,Ad=new WeakMap,Sd=new WeakMap,xd=new WeakMap,Id=new WeakMap,La=new WeakSet,Ld=async function(){O(this,xa)||(await de(this,xa,Promise.resolve()),de(this,xa,null),this.load())};var um=class extends vx(kx(Ox)){};Wf.customElements.get("mux-video")||(Wf.customElements.define("mux-video",um),Wf.MuxVideoElement=um);var zE=um;var Nx="en",ms={code:Nx};var XE="en";function xe(i,e=!0){var s,n;let t=e&&(n=(s=ms)==null?void 0:s[i])!=null?n:i,r=e?ms.code:XE;return new gm(t,r)}var gm=class{constructor(e,t=(r=>(r=ms.code)!=null?r:XE)()){this.message=e,this.locale=t}format(e){return this.message.replace(/\{(\w+)\}/g,(t,r)=>{var s;return(s=e[r])!=null?s:""})}toString(){return this.message}};function QE(i){let e="";return Object.entries(i).forEach(([t,r])=>{r!=null&&(e+=`${Pd(t)}: ${r}; `)}),e?e.trim():void 0}function Pd(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Od(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Hi(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function vm(i){let e=Ux(i).toString();return e?"?"+e:""}function Ux(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}function Ar(i){let e=(i!=null?i:"").split(".")[1];if(!e)return{};let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)}var Em=(i,e)=>!i||!e?!1:i.contains(e)?!0:Em(i,e.getRootNode().host);var ZE="mux.com",Fx=()=>{try{return"2.3.2"}catch{}return"UNKNOWN"},Bx=Fx(),Ud=()=>Bx,JE=(i,{token:e,customDomain:t=ZE,thumbnailTime:r}={})=>{let s=e==null?r:void 0,{aud:n}=Ar(e);if(!(e&&n!=="t"))return`https://image.${t}/${i}/thumbnail.webp${vm({token:e,time:s})}`},eb=(i,{token:e,customDomain:t=ZE}={})=>{let{aud:r}=Ar(e);if(!(e&&r!=="s"))return`https://image.${t}/${i}/storyboard.vtt${vm({token:e,format:"webp"})}`},Ra=i=>{if(i){if([Ye.LIVE,Ye.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return Ye.LIVE}};var $x={crossorigin:"crossOrigin",playsinline:"playsInline"};function tb(i){var e;return(e=$x[i])!=null?e:Od(i)}var ps,gs,Mt,Nd=class{constructor(e,t){dt(this,ps,void 0);dt(this,gs,void 0);dt(this,Mt,[]);Jt(this,ps,e),Jt(this,gs,t)}[Symbol.iterator](){return Pe(this,Mt).values()}get length(){return Pe(this,Mt).length}get value(){var e;return(e=Pe(this,Mt).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Jt(this,Mt,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return Pe(this,Mt)[e]}values(){return Pe(this,Mt).values()}keys(){return Pe(this,Mt).keys()}forEach(e){Pe(this,Mt).forEach(e)}add(...e){var t,r;e.forEach(s=>{this.contains(s)||Pe(this,Mt).push(s)}),!(this.value===""&&!((t=Pe(this,ps))!=null&&t.hasAttribute(`${Pe(this,gs)}`)))&&((r=Pe(this,ps))==null||r.setAttribute(`${Pe(this,gs)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>{Pe(this,Mt).splice(Pe(this,Mt).indexOf(r),1)}),(t=Pe(this,ps))==null||t.setAttribute(`${Pe(this,gs)}`,`${this.value}`)}contains(e){return Pe(this,Mt).includes(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};ps=new WeakMap,gs=new WeakMap,Mt=new WeakMap;var ib=`[mux-player ${Ud()}]`;function Sr(...i){console.warn(ib,...i)}function li(...i){console.error(ib,...i)}function bm(i){var t;let e=(t=i.message)!=null?t:"";if(i.context&&(e+=` ${i.context}`),i.file){let r="https://github.com/muxinc/elements/blob/main/errors/";e+=` ${xe("Read more: ")}
1122
- ${r}${i.file}`}Sr(e)}var Rt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},vs={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},sb=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),Gx=Dd.filter(i=>i!=="error"),Hx=Object.values(Rt).filter(i=>![Rt.PLAYSINLINE].includes(i)),Vx=Object.values(vs);function nb(i){i.querySelectorAll(":scope > track").forEach(e=>{var t;(t=i.media)==null||t.append(e.cloneNode())}),Gx.forEach(e=>{var t;(t=i.media)==null||t.addEventListener(e,r=>{i.dispatchEvent(new Event(r.type))})})}var ym=class extends Je.HTMLElement{static get observedAttributes(){return[...Hx,...Vx]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(r=>{var s;(s=this.media)==null||s.append(r.cloneNode())});let e=r=>{for(let s of r)s.type==="childList"&&(s.removedNodes.forEach(n=>{var o,l;let a=(o=this.media)==null?void 0:o.querySelector(`track[src="${n.src}"]`);a&&((l=this.media)==null||l.removeChild(a))}),s.addedNodes.forEach(n=>{var a;(a=this.media)==null||a.append(n.cloneNode())}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(e,t,r){var s,n;switch(e){case vs.MUTED:{this.media&&(this.media.muted=r!=null,this.media.defaultMuted=r!=null);return}case vs.VOLUME:{let a=(s=Hi(r))!=null?s:1;this.media&&(this.media.volume=a);return}case vs.PLAYBACKRATE:{let a=(n=Hi(r))!=null?n:1;this.media&&(this.media.playbackRate=a,this.media.defaultPlaybackRate=a);return}}}play(){var e,t;return(t=(e=this.media)==null?void 0:e.play())!=null?t:Promise.reject()}pause(){var e;(e=this.media)==null||e.pause()}requestCast(e){var t;return(t=this.media)==null?void 0:t.requestCast(e)}get media(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var e,t;return(t=(e=this.media)==null?void 0:e.paused)!=null?t:!0}get duration(){var e,t;return(t=(e=this.media)==null?void 0:e.duration)!=null?t:NaN}get ended(){var e,t;return(t=(e=this.media)==null?void 0:e.ended)!=null?t:!1}get buffered(){var e,t;return(t=(e=this.media)==null?void 0:e.buffered)!=null?t:sb}get seekable(){var e,t;return(t=(e=this.media)==null?void 0:e.seekable)!=null?t:sb}get readyState(){var e,t;return(t=(e=this.media)==null?void 0:e.readyState)!=null?t:0}get videoWidth(){var e,t;return(t=(e=this.media)==null?void 0:e.videoWidth)!=null?t:0}get videoHeight(){var e,t;return(t=(e=this.media)==null?void 0:e.videoHeight)!=null?t:0}get currentTime(){var e,t;return(t=(e=this.media)==null?void 0:e.currentTime)!=null?t:0}set currentTime(e){this.media&&(this.media.currentTime=Number(e))}get volume(){var e,t;return(t=(e=this.media)==null?void 0:e.volume)!=null?t:1}set volume(e){this.media&&(this.media.volume=Number(e))}get playbackRate(){var e,t;return(t=(e=this.media)==null?void 0:e.playbackRate)!=null?t:1}set playbackRate(e){this.media&&(this.media.playbackRate=Number(e))}get defaultPlaybackRate(){var e;return(e=Hi(this.getAttribute(vs.PLAYBACKRATE)))!=null?e:1}set defaultPlaybackRate(e){e!=null?this.setAttribute(vs.PLAYBACKRATE,`${e}`):this.removeAttribute(vs.PLAYBACKRATE)}get crossOrigin(){return ka(this,Rt.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(Rt.CROSSORIGIN,`${e}`)}get autoplay(){return ka(this,Rt.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(Rt.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(Rt.AUTOPLAY)}get loop(){return ka(this,Rt.LOOP)!=null}set loop(e){e?this.setAttribute(Rt.LOOP,""):this.removeAttribute(Rt.LOOP)}get muted(){var e,t;return(t=(e=this.media)==null?void 0:e.muted)!=null?t:!1}set muted(e){this.media&&(this.media.muted=!!e)}get defaultMuted(){return ka(this,Rt.MUTED)!=null}set defaultMuted(e){e?this.setAttribute(Rt.MUTED,""):this.removeAttribute(Rt.MUTED)}get playsInline(){return ka(this,Rt.PLAYSINLINE)!=null}set playsInline(e){li("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(e){["","none","metadata","auto"].includes(e)?this.setAttribute(Rt.PRELOAD,e):this.removeAttribute(Rt.PRELOAD)}};function ka(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var Tm=ym;var Wx=Object.defineProperty,Kx=(i,e,t)=>e in i?Wx(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,qx=(i,e,t)=>(Kx(i,typeof e!="symbol"?e+"":e,t),t),cb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Se=(i,e,t)=>(cb(i,e,"read from private field"),t?t.call(i):e.get(i)),Vi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Zi=(i,e,t,r)=>(cb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),mn,Fd,Es,wa,xr,Ir,Lr,bs,pn,Bd,Ti,ab=1,ob=0,Yx=1,jx={processCallback(i,e,t){if(t){for(let[r,s]of e)if(r in t){let n=t[r];typeof n=="boolean"&&s instanceof Pt&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Pt?s.element[s.attributeName]=n:s.value=n}}}},Ji=class extends D.DocumentFragment{constructor(e,t,r=jx){var s;super(),Vi(this,mn,void 0),Vi(this,Fd,void 0),this.append(e.content.cloneNode(!0)),Zi(this,mn,ub(this)),Zi(this,Fd,r),(s=r.createCallback)==null||s.call(r,this,Se(this,mn),t),r.processCallback(this,Se(this,mn),t)}update(e){Se(this,Fd).processCallback(this,Se(this,mn),e)}};mn=new WeakMap;Fd=new WeakMap;var ub=(i,e=[])=>{let t,r;for(let s of i.attributes||[])if(s.value.includes("{{")){let n=new _m;for([t,r]of db(s.value))if(!t)n.append(r);else{let a=new Pt(i,s.name,s.namespaceURI);n.append(a),e.push([r,a])}s.value=n.toString()}for(let s of i.childNodes)if(s.nodeType===ab&&!(s instanceof HTMLTemplateElement))ub(s,e);else if(s.nodeType===ab||s.data.includes("{{")){let n=[];if(s.data)for([t,r]of db(s.data))if(!t)n.push(new Text(r));else{let a=new er(i);n.push(a),e.push([r,a])}else if(s instanceof HTMLTemplateElement){let a=new Da(i,s);n.push(a),e.push([a.expression,a])}s.replaceWith(...n.flatMap(a=>a.replacementNodes||[a]))}return e},lb={},db=i=>{let e="",t=0,r=lb[i],s=0,n;if(r)return r;for(r=[];n=i[s];s++)n==="{"&&i[s+1]==="{"&&i[s-1]!=="\\"&&i[s+2]&&++t==1?(e&&r.push([ob,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([Yx,e.trim()]),e="",s++):e+=n||"";return e&&r.push([ob,(t>0?"{{":"")+e]),lb[i]=r},zx=11,$d=class{get value(){return""}set value(e){}toString(){return this.value}},hb=new WeakMap,_m=class{constructor(){Vi(this,Es,[])}[Symbol.iterator](){return Se(this,Es).values()}get length(){return Se(this,Es).length}item(e){return Se(this,Es)[e]}append(...e){for(let t of e)t instanceof Pt&&hb.set(t,this),Se(this,Es).push(t)}toString(){return Se(this,Es).join("")}};Es=new WeakMap;var Pt=class extends $d{constructor(e,t,r){super(),Vi(this,bs),Vi(this,wa,""),Vi(this,xr,void 0),Vi(this,Ir,void 0),Vi(this,Lr,void 0),Zi(this,xr,e),Zi(this,Ir,t),Zi(this,Lr,r)}get attributeName(){return Se(this,Ir)}get attributeNamespace(){return Se(this,Lr)}get element(){return Se(this,xr)}get value(){return Se(this,wa)}set value(e){Se(this,wa)!==e&&(Zi(this,wa,e),!Se(this,bs,pn)||Se(this,bs,pn).length===1?e==null?Se(this,xr).removeAttributeNS(Se(this,Lr),Se(this,Ir)):Se(this,xr).setAttributeNS(Se(this,Lr),Se(this,Ir),e):Se(this,xr).setAttributeNS(Se(this,Lr),Se(this,Ir),Se(this,bs,pn)))}get booleanValue(){return Se(this,xr).hasAttributeNS(Se(this,Lr),Se(this,Ir))}set booleanValue(e){if(!Se(this,bs,pn)||Se(this,bs,pn).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};wa=new WeakMap;xr=new WeakMap;Ir=new WeakMap;Lr=new WeakMap;bs=new WeakSet;pn=function(){return hb.get(this)};var er=class extends $d{constructor(e,t){super(),Vi(this,Bd,void 0),Vi(this,Ti,void 0),Zi(this,Bd,e),Zi(this,Ti,t?[...t]:[new Text])}get replacementNodes(){return Se(this,Ti)}get parentNode(){return Se(this,Bd)}get nextSibling(){return Se(this,Ti)[Se(this,Ti).length-1].nextSibling}get previousSibling(){return Se(this,Ti)[0].previousSibling}get value(){return Se(this,Ti).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(r=>r==null?[new Text]:r.forEach?[...r]:r.nodeType===zx?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),Zi(this,Ti,Xx(Se(this,Ti)[0].parentNode,Se(this,Ti),t,this.nextSibling))}};Bd=new WeakMap;Ti=new WeakMap;var Da=class extends er{constructor(e,t){let r=t.getAttribute("directive")||t.getAttribute("type"),s=t.getAttribute("expression")||t.getAttribute(r)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),qx(this,"directive"),this.expression=s,this.template=t,this.directive=r}};function Xx(i,e,t,r=null){let s=0,n,a,o,l=t.length,d=e.length;for(;s<l&&s<d&&e[s]==t[s];)s++;for(;s<l&&s<d&&t[l-1]==e[d-1];)r=t[--d,--l];if(s==d)for(;s<l;)i.insertBefore(t[s++],r);if(s==l)for(;s<d;)i.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:r,n==o?n=a:s<l&&t[s]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=r;)a=n.nextSibling,i.removeChild(n),n=a}return t}var fb={string:i=>String(i)},Hd=class{constructor(e){this.template=e,this.state=void 0}},ys=new WeakMap,Ts=new WeakMap,Am={partial:(i,e)=>{e[i.expression]=new Hd(i.template)},if:(i,e)=>{var t;if(pb(i.expression,e))if(ys.get(i)!==i.template){ys.set(i,i.template);let r=new Ji(i.template,e,Vd);i.replace(r),Ts.set(i,r)}else(t=Ts.get(i))==null||t.update(e);else i.replace(""),ys.delete(i),Ts.delete(i)}},Qx=Object.keys(Am),Vd={processCallback(i,e,t){var r,s;if(t)for(let[n,a]of e){if(a instanceof Da){if(!a.directive){let l=Qx.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=Am[a.directive])==null||r.call(Am,a,t);continue}let o=pb(n,t);if(o instanceof Hd){ys.get(a)!==o.template?(ys.set(a,o.template),o=new Ji(o.template,o.state,Vd),a.value=o,Ts.set(a,o)):(s=Ts.get(a))==null||s.update(o.state);continue}o?(a instanceof Pt&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Pt?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,ys.delete(a),Ts.delete(a))):a instanceof Pt?a.value=void 0:(a.value=void 0,ys.delete(a),Ts.delete(a))}}},mb={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i!=null?i:e,"|":(i,e)=>{var t;return(t=fb[e])==null?void 0:t.call(fb,i)}};function Zx(i){return Jx(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function pb(i,e={}){var t,r,s,n,a,o,l;let d=Zx(i);if(d.length===0||d.some(({type:c})=>!c))return Ca(i);if(((t=d[0])==null?void 0:t.token)===">"){let c=e[(r=d[1])==null?void 0:r.token];if(!c)return Ca(i);let u={...e};c.state=u;let h=d.slice(2);for(let f=0;f<h.length;f+=3){let g=(s=h[f])==null?void 0:s.token,E=(n=h[f+1])==null?void 0:n.token,T=(a=h[f+2])==null?void 0:a.token;g&&E==="="&&(u[g]=Ma(T,e))}return c}if(d.length===1)return Gd(d[0])?Ma(d[0].token,e):Ca(i);if(d.length===2){let c=(o=d[0])==null?void 0:o.token,u=mb[c];if(!u||!Gd(d[1]))return Ca(i);let h=Ma(d[1].token,e);return u(h)}if(d.length===3){let c=(l=d[1])==null?void 0:l.token,u=mb[c];if(!u||!Gd(d[0])||!Gd(d[2]))return Ca(i);let h=Ma(d[0].token,e);if(c==="|")return u(h,d[2].token);let f=Ma(d[2].token,e);return u(h,f)}}function Ca(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function Gd({type:i}){return["number","boolean","string","param"].includes(i)}function Ma(i,e){let t=i[0],r=i.slice(-1);return i==="true"||i==="false"?i==="true":t===r&&["'",'"'].includes(t)?i.slice(1,-1):Ya(i)?parseFloat(i):e[i]}function Jx(i,e){let t,r,s,n=[];for(;i;){s=null,t=i.length;for(let a in e)r=e[a].exec(i),r&&r.index<t&&(s={token:r[0],type:a,matches:r.slice(1)},t=r.index);t&&n.push({token:i.substr(0,t),type:void 0}),s&&n.push(s),i=i.substr(t+(s?s.token.length:0))}return n}var eI=Object.defineProperty,tI=(i,e,t)=>e in i?eI(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Oa=(i,e,t)=>(tI(i,typeof e!="symbol"?e+"":e,t),t),km=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Im=(i,e,t)=>(km(i,e,"read from private field"),t?t.call(i):e.get(i)),Pa=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},_s=(i,e,t,r)=>(km(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Sm=(i,e,t)=>(km(i,e,"access private method"),t),gn,Wd,vn,Lm,gb,Kd,Rm,xm={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},vb=q.createElement("template");vb.innerHTML=`
1196
+ `);var tb=(i,{tag:e,is:t})=>{var r,s,n,a,o,l,d,c,u,h,f,g,E,T,S,k;let L=(r=globalThis.document)==null?void 0:r.createElement(e,{is:t}),F=L?Ix(L):[];return s=class extends i{constructor(){super(),se(this,u),se(this,f),se(this,E),se(this,S),se(this,l,void 0),se(this,d,void 0),se(this,c,new Map),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var R,B,P;return ot(R=s,a,o).call(R),[...(P=(B=L==null?void 0:L.constructor)==null?void 0:B.observedAttributes)!=null?P:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var R,B,P;return(P=(B=(R=O(this,d))!=null?R:this.shadowRoot.querySelector(e))!=null?B:this.querySelector(":scope > [slot=media]"))!=null?P:this.querySelector(e)}set nativeEl(R){de(this,d,R)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(R){this.toggleAttribute("muted",!!R)}get src(){return this.getAttribute("src")}set src(R){this.setAttribute("src",`${R}`)}get preload(){var R,B;return(B=this.getAttribute("preload"))!=null?B:(R=this.nativeEl)==null?void 0:R.preload}set preload(R){this.setAttribute("preload",`${R}`)}init(){var R,B;if(!this.nativeEl){let P=document.createElement(e,{is:t});P.part=e,this.shadowRoot.querySelector('slot[name="media"]').append(P)}this.nativeEl.muted=this.hasAttribute("muted");for(let P of F)ot(this,E,T).call(this,P);this.shadowRoot.addEventListener("slotchange",this);for(let P of this.constructor.Events)(B=(R=this.shadowRoot).addEventListener)==null||B.call(R,P,this,!0)}handleEvent(R){if(R.type==="slotchange"){ot(this,f,g).call(this);return}R.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(R.type,{detail:R.detail}))}attributeChangedCallback(R,B,P){ot(this,u,h).call(this),ot(this,S,k).call(this,R,B,P)}connectedCallback(){ot(this,u,h).call(this)}},n=new WeakMap,a=new WeakSet,o=function(){if(O(this,n))return;de(this,n,!0);let R=new Set(this.observedAttributes);R.delete("muted");for(let B of F)if(!(B in this.prototype))if(typeof L[B]=="function")this.prototype[B]=function(...P){return ot(this,u,h).call(this),this.call?this.call(B,...P):this.nativeEl[B].apply(this.nativeEl,P)};else{let P={get(){var H,V,N;ot(this,u,h).call(this);let j=B.toLowerCase();if(R.has(j)){let Y=this.getAttribute(j);return Y===null?!1:Y===""?!0:Y}return(N=(H=this.get)==null?void 0:H.call(this,B))!=null?N:(V=this.nativeEl)==null?void 0:V[B]}};B!==B.toUpperCase()&&(P.set=function(H){ot(this,u,h).call(this);let V=B.toLowerCase();if(R.has(V)){H===!0||H===!1||H==null?this.toggleAttribute(V,!!H):this.setAttribute(V,H);return}if(this.set){this.set(B,H);return}this.nativeEl[B]=H}),Object.defineProperty(this.prototype,B,P)}},l=new WeakMap,d=new WeakMap,c=new WeakMap,u=new WeakSet,h=function(){O(this,l)||(de(this,l,!0),this.init())},f=new WeakSet,g=function(){let R=new Map(O(this,c));this.shadowRoot.querySelector("slot:not([name])").assignedElements().filter(B=>["track","source"].includes(B.localName)).forEach(B=>{var P,H;R.delete(B);let V=O(this,c).get(B);V||(V=B.cloneNode(),O(this,c).set(B,V)),(H=(P=this.nativeEl).append)==null||H.call(P,V),V.localName==="track"&&V.default&&(V.kind==="chapters"||V.kind==="metadata")&&V.track.mode==="disabled"&&(V.track.mode="hidden")}),R.forEach(B=>B.remove())},E=new WeakSet,T=function(R){if(Object.prototype.hasOwnProperty.call(this,R)){let B=this[R];delete this[R],this[R]=B}},S=new WeakSet,k=function(R,B,P){var H,V,N,j,Y,Ee;["id","class"].includes(R)||!s.observedAttributes.includes(R)&&this.constructor.observedAttributes.includes(R)||(P===null?(V=(H=this.nativeEl).removeAttribute)==null||V.call(H,R):((j=(N=this.nativeEl).getAttribute)==null?void 0:j.call(N,R))!=P&&((Ee=(Y=this.nativeEl).setAttribute)==null||Ee.call(Y,R,P)))},se(s,a),qe(s,"Events",Fd),qe(s,"template",e.endsWith("audio")?rm:sm),se(s,n,void 0),s};function Ix(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}var em=globalThis.document?tb(HTMLElement,{tag:"video"}):class{},sM=globalThis.document?tb(HTMLElement,{tag:"audio"}):class{},fs=new WeakMap,tm=class extends Error{},Lx=class extends Error{},Rx=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function kx(i){ib()?rb()?i(chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>i(chrome.cast.isAvailable)):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>i(chrome.cast.isAvailable))}}function wx(){return globalThis.chrome}function Dx(){let i="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if(globalThis.chrome.cast||document.querySelector(`script[src="${i}"]`))return;let e=document.createElement("script");e.src=i,document.head.append(e)}function ib(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable}function rb(){return typeof cast!="undefined"&&cast.framework}function ms(){if(rb())return cast.framework.CastContext.getInstance()}function Am(){var i;return(i=ms())==null?void 0:i.getCurrentSession()}function Sm(){var i;return(i=Am())==null?void 0:i.getSessionObj().media[0]}function Cx(i){return new Promise((e,t)=>{Sm().editTracksInfo(i,e,t)})}function Mx(i){return new Promise((e,t)=>{Sm().getStatus(i,e,t)})}function sb(i){return ms().setOptions({...nb(),...i})}function nb(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}var Sd=new Rx,Ar=new WeakSet,mt;kx(i=>{i&&!mt&&(mt=cast.framework,ms().addEventListener(mt.CastContextEventType.CAST_STATE_CHANGED,e=>{Sd.forEach(t=>{var r,s;return(s=(r=fs.get(t)).onCastStateChanged)==null?void 0:s.call(r,e)})}),ms().addEventListener(mt.CastContextEventType.SESSION_STATE_CHANGED,e=>{Sd.forEach(t=>{var r,s;return(s=(r=fs.get(t)).onSessionStateChanged)==null?void 0:s.call(r,e)})}),Sd.forEach(e=>{var t,r;return(r=(t=fs.get(e)).init)==null?void 0:r.call(t)}))});var jE=0,Be,xd,di,Tr,mn,cn,hs,nm,_r,Jr,am,zE,Od,om,lm,ab,Id,dm,cm,XE,Ld,im,Px=class extends EventTarget{constructor(i){super(),se(this,_r),se(this,am),se(this,Od),se(this,lm),se(this,Id),se(this,cm),se(this,Ld),se(this,Be,void 0),se(this,xd,void 0),se(this,di,void 0),se(this,Tr,void 0),se(this,mn,"disconnected"),se(this,cn,!1),se(this,hs,new Set),se(this,nm,new WeakMap),de(this,Be,i),Sd.add(this),fs.set(this,{init:()=>ot(this,Id,dm).call(this),onCastStateChanged:()=>ot(this,Od,om).call(this),onSessionStateChanged:()=>ot(this,lm,ab).call(this),getCastPlayer:()=>O(this,_r,Jr)}),ot(this,Id,dm).call(this)}get state(){return O(this,mn)}async watchAvailability(i){if(O(this,Be).disableRemotePlayback)throw new tm("disableRemotePlayback attribute is present.");return O(this,nm).set(i,++jE),O(this,hs).add(i),jE}async cancelWatchAvailability(i){if(O(this,Be).disableRemotePlayback)throw new tm("disableRemotePlayback attribute is present.");i?O(this,hs).delete(i):O(this,hs).clear()}async prompt(){var i,e;if(O(this,Be).disableRemotePlayback)throw new tm("disableRemotePlayback attribute is present.");if(!ib())throw new Lx("The RemotePlayback API is disabled on this platform.");let t=Ar.has(O(this,Be));Ar.add(O(this,Be)),sb(O(this,Be).castOptions),Object.entries(O(this,Tr)).forEach(([r,s])=>{O(this,di).controller.addEventListener(r,s)});try{await ms().requestSession()}catch(r){if(r==="cancel"){t||Ar.delete(O(this,Be));return}throw new Error(r)}(e=(i=fs.get(O(this,Be)))==null?void 0:i.loadOnPrompt)==null||e.call(i)}};Be=new WeakMap,xd=new WeakMap,di=new WeakMap,Tr=new WeakMap,mn=new WeakMap,cn=new WeakMap,hs=new WeakMap,nm=new WeakMap,_r=new WeakSet,Jr=function(){if(Ar.has(O(this,Be)))return O(this,di)},am=new WeakSet,zE=function(){Ar.has(O(this,Be))&&(Object.entries(O(this,Tr)).forEach(([i,e])=>{O(this,di).controller.removeEventListener(i,e)}),Ar.delete(O(this,Be)),O(this,Be).muted=O(this,di).isMuted,O(this,Be).currentTime=O(this,di).savedPlayerState.currentTime,O(this,di).savedPlayerState.isPaused===!1&&O(this,Be).play())},Od=new WeakSet,om=function(){let i=ms().getCastState();if(Ar.has(O(this,Be))&&i==="CONNECTING"&&(de(this,mn,"connecting"),this.dispatchEvent(new Event("connecting"))),!O(this,cn)&&i!=null&&i.includes("CONNECT")){de(this,cn,!0);for(let e of O(this,hs))e(!0)}else if(O(this,cn)&&(!i||i==="NO_DEVICES_AVAILABLE")){de(this,cn,!1);for(let e of O(this,hs))e(!1)}},lm=new WeakSet,ab=async function(){var i;let{SESSION_RESUMED:e}=mt.SessionState;if(ms().getSessionState()===e&&O(this,Be).castSrc===((i=Sm())==null?void 0:i.media.contentId)){Ar.add(O(this,Be)),Object.entries(O(this,Tr)).forEach(([t,r])=>{O(this,di).controller.addEventListener(t,r)});try{await Mx(new chrome.cast.media.GetStatusRequest)}catch(t){console.error(t)}O(this,Tr)[mt.RemotePlayerEventType.IS_PAUSED_CHANGED](),O(this,Tr)[mt.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},Id=new WeakSet,dm=function(){!mt||O(this,xd)||(de(this,xd,!0),sb(O(this,Be).castOptions),O(this,Be).textTracks.addEventListener("change",()=>ot(this,Ld,im).call(this)),ot(this,Od,om).call(this),de(this,di,new mt.RemotePlayer),new mt.RemotePlayerController(O(this,di)),de(this,Tr,{[mt.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:i})=>{i===!0?(de(this,mn,"connected"),this.dispatchEvent(new Event("connect"))):(ot(this,am,zE).call(this),de(this,mn,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[mt.RemotePlayerEventType.DURATION_CHANGED]:()=>{O(this,Be).dispatchEvent(new Event("durationchange"))},[mt.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{O(this,Be).dispatchEvent(new Event("volumechange"))},[mt.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{O(this,Be).dispatchEvent(new Event("volumechange"))},[mt.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var i;(i=O(this,_r,Jr))!=null&&i.isMediaLoaded&&O(this,Be).dispatchEvent(new Event("timeupdate"))},[mt.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{O(this,Be).dispatchEvent(new Event("resize"))},[mt.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{O(this,Be).dispatchEvent(new Event(this.paused?"pause":"play"))},[mt.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var i,e;((i=O(this,_r,Jr))==null?void 0:i.playerState)!==chrome.cast.media.PlayerState.PAUSED&&O(this,Be).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(e=O(this,_r,Jr))==null?void 0:e.playerState]))},[mt.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var i;(i=O(this,_r,Jr))!=null&&i.isMediaLoaded&&(await Promise.resolve(),ot(this,cm,XE).call(this))}}))},cm=new WeakSet,XE=function(){ot(this,Ld,im).call(this)},Ld=new WeakSet,im=async function(){var i,e,t,r,s;if(!O(this,_r,Jr))return;let n=((e=(i=O(this,di).mediaInfo)==null?void 0:i.tracks)!=null?e:[]).filter(({type:h})=>h===chrome.cast.media.TrackType.TEXT),a=[...O(this,Be).textTracks].filter(({kind:h})=>h==="subtitles"||h==="captions"),o=n.map(({language:h,name:f,trackId:g})=>{var E;let{mode:T}=(E=a.find(S=>S.language===h&&S.label===f))!=null?E:{};return T?{mode:T,trackId:g}:!1}).filter(Boolean),l=o.filter(({mode:h})=>h!=="showing").map(({trackId:h})=>h),d=o.find(({mode:h})=>h==="showing"),c=(s=(r=(t=Am())==null?void 0:t.getSessionObj().media[0])==null?void 0:r.activeTrackIds)!=null?s:[],u=c;if(c.length&&(u=u.filter(h=>!l.includes(h))),d!=null&&d.trackId&&(u=[...u,d.trackId]),u=[...new Set(u)],!((h,f)=>h.length===f.length&&h.every(g=>f.includes(g)))(c,u))try{let h=new chrome.cast.media.EditTracksInfoRequest(u);await Cx(h)}catch(h){console.error(h)}};var Ox=i=>{var e,t,r,s,n,a,o,l,d;return t=class extends i{constructor(){super(...arguments),se(this,a),se(this,l),se(this,r,{paused:!1}),se(this,s,nb()),se(this,n,void 0)}get remote(){return O(this,n)?O(this,n):wx()?(Dx(),fs.set(this,{loadOnPrompt:()=>ot(this,l,d).call(this)}),de(this,n,new Px(this))):super.remote}attributeChangedCallback(c,u,h){if(super.attributeChangedCallback(c,u,h),c==="cast-receiver"&&h){O(this,s).receiverApplicationId=h;return}if(O(this,a,o))switch(c){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var c,u;if(!O(this,a,o))return super.load();let h=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),f=[...this.querySelectorAll("track")].filter(({kind:S,src:k})=>k&&(S==="subtitles"||S==="captions")),g=[],E=0;f.length&&(h.tracks=f.map(S=>{let k=++E;g.length===0&&S.track.mode==="showing"&&g.push(k);let L=new chrome.cast.media.Track(k,chrome.cast.media.TrackType.TEXT);return L.trackContentId=S.src,L.trackContentType="text/vtt",L.subtype=S.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,L.name=S.label,L.language=S.srclang,L})),this.castStreamType==="live"?h.streamType=chrome.cast.media.StreamType.LIVE:h.streamType=chrome.cast.media.StreamType.BUFFERED,h.metadata=new chrome.cast.media.GenericMediaMetadata,h.metadata.title=this.title,h.metadata.images=[{url:this.poster}];let T=new chrome.cast.media.LoadRequest(h);T.currentTime=(c=super.currentTime)!=null?c:0,T.autoplay=!O(this,r).paused,T.activeTrackIds=g,await((u=Am())==null?void 0:u.loadMedia(T)),this.dispatchEvent(new Event("volumechange"))}play(){var c;if(O(this,a,o)){O(this,a,o).isPaused&&((c=O(this,a,o).controller)==null||c.playOrPause());return}return super.play()}pause(){var c;if(O(this,a,o)){O(this,a,o).isPaused||(c=O(this,a,o).controller)==null||c.playOrPause();return}super.pause()}get castOptions(){return O(this,s)}get castReceiver(){var c;return(c=this.getAttribute("cast-receiver"))!=null?c:void 0}set castReceiver(c){this.castReceiver!=c&&this.setAttribute("cast-receiver",`${c}`)}get castSrc(){var c,u,h;return(h=(u=this.getAttribute("cast-src"))!=null?u:(c=this.querySelector("source"))==null?void 0:c.src)!=null?h:this.currentSrc}set castSrc(c){this.castSrc!=c&&this.setAttribute("cast-src",`${c}`)}get castContentType(){var c;return(c=this.getAttribute("cast-content-type"))!=null?c:void 0}set castContentType(c){this.setAttribute("cast-content-type",`${c}`)}get castStreamType(){var c,u;return(u=(c=this.getAttribute("cast-stream-type"))!=null?c:this.streamType)!=null?u:void 0}set castStreamType(c){this.setAttribute("cast-stream-type",`${c}`)}get readyState(){if(O(this,a,o))switch(O(this,a,o).playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return O(this,a,o)?O(this,a,o).isPaused:super.paused}get muted(){var c;return O(this,a,o)?(c=O(this,a,o))==null?void 0:c.isMuted:super.muted}set muted(c){var u;if(O(this,a,o)){(c&&!O(this,a,o).isMuted||!c&&O(this,a,o).isMuted)&&((u=O(this,a,o).controller)==null||u.muteOrUnmute());return}super.muted=c}get volume(){var c,u;return O(this,a,o)?(u=(c=O(this,a,o))==null?void 0:c.volumeLevel)!=null?u:1:super.volume}set volume(c){var u;if(O(this,a,o)){O(this,a,o).volumeLevel=+c,(u=O(this,a,o).controller)==null||u.setVolumeLevel();return}super.volume=c}get duration(){var c,u,h;return O(this,a,o)&&(c=O(this,a,o))!=null&&c.isMediaLoaded?(h=(u=O(this,a,o))==null?void 0:u.duration)!=null?h:NaN:super.duration}get currentTime(){var c,u,h;return O(this,a,o)&&(c=O(this,a,o))!=null&&c.isMediaLoaded?(h=(u=O(this,a,o))==null?void 0:u.currentTime)!=null?h:0:super.currentTime}set currentTime(c){var u;if(O(this,a,o)){O(this,a,o).currentTime=c,(u=O(this,a,o).controller)==null||u.seek();return}super.currentTime=c}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakSet,o=function(){var c,u;return(u=(c=fs.get(this.remote))==null?void 0:c.getCastPlayer)==null?void 0:u.call(c)},l=new WeakSet,d=async function(){O(this,r).paused=Zf(t.prototype,this,"paused"),Zf(t.prototype,this,"pause").call(this),this.muted=Zf(t.prototype,this,"muted");try{await this.load()}catch(c){console.error(c)}},qe(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t},Bd=class extends Event{constructor(i,e){super(i),qe(this,"track"),this.track=e.track}},um=new WeakMap;function J(i){var e;return(e=um.get(i))!=null?e:Nx(i,{})}function Nx(i,e){let t=um.get(i);return t||um.set(i,t={}),Object.assign(t,e)}function hm(i,e){let t=i.videoTracks;J(e).media=i,J(e).renditionSet||(J(e).renditionSet=new Set);let r=J(t).trackSet;r.add(e);let s=r.size-1;s in mm.prototype||Object.defineProperty(mm.prototype,s,{get(){return[...J(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Bd("addtrack",{track:e}))})}function fm(i){var e;let t=(e=J(i).media)==null?void 0:e.videoTracks;t&&(J(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Bd("removetrack",{track:i}))}))}function Ux(i){var e;let t=(e=J(i).media.videoTracks)!=null?e:[],r=!1;for(let s of t)s!==i&&(s.selected=!1,r=!0);if(r){if(J(t).changeRequested)return;J(t).changeRequested=!0,queueMicrotask(()=>{delete J(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var es,ts,is,un,Sa,mm=class extends EventTarget{constructor(){super(),se(this,un),se(this,es,void 0),se(this,ts,void 0),se(this,is,void 0),J(this).trackSet=new Set}[Symbol.iterator](){return O(this,un,Sa).values()}get length(){return O(this,un,Sa).size}getTrackById(i){var e;return(e=[...O(this,un,Sa)].find(t=>t.id===i))!=null?e:null}get selectedIndex(){return[...O(this,un,Sa)].findIndex(i=>i.selected)}get onaddtrack(){return O(this,es)}set onaddtrack(i){O(this,es)&&(this.removeEventListener("addtrack",O(this,es)),de(this,es,void 0)),typeof i=="function"&&(de(this,es,i),this.addEventListener("addtrack",i))}get onremovetrack(){return O(this,ts)}set onremovetrack(i){O(this,ts)&&(this.removeEventListener("removetrack",O(this,ts)),de(this,ts,void 0)),typeof i=="function"&&(de(this,ts,i),this.addEventListener("removetrack",i))}get onchange(){return O(this,is)}set onchange(i){O(this,is)&&(this.removeEventListener("change",O(this,is)),de(this,is,void 0)),typeof i=="function"&&(de(this,is,i),this.addEventListener("change",i))}};es=new WeakMap,ts=new WeakMap,is=new WeakMap,un=new WeakSet,Sa=function(){return J(this).trackSet};var $d=class extends Event{constructor(i,e){super(i),qe(this,"rendition"),this.rendition=e.rendition}};function Fx(i,e){let t=J(i).media.videoRenditions;J(e).media=J(i).media,J(e).track=i;let r=J(i).renditionSet;r.add(e);let s=r.size-1;s in pm.prototype||Object.defineProperty(pm.prototype,s,{get(){return hn(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new $d("addrendition",{rendition:e}))})}function Bx(i){let e=J(i).media.videoRenditions,t=J(i).track;J(t).renditionSet.delete(i),queueMicrotask(()=>{J(i).track.selected&&e.dispatchEvent(new $d("removerendition",{rendition:i}))})}function $x(i){let e=J(i).media.videoRenditions;!e||J(e).changeRequested||(J(e).changeRequested=!0,queueMicrotask(()=>{delete J(e).changeRequested,J(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function hn(i){return[...J(i).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...J(e).renditionSet])}var rs,ss,ns,pm=class extends EventTarget{constructor(){super(...arguments),se(this,rs,void 0),se(this,ss,void 0),se(this,ns,void 0)}[Symbol.iterator](){return hn(this).values()}get length(){return hn(this).length}getRenditionById(i){var e;return(e=hn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return hn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of hn(this).entries())t.selected=e===i}get onaddrendition(){return O(this,rs)}set onaddrendition(i){O(this,rs)&&(this.removeEventListener("addrendition",O(this,rs)),de(this,rs,void 0)),typeof i=="function"&&(de(this,rs,i),this.addEventListener("addrendition",i))}get onremoverendition(){return O(this,ss)}set onremoverendition(i){O(this,ss)&&(this.removeEventListener("removerendition",O(this,ss)),de(this,ss,void 0)),typeof i=="function"&&(de(this,ss,i),this.addEventListener("removerendition",i))}get onchange(){return O(this,ns)}set onchange(i){O(this,ns)&&(this.removeEventListener("change",O(this,ns)),de(this,ns,void 0)),typeof i=="function"&&(de(this,ns,i),this.addEventListener("change",i))}};rs=new WeakMap,ss=new WeakMap,ns=new WeakMap;var xa,Hx=class{constructor(){qe(this,"src"),qe(this,"id"),qe(this,"width"),qe(this,"height"),qe(this,"bitrate"),qe(this,"frameRate"),qe(this,"codec"),se(this,xa,!1)}get selected(){return O(this,xa)}set selected(i){O(this,xa)!==i&&(de(this,xa,i),$x(this))}};xa=new WeakMap;var Ia,ob=class{constructor(){qe(this,"id"),qe(this,"kind"),qe(this,"label",""),qe(this,"language",""),qe(this,"sourceBuffer"),se(this,Ia,!1)}addRendition(i,e,t,r,s,n){let a=new Hx;return a.src=i,a.width=e,a.height=t,a.frameRate=n,a.bitrate=s,a.codec=r,Fx(this,a),a}removeRendition(i){Bx(i)}get selected(){return O(this,Ia)}set selected(i){O(this,Ia)!==i&&(de(this,Ia,i),i===!0&&Ux(this))}};Ia=new WeakMap;function Gx(i,e){let t=J(i).media.audioRenditions;J(e).media=J(i).media,J(e).track=i;let r=J(i).renditionSet;r.add(e);let s=r.size-1;s in gm.prototype||Object.defineProperty(gm.prototype,s,{get(){return fn(this)[s]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new $d("addrendition",{rendition:e}))})}function Vx(i){let e=J(i).media.audioRenditions,t=J(i).track;J(t).renditionSet.delete(i),queueMicrotask(()=>{J(i).track.enabled&&e.dispatchEvent(new $d("removerendition",{rendition:i}))})}function Wx(i){let e=J(i).media.audioRenditions;!e||J(e).changeRequested||(J(e).changeRequested=!0,queueMicrotask(()=>{delete J(e).changeRequested,J(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function fn(i){return[...J(i).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...J(e).renditionSet])}var as,os,ls,gm=class extends EventTarget{constructor(){super(...arguments),se(this,as,void 0),se(this,os,void 0),se(this,ls,void 0)}[Symbol.iterator](){return fn(this).values()}get length(){return fn(this).length}getRenditionById(i){var e;return(e=fn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return fn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of fn(this).entries())t.selected=e===i}get onaddrendition(){return O(this,as)}set onaddrendition(i){O(this,as)&&(this.removeEventListener("addrendition",O(this,as)),de(this,as,void 0)),typeof i=="function"&&(de(this,as,i),this.addEventListener("addrendition",i))}get onremoverendition(){return O(this,os)}set onremoverendition(i){O(this,os)&&(this.removeEventListener("removerendition",O(this,os)),de(this,os,void 0)),typeof i=="function"&&(de(this,os,i),this.addEventListener("removerendition",i))}get onchange(){return O(this,ls)}set onchange(i){O(this,ls)&&(this.removeEventListener("change",O(this,ls)),de(this,ls,void 0)),typeof i=="function"&&(de(this,ls,i),this.addEventListener("change",i))}};as=new WeakMap,os=new WeakMap,ls=new WeakMap;var La,Kx=class{constructor(){qe(this,"src"),qe(this,"id"),qe(this,"bitrate"),qe(this,"codec"),se(this,La,!1)}get selected(){return O(this,La)}set selected(i){O(this,La)!==i&&(de(this,La,i),Wx(this))}};La=new WeakMap;function vm(i,e){let t=i.audioTracks;J(e).media=i,J(e).renditionSet||(J(e).renditionSet=new Set);let r=J(t).trackSet;r.add(e);let s=r.size-1;s in bm.prototype||Object.defineProperty(bm.prototype,s,{get(){return[...J(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Bd("addtrack",{track:e}))})}function Em(i){var e;let t=(e=J(i).media)==null?void 0:e.audioTracks;t&&(J(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Bd("removetrack",{track:i}))}))}function qx(i){let e=J(i).media.audioTracks;!e||J(e).changeRequested||(J(e).changeRequested=!0,queueMicrotask(()=>{delete J(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var ds,cs,us,Ra,Rd,bm=class extends EventTarget{constructor(){super(),se(this,Ra),se(this,ds,void 0),se(this,cs,void 0),se(this,us,void 0),J(this).trackSet=new Set}[Symbol.iterator](){return O(this,Ra,Rd).values()}get length(){return O(this,Ra,Rd).size}getTrackById(i){var e;return(e=[...O(this,Ra,Rd)].find(t=>t.id===i))!=null?e:null}get onaddtrack(){return O(this,ds)}set onaddtrack(i){O(this,ds)&&(this.removeEventListener("addtrack",O(this,ds)),de(this,ds,void 0)),typeof i=="function"&&(de(this,ds,i),this.addEventListener("addtrack",i))}get onremovetrack(){return O(this,cs)}set onremovetrack(i){O(this,cs)&&(this.removeEventListener("removetrack",O(this,cs)),de(this,cs,void 0)),typeof i=="function"&&(de(this,cs,i),this.addEventListener("removetrack",i))}get onchange(){return O(this,us)}set onchange(i){O(this,us)&&(this.removeEventListener("change",O(this,us)),de(this,us,void 0)),typeof i=="function"&&(de(this,us,i),this.addEventListener("change",i))}};ds=new WeakMap,cs=new WeakMap,us=new WeakMap,Ra=new WeakSet,Rd=function(){return J(this).trackSet};var ka,lb=class{constructor(){qe(this,"id"),qe(this,"kind"),qe(this,"label",""),qe(this,"language",""),qe(this,"sourceBuffer"),se(this,ka,!1)}addRendition(i,e,t){let r=new Kx;return r.src=i,r.codec=e,r.bitrate=t,Gx(this,r),r}removeRendition(i){Vx(i)}get enabled(){return O(this,ka)}set enabled(i){O(this,ka)!==i&&(de(this,ka,i),qx(this))}};ka=new WeakMap;var QE=Nd(globalThis.HTMLMediaElement,"video"),ZE=Nd(globalThis.HTMLMediaElement,"audio");function Yx(i){if(!(i!=null&&i.prototype))return i;let e=Nd(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return jx(this)}});let t=Nd(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return zx(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new ob;return l.kind=n,l.label=a,l.language=o,hm(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=fm),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new lb;return l.kind=n,l.label=a,l.language=o,vm(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=Em),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return r(this)}});let r=n=>{let a=J(n).videoRenditions;return a||(a=new pm,J(a).media=n,J(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=J(n).audioRenditions;return a||(a=new gm,J(a).media=n,J(n).audioRenditions=a),a};return i}function Nd(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function jx(i){var e;let t=J(i).videoTracks;if(!t&&(t=new mm,J(i).videoTracks=t,QE)){let r=QE.call((e=i.nativeEl)!=null?e:i);for(let s of r)hm(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof ob)){for(let n of r)fm(n);return}hm(i,s.track)}),r.addEventListener("removetrack",s=>{fm(s.track)})}return t}function zx(i){var e;let t=J(i).audioTracks;if(!t&&(t=new bm,J(i).audioTracks=t,ZE)){let r=ZE.call((e=i.nativeEl)!=null?e:i);for(let s of r)vm(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof lb)){for(let n of r)Em(n);return}vm(i,s.track)}),r.addEventListener("removetrack",s=>{Em(s.track)})}return t}Fd.push("castchange","entercast","leavecast");var K={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},Xx=Object.values(K),Qx=xx(),Zx="mux-video",Ki,wa,kd,Da,wd,Dd,Cd,Md,Ca,Pd,Jx=class extends em{constructor(){super(),se(this,Ca),se(this,Ki,void 0),se(this,wa,void 0),se(this,kd,void 0),se(this,Da,{}),se(this,wd,void 0),se(this,Dd,void 0),se(this,Cd,void 0),se(this,Md,void 0),de(this,kd,PE())}static get observedAttributes(){var i;return[...Xx,...(i=em.observedAttributes)!=null?i:[]]}get preferCmcd(){var i;return(i=this.getAttribute(K.PREFER_CMCD))!=null?i:void 0}set preferCmcd(i){i!==this.preferCmcd&&(i?dn.includes(i)?this.setAttribute(K.PREFER_CMCD,i):console.warn(`Invalid value for preferCmcd. Must be one of ${dn.join()}`):this.removeAttribute(K.PREFER_CMCD))}get playerInitTime(){return O(this,kd)}get playerSoftwareName(){var i;return(i=O(this,Cd))!=null?i:Zx}set playerSoftwareName(i){de(this,Cd,i)}get playerSoftwareVersion(){var i;return(i=O(this,Dd))!=null?i:Qx}set playerSoftwareVersion(i){de(this,Dd,i)}get _hls(){var i;return(i=O(this,Ki))==null?void 0:i.engine}get mux(){var i;return(i=this.nativeEl)==null?void 0:i.mux}get error(){var i;return(i=OE(this.nativeEl))!=null?i:null}get errorTranslator(){return O(this,Md)}set errorTranslator(i){de(this,Md,i)}get src(){return this.getAttribute("src")}set src(i){i!==this.src&&(i==null?this.removeAttribute("src"):this.setAttribute("src",i))}get type(){var i;return(i=this.getAttribute(K.TYPE))!=null?i:void 0}set type(i){i!==this.type&&(i?this.setAttribute(K.TYPE,i):this.removeAttribute(K.TYPE))}get autoplay(){let i=this.getAttribute("autoplay");return i===null?!1:i===""?!0:i}set autoplay(i){let e=this.autoplay;i!==e&&(i?this.setAttribute("autoplay",typeof i=="string"?i:""):this.removeAttribute("autoplay"))}get preload(){let i=this.getAttribute("preload");return i===""?"auto":["none","metadata","auto"].includes(i)?i:super.preload}set preload(i){i!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(i)?this.setAttribute("preload",i):this.removeAttribute("preload"))}get debug(){return this.getAttribute(K.DEBUG)!=null}set debug(i){i!==this.debug&&(i?this.setAttribute(K.DEBUG,""):this.removeAttribute(K.DEBUG))}get disableCookies(){return this.hasAttribute(K.DISABLE_COOKIES)}set disableCookies(i){i!==this.disableCookies&&(i?this.setAttribute(K.DISABLE_COOKIES,""):this.removeAttribute(K.DISABLE_COOKIES))}get startTime(){let i=this.getAttribute(K.START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set startTime(i){i!==this.startTime&&(i==null?this.removeAttribute(K.START_TIME):this.setAttribute(K.START_TIME,`${i}`))}get playbackId(){var i;return(i=this.getAttribute(K.PLAYBACK_ID))!=null?i:void 0}set playbackId(i){i!==this.playbackId&&(i?this.setAttribute(K.PLAYBACK_ID,i):this.removeAttribute(K.PLAYBACK_ID))}get maxResolution(){var i;return(i=this.getAttribute(K.MAX_RESOLUTION))!=null?i:void 0}set maxResolution(i){i!==this.maxResolution&&(i?this.setAttribute(K.MAX_RESOLUTION,i):this.removeAttribute(K.MAX_RESOLUTION))}get minResolution(){var i;return(i=this.getAttribute(K.MIN_RESOLUTION))!=null?i:void 0}set minResolution(i){i!==this.minResolution&&(i?this.setAttribute(K.MIN_RESOLUTION,i):this.removeAttribute(K.MIN_RESOLUTION))}get renditionOrder(){var i;return(i=this.getAttribute(K.RENDITION_ORDER))!=null?i:void 0}set renditionOrder(i){i!==this.renditionOrder&&(i?this.setAttribute(K.RENDITION_ORDER,i):this.removeAttribute(K.RENDITION_ORDER))}get customDomain(){var i;return(i=this.getAttribute(K.CUSTOM_DOMAIN))!=null?i:void 0}set customDomain(i){i!==this.customDomain&&(i?this.setAttribute(K.CUSTOM_DOMAIN,i):this.removeAttribute(K.CUSTOM_DOMAIN))}get ended(){return Xf(this.nativeEl,this._hls)}get envKey(){var i;return(i=this.getAttribute(K.ENV_KEY))!=null?i:void 0}set envKey(i){i!==this.envKey&&(i?this.setAttribute(K.ENV_KEY,i):this.removeAttribute(K.ENV_KEY))}get beaconCollectionDomain(){var i;return(i=this.getAttribute(K.BEACON_COLLECTION_DOMAIN))!=null?i:void 0}set beaconCollectionDomain(i){i!==this.beaconCollectionDomain&&(i?this.setAttribute(K.BEACON_COLLECTION_DOMAIN,i):this.removeAttribute(K.BEACON_COLLECTION_DOMAIN))}get streamType(){var i;return(i=this.getAttribute(K.STREAM_TYPE))!=null?i:NE(this.nativeEl)}set streamType(i){i!==this.streamType&&(i?this.setAttribute(K.STREAM_TYPE,i):this.removeAttribute(K.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(K.TARGET_LIVE_WINDOW)?+this.getAttribute(K.TARGET_LIVE_WINDOW):UE(this.nativeEl)}set targetLiveWindow(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(K.TARGET_LIVE_WINDOW):this.setAttribute(K.TARGET_LIVE_WINDOW,`${+i}`))}get liveEdgeStart(){var i,e;if(this.hasAttribute(K.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,r=(i=this.nativeEl.seekable.end(0))!=null?i:0,s=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(s,r-t)}return FE(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(K.LIVE_EDGE_OFFSET))return+this.getAttribute(K.LIVE_EDGE_OFFSET)}set liveEdgeOffset(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(K.LIVE_EDGE_OFFSET):this.setAttribute(K.LIVE_EDGE_OFFSET,`${+i}`))}get seekable(){return jf(this.nativeEl)}async addCuePoints(i){return qf(this.nativeEl,i)}get activeCuePoint(){return Yf(this.nativeEl)}get cuePoints(){return kE(this.nativeEl)}getStartDate(){return wE(this.nativeEl,this._hls)}get currentPdt(){return DE(this.nativeEl,this._hls)}get preferPlayback(){let i=this.getAttribute(K.PREFER_PLAYBACK);if(i===li.MSE||i===li.NATIVE)return i}set preferPlayback(i){i!==this.preferPlayback&&(i===li.MSE||i===li.NATIVE?this.setAttribute(K.PREFER_PLAYBACK,i):this.removeAttribute(K.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(i=>i.startsWith("metadata-")&&![K.METADATA_URL].includes(i)).reduce((i,e)=>{let t=this.getAttribute(e);return t!=null&&(i[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),i},{}),...O(this,Da)}}set metadata(i){de(this,Da,i!=null?i:{}),this.mux&&this.mux.emit("hb",O(this,Da))}get _hlsConfig(){return O(this,wd)}set _hlsConfig(i){de(this,wd,i)}load(){de(this,Ki,HE(this,this.nativeEl,O(this,Ki)))}unload(){Qf(this.nativeEl,O(this,Ki)),de(this,Ki,void 0)}attributeChangedCallback(i,e,t){var r,s;switch(em.observedAttributes.includes(i)&&!["src","autoplay","preload"].includes(i)&&super.attributeChangedCallback(i,e,t),i){case K.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case K.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?ot(this,Ca,Pd).call(this):n&&!a?this.unload():n&&a&&(this.unload(),ot(this,Ca,Pd).call(this));break}case"autoplay":if(t===e)break;(r=O(this,Ki))==null||r.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=O(this,Ki))==null||s.setPreload(t);break;case K.PLAYBACK_ID:this.src=Aa(this);break;case K.DEBUG:{let n=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=n);break}case K.METADATA_URL:t&&fetch(t).then(n=>n.json()).then(n=>this.metadata=n).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${t}!`));break;case K.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case K.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}connectedCallback(){var i;(i=super.connectedCallback)==null||i.call(this),this.nativeEl&&this.src&&!O(this,Ki)&&ot(this,Ca,Pd).call(this)}disconnectedCallback(){this.unload()}};Ki=new WeakMap,wa=new WeakMap,kd=new WeakMap,Da=new WeakMap,wd=new WeakMap,Dd=new WeakMap,Cd=new WeakMap,Md=new WeakMap,Ca=new WeakSet,Pd=async function(){O(this,wa)||(await de(this,wa,Promise.resolve()),de(this,wa,null),this.load())};var ym=class extends Ox(Yx(Jx)){};Jf.customElements.get("mux-video")||(Jf.customElements.define("mux-video",ym),Jf.MuxVideoElement=ym);var db=ym;var eI="en",ps={code:eI};var cb="en";function xe(i,e=!0){var s,n;let t=e&&(n=(s=ps)==null?void 0:s[i])!=null?n:i,r=e?ps.code:cb;return new xm(t,r)}var xm=class{constructor(e,t=(r=>(r=ps.code)!=null?r:cb)()){this.message=e,this.locale=t}format(e){return this.message.replace(/\{(\w+)\}/g,(t,r)=>{var s;return(s=e[r])!=null?s:""})}toString(){return this.message}};function ub(i){let e="";return Object.entries(i).forEach(([t,r])=>{r!=null&&(e+=`${Hd(t)}: ${r}; `)}),e?e.trim():void 0}function Hd(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Gd(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function qi(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function Im(i){let e=tI(i).toString();return e?"?"+e:""}function tI(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}function Sr(i){let e=(i!=null?i:"").split(".")[1];if(!e)return{};let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)}var Lm=(i,e)=>!i||!e?!1:i.contains(e)?!0:Lm(i,e.getRootNode().host);var hb="mux.com",iI=()=>{try{return"2.3.3"}catch{}return"UNKNOWN"},rI=iI(),Wd=()=>rI,fb=(i,{token:e,customDomain:t=hb,thumbnailTime:r}={})=>{let s=e==null?r:void 0,{aud:n}=Sr(e);if(!(e&&n!=="t"))return`https://image.${t}/${i}/thumbnail.webp${Im({token:e,time:s})}`},mb=(i,{token:e,customDomain:t=hb}={})=>{let{aud:r}=Sr(e);if(!(e&&r!=="s"))return`https://image.${t}/${i}/storyboard.vtt${Im({token:e,format:"webp"})}`},Ma=i=>{if(i){if([je.LIVE,je.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return je.LIVE}};var sI={crossorigin:"crossOrigin",playsinline:"playsInline"};function pb(i){var e;return(e=sI[i])!=null?e:Gd(i)}var gs,vs,Ut,Vd=class{constructor(e,t){ct(this,gs,void 0);ct(this,vs,void 0);ct(this,Ut,[]);ei(this,gs,e),ei(this,vs,t)}[Symbol.iterator](){return Pe(this,Ut).values()}get length(){return Pe(this,Ut).length}get value(){var e;return(e=Pe(this,Ut).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(ei(this,Ut,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return Pe(this,Ut)[e]}values(){return Pe(this,Ut).values()}keys(){return Pe(this,Ut).keys()}forEach(e){Pe(this,Ut).forEach(e)}add(...e){var t,r;e.forEach(s=>{this.contains(s)||Pe(this,Ut).push(s)}),!(this.value===""&&!((t=Pe(this,gs))!=null&&t.hasAttribute(`${Pe(this,vs)}`)))&&((r=Pe(this,gs))==null||r.setAttribute(`${Pe(this,vs)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>{Pe(this,Ut).splice(Pe(this,Ut).indexOf(r),1)}),(t=Pe(this,gs))==null||t.setAttribute(`${Pe(this,vs)}`,`${this.value}`)}contains(e){return Pe(this,Ut).includes(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};gs=new WeakMap,vs=new WeakMap,Ut=new WeakMap;var gb=`[mux-player ${Wd()}]`;function xr(...i){console.warn(gb,...i)}function ci(...i){console.error(gb,...i)}function Rm(i){var t;let e=(t=i.message)!=null?t:"";if(i.context&&(e+=` ${i.context}`),i.file){let r="https://github.com/muxinc/elements/blob/main/errors/";e+=` ${xe("Read more: ")}
1197
+ ${r}${i.file}`}xr(e)}var Ct={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},Es={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},Eb=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),nI=Fd.filter(i=>i!=="error"),aI=Object.values(Ct).filter(i=>![Ct.PLAYSINLINE].includes(i)),oI=Object.values(Es);function bb(i){i.querySelectorAll(":scope > track").forEach(e=>{var t;(t=i.media)==null||t.append(e.cloneNode())}),nI.forEach(e=>{var t;(t=i.media)==null||t.addEventListener(e,r=>{i.dispatchEvent(new Event(r.type))})})}var km=class extends Je.HTMLElement{static get observedAttributes(){return[...aI,...oI]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(r=>{var s;(s=this.media)==null||s.append(r.cloneNode())});let e=r=>{for(let s of r)s.type==="childList"&&(s.removedNodes.forEach(n=>{var o,l;let a=(o=this.media)==null?void 0:o.querySelector(`track[src="${n.src}"]`);a&&((l=this.media)==null||l.removeChild(a))}),s.addedNodes.forEach(n=>{var a;(a=this.media)==null||a.append(n.cloneNode())}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(e,t,r){var s,n;switch(e){case Es.MUTED:{this.media&&(this.media.muted=r!=null,this.media.defaultMuted=r!=null);return}case Es.VOLUME:{let a=(s=qi(r))!=null?s:1;this.media&&(this.media.volume=a);return}case Es.PLAYBACKRATE:{let a=(n=qi(r))!=null?n:1;this.media&&(this.media.playbackRate=a,this.media.defaultPlaybackRate=a);return}}}play(){var e,t;return(t=(e=this.media)==null?void 0:e.play())!=null?t:Promise.reject()}pause(){var e;(e=this.media)==null||e.pause()}requestCast(e){var t;return(t=this.media)==null?void 0:t.requestCast(e)}get media(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var e,t;return(t=(e=this.media)==null?void 0:e.paused)!=null?t:!0}get duration(){var e,t;return(t=(e=this.media)==null?void 0:e.duration)!=null?t:NaN}get ended(){var e,t;return(t=(e=this.media)==null?void 0:e.ended)!=null?t:!1}get buffered(){var e,t;return(t=(e=this.media)==null?void 0:e.buffered)!=null?t:Eb}get seekable(){var e,t;return(t=(e=this.media)==null?void 0:e.seekable)!=null?t:Eb}get readyState(){var e,t;return(t=(e=this.media)==null?void 0:e.readyState)!=null?t:0}get videoWidth(){var e,t;return(t=(e=this.media)==null?void 0:e.videoWidth)!=null?t:0}get videoHeight(){var e,t;return(t=(e=this.media)==null?void 0:e.videoHeight)!=null?t:0}get currentTime(){var e,t;return(t=(e=this.media)==null?void 0:e.currentTime)!=null?t:0}set currentTime(e){this.media&&(this.media.currentTime=Number(e))}get volume(){var e,t;return(t=(e=this.media)==null?void 0:e.volume)!=null?t:1}set volume(e){this.media&&(this.media.volume=Number(e))}get playbackRate(){var e,t;return(t=(e=this.media)==null?void 0:e.playbackRate)!=null?t:1}set playbackRate(e){this.media&&(this.media.playbackRate=Number(e))}get defaultPlaybackRate(){var e;return(e=qi(this.getAttribute(Es.PLAYBACKRATE)))!=null?e:1}set defaultPlaybackRate(e){e!=null?this.setAttribute(Es.PLAYBACKRATE,`${e}`):this.removeAttribute(Es.PLAYBACKRATE)}get crossOrigin(){return Pa(this,Ct.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(Ct.CROSSORIGIN,`${e}`)}get autoplay(){return Pa(this,Ct.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(Ct.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(Ct.AUTOPLAY)}get loop(){return Pa(this,Ct.LOOP)!=null}set loop(e){e?this.setAttribute(Ct.LOOP,""):this.removeAttribute(Ct.LOOP)}get muted(){var e,t;return(t=(e=this.media)==null?void 0:e.muted)!=null?t:!1}set muted(e){this.media&&(this.media.muted=!!e)}get defaultMuted(){return Pa(this,Ct.MUTED)!=null}set defaultMuted(e){e?this.setAttribute(Ct.MUTED,""):this.removeAttribute(Ct.MUTED)}get playsInline(){return Pa(this,Ct.PLAYSINLINE)!=null}set playsInline(e){ci("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(e){["","none","metadata","auto"].includes(e)?this.setAttribute(Ct.PRELOAD,e):this.removeAttribute(Ct.PRELOAD)}};function Pa(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var wm=km;var lI=Object.defineProperty,dI=(i,e,t)=>e in i?lI(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,cI=(i,e,t)=>(dI(i,typeof e!="symbol"?e+"":e,t),t),Sb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Se=(i,e,t)=>(Sb(i,e,"read from private field"),t?t.call(i):e.get(i)),Yi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},er=(i,e,t,r)=>(Sb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),pn,Kd,bs,Oa,Ir,Lr,Rr,ys,gn,qd,Ai,yb=1,Tb=0,uI=1,hI={processCallback(i,e,t){if(t){for(let[r,s]of e)if(r in t){let n=t[r];typeof n=="boolean"&&s instanceof Ft&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Ft?s.element[s.attributeName]=n:s.value=n}}}},tr=class extends w.DocumentFragment{constructor(e,t,r=hI){var s;super(),Yi(this,pn,void 0),Yi(this,Kd,void 0),this.append(e.content.cloneNode(!0)),er(this,pn,xb(this)),er(this,Kd,r),(s=r.createCallback)==null||s.call(r,this,Se(this,pn),t),r.processCallback(this,Se(this,pn),t)}update(e){Se(this,Kd).processCallback(this,Se(this,pn),e)}};pn=new WeakMap;Kd=new WeakMap;var xb=(i,e=[])=>{let t,r;for(let s of i.attributes||[])if(s.value.includes("{{")){let n=new Dm;for([t,r]of Ab(s.value))if(!t)n.append(r);else{let a=new Ft(i,s.name,s.namespaceURI);n.append(a),e.push([r,a])}s.value=n.toString()}for(let s of i.childNodes)if(s.nodeType===yb&&!(s instanceof HTMLTemplateElement))xb(s,e);else if(s.nodeType===yb||s.data.includes("{{")){let n=[];if(s.data)for([t,r]of Ab(s.data))if(!t)n.push(new Text(r));else{let a=new ir(i);n.push(a),e.push([r,a])}else if(s instanceof HTMLTemplateElement){let a=new Na(i,s);n.push(a),e.push([a.expression,a])}s.replaceWith(...n.flatMap(a=>a.replacementNodes||[a]))}return e},_b={},Ab=i=>{let e="",t=0,r=_b[i],s=0,n;if(r)return r;for(r=[];n=i[s];s++)n==="{"&&i[s+1]==="{"&&i[s-1]!=="\\"&&i[s+2]&&++t==1?(e&&r.push([Tb,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([uI,e.trim()]),e="",s++):e+=n||"";return e&&r.push([Tb,(t>0?"{{":"")+e]),_b[i]=r},fI=11,Yd=class{get value(){return""}set value(e){}toString(){return this.value}},Ib=new WeakMap,Dm=class{constructor(){Yi(this,bs,[])}[Symbol.iterator](){return Se(this,bs).values()}get length(){return Se(this,bs).length}item(e){return Se(this,bs)[e]}append(...e){for(let t of e)t instanceof Ft&&Ib.set(t,this),Se(this,bs).push(t)}toString(){return Se(this,bs).join("")}};bs=new WeakMap;var Ft=class extends Yd{constructor(e,t,r){super(),Yi(this,ys),Yi(this,Oa,""),Yi(this,Ir,void 0),Yi(this,Lr,void 0),Yi(this,Rr,void 0),er(this,Ir,e),er(this,Lr,t),er(this,Rr,r)}get attributeName(){return Se(this,Lr)}get attributeNamespace(){return Se(this,Rr)}get element(){return Se(this,Ir)}get value(){return Se(this,Oa)}set value(e){Se(this,Oa)!==e&&(er(this,Oa,e),!Se(this,ys,gn)||Se(this,ys,gn).length===1?e==null?Se(this,Ir).removeAttributeNS(Se(this,Rr),Se(this,Lr)):Se(this,Ir).setAttributeNS(Se(this,Rr),Se(this,Lr),e):Se(this,Ir).setAttributeNS(Se(this,Rr),Se(this,Lr),Se(this,ys,gn)))}get booleanValue(){return Se(this,Ir).hasAttributeNS(Se(this,Rr),Se(this,Lr))}set booleanValue(e){if(!Se(this,ys,gn)||Se(this,ys,gn).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};Oa=new WeakMap;Ir=new WeakMap;Lr=new WeakMap;Rr=new WeakMap;ys=new WeakSet;gn=function(){return Ib.get(this)};var ir=class extends Yd{constructor(e,t){super(),Yi(this,qd,void 0),Yi(this,Ai,void 0),er(this,qd,e),er(this,Ai,t?[...t]:[new Text])}get replacementNodes(){return Se(this,Ai)}get parentNode(){return Se(this,qd)}get nextSibling(){return Se(this,Ai)[Se(this,Ai).length-1].nextSibling}get previousSibling(){return Se(this,Ai)[0].previousSibling}get value(){return Se(this,Ai).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(r=>r==null?[new Text]:r.forEach?[...r]:r.nodeType===fI?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),er(this,Ai,mI(Se(this,Ai)[0].parentNode,Se(this,Ai),t,this.nextSibling))}};qd=new WeakMap;Ai=new WeakMap;var Na=class extends ir{constructor(e,t){let r=t.getAttribute("directive")||t.getAttribute("type"),s=t.getAttribute("expression")||t.getAttribute(r)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),cI(this,"directive"),this.expression=s,this.template=t,this.directive=r}};function mI(i,e,t,r=null){let s=0,n,a,o,l=t.length,d=e.length;for(;s<l&&s<d&&e[s]==t[s];)s++;for(;s<l&&s<d&&t[l-1]==e[d-1];)r=t[--d,--l];if(s==d)for(;s<l;)i.insertBefore(t[s++],r);if(s==l)for(;s<d;)i.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:r,n==o?n=a:s<l&&t[s]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=r;)a=n.nextSibling,i.removeChild(n),n=a}return t}var Lb={string:i=>String(i)},zd=class{constructor(e){this.template=e,this.state=void 0}},Ts=new WeakMap,_s=new WeakMap,Cm={partial:(i,e)=>{e[i.expression]=new zd(i.template)},if:(i,e)=>{var t;if(kb(i.expression,e))if(Ts.get(i)!==i.template){Ts.set(i,i.template);let r=new tr(i.template,e,Xd);i.replace(r),_s.set(i,r)}else(t=_s.get(i))==null||t.update(e);else i.replace(""),Ts.delete(i),_s.delete(i)}},pI=Object.keys(Cm),Xd={processCallback(i,e,t){var r,s;if(t)for(let[n,a]of e){if(a instanceof Na){if(!a.directive){let l=pI.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=Cm[a.directive])==null||r.call(Cm,a,t);continue}let o=kb(n,t);if(o instanceof zd){Ts.get(a)!==o.template?(Ts.set(a,o.template),o=new tr(o.template,o.state,Xd),a.value=o,_s.set(a,o)):(s=_s.get(a))==null||s.update(o.state);continue}o?(a instanceof Ft&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Ft?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,Ts.delete(a),_s.delete(a))):a instanceof Ft?a.value=void 0:(a.value=void 0,Ts.delete(a),_s.delete(a))}}},Rb={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i!=null?i:e,"|":(i,e)=>{var t;return(t=Lb[e])==null?void 0:t.call(Lb,i)}};function gI(i){return vI(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function kb(i,e={}){var t,r,s,n,a,o,l;let d=gI(i);if(d.length===0||d.some(({type:c})=>!c))return Ua(i);if(((t=d[0])==null?void 0:t.token)===">"){let c=e[(r=d[1])==null?void 0:r.token];if(!c)return Ua(i);let u={...e};c.state=u;let h=d.slice(2);for(let f=0;f<h.length;f+=3){let g=(s=h[f])==null?void 0:s.token,E=(n=h[f+1])==null?void 0:n.token,T=(a=h[f+2])==null?void 0:a.token;g&&E==="="&&(u[g]=Fa(T,e))}return c}if(d.length===1)return jd(d[0])?Fa(d[0].token,e):Ua(i);if(d.length===2){let c=(o=d[0])==null?void 0:o.token,u=Rb[c];if(!u||!jd(d[1]))return Ua(i);let h=Fa(d[1].token,e);return u(h)}if(d.length===3){let c=(l=d[1])==null?void 0:l.token,u=Rb[c];if(!u||!jd(d[0])||!jd(d[2]))return Ua(i);let h=Fa(d[0].token,e);if(c==="|")return u(h,d[2].token);let f=Fa(d[2].token,e);return u(h,f)}}function Ua(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function jd({type:i}){return["number","boolean","string","param"].includes(i)}function Fa(i,e){let t=i[0],r=i.slice(-1);return i==="true"||i==="false"?i==="true":t===r&&["'",'"'].includes(t)?i.slice(1,-1):Za(i)?parseFloat(i):e[i]}function vI(i,e){let t,r,s,n=[];for(;i;){s=null,t=i.length;for(let a in e)r=e[a].exec(i),r&&r.index<t&&(s={token:r[0],type:a,matches:r.slice(1)},t=r.index);t&&n.push({token:i.substr(0,t),type:void 0}),s&&n.push(s),i=i.substr(t+(s?s.token.length:0))}return n}var EI=Object.defineProperty,bI=(i,e,t)=>e in i?EI(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,$a=(i,e,t)=>(bI(i,typeof e!="symbol"?e+"":e,t),t),Fm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Om=(i,e,t)=>(Fm(i,e,"read from private field"),t?t.call(i):e.get(i)),Ba=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},As=(i,e,t,r)=>(Fm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mm=(i,e,t)=>(Fm(i,e,"access private method"),t),vn,Qd,En,Nm,wb,Zd,Um,Pm={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},Db=q.createElement("template");Db.innerHTML=`
1123
1198
  <style>
1124
1199
  :host {
1125
1200
  display: inline-block;
@@ -1143,7 +1218,7 @@ ${r}${i.file}`}Sr(e)}var Rt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:
1143
1218
  display: none;
1144
1219
  }
1145
1220
  </style>
1146
- `;var Rr=class extends D.HTMLElement{constructor(){super(),Pa(this,Lm),Pa(this,Kd),Oa(this,"renderRoot"),Oa(this,"renderer"),Pa(this,gn,void 0),Pa(this,Wd,void 0),Pa(this,vn,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());let e=new MutationObserver(t=>{var r;this.mediaController&&!((r=this.mediaController)!=null&&r.breakpointsComputed)||t.some(s=>{let n=s.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(xm[s.attributeName]||s.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(qi.BREAKPOINTS_COMPUTED,this.render),Sm(this,Lm,gb).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=Im(this,gn))!=null?e:this.constructor.template}set template(e){_s(this,vn,null),_s(this,gn,e),this.createRenderer()}get props(){var e,t,r;let s=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>xm[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of s){let o=(r=xm[a.name])!=null?r:kp(a.name),{value:l}=a;l!=null?(Ya(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,r){e==="template"&&t!=r&&Sm(this,Kd,Rm).call(this)}connectedCallback(){Sm(this,Kd,Rm).call(this)}createRenderer(){this.template&&this.template!==Im(this,Wd)&&(_s(this,Wd,this.template),this.renderer=new Ji(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(vb.content.cloneNode(!0),this.renderer))}render(){var e;(e=this.renderer)==null||e.update(this.props)}};gn=new WeakMap;Wd=new WeakMap;vn=new WeakMap;Lm=new WeakSet;gb=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){let e=this[i];delete this[i],this[i]=e}};Kd=new WeakSet;Rm=function(){var i;let e=this.getAttribute("template");if(!e||e===Im(this,vn))return;let t=this.getRootNode(),r=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(r){_s(this,vn,e),_s(this,gn,r),this.createRenderer();return}iI(e)&&(_s(this,vn,e),rI(e).then(s=>{let n=q.createElement("template");n.innerHTML=s,_s(this,gn,n),this.createRenderer()}).catch(console.error))};Oa(Rr,"template");Oa(Rr,"observedAttributes",["template"]);Oa(Rr,"processor",Vd);function iI(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;let e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function rI(i){let e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}D.customElements.get("media-theme")||D.customElements.define("media-theme",Rr);var Eb=`:host {
1221
+ `;var kr=class extends w.HTMLElement{constructor(){super(),Ba(this,Nm),Ba(this,Zd),$a(this,"renderRoot"),$a(this,"renderer"),Ba(this,vn,void 0),Ba(this,Qd,void 0),Ba(this,En,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());let e=new MutationObserver(t=>{var r;this.mediaController&&!((r=this.mediaController)!=null&&r.breakpointsComputed)||t.some(s=>{let n=s.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(Pm[s.attributeName]||s.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(Xi.BREAKPOINTS_COMPUTED,this.render),Mm(this,Nm,wb).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=Om(this,vn))!=null?e:this.constructor.template}set template(e){As(this,En,null),As(this,vn,e),this.createRenderer()}get props(){var e,t,r;let s=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>Pm[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of s){let o=(r=Pm[a.name])!=null?r:Fp(a.name),{value:l}=a;l!=null?(Za(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,r){e==="template"&&t!=r&&Mm(this,Zd,Um).call(this)}connectedCallback(){Mm(this,Zd,Um).call(this)}createRenderer(){this.template&&this.template!==Om(this,Qd)&&(As(this,Qd,this.template),this.renderer=new tr(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(Db.content.cloneNode(!0),this.renderer))}render(){var e;(e=this.renderer)==null||e.update(this.props)}};vn=new WeakMap;Qd=new WeakMap;En=new WeakMap;Nm=new WeakSet;wb=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){let e=this[i];delete this[i],this[i]=e}};Zd=new WeakSet;Um=function(){var i;let e=this.getAttribute("template");if(!e||e===Om(this,En))return;let t=this.getRootNode(),r=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(r){As(this,En,e),As(this,vn,r),this.createRenderer();return}yI(e)&&(As(this,En,e),TI(e).then(s=>{let n=q.createElement("template");n.innerHTML=s,As(this,vn,n),this.createRenderer()}).catch(console.error))};$a(kr,"template");$a(kr,"observedAttributes",["template"]);$a(kr,"processor",Xd);function yI(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;let e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function TI(i){let e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}w.customElements.get("media-theme")||w.customElements.define("media-theme",kr);var Cb=`:host {
1147
1222
  --media-control-display: var(--controls);
1148
1223
  --media-loading-indicator-display: var(--loading-indicator);
1149
1224
  --media-dialog-display: var(--dialog);
@@ -1290,7 +1365,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1290
1365
  --media-duration-display-display: var(--duration-display, var(--bottom-duration-display));
1291
1366
  --media-title-display-display: var(--title-display, var(--bottom-title-display));
1292
1367
  }
1293
- `;var yb=`
1368
+ `;var Pb=`
1294
1369
  :host {
1295
1370
  z-index: 100;
1296
1371
  display: var(--media-dialog-display, flex);
@@ -1342,17 +1417,17 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1342
1417
  text-align: center;
1343
1418
  line-height: 1.4;
1344
1419
  }
1345
- `,Tb=Kt.createElement("template");Tb.innerHTML=`
1420
+ `,Ob=jt.createElement("template");Ob.innerHTML=`
1346
1421
  <style>
1347
- ${yb}
1422
+ ${Pb}
1348
1423
  </style>
1349
1424
 
1350
1425
  <div class="dialog">
1351
1426
  <slot></slot>
1352
1427
  </div>
1353
- `;var kr=class extends Je.HTMLElement{constructor(){var t;super();this.attachShadow({mode:"open"}),(t=this.shadowRoot)==null||t.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),bb(this)}close(){this.hasAttribute("open")&&(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),nI(this))}attributeChangedCallback(t,r,s){t==="open"&&r!==s&&(s!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&bb(this)}};kr.styles=yb,kr.template=Tb,kr.observedAttributes=["open"];function bb(i){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(i.dispatchEvent(e),e.defaultPrevented)return;let t=i.querySelector("[autofocus]:not([disabled])");!t&&i.tabIndex>=0&&(t=i),t||(t=_b(i.shadowRoot)),i._previouslyFocusedElement=Kt.activeElement,Kt.activeElement instanceof HTMLElement&&Kt.activeElement.blur(),i.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function _b(i){let t=["button","input","keygen","select","textarea"].map(function(s){return s+":not([disabled])"});t.push('[tabindex]:not([disabled]):not([tabindex=""])');let r=i==null?void 0:i.querySelector(t.join(", "));if(!r&&"attachShadow"in Element.prototype){let s=(i==null?void 0:i.querySelectorAll("*"))||[];for(let n=0;n<s.length&&!(s[n].tagName&&s[n].shadowRoot&&(r=_b(s[n].shadowRoot),r));n++);}return r}function nI(i){i._previouslyFocusedElement instanceof HTMLElement&&i._previouslyFocusedElement.focus()}Je.customElements.get("media-dialog")||(Je.customElements.define("media-dialog",kr),Je.MediaDialog=kr);var wm=kr;var Ab=Kt.createElement("template");Ab.innerHTML=`
1428
+ `;var wr=class extends Je.HTMLElement{constructor(){var t;super();this.attachShadow({mode:"open"}),(t=this.shadowRoot)==null||t.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),Mb(this)}close(){this.hasAttribute("open")&&(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),AI(this))}attributeChangedCallback(t,r,s){t==="open"&&r!==s&&(s!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&Mb(this)}};wr.styles=Pb,wr.template=Ob,wr.observedAttributes=["open"];function Mb(i){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(i.dispatchEvent(e),e.defaultPrevented)return;let t=i.querySelector("[autofocus]:not([disabled])");!t&&i.tabIndex>=0&&(t=i),t||(t=Nb(i.shadowRoot)),i._previouslyFocusedElement=jt.activeElement,jt.activeElement instanceof HTMLElement&&jt.activeElement.blur(),i.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function Nb(i){let t=["button","input","keygen","select","textarea"].map(function(s){return s+":not([disabled])"});t.push('[tabindex]:not([disabled]):not([tabindex=""])');let r=i==null?void 0:i.querySelector(t.join(", "));if(!r&&"attachShadow"in Element.prototype){let s=(i==null?void 0:i.querySelectorAll("*"))||[];for(let n=0;n<s.length&&!(s[n].tagName&&s[n].shadowRoot&&(r=Nb(s[n].shadowRoot),r));n++);}return r}function AI(i){i._previouslyFocusedElement instanceof HTMLElement&&i._previouslyFocusedElement.focus()}Je.customElements.get("media-dialog")||(Je.customElements.define("media-dialog",wr),Je.MediaDialog=wr);var Bm=wr;var Ub=jt.createElement("template");Ub.innerHTML=`
1354
1429
  <style>
1355
- ${wm.styles}
1430
+ ${Bm.styles}
1356
1431
 
1357
1432
  .close {
1358
1433
  background: none;
@@ -1381,22 +1456,22 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1381
1456
  </svg>
1382
1457
  </button>
1383
1458
  </slot>
1384
- `;var Na=class extends wm{constructor(){var e,t;super(),(t=(e=this.shadowRoot)==null?void 0:e.querySelector(".close"))==null||t.addEventListener("click",()=>{this.close()})}};Na.template=Ab;Je.customElements.get("mxp-dialog")||(Je.customElements.define("mxp-dialog",Na),Je.MxpDialog=Na);var Ua=new WeakMap,Cm=class i{constructor(e,t){this.element=e;this.type=t;this.element.addEventListener(this.type,this);let r=Ua.get(this.element);r&&r.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=Ua.get(this.element);t&&t.delete(this.type)}}static for(e){Ua.has(e.element)||Ua.set(e.element,new Map);let t=e.attributeName.slice(2),r=Ua.get(e.element);return r&&r.has(t)?r.get(t):new i(e.element,t)}};function aI(i,e){return i instanceof Pt&&i.attributeName.startsWith("on")?(Cm.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function oI(i,e){return e instanceof qd&&i instanceof er?(e.renderInto(i),!0):!1}function lI(i,e){return e instanceof DocumentFragment&&i instanceof er?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function dI(i,e){if(i instanceof Pt){let t=i.attributeNamespace,r=i.element.getAttributeNS(t,i.attributeName);return String(e)!==r&&(i.value=String(e)),!0}return i.value=String(e),!0}function cI(i,e){if(i instanceof Pt&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function uI(i,e){if(typeof e=="boolean"&&i instanceof Pt){let t=i.attributeNamespace,r=i.element.hasAttributeNS(t,i.attributeName);return e!==r&&(i.booleanValue=e),!0}return!1}function hI(i,e){return e===!1&&i instanceof er?(i.replace(""),!0):!1}function fI(i,e){cI(i,e)||uI(i,e)||aI(i,e)||hI(i,e)||oI(i,e)||lI(i,e)||dI(i,e)}var Dm=new Map,Sb=new WeakMap,xb=new WeakMap,qd=class{constructor(e,t,r){this.strings=e;this.values=t;this.processor=r;this.stringsKey=this.strings.join("")}get template(){if(Dm.has(this.stringsKey))return Dm.get(this.stringsKey);{let e=Kt.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((r,s,n)=>r+s+(n<t?`{{ ${n} }}`:""),""),Dm.set(this.stringsKey,e),e}}renderInto(e){var s;let t=this.template;if(Sb.get(e)!==t){Sb.set(e,t);let n=new Ji(t,this.values,this.processor);xb.set(e,n),e instanceof er?e.replace(...n.children):e.appendChild(n);return}let r=xb.get(e);(s=r==null?void 0:r.update)==null||s.call(r,this.values)}},mI={processCallback(i,e,t){var r;if(t){for(let[s,n]of e)if(s in t){let a=(r=t[s])!=null?r:"";fI(n,a)}}}};function tr(i,...e){return new qd(i,e,mI)}function Ib(i,e){i.renderInto(e)}var Lb=i=>tr`
1459
+ `;var Ha=class extends Bm{constructor(){var e,t;super(),(t=(e=this.shadowRoot)==null?void 0:e.querySelector(".close"))==null||t.addEventListener("click",()=>{this.close()})}};Ha.template=Ub;Je.customElements.get("mxp-dialog")||(Je.customElements.define("mxp-dialog",Ha),Je.MxpDialog=Ha);var Ga=new WeakMap,Hm=class i{constructor(e,t){this.element=e;this.type=t;this.element.addEventListener(this.type,this);let r=Ga.get(this.element);r&&r.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=Ga.get(this.element);t&&t.delete(this.type)}}static for(e){Ga.has(e.element)||Ga.set(e.element,new Map);let t=e.attributeName.slice(2),r=Ga.get(e.element);return r&&r.has(t)?r.get(t):new i(e.element,t)}};function SI(i,e){return i instanceof Ft&&i.attributeName.startsWith("on")?(Hm.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function xI(i,e){return e instanceof Jd&&i instanceof ir?(e.renderInto(i),!0):!1}function II(i,e){return e instanceof DocumentFragment&&i instanceof ir?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function LI(i,e){if(i instanceof Ft){let t=i.attributeNamespace,r=i.element.getAttributeNS(t,i.attributeName);return String(e)!==r&&(i.value=String(e)),!0}return i.value=String(e),!0}function RI(i,e){if(i instanceof Ft&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function kI(i,e){if(typeof e=="boolean"&&i instanceof Ft){let t=i.attributeNamespace,r=i.element.hasAttributeNS(t,i.attributeName);return e!==r&&(i.booleanValue=e),!0}return!1}function wI(i,e){return e===!1&&i instanceof ir?(i.replace(""),!0):!1}function DI(i,e){RI(i,e)||kI(i,e)||SI(i,e)||wI(i,e)||xI(i,e)||II(i,e)||LI(i,e)}var $m=new Map,Fb=new WeakMap,Bb=new WeakMap,Jd=class{constructor(e,t,r){this.strings=e;this.values=t;this.processor=r;this.stringsKey=this.strings.join("")}get template(){if($m.has(this.stringsKey))return $m.get(this.stringsKey);{let e=jt.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((r,s,n)=>r+s+(n<t?`{{ ${n} }}`:""),""),$m.set(this.stringsKey,e),e}}renderInto(e){var s;let t=this.template;if(Fb.get(e)!==t){Fb.set(e,t);let n=new tr(t,this.values,this.processor);Bb.set(e,n),e instanceof ir?e.replace(...n.children):e.appendChild(n);return}let r=Bb.get(e);(s=r==null?void 0:r.update)==null||s.call(r,this.values)}},CI={processCallback(i,e,t){var r;if(t){for(let[s,n]of e)if(s in t){let a=(r=t[s])!=null?r:"";DI(n,a)}}}};function rr(i,...e){return new Jd(i,e,CI)}function $b(i,e){i.renderInto(e)}var Hb=i=>rr`
1385
1460
  <style>
1386
- ${Eb}
1461
+ ${Cb}
1387
1462
  </style>
1388
- ${EI(i)}
1389
- `,pI=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return Ra(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},gI={TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",DISPLAY:"display",CONTROL_BAR:"control-bar",SELECTMENU:"selectmenu",LISTBOX:"listbox",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"},vI=Object.values(gI).join(", "),EI=i=>{var e,t,r,s,n,a,o,l,d,c,u,h,f,g,E,T,A,k,L,F,R,B,P,G,K,N,j,Y,Ee,ge,ye,we,Ie,Z,te;return tr`
1463
+ ${NI(i)}
1464
+ `,MI=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return Ma(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},PI={TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",DISPLAY:"display",CONTROL_BAR:"control-bar",SELECTMENU:"selectmenu",LISTBOX:"listbox",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"},OI=Object.values(PI).join(", "),NI=i=>{var e,t,r,s,n,a,o,l,d,c,u,h,f,g,E,T,S,k,L,F,R,B,P,H,V,N,j,Y,Ee,ge,ye,we,Ie,Z,te;return rr`
1390
1465
  <media-theme
1391
1466
  template="${i.themeTemplate||!1}"
1392
1467
  defaultstreamtype="${(e=i.defaultStreamType)!=null?e:!1}"
1393
- hotkeys="${pI(i)||!1}"
1468
+ hotkeys="${MI(i)||!1}"
1394
1469
  nohotkeys="${i.noHotKeys||!i.hasSrc||i.isDialogOpen||!1}"
1395
- noautoseektolive="${!!((t=i.streamType)!=null&&t.includes(Ye.LIVE))&&i.targetLiveWindow!==0}"
1470
+ noautoseektolive="${!!((t=i.streamType)!=null&&t.includes(je.LIVE))&&i.targetLiveWindow!==0}"
1396
1471
  novolumepref="${i.novolumepref||!1}"
1397
1472
  disabled="${!i.hasSrc||i.isDialogOpen}"
1398
1473
  audio="${(r=i.audio)!=null?r:!1}"
1399
- style="${(s=QE({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?s:!1}"
1474
+ style="${(s=ub({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?s:!1}"
1400
1475
  defaultsubtitles="${!i.defaultHiddenCaptions}"
1401
1476
  forwardseekoffset="${(n=i.forwardSeekOffset)!=null?n:!1}"
1402
1477
  backwardseekoffset="${(a=i.backwardSeekOffset)!=null?a:!1}"
@@ -1405,17 +1480,17 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1405
1480
  defaultduration="${(d=i.defaultDuration)!=null?d:!1}"
1406
1481
  hideduration="${(c=i.hideDuration)!=null?c:!1}"
1407
1482
  title="${(u=i.title)!=null?u:!1}"
1408
- exportparts="${vI}"
1483
+ exportparts="${OI}"
1409
1484
  >
1410
1485
  <mux-video
1411
1486
  slot="media"
1412
1487
  target-live-window="${(h=i.targetLiveWindow)!=null?h:!1}"
1413
- stream-type="${(f=Ra(i.streamType))!=null?f:!1}"
1488
+ stream-type="${(f=Ma(i.streamType))!=null?f:!1}"
1414
1489
  crossorigin="${(g=i.crossOrigin)!=null?g:""}"
1415
1490
  playsinline
1416
1491
  autoplay="${(E=i.autoplay)!=null?E:!1}"
1417
1492
  muted="${(T=i.muted)!=null?T:!1}"
1418
- loop="${(A=i.loop)!=null?A:!1}"
1493
+ loop="${(S=i.loop)!=null?S:!1}"
1419
1494
  preload="${(k=i.preload)!=null?k:!1}"
1420
1495
  debug="${(L=i.debug)!=null?L:!1}"
1421
1496
  prefer-cmcd="${(F=i.preferCmcd)!=null?F:!1}"
@@ -1423,15 +1498,15 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1423
1498
  prefer-playback="${(B=i.preferPlayback)!=null?B:!1}"
1424
1499
  start-time="${i.startTime!=null?i.startTime:!1}"
1425
1500
  beacon-collection-domain="${(P=i.beaconCollectionDomain)!=null?P:!1}"
1426
- player-software-name="${(G=i.playerSoftwareName)!=null?G:!1}"
1427
- player-software-version="${(K=i.playerSoftwareVersion)!=null?K:!1}"
1501
+ player-software-name="${(H=i.playerSoftwareName)!=null?H:!1}"
1502
+ player-software-version="${(V=i.playerSoftwareVersion)!=null?V:!1}"
1428
1503
  env-key="${(N=i.envKey)!=null?N:!1}"
1429
1504
  custom-domain="${(j=i.customDomain)!=null?j:!1}"
1430
- src="${i.src?i.src:i.playbackId?Ea(i):!1}"
1431
- cast-src="${i.src?i.src:i.playbackId?Ea(i):!1}"
1505
+ src="${i.src?i.src:i.playbackId?Aa(i):!1}"
1506
+ cast-src="${i.src?i.src:i.playbackId?Aa(i):!1}"
1432
1507
  exportparts="video"
1433
1508
  >
1434
- ${i.storyboard?tr`<track label="thumbnails" default kind="metadata" src="${i.storyboard}" />`:tr``}
1509
+ ${i.storyboard?rr`<track label="thumbnails" default kind="metadata" src="${i.storyboard}" />`:rr``}
1435
1510
  </mux-video>
1436
1511
  <slot name="poster" slot="poster">
1437
1512
  <media-poster-image
@@ -1447,20 +1522,20 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1447
1522
  onclose="${i.onCloseErrorDialog}"
1448
1523
  oninitfocus="${i.onInitFocusDialog}"
1449
1524
  >
1450
- ${(ye=i.dialog)!=null&&ye.title?tr`<h3>${i.dialog.title}</h3>`:tr``}
1525
+ ${(ye=i.dialog)!=null&&ye.title?rr`<h3>${i.dialog.title}</h3>`:rr``}
1451
1526
  <p>
1452
1527
  ${(we=i.dialog)==null?void 0:we.message}
1453
- ${(Ie=i.dialog)!=null&&Ie.linkUrl?tr`<a
1528
+ ${(Ie=i.dialog)!=null&&Ie.linkUrl?rr`<a
1454
1529
  href="${i.dialog.linkUrl}"
1455
1530
  target="_blank"
1456
1531
  rel="external noopener"
1457
1532
  aria-label="${(Z=i.dialog.linkText)!=null?Z:""} ${xe("(opens in a new window)")}"
1458
1533
  >${(te=i.dialog.linkText)!=null?te:i.dialog.linkUrl}</a
1459
- >`:tr``}
1534
+ >`:rr``}
1460
1535
  </p>
1461
1536
  </mxp-dialog>
1462
1537
  </media-theme>
1463
- `};function Yd(i,e,t,r,s){var o,l,d;let n={},a={};switch(i.code){case _t.MEDIA_ERR_NETWORK:{switch(n.title=xe("Network Error",s),n.message=i.message,(o=i.data)==null?void 0:o.response.code){case 412:{n.title=xe("Video is not currently available",s),n.message=xe("The live stream or video file are not yet ready.",s),a.message=xe("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",s),a.file="412-not-playable.md";break}case 404:{n.title=xe("Video does not exist",s),n.message="",a.message=xe("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",s),a.file="404-not-found.md";break}case 403:{if(n.title=xe("Invalid playback URL",s),n.message=xe("The video URL or playback-token are formatted with incorrect or incomplete information.",s),a.message=xe("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",s),a.file="missing-signed-tokens.md",!r)break;let{exp:c,aud:u,sub:h}=Ar(r),f=Date.now()>c*1e3,g=h!==t,E=u!=="v",T={timeStyle:"medium",dateStyle:"medium"};if(f){n.title=xe("Video URL has expired",s),n.message=xe("The video\u2019s secured playback-token has expired.",s),a.message=xe("The video\u2019s secured playback-token has expired.",s),a.context=xe("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat(ms.code,T).format(c*1e3),currentDate:new Intl.DateTimeFormat(ms.code,T).format(Date.now())}),a.file="403-expired-token.md";break}if(g){n.title=xe("Video URL is formatted incorrectly",s),n.message=xe("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.message=xe("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.context=xe("Specified playback ID: {playbackId} and the playback ID encoded in the playback-token: {tokenPlaybackId}",s).format({playbackId:t,tokenPlaybackId:h}),a.file="403-playback-id-mismatch.md";break}if(E){n.title=xe("Video URL is formatted incorrectly",s),n.message=xe("The playback-token is formatted with incorrect information.",s),a.message=xe("The playback-token is formatted with incorrect information.",s),a.context=xe("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",s).format({tokenType:u}),a.file="403-incorrect-aud-value.md";break}a.message=xe("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",s),a.file="403-malformatted-token.md";break}}break}case _t.MEDIA_ERR_DECODE:{let{message:c}=i;n={title:xe("Media Error",s),message:c},a.file="media-decode-error.md";break}case _t.MEDIA_ERR_SRC_NOT_SUPPORTED:{let c=(d=(l=i.data)==null?void 0:l.response)==null?void 0:d.code;if(c>=400&&c<500){i.code=_t.MEDIA_ERR_NETWORK,i.data={response:{code:c}},{dialog:n,devlog:a}=Yd(i,e,t,r);break}n={title:xe("Source Not Supported",s),message:i.message},a.file="media-src-not-supported.md";break}default:n={title:xe("Error",s),message:i.message};break}return e&&(n={title:xe("Your device appears to be offline",s),message:xe("Check your internet connection and try reloading this video.",s)}),{dialog:n,devlog:a}}var Rb=`<template id="media-theme-gerwig">
1538
+ `};function ec(i,e,t,r,s){var o,l,d;let n={},a={};switch(i.code){case xt.MEDIA_ERR_NETWORK:{switch(n.title=xe("Network Error",s),n.message=i.message,(o=i.data)==null?void 0:o.response.code){case 412:{n.title=xe("Video is not currently available",s),n.message=xe("The live stream or video file are not yet ready.",s),a.message=xe("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",s),a.file="412-not-playable.md";break}case 404:{n.title=xe("Video does not exist",s),n.message="",a.message=xe("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",s),a.file="404-not-found.md";break}case 403:{if(n.title=xe("Invalid playback URL",s),n.message=xe("The video URL or playback-token are formatted with incorrect or incomplete information.",s),a.message=xe("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",s),a.file="missing-signed-tokens.md",!r)break;let{exp:c,aud:u,sub:h}=Sr(r),f=Date.now()>c*1e3,g=h!==t,E=u!=="v",T={timeStyle:"medium",dateStyle:"medium"};if(f){n.title=xe("Video URL has expired",s),n.message=xe("The video\u2019s secured playback-token has expired.",s),a.message=xe("The video\u2019s secured playback-token has expired.",s),a.context=xe("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat(ps.code,T).format(c*1e3),currentDate:new Intl.DateTimeFormat(ps.code,T).format(Date.now())}),a.file="403-expired-token.md";break}if(g){n.title=xe("Video URL is formatted incorrectly",s),n.message=xe("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.message=xe("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.context=xe("Specified playback ID: {playbackId} and the playback ID encoded in the playback-token: {tokenPlaybackId}",s).format({playbackId:t,tokenPlaybackId:h}),a.file="403-playback-id-mismatch.md";break}if(E){n.title=xe("Video URL is formatted incorrectly",s),n.message=xe("The playback-token is formatted with incorrect information.",s),a.message=xe("The playback-token is formatted with incorrect information.",s),a.context=xe("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",s).format({tokenType:u}),a.file="403-incorrect-aud-value.md";break}a.message=xe("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",s),a.file="403-malformatted-token.md";break}}break}case xt.MEDIA_ERR_DECODE:{let{message:c}=i;n={title:xe("Media Error",s),message:c},a.file="media-decode-error.md";break}case xt.MEDIA_ERR_SRC_NOT_SUPPORTED:{let c=(d=(l=i.data)==null?void 0:l.response)==null?void 0:d.code;if(c>=400&&c<500){i.code=xt.MEDIA_ERR_NETWORK,i.data={response:{code:c}},{dialog:n,devlog:a}=ec(i,e,t,r);break}n={title:xe("Source Not Supported",s),message:i.message},a.file="media-src-not-supported.md";break}default:n={title:xe("Error",s),message:i.message};break}return e&&(n={title:xe("Your device appears to be offline",s),message:xe("Check your internet connection and try reloading this video.",s)}),{dialog:n,devlog:a}}var Gb=`<template id="media-theme-gerwig">
1464
1539
  <style>
1465
1540
  @keyframes pre-play-hide {
1466
1541
  0% {
@@ -2454,8 +2529,8 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2454
2529
  <slot></slot>
2455
2530
  </media-controller>
2456
2531
  </template>
2457
- `;var Mm=Kt.createElement("template");"innerHTML"in Mm&&(Mm.innerHTML=Rb);var kb,wb,jd=class extends Rr{};jd.template=(wb=(kb=Mm.content)==null?void 0:kb.children)==null?void 0:wb[0];Je.customElements.get("media-theme-gerwig")||Je.customElements.define("media-theme-gerwig",jd);var yI="gerwig";var ir={SRC:"src",POSTER:"poster"},z={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref"},Pm=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function TI(i,e){var r;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute(z.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:_I(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute(z.NOHOTKEYS),hotKeys:i.getAttribute(z.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,renditionOrder:i.renditionOrder,metadata:i.metadata,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(W.TARGET_LIVE_WINDOW),streamType:Ra(i.getAttribute(W.STREAM_TYPE)),primaryColor:i.getAttribute(z.PRIMARY_COLOR),secondaryColor:i.getAttribute(z.SECONDARY_COLOR),accentColor:i.getAttribute(z.ACCENT_COLOR),forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultDuration:i.defaultDuration,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:AI(i),playbackRates:i.getAttribute(z.PLAYBACK_RATES),customDomain:(r=i.getAttribute(W.CUSTOM_DOMAIN))!=null?r:void 0,title:i.getAttribute(z.TITLE),novolumepref:i.hasAttribute(z.NO_VOLUME_PREF),...e,extraSourceParams:i.extraSourceParams}}function _I(i){var t,r;let e=i.theme;if(e){let s=(r=(t=i.getRootNode())==null?void 0:t.getElementById)==null?void 0:r.call(t,e);if(s&&s instanceof HTMLTemplateElement)return s;e.startsWith("media-theme-")||(e=`media-theme-${e}`);let n=Je.customElements.get(e);if(n!=null&&n.template)return n.template}}function AI(i){var t;let e=(t=i.mediaController)==null?void 0:t.querySelector("media-time-display");return e&&getComputedStyle(e).getPropertyValue("--media-duration-display-display").trim()==="none"}function Db(i){let e=i.hasAttribute(z.TITLE)?{video_title:i.getAttribute(z.TITLE)}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,r)=>{let s=i.getAttribute(r);return s!==null&&(t[r.replace(/^metadata-/,"").replace(/-/g,"_")]=s),t},e)}var SI=Object.values(W),xI=Object.values(ir),II=Object.values(z),LI=Ud(),RI="mux-player",Cb={dialog:void 0,isDialogOpen:!1},kI={redundant_streams:!0},Ba,$a,wr,Ga,Ss,rr,As,zd,Mb,Ha,Om,Dr,bn,Xd,Pb,Qd,Ob,Zd,Nb,Jd,Ub,Fa=class extends Tm{constructor(){super();dt(this,rr);dt(this,zd);dt(this,Ha);dt(this,Dr);dt(this,Xd);dt(this,Qd);dt(this,Zd);dt(this,Jd);dt(this,Ba,!1);dt(this,$a,{});dt(this,wr,!0);dt(this,Ga,new Nd(this,"hotkeys"));dt(this,Ss,{...Cb,onCloseErrorDialog:()=>ct(this,Ha,Om).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:t=>{Em(this,Kt.activeElement)||t.preventDefault()}});this.attachShadow({mode:"open"}),ct(this,zd,Mb).call(this),this.isConnected&&ct(this,rr,As).call(this)}static get observedAttributes(){var t;return[...(t=Tm.observedAttributes)!=null?t:[],...xI,...SI,...II]}get mediaTheme(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("media-theme")}get mediaController(){var t,r;return(r=(t=this.mediaTheme)==null?void 0:t.shadowRoot)==null?void 0:r.querySelector("media-controller")}connectedCallback(){var r;let t=(r=this.shadowRoot)==null?void 0:r.querySelector("mux-video");t&&(t.metadata=Db(this))}attributeChangedCallback(t,r,s){switch(ct(this,rr,As).call(this),super.attributeChangedCallback(t,r,s),t){case z.HOTKEYS:Pe(this,Ga).value=s;break;case z.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&Sr(xe("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case z.THUMBNAIL_TOKEN:{let{aud:a}=Ar(s);s&&a!=="t"&&Sr(xe("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:a}));break}case z.STORYBOARD_TOKEN:{let{aud:a}=Ar(s);s&&a!=="s"&&Sr(xe("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:a}));break}case W.PLAYBACK_ID:{s!=null&&s.includes("?token")&&li(xe("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s}));break}case W.STREAM_TYPE:s&&![Ye.LIVE,Ye.ON_DEMAND,Ye.UNKNOWN].includes(s)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=s.includes("dvr")?Number.POSITIVE_INFINITY:0:bm({file:"invalid-stream-type.md",message:xe("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):s===Ye.LIVE?this.getAttribute(z.TARGET_LIVE_WINDOW)==null&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN}[W.PLAYBACK_ID,ir.SRC,z.PLAYBACK_TOKEN].includes(t)&&r!==s&&Jt(this,Ss,{...Pe(this,Ss),...Cb}),ct(this,Dr,bn).call(this,{[tb(t)]:s})}get preferCmcd(){var t;return(t=this.getAttribute(W.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?ln.includes(t)?this.setAttribute(W.PREFER_CMCD,t):Sr(`Invalid value for preferCmcd. Must be one of ${ln.join()}`):this.removeAttribute(W.PREFER_CMCD))}get hasPlayed(){var t,r;return(r=(t=this.mediaController)==null?void 0:t.hasAttribute(S.MEDIA_HAS_PLAYED))!=null?r:!1}get inLiveWindow(){var t;return(t=this.mediaController)==null?void 0:t.hasAttribute(S.MEDIA_TIME_IS_LIVE)}get _hls(){var t;return(t=this.media)==null?void 0:t._hls}get mux(){var t;return(t=this.media)==null?void 0:t.mux}get theme(){var t;return(t=this.getAttribute(z.THEME))!=null?t:yI}set theme(t){this.setAttribute(z.THEME,`${t}`)}get themeProps(){let t=this.mediaTheme;if(!t)return;let r={};for(let s of t.getAttributeNames()){if(Pm.includes(s))continue;let n=t.getAttribute(s);r[Od(s)]=n===""?!0:n}return r}set themeProps(t){var s,n;ct(this,rr,As).call(this);let r={...this.themeProps,...t};for(let a in r){if(Pm.includes(a))continue;let o=t==null?void 0:t[a];typeof o=="boolean"||o==null?(s=this.mediaTheme)==null||s.toggleAttribute(Pd(a),!!o):(n=this.mediaTheme)==null||n.setAttribute(Pd(a),o)}}get playbackId(){var t;return(t=this.getAttribute(W.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t?this.setAttribute(W.PLAYBACK_ID,t):this.removeAttribute(W.PLAYBACK_ID)}get src(){var t,r;return this.playbackId?(t=En(this,ir.SRC))!=null?t:void 0:(r=this.getAttribute(ir.SRC))!=null?r:void 0}set src(t){t?this.setAttribute(ir.SRC,t):this.removeAttribute(ir.SRC)}get poster(){var r;let t=this.getAttribute(ir.POSTER);if(t!=null)return t;if(this.playbackId&&!this.audio)return JE(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(r=this.thumbnailTime)!=null?r:this.startTime,token:this.tokens.thumbnail})}set poster(t){t||t===""?this.setAttribute(ir.POSTER,t):this.removeAttribute(ir.POSTER)}get storyboardSrc(){var t;return(t=this.getAttribute(z.STORYBOARD_SRC))!=null?t:void 0}set storyboardSrc(t){t?this.setAttribute(z.STORYBOARD_SRC,t):this.removeAttribute(z.STORYBOARD_SRC)}get storyboard(){if(this.storyboardSrc&&!this.tokens.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[Ye.LIVE,Ye.UNKNOWN].includes(this.streamType)))return eb(this.playbackId,{customDomain:this.customDomain,token:this.tokens.storyboard})}get audio(){return this.hasAttribute(z.AUDIO)}set audio(t){if(!t){this.removeAttribute(z.AUDIO);return}this.setAttribute(z.AUDIO,"")}get hotkeys(){return Pe(this,Ga)}get nohotkeys(){return this.hasAttribute(z.NOHOTKEYS)}set nohotkeys(t){if(!t){this.removeAttribute(z.NOHOTKEYS);return}this.setAttribute(z.NOHOTKEYS,"")}get thumbnailTime(){return Hi(this.getAttribute(z.THUMBNAIL_TIME))}set thumbnailTime(t){this.setAttribute(z.THUMBNAIL_TIME,`${t}`)}get title(){var t;return(t=this.getAttribute(z.TITLE))!=null?t:""}set title(t){t!==this.title&&(t?this.setAttribute(z.TITLE,t):this.removeAttribute("title"),super.title=t)}get placeholder(){var t;return(t=En(this,z.PLACEHOLDER))!=null?t:""}set placeholder(t){this.setAttribute(z.PLACEHOLDER,`${t}`)}get primaryColor(){var r,s;let t=this.getAttribute(z.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Je.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_primary-color"))==null?void 0:s.trim(),t))return t}set primaryColor(t){this.setAttribute(z.PRIMARY_COLOR,`${t}`)}get secondaryColor(){var r,s;let t=this.getAttribute(z.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Je.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_secondary-color"))==null?void 0:s.trim(),t))return t}set secondaryColor(t){this.setAttribute(z.SECONDARY_COLOR,`${t}`)}get accentColor(){var r,s;let t=this.getAttribute(z.ACCENT_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Je.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_accent-color"))==null?void 0:s.trim(),t))return t}set accentColor(t){this.setAttribute(z.ACCENT_COLOR,`${t}`)}get defaultShowRemainingTime(){return this.hasAttribute(z.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(t){t?this.setAttribute(z.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(z.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute(z.PLAYBACK_RATES))return this.getAttribute(z.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(t=>Number(t)).filter(t=>!Number.isNaN(t)).sort((t,r)=>t-r)}set playbackRates(t){if(!t){this.removeAttribute(z.PLAYBACK_RATES);return}this.setAttribute(z.PLAYBACK_RATES,t.join(" "))}get forwardSeekOffset(){var t;return(t=Hi(this.getAttribute(z.FORWARD_SEEK_OFFSET)))!=null?t:10}set forwardSeekOffset(t){this.setAttribute(z.FORWARD_SEEK_OFFSET,`${t}`)}get backwardSeekOffset(){var t;return(t=Hi(this.getAttribute(z.BACKWARD_SEEK_OFFSET)))!=null?t:10}set backwardSeekOffset(t){this.setAttribute(z.BACKWARD_SEEK_OFFSET,`${t}`)}get defaultHiddenCaptions(){return this.hasAttribute(z.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(t){t?this.setAttribute(z.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(z.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return Hi(this.getAttribute(z.DEFAULT_DURATION))}set defaultDuration(t){t==null?this.removeAttribute(z.DEFAULT_DURATION):this.setAttribute(z.DEFAULT_DURATION,`${t}`)}get playerSoftwareName(){var t;return(t=this.getAttribute(W.PLAYER_SOFTWARE_NAME))!=null?t:RI}get playerSoftwareVersion(){var t;return(t=this.getAttribute(W.PLAYER_SOFTWARE_VERSION))!=null?t:LI}get beaconCollectionDomain(){var t;return(t=this.getAttribute(W.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(W.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(W.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var t;return(t=this.getAttribute(W.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(W.MAX_RESOLUTION,t):this.removeAttribute(W.MAX_RESOLUTION))}get minResolution(){var t;return(t=this.getAttribute(W.MIN_RESOLUTION))!=null?t:void 0}set minResolution(t){t!==this.minResolution&&(t?this.setAttribute(W.MIN_RESOLUTION,t):this.removeAttribute(W.MIN_RESOLUTION))}get renditionOrder(){var t;return(t=this.getAttribute(W.RENDITION_ORDER))!=null?t:void 0}set renditionOrder(t){t!==this.renditionOrder&&(t?this.setAttribute(W.RENDITION_ORDER,t):this.removeAttribute(W.RENDITION_ORDER))}get extraSourceParams(){return this.hasAttribute(z.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute(z.EXTRA_SOURCE_PARAMS)).entries()].reduce((t,[r,s])=>(t[r]=s,t),{}):kI}set extraSourceParams(t){t==null?this.removeAttribute(z.EXTRA_SOURCE_PARAMS):this.setAttribute(z.EXTRA_SOURCE_PARAMS,new URLSearchParams(t).toString())}get customDomain(){var t;return(t=this.getAttribute(W.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(W.CUSTOM_DOMAIN,t):this.removeAttribute(W.CUSTOM_DOMAIN))}get envKey(){var t;return(t=En(this,W.ENV_KEY))!=null?t:void 0}set envKey(t){this.setAttribute(W.ENV_KEY,`${t}`)}get noVolumePref(){return this.hasAttribute(z.NO_VOLUME_PREF)}set noVolumePref(t){t?this.setAttribute(z.NO_VOLUME_PREF,""):this.removeAttribute(z.NO_VOLUME_PREF)}get debug(){return En(this,W.DEBUG)!=null}set debug(t){t?this.setAttribute(W.DEBUG,""):this.removeAttribute(W.DEBUG)}get disableCookies(){return En(this,W.DISABLE_COOKIES)!=null}set disableCookies(t){t?this.setAttribute(W.DISABLE_COOKIES,""):this.removeAttribute(W.DISABLE_COOKIES)}get streamType(){var t,r,s;return(s=(r=this.getAttribute(W.STREAM_TYPE))!=null?r:(t=this.media)==null?void 0:t.streamType)!=null?s:Ye.UNKNOWN}set streamType(t){this.setAttribute(W.STREAM_TYPE,`${t}`)}get defaultStreamType(){var t,r,s;return(s=(r=this.getAttribute(z.DEFAULT_STREAM_TYPE))!=null?r:(t=this.mediaController)==null?void 0:t.getAttribute(z.DEFAULT_STREAM_TYPE))!=null?s:Ye.ON_DEMAND}set defaultStreamType(t){t?this.setAttribute(z.DEFAULT_STREAM_TYPE,t):this.removeAttribute(z.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var t,r;return this.hasAttribute(z.TARGET_LIVE_WINDOW)?+this.getAttribute(z.TARGET_LIVE_WINDOW):(r=(t=this.media)==null?void 0:t.targetLiveWindow)!=null?r:Number.NaN}set targetLiveWindow(t){t==this.targetLiveWindow||Number.isNaN(t)&&Number.isNaN(this.targetLiveWindow)||(t==null?this.removeAttribute(z.TARGET_LIVE_WINDOW):this.setAttribute(z.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t;return(t=this.media)==null?void 0:t.liveEdgeStart}get startTime(){return Hi(En(this,W.START_TIME))}set startTime(t){this.setAttribute(W.START_TIME,`${t}`)}get preferPlayback(){let t=this.getAttribute(W.PREFER_PLAYBACK);if(t===ai.MSE||t===ai.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===ai.MSE||t===ai.NATIVE?this.setAttribute(W.PREFER_PLAYBACK,t):this.removeAttribute(W.PREFER_PLAYBACK))}get metadata(){var t;return(t=this.media)==null?void 0:t.metadata}set metadata(t){if(ct(this,rr,As).call(this),!this.media){li("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...Db(this),...t}}get _hlsConfig(){var t;return(t=this.media)==null?void 0:t._hlsConfig}set _hlsConfig(t){if(ct(this,rr,As).call(this),!this.media){li("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=t}async addCuePoints(t){var r;if(ct(this,rr,As).call(this),!this.media){li("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(r=this.media)==null?void 0:r.addCuePoints(t)}get activeCuePoint(){var t;return(t=this.media)==null?void 0:t.activeCuePoint}get cuePoints(){var t,r;return(r=(t=this.media)==null?void 0:t.cuePoints)!=null?r:[]}getStartDate(){var t;return(t=this.media)==null?void 0:t.getStartDate()}get currentPdt(){var t;return(t=this.media)==null?void 0:t.currentPdt}get tokens(){let t=this.getAttribute(z.PLAYBACK_TOKEN),r=this.getAttribute(z.THUMBNAIL_TOKEN),s=this.getAttribute(z.STORYBOARD_TOKEN);return{...Pe(this,$a),...t!=null?{playback:t}:{},...r!=null?{thumbnail:r}:{},...s!=null?{storyboard:s}:{}}}set tokens(t){Jt(this,$a,t!=null?t:{})}get playbackToken(){var t;return(t=this.getAttribute(z.PLAYBACK_TOKEN))!=null?t:void 0}set playbackToken(t){this.setAttribute(z.PLAYBACK_TOKEN,`${t}`)}get thumbnailToken(){var t;return(t=this.getAttribute(z.THUMBNAIL_TOKEN))!=null?t:void 0}set thumbnailToken(t){this.setAttribute(z.THUMBNAIL_TOKEN,`${t}`)}get storyboardToken(){var t;return(t=this.getAttribute(z.STORYBOARD_TOKEN))!=null?t:void 0}set storyboardToken(t){this.setAttribute(z.STORYBOARD_TOKEN,`${t}`)}addTextTrack(t,r,s,n){var o;let a=(o=this.media)==null?void 0:o.nativeEl;if(a)return pd(a,t,r,s,n)}removeTextTrack(t){var s;let r=(s=this.media)==null?void 0:s.nativeEl;if(r)return mE(r,t)}get textTracks(){var t;return(t=this.media)==null?void 0:t.textTracks}};Ba=new WeakMap,$a=new WeakMap,wr=new WeakMap,Ga=new WeakMap,Ss=new WeakMap,rr=new WeakSet,As=function(){var t,r,s;if(!Pe(this,Ba)){Jt(this,Ba,!0),ct(this,Dr,bn).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof Je.HTMLElement))throw""}catch{li("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof zE))throw""}catch{li("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof Pc))throw""}catch{li("<media-controller> failed to upgrade!")}nb(this),ct(this,Xd,Pb).call(this),ct(this,Qd,Ob).call(this),ct(this,Zd,Nb).call(this),Jt(this,wr,(r=(t=this.mediaController)==null?void 0:t.hasAttribute(ke.USER_INACTIVE))!=null?r:!0),ct(this,Jd,Ub).call(this),(s=this.media)==null||s.addEventListener("streamtypechange",()=>{ct(this,Dr,bn).call(this)})}},zd=new WeakSet,Mb=function(){var t,r;try{(t=window==null?void 0:window.CSS)==null||t.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(r=window==null?void 0:window.CSS)==null||r.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},Ha=new WeakSet,Om=function(t){Object.assign(Pe(this,Ss),t),ct(this,Dr,bn).call(this)},Dr=new WeakSet,bn=function(t={}){Ib(Lb(TI(this,{...Pe(this,Ss),...t})),this.shadowRoot)},Xd=new WeakSet,Pb=function(){let t=s=>{var o,l;if(!(s!=null&&s.startsWith("theme-")))return;let n=s.replace(/^theme-/,"");if(Pm.includes(n))return;let a=this.getAttribute(s);a!=null?(o=this.mediaTheme)==null||o.setAttribute(n,a):(l=this.mediaTheme)==null||l.removeAttribute(n)};new MutationObserver(s=>{for(let{attributeName:n}of s)t(n)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(t)},Qd=new WeakSet,Ob=function(){var r;let t=s=>{let{detail:n}=s;if(n instanceof _t||(n=new _t(n.message,n.code,n.fatal)),!(n!=null&&n.fatal)){Sr(n),n.data&&Sr(`${n.name} data:`,n.data);return}let{dialog:a,devlog:o}=Yd(n,!window.navigator.onLine,this.playbackId,this.playbackToken);o.message&&bm(o),li(n),n.data&&li(`${n.name} data:`,n.data),ct(this,Ha,Om).call(this,{isDialogOpen:!0,dialog:a})};this.addEventListener("error",t),this.media&&(this.media.errorTranslator=(s={})=>{var a,o,l;if(!(((a=this.media)==null?void 0:a.error)instanceof _t))return s;let{devlog:n}=Yd((o=this.media)==null?void 0:o.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(l=this.media)==null?void 0:l.error.code,player_error_message:n.message?String(n.message):s.player_error_message,player_error_context:n.context?String(n.context):s.player_error_context}}),(r=this.media)==null||r.addEventListener("error",s=>{var a,o;let{detail:n}=s;if(!n){let{message:l,code:d}=(o=(a=this.media)==null?void 0:a.error)!=null?o:{};n=new _t(l,d)}n!=null&&n.fatal&&this.dispatchEvent(new CustomEvent("error",{detail:n}))})},Zd=new WeakSet,Nb=function(){var r,s,n,a;let t=()=>ct(this,Dr,bn).call(this);(s=(r=this.media)==null?void 0:r.textTracks)==null||s.addEventListener("addtrack",t),(a=(n=this.media)==null?void 0:n.textTracks)==null||a.addEventListener("removetrack",t)},Jd=new WeakSet,Ub=function(){var d,c;if(!/Firefox/i.test(navigator.userAgent))return;let r,s=new WeakMap,n=()=>this.streamType===Ye.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,a=(u,h,f=!1)=>{if(n())return;Array.from(u&&u.activeCues||[]).forEach(E=>{if(!(!E.snapToLines||E.line<-5||E.line>=0&&E.line<10))if(!h||this.paused){let T=E.text.split(`
2458
- `).length,A=-3;this.streamType===Ye.LIVE&&(A=-2);let k=A-T;if(E.line===k&&!f)return;s.has(E)||s.set(E,E.line),E.line=k}else setTimeout(()=>{E.line=s.get(E)||"auto"},500)})},o=()=>{var u,h;a(r,(h=(u=this.mediaController)==null?void 0:u.hasAttribute(ke.USER_INACTIVE))!=null?h:!1)},l=()=>{var f,g;let h=Array.from(((g=(f=this.mediaController)==null?void 0:f.media)==null?void 0:g.textTracks)||[]).filter(E=>["subtitles","captions"].includes(E.kind)&&E.mode==="showing")[0];h!==r&&(r==null||r.removeEventListener("cuechange",o)),r=h,r==null||r.addEventListener("cuechange",o),a(r,Pe(this,wr))};l(),(d=this.textTracks)==null||d.addEventListener("change",l),(c=this.textTracks)==null||c.addEventListener("addtrack",l),this.addEventListener("userinactivechange",()=>{var h,f;let u=(f=(h=this.mediaController)==null?void 0:h.hasAttribute(ke.USER_INACTIVE))!=null?f:!0;Pe(this,wr)!==u&&(Jt(this,wr,u),a(r,Pe(this,wr)))})};function En(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}Je.customElements.get("mux-player")||(Je.customElements.define("mux-player",Fa),Je.MuxPlayerElement=Fa);var pP=Fa;})();
2532
+ `;var Gm=jt.createElement("template");"innerHTML"in Gm&&(Gm.innerHTML=Gb);var Vb,Wb,tc=class extends kr{};tc.template=(Wb=(Vb=Gm.content)==null?void 0:Vb.children)==null?void 0:Wb[0];Je.customElements.get("media-theme-gerwig")||Je.customElements.define("media-theme-gerwig",tc);var FI="gerwig";var sr={SRC:"src",POSTER:"poster"},z={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref"},Vm=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function BI(i,e){var r;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute(z.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:$I(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute(z.NOHOTKEYS),hotKeys:i.getAttribute(z.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,renditionOrder:i.renditionOrder,metadata:i.metadata,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(K.TARGET_LIVE_WINDOW),streamType:Ma(i.getAttribute(K.STREAM_TYPE)),primaryColor:i.getAttribute(z.PRIMARY_COLOR),secondaryColor:i.getAttribute(z.SECONDARY_COLOR),accentColor:i.getAttribute(z.ACCENT_COLOR),forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultDuration:i.defaultDuration,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:HI(i),playbackRates:i.getAttribute(z.PLAYBACK_RATES),customDomain:(r=i.getAttribute(K.CUSTOM_DOMAIN))!=null?r:void 0,title:i.getAttribute(z.TITLE),novolumepref:i.hasAttribute(z.NO_VOLUME_PREF),...e,extraSourceParams:i.extraSourceParams}}function $I(i){var t,r;let e=i.theme;if(e){let s=(r=(t=i.getRootNode())==null?void 0:t.getElementById)==null?void 0:r.call(t,e);if(s&&s instanceof HTMLTemplateElement)return s;e.startsWith("media-theme-")||(e=`media-theme-${e}`);let n=Je.customElements.get(e);if(n!=null&&n.template)return n.template}}function HI(i){var t;let e=(t=i.mediaController)==null?void 0:t.querySelector("media-time-display");return e&&getComputedStyle(e).getPropertyValue("--media-duration-display-display").trim()==="none"}function Kb(i){let e=i.hasAttribute(z.TITLE)?{video_title:i.getAttribute(z.TITLE)}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,r)=>{let s=i.getAttribute(r);return s!==null&&(t[r.replace(/^metadata-/,"").replace(/-/g,"_")]=s),t},e)}var GI=Object.values(K),VI=Object.values(sr),WI=Object.values(z),KI=Wd(),qI="mux-player",qb={dialog:void 0,isDialogOpen:!1},YI={redundant_streams:!0},Wa,Ka,Dr,qa,xs,nr,Ss,ic,Yb,Ya,Wm,Cr,yn,rc,jb,sc,zb,nc,Xb,ac,Qb,Va=class extends wm{constructor(){super();ct(this,nr);ct(this,ic);ct(this,Ya);ct(this,Cr);ct(this,rc);ct(this,sc);ct(this,nc);ct(this,ac);ct(this,Wa,!1);ct(this,Ka,{});ct(this,Dr,!0);ct(this,qa,new Vd(this,"hotkeys"));ct(this,xs,{...qb,onCloseErrorDialog:()=>ut(this,Ya,Wm).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:t=>{Lm(this,jt.activeElement)||t.preventDefault()}});this.attachShadow({mode:"open"}),ut(this,ic,Yb).call(this),this.isConnected&&ut(this,nr,Ss).call(this)}static get observedAttributes(){var t;return[...(t=wm.observedAttributes)!=null?t:[],...VI,...GI,...WI]}get mediaTheme(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("media-theme")}get mediaController(){var t,r;return(r=(t=this.mediaTheme)==null?void 0:t.shadowRoot)==null?void 0:r.querySelector("media-controller")}connectedCallback(){var r;let t=(r=this.shadowRoot)==null?void 0:r.querySelector("mux-video");t&&(t.metadata=Kb(this))}attributeChangedCallback(t,r,s){switch(ut(this,nr,Ss).call(this),super.attributeChangedCallback(t,r,s),t){case z.HOTKEYS:Pe(this,qa).value=s;break;case z.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&xr(xe("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case z.THUMBNAIL_TOKEN:{let{aud:a}=Sr(s);s&&a!=="t"&&xr(xe("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:a}));break}case z.STORYBOARD_TOKEN:{let{aud:a}=Sr(s);s&&a!=="s"&&xr(xe("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:a}));break}case K.PLAYBACK_ID:{s!=null&&s.includes("?token")&&ci(xe("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s}));break}case K.STREAM_TYPE:s&&![je.LIVE,je.ON_DEMAND,je.UNKNOWN].includes(s)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=s.includes("dvr")?Number.POSITIVE_INFINITY:0:Rm({file:"invalid-stream-type.md",message:xe("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):s===je.LIVE?this.getAttribute(z.TARGET_LIVE_WINDOW)==null&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN}[K.PLAYBACK_ID,sr.SRC,z.PLAYBACK_TOKEN].includes(t)&&r!==s&&ei(this,xs,{...Pe(this,xs),...qb}),ut(this,Cr,yn).call(this,{[pb(t)]:s})}get preferCmcd(){var t;return(t=this.getAttribute(K.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?dn.includes(t)?this.setAttribute(K.PREFER_CMCD,t):xr(`Invalid value for preferCmcd. Must be one of ${dn.join()}`):this.removeAttribute(K.PREFER_CMCD))}get hasPlayed(){var t,r;return(r=(t=this.mediaController)==null?void 0:t.hasAttribute(A.MEDIA_HAS_PLAYED))!=null?r:!1}get inLiveWindow(){var t;return(t=this.mediaController)==null?void 0:t.hasAttribute(A.MEDIA_TIME_IS_LIVE)}get _hls(){var t;return(t=this.media)==null?void 0:t._hls}get mux(){var t;return(t=this.media)==null?void 0:t.mux}get theme(){var t;return(t=this.getAttribute(z.THEME))!=null?t:FI}set theme(t){this.setAttribute(z.THEME,`${t}`)}get themeProps(){let t=this.mediaTheme;if(!t)return;let r={};for(let s of t.getAttributeNames()){if(Vm.includes(s))continue;let n=t.getAttribute(s);r[Gd(s)]=n===""?!0:n}return r}set themeProps(t){var s,n;ut(this,nr,Ss).call(this);let r={...this.themeProps,...t};for(let a in r){if(Vm.includes(a))continue;let o=t==null?void 0:t[a];typeof o=="boolean"||o==null?(s=this.mediaTheme)==null||s.toggleAttribute(Hd(a),!!o):(n=this.mediaTheme)==null||n.setAttribute(Hd(a),o)}}get playbackId(){var t;return(t=this.getAttribute(K.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t?this.setAttribute(K.PLAYBACK_ID,t):this.removeAttribute(K.PLAYBACK_ID)}get src(){var t,r;return this.playbackId?(t=bn(this,sr.SRC))!=null?t:void 0:(r=this.getAttribute(sr.SRC))!=null?r:void 0}set src(t){t?this.setAttribute(sr.SRC,t):this.removeAttribute(sr.SRC)}get poster(){var r;let t=this.getAttribute(sr.POSTER);if(t!=null)return t;if(this.playbackId&&!this.audio)return fb(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(r=this.thumbnailTime)!=null?r:this.startTime,token:this.tokens.thumbnail})}set poster(t){t||t===""?this.setAttribute(sr.POSTER,t):this.removeAttribute(sr.POSTER)}get storyboardSrc(){var t;return(t=this.getAttribute(z.STORYBOARD_SRC))!=null?t:void 0}set storyboardSrc(t){t?this.setAttribute(z.STORYBOARD_SRC,t):this.removeAttribute(z.STORYBOARD_SRC)}get storyboard(){if(this.storyboardSrc&&!this.tokens.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[je.LIVE,je.UNKNOWN].includes(this.streamType)))return mb(this.playbackId,{customDomain:this.customDomain,token:this.tokens.storyboard})}get audio(){return this.hasAttribute(z.AUDIO)}set audio(t){if(!t){this.removeAttribute(z.AUDIO);return}this.setAttribute(z.AUDIO,"")}get hotkeys(){return Pe(this,qa)}get nohotkeys(){return this.hasAttribute(z.NOHOTKEYS)}set nohotkeys(t){if(!t){this.removeAttribute(z.NOHOTKEYS);return}this.setAttribute(z.NOHOTKEYS,"")}get thumbnailTime(){return qi(this.getAttribute(z.THUMBNAIL_TIME))}set thumbnailTime(t){this.setAttribute(z.THUMBNAIL_TIME,`${t}`)}get title(){var t;return(t=this.getAttribute(z.TITLE))!=null?t:""}set title(t){t!==this.title&&(t?this.setAttribute(z.TITLE,t):this.removeAttribute("title"),super.title=t)}get placeholder(){var t;return(t=bn(this,z.PLACEHOLDER))!=null?t:""}set placeholder(t){this.setAttribute(z.PLACEHOLDER,`${t}`)}get primaryColor(){var r,s;let t=this.getAttribute(z.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Je.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_primary-color"))==null?void 0:s.trim(),t))return t}set primaryColor(t){this.setAttribute(z.PRIMARY_COLOR,`${t}`)}get secondaryColor(){var r,s;let t=this.getAttribute(z.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Je.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_secondary-color"))==null?void 0:s.trim(),t))return t}set secondaryColor(t){this.setAttribute(z.SECONDARY_COLOR,`${t}`)}get accentColor(){var r,s;let t=this.getAttribute(z.ACCENT_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Je.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_accent-color"))==null?void 0:s.trim(),t))return t}set accentColor(t){this.setAttribute(z.ACCENT_COLOR,`${t}`)}get defaultShowRemainingTime(){return this.hasAttribute(z.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(t){t?this.setAttribute(z.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(z.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute(z.PLAYBACK_RATES))return this.getAttribute(z.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(t=>Number(t)).filter(t=>!Number.isNaN(t)).sort((t,r)=>t-r)}set playbackRates(t){if(!t){this.removeAttribute(z.PLAYBACK_RATES);return}this.setAttribute(z.PLAYBACK_RATES,t.join(" "))}get forwardSeekOffset(){var t;return(t=qi(this.getAttribute(z.FORWARD_SEEK_OFFSET)))!=null?t:10}set forwardSeekOffset(t){this.setAttribute(z.FORWARD_SEEK_OFFSET,`${t}`)}get backwardSeekOffset(){var t;return(t=qi(this.getAttribute(z.BACKWARD_SEEK_OFFSET)))!=null?t:10}set backwardSeekOffset(t){this.setAttribute(z.BACKWARD_SEEK_OFFSET,`${t}`)}get defaultHiddenCaptions(){return this.hasAttribute(z.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(t){t?this.setAttribute(z.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(z.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return qi(this.getAttribute(z.DEFAULT_DURATION))}set defaultDuration(t){t==null?this.removeAttribute(z.DEFAULT_DURATION):this.setAttribute(z.DEFAULT_DURATION,`${t}`)}get playerSoftwareName(){var t;return(t=this.getAttribute(K.PLAYER_SOFTWARE_NAME))!=null?t:qI}get playerSoftwareVersion(){var t;return(t=this.getAttribute(K.PLAYER_SOFTWARE_VERSION))!=null?t:KI}get beaconCollectionDomain(){var t;return(t=this.getAttribute(K.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(K.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(K.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var t;return(t=this.getAttribute(K.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(K.MAX_RESOLUTION,t):this.removeAttribute(K.MAX_RESOLUTION))}get minResolution(){var t;return(t=this.getAttribute(K.MIN_RESOLUTION))!=null?t:void 0}set minResolution(t){t!==this.minResolution&&(t?this.setAttribute(K.MIN_RESOLUTION,t):this.removeAttribute(K.MIN_RESOLUTION))}get renditionOrder(){var t;return(t=this.getAttribute(K.RENDITION_ORDER))!=null?t:void 0}set renditionOrder(t){t!==this.renditionOrder&&(t?this.setAttribute(K.RENDITION_ORDER,t):this.removeAttribute(K.RENDITION_ORDER))}get extraSourceParams(){return this.hasAttribute(z.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute(z.EXTRA_SOURCE_PARAMS)).entries()].reduce((t,[r,s])=>(t[r]=s,t),{}):YI}set extraSourceParams(t){t==null?this.removeAttribute(z.EXTRA_SOURCE_PARAMS):this.setAttribute(z.EXTRA_SOURCE_PARAMS,new URLSearchParams(t).toString())}get customDomain(){var t;return(t=this.getAttribute(K.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(K.CUSTOM_DOMAIN,t):this.removeAttribute(K.CUSTOM_DOMAIN))}get envKey(){var t;return(t=bn(this,K.ENV_KEY))!=null?t:void 0}set envKey(t){this.setAttribute(K.ENV_KEY,`${t}`)}get noVolumePref(){return this.hasAttribute(z.NO_VOLUME_PREF)}set noVolumePref(t){t?this.setAttribute(z.NO_VOLUME_PREF,""):this.removeAttribute(z.NO_VOLUME_PREF)}get debug(){return bn(this,K.DEBUG)!=null}set debug(t){t?this.setAttribute(K.DEBUG,""):this.removeAttribute(K.DEBUG)}get disableCookies(){return bn(this,K.DISABLE_COOKIES)!=null}set disableCookies(t){t?this.setAttribute(K.DISABLE_COOKIES,""):this.removeAttribute(K.DISABLE_COOKIES)}get streamType(){var t,r,s;return(s=(r=this.getAttribute(K.STREAM_TYPE))!=null?r:(t=this.media)==null?void 0:t.streamType)!=null?s:je.UNKNOWN}set streamType(t){this.setAttribute(K.STREAM_TYPE,`${t}`)}get defaultStreamType(){var t,r,s;return(s=(r=this.getAttribute(z.DEFAULT_STREAM_TYPE))!=null?r:(t=this.mediaController)==null?void 0:t.getAttribute(z.DEFAULT_STREAM_TYPE))!=null?s:je.ON_DEMAND}set defaultStreamType(t){t?this.setAttribute(z.DEFAULT_STREAM_TYPE,t):this.removeAttribute(z.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var t,r;return this.hasAttribute(z.TARGET_LIVE_WINDOW)?+this.getAttribute(z.TARGET_LIVE_WINDOW):(r=(t=this.media)==null?void 0:t.targetLiveWindow)!=null?r:Number.NaN}set targetLiveWindow(t){t==this.targetLiveWindow||Number.isNaN(t)&&Number.isNaN(this.targetLiveWindow)||(t==null?this.removeAttribute(z.TARGET_LIVE_WINDOW):this.setAttribute(z.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t;return(t=this.media)==null?void 0:t.liveEdgeStart}get startTime(){return qi(bn(this,K.START_TIME))}set startTime(t){this.setAttribute(K.START_TIME,`${t}`)}get preferPlayback(){let t=this.getAttribute(K.PREFER_PLAYBACK);if(t===li.MSE||t===li.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===li.MSE||t===li.NATIVE?this.setAttribute(K.PREFER_PLAYBACK,t):this.removeAttribute(K.PREFER_PLAYBACK))}get metadata(){var t;return(t=this.media)==null?void 0:t.metadata}set metadata(t){if(ut(this,nr,Ss).call(this),!this.media){ci("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...Kb(this),...t}}get _hlsConfig(){var t;return(t=this.media)==null?void 0:t._hlsConfig}set _hlsConfig(t){if(ut(this,nr,Ss).call(this),!this.media){ci("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=t}async addCuePoints(t){var r;if(ut(this,nr,Ss).call(this),!this.media){ci("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(r=this.media)==null?void 0:r.addCuePoints(t)}get activeCuePoint(){var t;return(t=this.media)==null?void 0:t.activeCuePoint}get cuePoints(){var t,r;return(r=(t=this.media)==null?void 0:t.cuePoints)!=null?r:[]}getStartDate(){var t;return(t=this.media)==null?void 0:t.getStartDate()}get currentPdt(){var t;return(t=this.media)==null?void 0:t.currentPdt}get tokens(){let t=this.getAttribute(z.PLAYBACK_TOKEN),r=this.getAttribute(z.THUMBNAIL_TOKEN),s=this.getAttribute(z.STORYBOARD_TOKEN);return{...Pe(this,Ka),...t!=null?{playback:t}:{},...r!=null?{thumbnail:r}:{},...s!=null?{storyboard:s}:{}}}set tokens(t){ei(this,Ka,t!=null?t:{})}get playbackToken(){var t;return(t=this.getAttribute(z.PLAYBACK_TOKEN))!=null?t:void 0}set playbackToken(t){this.setAttribute(z.PLAYBACK_TOKEN,`${t}`)}get thumbnailToken(){var t;return(t=this.getAttribute(z.THUMBNAIL_TOKEN))!=null?t:void 0}set thumbnailToken(t){this.setAttribute(z.THUMBNAIL_TOKEN,`${t}`)}get storyboardToken(){var t;return(t=this.getAttribute(z.STORYBOARD_TOKEN))!=null?t:void 0}set storyboardToken(t){this.setAttribute(z.STORYBOARD_TOKEN,`${t}`)}addTextTrack(t,r,s,n){var o;let a=(o=this.media)==null?void 0:o.nativeEl;if(a)return _d(a,t,r,s,n)}removeTextTrack(t){var s;let r=(s=this.media)==null?void 0:s.nativeEl;if(r)return LE(r,t)}get textTracks(){var t;return(t=this.media)==null?void 0:t.textTracks}};Wa=new WeakMap,Ka=new WeakMap,Dr=new WeakMap,qa=new WeakMap,xs=new WeakMap,nr=new WeakSet,Ss=function(){var t,r,s;if(!Pe(this,Wa)){ei(this,Wa,!0),ut(this,Cr,yn).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof Je.HTMLElement))throw""}catch{ci("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof db))throw""}catch{ci("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof Hc))throw""}catch{ci("<media-controller> failed to upgrade!")}bb(this),ut(this,rc,jb).call(this),ut(this,sc,zb).call(this),ut(this,nc,Xb).call(this),ei(this,Dr,(r=(t=this.mediaController)==null?void 0:t.hasAttribute(ke.USER_INACTIVE))!=null?r:!0),ut(this,ac,Qb).call(this),(s=this.media)==null||s.addEventListener("streamtypechange",()=>{ut(this,Cr,yn).call(this)})}},ic=new WeakSet,Yb=function(){var t,r;try{(t=window==null?void 0:window.CSS)==null||t.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(r=window==null?void 0:window.CSS)==null||r.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},Ya=new WeakSet,Wm=function(t){Object.assign(Pe(this,xs),t),ut(this,Cr,yn).call(this)},Cr=new WeakSet,yn=function(t={}){$b(Hb(BI(this,{...Pe(this,xs),...t})),this.shadowRoot)},rc=new WeakSet,jb=function(){let t=s=>{var o,l;if(!(s!=null&&s.startsWith("theme-")))return;let n=s.replace(/^theme-/,"");if(Vm.includes(n))return;let a=this.getAttribute(s);a!=null?(o=this.mediaTheme)==null||o.setAttribute(n,a):(l=this.mediaTheme)==null||l.removeAttribute(n)};new MutationObserver(s=>{for(let{attributeName:n}of s)t(n)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(t)},sc=new WeakSet,zb=function(){var r;let t=s=>{let{detail:n}=s;if(n instanceof xt||(n=new xt(n.message,n.code,n.fatal)),!(n!=null&&n.fatal)){xr(n),n.data&&xr(`${n.name} data:`,n.data);return}let{dialog:a,devlog:o}=ec(n,!window.navigator.onLine,this.playbackId,this.playbackToken);o.message&&Rm(o),ci(n),n.data&&ci(`${n.name} data:`,n.data),ut(this,Ya,Wm).call(this,{isDialogOpen:!0,dialog:a})};this.addEventListener("error",t),this.media&&(this.media.errorTranslator=(s={})=>{var a,o,l;if(!(((a=this.media)==null?void 0:a.error)instanceof xt))return s;let{devlog:n}=ec((o=this.media)==null?void 0:o.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(l=this.media)==null?void 0:l.error.code,player_error_message:n.message?String(n.message):s.player_error_message,player_error_context:n.context?String(n.context):s.player_error_context}}),(r=this.media)==null||r.addEventListener("error",s=>{var a,o;let{detail:n}=s;if(!n){let{message:l,code:d}=(o=(a=this.media)==null?void 0:a.error)!=null?o:{};n=new xt(l,d)}n!=null&&n.fatal&&this.dispatchEvent(new CustomEvent("error",{detail:n}))})},nc=new WeakSet,Xb=function(){var r,s,n,a;let t=()=>ut(this,Cr,yn).call(this);(s=(r=this.media)==null?void 0:r.textTracks)==null||s.addEventListener("addtrack",t),(a=(n=this.media)==null?void 0:n.textTracks)==null||a.addEventListener("removetrack",t)},ac=new WeakSet,Qb=function(){var d,c;if(!/Firefox/i.test(navigator.userAgent))return;let r,s=new WeakMap,n=()=>this.streamType===je.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,a=(u,h,f=!1)=>{if(n())return;Array.from(u&&u.activeCues||[]).forEach(E=>{if(!(!E.snapToLines||E.line<-5||E.line>=0&&E.line<10))if(!h||this.paused){let T=E.text.split(`
2533
+ `).length,S=-3;this.streamType===je.LIVE&&(S=-2);let k=S-T;if(E.line===k&&!f)return;s.has(E)||s.set(E,E.line),E.line=k}else setTimeout(()=>{E.line=s.get(E)||"auto"},500)})},o=()=>{var u,h;a(r,(h=(u=this.mediaController)==null?void 0:u.hasAttribute(ke.USER_INACTIVE))!=null?h:!1)},l=()=>{var f,g;let h=Array.from(((g=(f=this.mediaController)==null?void 0:f.media)==null?void 0:g.textTracks)||[]).filter(E=>["subtitles","captions"].includes(E.kind)&&E.mode==="showing")[0];h!==r&&(r==null||r.removeEventListener("cuechange",o)),r=h,r==null||r.addEventListener("cuechange",o),a(r,Pe(this,Dr))};l(),(d=this.textTracks)==null||d.addEventListener("change",l),(c=this.textTracks)==null||c.addEventListener("addtrack",l),this.addEventListener("userinactivechange",()=>{var h,f;let u=(f=(h=this.mediaController)==null?void 0:h.hasAttribute(ke.USER_INACTIVE))!=null?f:!0;Pe(this,Dr)!==u&&(ei(this,Dr,u),a(r,Pe(this,Dr)))})};function bn(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}Je.customElements.get("mux-player")||(Je.customElements.define("mux-player",Va),Je.MuxPlayerElement=Va);var WP=Va;})();
2459
2534
  /*! Bundled license information:
2460
2535
 
2461
2536
  mux-embed/dist/mux.js: